diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-04-03 15:21:33 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-04-03 15:21:33 +0000 |
commit | 74cb10586cf7f1c415930d5ab1d59a6e44b253ee (patch) | |
tree | a6c5079ac724479adc4d6eabfb7144e38f713732 /archiva-base/archiva-common | |
parent | 54e1d8c6083cd552d9b8d3ee2d2ced20e9a6f460 (diff) | |
download | archiva-74cb10586cf7f1c415930d5ab1d59a6e44b253ee.tar.gz archiva-74cb10586cf7f1c415930d5ab1d59a6e44b253ee.zip |
Updating branch with latest work towards database refactor.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@525176 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base/archiva-common')
16 files changed, 32 insertions, 1499 deletions
diff --git a/archiva-base/archiva-common/pom.xml b/archiva-base/archiva-common/pom.xml index 263206850..17a20abd5 100644 --- a/archiva-base/archiva-common/pom.xml +++ b/archiva-base/archiva-common/pom.xml @@ -39,6 +39,7 @@ <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-component-api</artifactId> </dependency> + <!-- <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-artifact-manager</artifactId> @@ -47,6 +48,7 @@ <groupId>org.apache.maven</groupId> <artifactId>maven-project</artifactId> </dependency> + --> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java deleted file mode 100644 index b77826ad1..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.factory.ArtifactFactory; - -/** - * AbstractLayoutArtifactBuilder - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public abstract class AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - /** - * @plexus.requirement - */ - protected ArtifactFactory artifactFactory; - - /** - * Constructor used by plexus - */ - public AbstractLayoutArtifactBuilder() - { - - } - - /** - * Constructor used by manual process. - * - * @param artifactFactory the artifact factory to use. - */ - public AbstractLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - this.artifactFactory = artifactFactory; - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java deleted file mode 100644 index 0845dc750..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.ArchivaException; - -/** - * BuilderException - used to indicate a problem during the building of an object from file. - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class BuilderException - extends ArchivaException -{ - - public BuilderException( String message, Throwable cause ) - { - super( message, cause ); - } - - public BuilderException( String message ) - { - super( message ); - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java deleted file mode 100644 index bfee01508..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java +++ /dev/null @@ -1,218 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.codehaus.plexus.util.StringUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; - -/** - * DefaultLayoutArtifactBuilder - artifact builder for default layout repositories. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" - * role-hint="default" - */ -public class DefaultLayoutArtifactBuilder - extends AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - public DefaultLayoutArtifactBuilder() - { - super(); - } - - public DefaultLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - super( artifactFactory ); - } - - public Artifact build( String pathToArtifact ) - throws BuilderException - { - if( artifactFactory == null ) - { - throw new IllegalStateException( "Unable to build artifact with a null artifactFactory." ); - } - - List pathParts = new ArrayList(); - StringTokenizer st = new StringTokenizer( pathToArtifact, "/\\" ); - while ( st.hasMoreTokens() ) - { - pathParts.add( st.nextToken() ); - } - - Collections.reverse( pathParts ); - - Artifact artifact; - if ( pathParts.size() >= 4 ) - { - // maven 2.x path - - // the actual artifact filename. - String filename = (String) pathParts.remove( 0 ); - - // the next one is the version. - String version = (String) pathParts.remove( 0 ); - - // the next one is the artifactId. - String artifactId = (String) pathParts.remove( 0 ); - - // the remaining are the groupId. - Collections.reverse( pathParts ); - String groupId = StringUtils.join( pathParts.iterator(), "." ); - - String remainingFilename = filename; - if ( remainingFilename.startsWith( artifactId + "-" ) ) - { - remainingFilename = remainingFilename.substring( artifactId.length() + 1 ); - - String classifier = null; - - // TODO: use artifact handler, share with legacy discoverer - String type; - if ( remainingFilename.endsWith( ".tar.gz" ) ) - { - type = "distribution-tgz"; - remainingFilename = remainingFilename - .substring( 0, remainingFilename.length() - ".tar.gz".length() ); - } - else if ( remainingFilename.endsWith( ".zip" ) ) - { - type = "distribution-zip"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - ".zip".length() ); - } - else if ( remainingFilename.endsWith( "-test-sources.jar" ) ) - { - type = "java-source"; - classifier = "test-sources"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - - "-test-sources.jar".length() ); - } - else if ( remainingFilename.endsWith( "-sources.jar" ) ) - { - type = "java-source"; - classifier = "sources"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - - "-sources.jar".length() ); - } - else - { - int index = remainingFilename.lastIndexOf( "." ); - if ( index >= 0 ) - { - type = remainingFilename.substring( index + 1 ); - remainingFilename = remainingFilename.substring( 0, index ); - } - else - { - throw new BuilderException( "Path filename does not have an extension." ); - } - } - - Artifact result; - if ( classifier == null ) - { - result = artifactFactory - .createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); - } - else - { - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifier ); - } - - if ( result.isSnapshot() ) - { - // version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b - int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 ); - if ( classifierIndex >= 0 ) - { - classifier = remainingFilename.substring( classifierIndex + 1 ); - remainingFilename = remainingFilename.substring( 0, classifierIndex ); - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename, - type, classifier ); - } - else - { - result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename, - Artifact.SCOPE_RUNTIME, type ); - } - - // poor encapsulation requires we do this to populate base version - if ( !result.isSnapshot() ) - { - throw new BuilderException( "Failed to create a snapshot artifact: " + result ); - } - else if ( !result.getBaseVersion().equals( version ) ) - { - throw new BuilderException( - "Built snapshot artifact base version does not match path version: " - + result.getBaseVersion() + "; should have been version: " - + version ); - } - else - { - artifact = result; - } - } - else if ( !remainingFilename.startsWith( version ) ) - { - throw new BuilderException( "Built artifact version does not match path version" ); - } - else if ( !remainingFilename.equals( version ) ) - { - if ( remainingFilename.charAt( version.length() ) == '-' ) - { - classifier = remainingFilename.substring( version.length() + 1 ); - artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifier ); - } - else - { - throw new BuilderException( "Path version does not corresspond to an artifact version" ); - } - } - else - { - artifact = result; - } - } - else - { - throw new BuilderException( "Path filename does not correspond to an artifact." ); - } - } - else - { - throw new BuilderException( "Path is too short to build an artifact from." ); - } - - return artifact; - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java deleted file mode 100644 index 494a4a7c1..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; - -/** - * LayoutArtifactBuilder - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - * - * @todo this concept should really exist inside of the {@link ArtifactRepositoryLayout} object in maven itself. - */ -public interface LayoutArtifactBuilder -{ - public Artifact build( String pathToArtifact ) throws BuilderException; -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java deleted file mode 100644 index e3436e966..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.StringTokenizer; - -/** - * LegacyLayoutArtifactBuilder - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" - * role-hint="legacy" - */ -public class LegacyLayoutArtifactBuilder - extends AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - public LegacyLayoutArtifactBuilder() - { - super(); - } - - public LegacyLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - super( artifactFactory ); - } - - public Artifact build( String pathToArtifact ) - throws BuilderException - { - if( artifactFactory == null ) - { - throw new IllegalStateException( "Unable to build legacy artifact with a null artifactFactory." ); - } - - StringTokenizer tokens = new StringTokenizer( pathToArtifact, "/\\" ); - - Artifact result; - - int numberOfTokens = tokens.countTokens(); - - if ( numberOfTokens == 3 ) - { - String groupId = tokens.nextToken(); - - String type = tokens.nextToken(); - - if ( type.endsWith( "s" ) ) - { - type = type.substring( 0, type.length() - 1 ); - - // contains artifactId, version, classifier, and extension. - String avceGlob = tokens.nextToken(); - - //noinspection CollectionDeclaredAsConcreteClass - LinkedList avceTokenList = new LinkedList(); - - StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" ); - while ( avceTokenizer.hasMoreTokens() ) - { - avceTokenList.addLast( avceTokenizer.nextToken() ); - } - - String lastAvceToken = (String) avceTokenList.removeLast(); - - // TODO: share with other discoverer, use artifact handlers instead - if ( lastAvceToken.endsWith( ".tar.gz" ) ) - { - type = "distribution-tgz"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".tar.gz".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( "sources.jar" ) ) - { - type = "java-source"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( "javadoc.jar" ) ) - { - type = "javadoc.jar"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( ".zip" ) ) - { - type = "distribution-zip"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".zip".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else - { - int extPos = lastAvceToken.lastIndexOf( '.' ); - - if ( extPos > 0 ) - { - String ext = lastAvceToken.substring( extPos + 1 ); - if ( type.equals( ext ) || "plugin".equals( type ) ) - { - lastAvceToken = lastAvceToken.substring( 0, extPos ); - - avceTokenList.addLast( lastAvceToken ); - } - else - { - throw new BuilderException( "Path type does not match the extension" ); - } - } - else - { - throw new BuilderException( "Path filename does not have an extension" ); - } - } - - // let's discover the version, and whatever's leftover will be either - // a classifier, or part of the artifactId, depending on position. - // Since version is at the end, we have to move in from the back. - Collections.reverse( avceTokenList ); - - // TODO: this is obscene - surely a better way? - String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" - + "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" - + "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" - + "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" - + "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" - + "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" - + "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)"; - - StringBuffer classifierBuffer = new StringBuffer(); - StringBuffer versionBuffer = new StringBuffer(); - - boolean firstVersionTokenEncountered = false; - boolean firstToken = true; - - int tokensIterated = 0; - for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) - { - String token = (String) it.next(); - - boolean tokenIsVersionPart = token.matches( validVersionParts ); - - StringBuffer bufferToUpdate; - - // NOTE: logic in code is reversed, since we're peeling off the back - // Any token after the last versionPart will be in the classifier. - // Any token UP TO first non-versionPart is part of the version. - if ( !tokenIsVersionPart ) - { - if ( firstVersionTokenEncountered ) - { - //noinspection BreakStatement - break; - } - else - { - bufferToUpdate = classifierBuffer; - } - } - else - { - firstVersionTokenEncountered = true; - - bufferToUpdate = versionBuffer; - } - - if ( firstToken ) - { - firstToken = false; - } - else - { - bufferToUpdate.insert( 0, '-' ); - } - - bufferToUpdate.insert( 0, token ); - - tokensIterated++; - } - - // Now, restore the proper ordering so we can build the artifactId. - Collections.reverse( avceTokenList ); - - // if we didn't find a version, then punt. Use the last token - // as the version, and set the classifier empty. - if ( versionBuffer.length() < 1 ) - { - if ( avceTokenList.size() > 1 ) - { - int lastIdx = avceTokenList.size() - 1; - - versionBuffer.append( avceTokenList.get( lastIdx ) ); - avceTokenList.remove( lastIdx ); - } - - classifierBuffer.setLength( 0 ); - } - else - { - // if everything is kosher, then pop off all the classifier and - // version tokens, leaving the naked artifact id in the list. - avceTokenList = new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) ); - } - - StringBuffer artifactIdBuffer = new StringBuffer(); - - firstToken = true; - for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) - { - String token = (String) it.next(); - - if ( firstToken ) - { - firstToken = false; - } - else - { - artifactIdBuffer.append( '-' ); - } - - artifactIdBuffer.append( token ); - } - - String artifactId = artifactIdBuffer.toString(); - - if ( artifactId.length() > 0 ) - { - int lastVersionCharIdx = versionBuffer.length() - 1; - if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' ) - { - versionBuffer.setLength( lastVersionCharIdx ); - } - - String version = versionBuffer.toString(); - - if ( version.length() > 0 ) - { - if ( classifierBuffer.length() > 0 ) - { - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifierBuffer.toString() ); - } - else - { - result = artifactFactory.createArtifact( groupId, artifactId, version, - Artifact.SCOPE_RUNTIME, type ); - } - } - else - { - throw new BuilderException( "Path filename version is empty" ); - } - } - else - { - throw new BuilderException( "Path filename artifactId is empty" ); - } - } - else - { - throw new BuilderException( "Path artifact type does not corresspond to an artifact type" ); - } - } - else - { - throw new BuilderException( "Path does not match a legacy repository path for an artifact" ); - } - - return result; - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java deleted file mode 100644 index 8e3c67838..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -import java.util.HashMap; -import java.util.Map; - -/** - * ManagedArtifact - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class ManagedArtifact -{ - private String repositoryId; - - private Artifact artifact; - - private String path; - - protected Map attached; - - public ManagedArtifact( String repoId, Artifact artifact, String path ) - { - super(); - this.repositoryId = repoId; - this.artifact = artifact; - this.path = path; - this.attached = new HashMap(); - } - - public Artifact getArtifact() - { - return artifact; - } - - public String getPath() - { - return path; - } - - public String getRepositoryId() - { - return repositoryId; - } - - public Map getAttached() - { - return attached; - } - - public void setAttached( Map attached ) - { - this.attached = attached; - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java deleted file mode 100644 index b653d160a..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * ManagedArtifactTypes - provides place to test an unknown artifact type. - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class ManagedArtifactTypes -{ - public static final int GENERIC = 0; - - public static final int JAVA = 1; - - public static final int EJB = 2; - - private static List javaArtifacts; - - private static List ejbArtifacts; - - static - { - javaArtifacts = new ArrayList(); - javaArtifacts.add( "jar" ); - javaArtifacts.add( "war" ); - javaArtifacts.add( "sar" ); - javaArtifacts.add( "rar" ); - javaArtifacts.add( "ear" ); - - ejbArtifacts = new ArrayList(); - ejbArtifacts.add( "ejb" ); - ejbArtifacts.add( "ejb-client" ); - } - - public static int whichType( String type ) - { - if ( StringUtils.isBlank( type ) ) - { - // TODO: is an empty type even possible? - return GENERIC; - } - - type = type.toLowerCase(); - - if ( ejbArtifacts.contains( type ) ) - { - return EJB; - } - - if ( javaArtifacts.contains( type ) ) - { - return JAVA; - } - - return GENERIC; - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java deleted file mode 100644 index 1759df2db..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -/** - * ManagedEjbArtifact - adds the ability to reference the ejb-client jar too. - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class ManagedEjbArtifact - extends ManagedJavaArtifact -{ - public static final String CLIENT = "client"; - - public ManagedEjbArtifact( String repoId, Artifact artifact, String path ) - { - super( repoId, artifact, path ); - } - - public String getClientPath() - { - return (String) super.attached.get( CLIENT ); - } - - public void setClientPath( String clientPath ) - { - super.attached.put( CLIENT, clientPath ); - } -} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java deleted file mode 100644 index 203234b06..000000000 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -/** - * ManagedJavaArtifact - a ManagedArtifact with optional javadoc and source - * reference jars. - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class ManagedJavaArtifact - extends ManagedArtifact -{ - public static final String JAVADOC = "javadoc"; - - public static final String SOURCES = "sources"; - - public ManagedJavaArtifact( String repoId, Artifact artifact, String path ) - { - super( repoId, artifact, path ); - } - - public String getJavadocPath() - { - return (String) super.attached.get( JAVADOC ); - } - - public void setJavadocPath( String javadocPath ) - { - super.attached.put( JAVADOC, javadocPath ); - } - - public String getSourcesPath() - { - return (String) super.attached.get( SOURCES ); - } - - public void setSourcesPath( String sourcesPath ) - { - super.attached.put( SOURCES, sourcesPath ); - } -} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java index 45511c374..91111e82c 100644 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java @@ -1,4 +1,4 @@ -package org.apache.maven.archiva.common.artifact.builder; +package org.apache.maven.archiva.common.utils; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,26 +19,44 @@ package org.apache.maven.archiva.common.artifact.builder; * under the License. */ -import junit.framework.Test; -import junit.framework.TestSuite; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** - * AllTests + * VersionConstants * * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @version $Id$ */ -public class AllTests +public class VersionUtil { + public static final String SNAPSHOT = "SNAPSHOT"; - public static Test suite() + public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" ); + + public static boolean isSnapshot( String version ) { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.discoverer.builders" ); - //$JUnit-BEGIN$ - suite.addTestSuite( LegacyLayoutArtifactBuilderTest.class ); - suite.addTestSuite( DefaultLayoutArtifactBuilderTest.class ); - //$JUnit-END$ - return suite; + Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); + if ( m.matches() ) + { + return true; + } + else + { + return version.endsWith( SNAPSHOT ); + } } + public static String getBaseVersion( String version ) + { + Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); + if ( m.matches() ) + { + return m.group( 1 ) + "-" + SNAPSHOT; + } + else + { + return version; + } + } } diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java deleted file mode 100644 index 4ee9785d0..000000000 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.apache.maven.archiva.common; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * AbstractArchivaCommonTestCase - * - * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> - * @version $Id$ - */ -public abstract class AbstractArchivaCommonTestCase - extends PlexusTestCase -{ - protected ArtifactRepository createRepository( File basedir, String layout ) - throws Exception - { - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout ); - - return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, repoLayout, null, null ); - } - - public List getLegacyLayoutArtifactPaths() - { - List files = new ArrayList(); - - files.add( "invalid/jars/1.0/invalid-1.0.jar" ); - files.add( "invalid/jars/invalid-1.0.rar" ); - files.add( "invalid/jars/invalid.jar" ); - files.add( "invalid/invalid-1.0.jar" ); - files.add( "javax.sql/jars/jdbc-2.0.jar" ); - files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.jar" ); - files.add( "org.apache.maven/jars/testing-1.0-sources.jar" ); - files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.zip" ); - files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.tar.gz" ); - files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" ); - files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" ); - - return files; - } - - public List getDefaultLayoutArtifactPaths() - { - List files = new ArrayList(); - - files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); - files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); - files.add( "invalid/invalid/1.0/invalid-1.0b.jar" ); - files.add( "invalid/invalid/1.0/invalid-2.0.jar" ); - files.add( "invalid/invalid-1.0.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ); - files.add( "org/apache/maven/A/1.0/A-1.0.war" ); - files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); - files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); - files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); - files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ); - files.add( "org/apache/maven/C/1.0/C-1.0.war" ); - files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" ); - files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ); - files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); - files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ); - - return files; - } - - public List getDefaultLayoutMetadataPaths() - { - List files = new ArrayList(); - - files.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" ); - files.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" ); - files.add( "org/apache/maven/update/test-updated/maven-metadata.xml" ); - files.add( "org/apache/maven/maven-metadata.xml" ); - files.add( "org/apache/testgroup/discovery/1.0/maven-metadata.xml" ); - files.add( "org/apache/testgroup/discovery/maven-metadata.xml" ); - files.add( "javax/sql/jdbc/2.0/maven-metadata-repository.xml" ); - files.add( "javax/sql/jdbc/maven-metadata-repository.xml" ); - files.add( "javax/sql/maven-metadata-repository.xml" ); - files.add( "javax/maven-metadata.xml" ); - - return files; - } - - public List getDefaultLayoutModelPaths() - { - List files = new ArrayList(); - - files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); - files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); - files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); - files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); - files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); - files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); - - return files; - } -} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java index b6bde475a..58848a134 100644 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java @@ -35,7 +35,6 @@ public class AllTests { TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common" ); //$JUnit-BEGIN$ - suite.addTest( org.apache.maven.archiva.common.artifact.builder.AllTests.suite() ); suite.addTest( org.apache.maven.archiva.common.utils.AllTests.suite() ); //$JUnit-END$ return suite; diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java deleted file mode 100644 index 9d9b55df0..000000000 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.Artifact; -import org.codehaus.plexus.PlexusTestCase; - -/** - * AbstractLayoutArtifactBuilderTestCase - * - * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> - * @version $Id$ - */ -public abstract class AbstractLayoutArtifactBuilderTestCase -extends PlexusTestCase -{ - - protected void assertArtifact( String groupId, String artifactId, String version, String type, String classifier, Artifact artifact ) - { - assertNotNull( "Artifact cannot be null.", artifact ); - - assertEquals( "Artifact groupId", groupId, artifact.getGroupId() ); - assertEquals( "Artifact artifactId", artifactId, artifact.getArtifactId() ); - assertEquals( "Artifact version", version, artifact.getVersion() ); - assertEquals( "Artifact type", type, artifact.getType() ); - - if ( StringUtils.isNotBlank( classifier ) ) - { - assertEquals( "Artifact classifier", classifier, artifact.getClassifier() ); - } - } - -} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java deleted file mode 100644 index 954a5bb68..000000000 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * DefaultLayoutArtifactBuilderTest - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class DefaultLayoutArtifactBuilderTest - extends AbstractLayoutArtifactBuilderTestCase -{ - LayoutArtifactBuilder builder; - - protected void setUp() - throws Exception - { - super.setUp(); - - builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "default" ); - assertNotNull( builder ); - } - - protected void tearDown() - throws Exception - { - if ( builder != null ) - { - release( builder ); - } - super.tearDown(); - } - - public void testPathDistributionArtifacts() - throws BuilderException - { - assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz", null, builder - .build( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ) ); - - assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip", null, builder - .build( "org/apache/maven/testing/1.0/testing-1.0.zip" ) ); - } - - public void testPathNormal() - throws BuilderException - { - assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder - .build( "/org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); - - assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder - .build( "org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, builder.build( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ) ); - - } - - public void testPathSnapshots() - throws BuilderException - { - assertArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT", "jar", null, builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar" ) ); - - assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", null, builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ) ); - } - - public void testPathSnapshotWithClassifier() - throws BuilderException - { - assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc", builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ) ); - } - - public void testPathWithClassifier() - throws BuilderException - { - assertArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client", builder - .build( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ) ); - } - - public void testPathWithJavaSourceInclusion() - throws BuilderException - { - assertArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources", builder - .build( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ) ); - } - - public void testProblemMissingType() - { - try - { - builder.build( "invalid/invalid/1/invalid-1" ); - fail( "Should have detected missing type." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename does not have an extension.", e.getMessage() ); - } - } - - public void testProblemNonSnapshotInSnapshotDir() - { - try - { - builder.build( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); - fail( "Non Snapshot artifact inside of an Snapshot dir is invalid." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Failed to create a snapshot artifact: invalid:invalid:jar:1.0:runtime", e.getMessage() ); - } - } - - public void testProblemPathTooShort() - { - try - { - builder.build( "invalid/invalid-1.0.jar" ); - fail( "Should have detected that path is too short." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path is too short to build an artifact from.", e.getMessage() ); - } - } - - public void testProblemTimestampSnapshotNotInSnapshotDir() - { - try - { - builder.build( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); - fail( "Timestamped Snapshot artifact not inside of an Snapshot dir is invalid." ); - } - catch ( BuilderException e ) - { - /* expected path */ - // TODO: Is this really the right thing to do for this kind of artifact?? - assertEquals( "Built snapshot artifact base version does not match path version: 1.0-SNAPSHOT; " - + "should have been version: 1.0-20050611.123456-1", e.getMessage() ); - } - } - - public void testProblemVersionPathMismatch() - { - try - { - builder.build( "invalid/invalid/1.0/invalid-2.0.jar" ); - fail( "Should have detected version mismatch between path and artifact." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Built artifact version does not match path version", e.getMessage() ); - } - } - - public void testProblemVersionPathMismatchAlt() - { - try - { - builder.build( "invalid/invalid/1.0/invalid-1.0b.jar" ); - fail( "Should have version mismatch between directory and artifact." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path version does not corresspond to an artifact version", e.getMessage() ); - } - } - - public void testProblemWrongArtifactId() - { - try - { - builder.build( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); - fail( "Should have detected wrong artifact Id." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename does not correspond to an artifact.", e.getMessage() ); - } - } -} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java deleted file mode 100644 index 2fdae4a14..000000000 --- a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * LegacyLayoutArtifactBuilderTest - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class LegacyLayoutArtifactBuilderTest - extends AbstractLayoutArtifactBuilderTestCase -{ - LayoutArtifactBuilder builder; - - protected void setUp() - throws Exception - { - super.setUp(); - - builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "legacy" ); - assertNotNull( builder ); - } - - protected void tearDown() - throws Exception - { - if ( builder != null ) - { - release( builder ); - } - super.tearDown(); - } - - public void testPathNormal() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/jars/jdbc-2.0.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, artifact ); - } - - public void testPathFinal() - throws BuilderException - { - Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-final-20060606.jar" ); - - assertArtifact( "org.apache.maven.test", "maven-model", "1.0-final-20060606", "jar", null, artifact ); - } - - public void testPathSnapshot() - throws BuilderException - { - Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-SNAPSHOT.jar" ); - - assertArtifact( "org.apache.maven.test", "maven-model", "1.0-SNAPSHOT", "jar", null, artifact ); - } - - public void testPathJavadoc() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/javadoc.jars/jdbc-2.0-javadoc.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "javadoc.jar", "javadoc", artifact ); - } - - public void testPathSources() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/java-sources/jdbc-2.0-sources.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "java-source", "sources", artifact ); - } - - public void testPathPlugin() - throws BuilderException - { - Artifact artifact = builder.build( "maven/plugins/maven-test-plugin-1.8.jar" ); - - assertArtifact( "maven", "maven-test-plugin", "1.8", "plugin", null, artifact ); - } - - public void testProblemNoType() - { - try - { - builder.build( "invalid/invalid/1/invalid-1" ); - - fail( "Should have detected no type." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path does not match a legacy repository path for an artifact", e.getMessage() ); - } - } - - public void testProblemWrongArtifactPackaging() - throws ComponentLookupException - { - try - { - builder.build( "org.apache.maven.test/jars/artifactId-1.0.jar.md5" ); - - fail( "Should have detected wrong package extension." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path type does not match the extension", e.getMessage() ); - } - } - - public void testProblemNoArtifactId() - { - try - { - builder.build( "groupId/jars/-1.0.jar" ); - - fail( "Should have detected artifactId is missing" ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename artifactId is empty", e.getMessage() ); - } - - try - { - builder.build( "groupId/jars/1.0.jar" ); - - fail( "Should have detected artifactId is missing" ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename artifactId is empty", e.getMessage() ); - } - } -} |