aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-discoverer/src
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2006-08-26 05:47:59 +0000
committerBrett Porter <brett@apache.org>2006-08-26 05:47:59 +0000
commit209ef5ca84ee8de9e5ee61952e0d380749c3074b (patch)
tree1f64a28aa8f3bfab1ab17cb8715fe6eb0485391e /archiva-discoverer/src
parent72cbf8748f2f0cb7dad3b45cd5668461aa4a76b2 (diff)
downloadarchiva-209ef5ca84ee8de9e5ee61952e0d380749c3074b.tar.gz
archiva-209ef5ca84ee8de9e5ee61952e0d380749c3074b.zip
rename archiva artifacts
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@437088 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-discoverer/src')
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java149
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java304
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java64
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java190
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java254
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/Discoverer.java64
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java34
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java49
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java282
-rw-r--r--archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java41
-rw-r--r--archiva-discoverer/src/site/apt/design.apt37
-rw-r--r--archiva-discoverer/src/site/site.xml24
-rw-r--r--archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/AbstractArtifactDiscovererTest.java254
-rw-r--r--archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java668
-rw-r--r--archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java311
-rw-r--r--archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java479
-rw-r--r--archiva-discoverer/src/test/legacy-repository/KEYS0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/foo/invalid-1.0.foo0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/invalid-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid-1.0.rar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/invalid/jars/no-extension0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip0
-rw-r--r--archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar0
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.war1
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/1.0/B-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/2.0/B-2.0.pom9
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.war1
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/discovery/1.0/discovery-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.pom10
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.jar1
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.pom10
-rw-r--r--archiva-discoverer/src/test/pom-artifacts/org/apache/testgroup/discovery/1.0/discovery-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/KEYS1
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar0
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar0
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar0
-rw-r--r--archiva-discoverer/src/test/repository/invalid/invalid/1/invalid-10
-rw-r--r--archiva-discoverer/src/test/repository/javax/maven-metadata.xml21
-rw-r--r--archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar0
-rw-r--r--archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml21
-rw-r--r--archiva-discoverer/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml26
-rw-r--r--archiva-discoverer/src/test/repository/javax/sql/maven-metadata-repository.xml21
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.war1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.war1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/maven-metadata.xml3
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom10
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom10
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip0
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom10
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml4
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar1
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom10
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml4
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom9
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml5
-rw-r--r--archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml4
87 files changed, 3494 insertions, 0 deletions
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
new file mode 100644
index 000000000..3faa8bd47
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
@@ -0,0 +1,149 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.ArtifactRepository;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Base class for artifact discoverers.
+ *
+ * @author John Casey
+ * @author Brett Porter
+ */
+public abstract class AbstractArtifactDiscoverer
+ extends AbstractDiscoverer
+ implements ArtifactDiscoverer
+{
+ /**
+ * Standard patterns to exclude from discovery as they are not artifacts.
+ */
+ private static final String[] STANDARD_DISCOVERY_EXCLUDES = {"bin/**", "reports/**", ".maven/**", "**/*.md5",
+ "**/*.MD5", "**/*.sha1", "**/*.SHA1", "**/*snapshot-version", "*/website/**", "*/licenses/**", "*/licences/**",
+ "**/.htaccess", "**/*.html", "**/*.asc", "**/*.txt", "**/*.xml", "**/README*", "**/CHANGELOG*", "**/KEYS*"};
+
+ private List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, long comparisonTimestamp )
+ {
+ return scanForArtifactPaths( repositoryBase, blacklistedPatterns, null, STANDARD_DISCOVERY_EXCLUDES,
+ comparisonTimestamp );
+ }
+
+ public List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns,
+ boolean includeSnapshots )
+ throws DiscovererException
+ {
+ if ( !"file".equals( repository.getProtocol() ) )
+ {
+ throw new UnsupportedOperationException( "Only filesystem repositories are supported" );
+ }
+
+ Xpp3Dom dom = getLastArtifactDiscoveryDom( readRepositoryMetadataDom( repository ) );
+ long comparisonTimestamp = readComparisonTimestamp( repository, operation, dom );
+
+ // Note that last checked time is deliberately set to the start of the process so that anything added
+ // mid-discovery and missed by the scanner will get checked next time.
+ // Due to this, there must be no negative side-effects of discovering something twice.
+ Date newLastCheckedTime = new Date();
+
+ File repositoryBase = new File( repository.getBasedir() );
+
+ List artifacts = new ArrayList();
+
+ List artifactPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns, comparisonTimestamp );
+
+ // Also note that the last check time, while set at the start, is saved at the end, so that if any exceptions
+ // occur, then the timestamp is not updated so that the discovery is attempted again
+ // TODO: under the list-return behaviour we have now, exceptions might occur later and the timestamp will not be reset - see MRM-83
+ try
+ {
+ setLastCheckedTime( repository, operation, newLastCheckedTime );
+ }
+ catch ( IOException e )
+ {
+ throw new DiscovererException( "Error writing metadata: " + e.getMessage(), e );
+ }
+
+ for ( Iterator i = artifactPaths.iterator(); i.hasNext(); )
+ {
+ String path = (String) i.next();
+
+ try
+ {
+ Artifact artifact = buildArtifactFromPath( path, repository );
+
+ if ( includeSnapshots || !artifact.isSnapshot() )
+ {
+ artifacts.add( artifact );
+ }
+ }
+ catch ( DiscovererException e )
+ {
+ addKickedOutPath( path, e.getMessage() );
+ }
+ }
+
+ return artifacts;
+ }
+
+ /**
+ * Returns an artifact object that is represented by the specified path in a repository
+ *
+ * @param path The path that is pointing to an artifact
+ * @param repository The repository of the artifact
+ * @return Artifact
+ * @throws DiscovererException when the specified path does correspond to an artifact
+ */
+ public Artifact buildArtifactFromPath( String path, ArtifactRepository repository )
+ throws DiscovererException
+ {
+ Artifact artifact = buildArtifact( path );
+
+ if ( artifact != null )
+ {
+ artifact.setRepository( repository );
+ artifact.setFile( new File( repository.getBasedir(), path ) );
+ }
+
+ return artifact;
+ }
+
+ public void setLastCheckedTime( ArtifactRepository repository, String operation, Date date )
+ throws IOException
+ {
+ // see notes in resetLastCheckedTime
+
+ File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+
+ Xpp3Dom dom = readDom( file );
+
+ String dateString = new SimpleDateFormat( DATE_FMT, Locale.US ).format( date );
+
+ setEntry( getLastArtifactDiscoveryDom( dom ), operation, dateString );
+
+ saveDom( file, dom );
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
new file mode 100644
index 000000000..6888b23a9
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
@@ -0,0 +1,304 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Base class for the artifact and metadata discoverers.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public abstract class AbstractDiscoverer
+ extends AbstractLogEnabled
+ implements Discoverer
+{
+ private List kickedOutPaths = new ArrayList();
+
+ /**
+ * @plexus.requirement
+ */
+ protected ArtifactFactory artifactFactory;
+
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ private List excludedPaths = new ArrayList();
+
+ /**
+ * @plexus.configuration default-value="60000"
+ */
+ private int blackoutPeriod;
+
+ protected static final String DATE_FMT = "yyyyMMddHHmmss";
+
+ /**
+ * Add a path to the list of files that were kicked out due to being invalid.
+ *
+ * @param path the path to add
+ * @param reason the reason why the path is being kicked out
+ */
+ protected void addKickedOutPath( String path, String reason )
+ {
+ kickedOutPaths.add( new DiscovererPath( path, reason ) );
+ }
+
+ /**
+ * Returns an iterator for the list if DiscovererPaths that were found to not represent a searched object
+ *
+ * @return Iterator for the DiscovererPath List
+ */
+ public Iterator getKickedOutPathsIterator()
+ {
+ return kickedOutPaths.iterator();
+ }
+
+ protected List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, String[] includes,
+ String[] excludes, long comparisonTimestamp )
+ {
+ List allExcludes = new ArrayList();
+ allExcludes.addAll( FileUtils.getDefaultExcludesAsList() );
+ if ( excludes != null )
+ {
+ allExcludes.addAll( Arrays.asList( excludes ) );
+ }
+
+ if ( !StringUtils.isEmpty( blacklistedPatterns ) )
+ {
+ allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) );
+ }
+
+ DirectoryScanner scanner = new DirectoryScanner();
+ scanner.setBasedir( repositoryBase );
+ if ( includes != null )
+ {
+ scanner.setIncludes( includes );
+ }
+ scanner.setExcludes( (String[]) allExcludes.toArray( EMPTY_STRING_ARRAY ) );
+
+ // TODO: Correct for extremely large repositories (artifact counts over 200,000 entries)
+ scanner.scan();
+
+ for ( Iterator files = Arrays.asList( scanner.getExcludedFiles() ).iterator(); files.hasNext(); )
+ {
+ String path = files.next().toString();
+
+ excludedPaths.add( new DiscovererPath( path, "Artifact was in the specified list of exclusions" ) );
+ }
+
+ // TODO: this could be a part of the scanner
+ List includedPaths = new ArrayList();
+ for ( Iterator files = Arrays.asList( scanner.getIncludedFiles() ).iterator(); files.hasNext(); )
+ {
+ String path = files.next().toString();
+
+ long modTime = new File( repositoryBase, path ).lastModified();
+ if ( modTime < System.currentTimeMillis() - blackoutPeriod )
+ {
+ if ( modTime > comparisonTimestamp )
+ {
+ includedPaths.add( path );
+ }
+ }
+ }
+
+ return includedPaths;
+ }
+
+ /**
+ * Returns an iterator for the list if DiscovererPaths that were not processed because they are explicitly excluded
+ *
+ * @return Iterator for the DiscovererPath List
+ */
+ public Iterator getExcludedPathsIterator()
+ {
+ return excludedPaths.iterator();
+ }
+
+ protected long readComparisonTimestamp( ArtifactRepository repository, String operation, Xpp3Dom dom )
+ {
+ Xpp3Dom entry = dom.getChild( operation );
+ long comparisonTimestamp = 0;
+ if ( entry != null )
+ {
+ try
+ {
+ comparisonTimestamp = new SimpleDateFormat( DATE_FMT, Locale.US ).parse( entry.getValue() ).getTime();
+ }
+ catch ( ParseException e )
+ {
+ getLogger().error( "Timestamp was invalid: " + entry.getValue() + "; ignoring" );
+ }
+ }
+ return comparisonTimestamp;
+ }
+
+ protected Xpp3Dom readDom( File file )
+ {
+ Xpp3Dom dom;
+ FileReader fileReader = null;
+ try
+ {
+ fileReader = new FileReader( file );
+ dom = Xpp3DomBuilder.build( fileReader );
+ }
+ catch ( FileNotFoundException e )
+ {
+ // Safe to ignore
+ dom = new Xpp3Dom( "metadata" );
+ }
+ catch ( XmlPullParserException e )
+ {
+ getLogger().error( "Error reading metadata (ignoring and recreating): " + e.getMessage() );
+ dom = new Xpp3Dom( "metadata" );
+ }
+ catch ( IOException e )
+ {
+ getLogger().error( "Error reading metadata (ignoring and recreating): " + e.getMessage() );
+ dom = new Xpp3Dom( "metadata" );
+ }
+ finally
+ {
+ IOUtil.close( fileReader );
+ }
+ return dom;
+ }
+
+ protected Xpp3Dom getLastArtifactDiscoveryDom( Xpp3Dom dom )
+ {
+ Xpp3Dom lastDiscoveryDom = dom.getChild( "lastArtifactDiscovery" );
+ if ( lastDiscoveryDom == null )
+ {
+ dom.addChild( new Xpp3Dom( "lastArtifactDiscovery" ) );
+ lastDiscoveryDom = dom.getChild( "lastArtifactDiscovery" );
+ }
+ return lastDiscoveryDom;
+ }
+
+ protected Xpp3Dom getLastMetadataDiscoveryDom( Xpp3Dom dom )
+ {
+ Xpp3Dom lastDiscoveryDom = dom.getChild( "lastMetadataDiscovery" );
+ if ( lastDiscoveryDom == null )
+ {
+ dom.addChild( new Xpp3Dom( "lastMetadataDiscovery" ) );
+ lastDiscoveryDom = dom.getChild( "lastMetadataDiscovery" );
+ }
+ return lastDiscoveryDom;
+ }
+
+ public void resetLastCheckedTime( ArtifactRepository repository, String operation )
+ throws IOException
+ {
+ // TODO: get these changes into maven-metadata.xml and migrate towards that. The model is further diverging to a different layout at each level so submodels might be a good idea.
+ // TODO: maven-artifact probably needs an improved pathOfMetadata to cope with top level metadata
+ // TODO: might we need to write this as maven-metadata-local in some circumstances? merge others? Probably best to keep it simple and just use this format at the root. No need to merge anything that I can see
+ // TODO: since this metadata isn't meant to be shared, perhaps another file is called for after all.
+ // Format is: <repository><lastDiscovery><KEY>yyyyMMddHHmmss</KEY></lastDiscovery></repository> (ie, flat properties)
+
+ File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+
+ Xpp3Dom dom = readDom( file );
+
+ boolean changed = false;
+
+ if ( removeEntry( getLastArtifactDiscoveryDom( dom ), operation ) )
+ {
+ changed = true;
+ }
+
+ if ( removeEntry( getLastMetadataDiscoveryDom( dom ), operation ) )
+ {
+ changed = true;
+ }
+
+ if ( changed )
+ {
+ saveDom( file, dom );
+ }
+ }
+
+ private boolean removeEntry( Xpp3Dom lastDiscoveryDom, String operation )
+ {
+ boolean changed = false;
+
+ // do this in reverse so that removing doesn't affect counter
+ Xpp3Dom[] children = lastDiscoveryDom.getChildren();
+ for ( int i = lastDiscoveryDom.getChildCount() - 1; i >= 0; i-- )
+ {
+ if ( children[i].getName().equals( operation ) )
+ {
+ changed = true;
+ lastDiscoveryDom.removeChild( i );
+ }
+ }
+ return changed;
+ }
+
+ protected void saveDom( File file, Xpp3Dom dom )
+ throws IOException
+ {
+ FileWriter writer = new FileWriter( file );
+
+ // save metadata
+ try
+ {
+ Xpp3DomWriter.write( writer, dom );
+ }
+ finally
+ {
+ IOUtil.close( writer );
+ }
+ }
+
+ protected void setEntry( Xpp3Dom lastDiscoveryDom, String operation, String dateString )
+ {
+ Xpp3Dom entry = lastDiscoveryDom.getChild( operation );
+ if ( entry == null )
+ {
+ entry = new Xpp3Dom( operation );
+ lastDiscoveryDom.addChild( entry );
+ }
+ entry.setValue( dateString );
+ }
+
+ protected Xpp3Dom readRepositoryMetadataDom( ArtifactRepository repository )
+ {
+ return readDom( new File( repository.getBasedir(), "maven-metadata.xml" ) );
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java
new file mode 100644
index 000000000..ec9698cdf
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/ArtifactDiscoverer.java
@@ -0,0 +1,64 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.ArtifactRepository;
+
+import java.util.List;
+
+/**
+ * Interface for implementation that can discover artifacts within a repository.
+ *
+ * @author John Casey
+ * @author Brett Porter
+ * @todo do we want blacklisted patterns in another form? Part of the object construction?
+ * @todo should includeSnapshots be configuration on the component? If not, should the methods be changed to include alternates for both possibilities (discoverReleaseArtifacts, discoverReleaseAndSnapshotArtifacts)?
+ * @todo instead of a returned list, should a listener be passed in?
+ */
+public interface ArtifactDiscoverer
+ extends Discoverer
+{
+ String ROLE = ArtifactDiscoverer.class.getName();
+
+ /**
+ * Discover artifacts in the repository. Only artifacts added since the last attempt at discovery will be found.
+ * This process guarantees never to miss an artifact, however it is possible that an artifact will be received twice
+ * consecutively even if unchanged, so any users of this list must handle such a situation gracefully.
+ *
+ * @param repository the location of the repository
+ * @param operation the operation being used to discover for timestamp checking
+ * @param blacklistedPatterns pattern that lists any files to prevent from being included when scanning
+ * @param includeSnapshots whether to discover snapshots
+ * @return the list of artifacts discovered
+ * @throws DiscovererException if there was an unrecoverable problem discovering artifacts or recording progress
+ */
+ List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns,
+ boolean includeSnapshots )
+ throws DiscovererException;
+
+ /**
+ * Build an artifact from a path in the repository
+ *
+ * @param path the path
+ * @return the artifact
+ * @throws DiscovererException if the file is not a valid artifact
+ * @todo this should be in maven-artifact
+ */
+ Artifact buildArtifact( String path )
+ throws DiscovererException;
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
new file mode 100644
index 000000000..f7dabe3fc
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultArtifactDiscoverer.java
@@ -0,0 +1,190 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * Artifact discoverer for the new repository layout (Maven 2.0+).
+ *
+ * @author John Casey
+ * @author Brett Porter
+ * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="default"
+ */
+public class DefaultArtifactDiscoverer
+ extends AbstractArtifactDiscoverer
+{
+ /**
+ * @see org.apache.maven.repository.discovery.ArtifactDiscoverer#buildArtifact(String)
+ */
+ public Artifact buildArtifact( String path )
+ throws DiscovererException
+ {
+ List pathParts = new ArrayList();
+ StringTokenizer st = new StringTokenizer( path, "/\\" );
+ 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( "-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 DiscovererException( "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 DiscovererException( "Failed to create a snapshot artifact: " + result );
+ }
+ else if ( !result.getBaseVersion().equals( version ) )
+ {
+ throw new DiscovererException(
+ "Built snapshot artifact base version does not match path version: " + result +
+ "; should have been version: " + version );
+ }
+ else
+ {
+ artifact = result;
+ }
+ }
+ else if ( !remainingFilename.startsWith( version ) )
+ {
+ throw new DiscovererException( "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 DiscovererException( "Path version does not corresspond to an artifact version" );
+ }
+ }
+ else
+ {
+ artifact = result;
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "Path filename does not correspond to an artifact" );
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "Path is too short to build an artifact from" );
+ }
+
+ return artifact;
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
new file mode 100644
index 000000000..6aad837df
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
@@ -0,0 +1,254 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+/**
+ * This class gets all the paths that contain the metadata files.
+ *
+ * @plexus.component role="org.apache.maven.repository.discovery.MetadataDiscoverer" role-hint="default"
+ */
+public class DefaultMetadataDiscoverer
+ extends AbstractDiscoverer
+ implements MetadataDiscoverer
+{
+ /**
+ * Standard patterns to include in discovery of metadata files.
+ *
+ * @todo Note that only the remote format is supported at this time: you cannot search local repository metadata due
+ * to the way it is later loaded in the searchers. Review code using pathOfRemoteMetadata. IS there any value in
+ * searching the local metadata in the first place though?
+ */
+ private static final String[] STANDARD_DISCOVERY_INCLUDES = {"**/maven-metadata.xml"};
+
+ public List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns )
+ throws DiscovererException
+ {
+ if ( !"file".equals( repository.getProtocol() ) )
+ {
+ throw new UnsupportedOperationException( "Only filesystem repositories are supported" );
+ }
+
+ Xpp3Dom dom = getLastMetadataDiscoveryDom( readRepositoryMetadataDom( repository ) );
+ long comparisonTimestamp = readComparisonTimestamp( repository, operation, dom );
+
+ // Note that last checked time is deliberately set to the start of the process so that anything added
+ // mid-discovery and missed by the scanner will get checked next time.
+ // Due to this, there must be no negative side-effects of discovering something twice.
+ Date newLastCheckedTime = new Date();
+
+ List metadataFiles = new ArrayList();
+ List metadataPaths = scanForArtifactPaths( new File( repository.getBasedir() ), blacklistedPatterns,
+ STANDARD_DISCOVERY_INCLUDES, null, comparisonTimestamp );
+
+ // Also note that the last check time, while set at the start, is saved at the end, so that if any exceptions
+ // occur, then the timestamp is not updated so that the discovery is attempted again
+ // TODO: under the list-return behaviour we have now, exceptions might occur later and the timestamp will not be reset - see MRM-83
+ try
+ {
+ setLastCheckedTime( repository, operation, newLastCheckedTime );
+ }
+ catch ( IOException e )
+ {
+ throw new DiscovererException( "Error writing metadata: " + e.getMessage(), e );
+ }
+
+ for ( Iterator i = metadataPaths.iterator(); i.hasNext(); )
+ {
+ String metadataPath = (String) i.next();
+ try
+ {
+ RepositoryMetadata metadata = buildMetadata( repository.getBasedir(), metadataPath );
+ metadataFiles.add( metadata );
+ }
+ catch ( DiscovererException e )
+ {
+ addKickedOutPath( metadataPath, e.getMessage() );
+ }
+ }
+
+ return metadataFiles;
+ }
+
+ private RepositoryMetadata buildMetadata( String repo, String metadataPath )
+ throws DiscovererException
+ {
+ Metadata m;
+ String repoPath = repo + "/" + metadataPath;
+ try
+ {
+ URL url = new File( repoPath ).toURI().toURL();
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader( is );
+ MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
+
+ m = metadataReader.read( reader );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new DiscovererException( "Error parsing metadata file '" + repoPath + "': " + e.getMessage(), e );
+ }
+ catch ( MalformedURLException e )
+ {
+ // shouldn't happen
+ throw new DiscovererException( "Error constructing metadata file '" + repoPath + "': " + e.getMessage(),
+ e );
+ }
+ catch ( IOException e )
+ {
+ throw new DiscovererException( "Error reading metadata file '" + repoPath + "': " + e.getMessage(), e );
+ }
+
+ RepositoryMetadata repositoryMetadata = buildMetadata( m, metadataPath );
+
+ if ( repositoryMetadata == null )
+ {
+ throw new DiscovererException( "Unable to build a repository metadata from path" );
+ }
+
+ return repositoryMetadata;
+ }
+
+ /**
+ * Builds a RepositoryMetadata object from a Metadata object and its path.
+ *
+ * @param m Metadata
+ * @param metadataPath path
+ * @return RepositoryMetadata if the parameters represent one; null if not
+ * @todo should we just be using the path information, and loading it later when it is needed? (for reporting, etc)
+ */
+ private RepositoryMetadata buildMetadata( Metadata m, String metadataPath )
+ {
+ String metaGroupId = m.getGroupId();
+ String metaArtifactId = m.getArtifactId();
+ String metaVersion = m.getVersion();
+
+ // check if the groupId, artifactId and version is in the
+ // metadataPath
+ // parse the path, in reverse order
+ List pathParts = new ArrayList();
+ StringTokenizer st = new StringTokenizer( metadataPath, "/\\" );
+ while ( st.hasMoreTokens() )
+ {
+ pathParts.add( st.nextToken() );
+ }
+
+ Collections.reverse( pathParts );
+ // remove the metadata file
+ pathParts.remove( 0 );
+ Iterator it = pathParts.iterator();
+ String tmpDir = (String) it.next();
+
+ Artifact artifact = null;
+ if ( !StringUtils.isEmpty( metaVersion ) )
+ {
+ artifact = artifactFactory.createProjectArtifact( metaGroupId, metaArtifactId, metaVersion );
+ }
+
+ // snapshotMetadata
+ RepositoryMetadata metadata = null;
+ if ( tmpDir != null && tmpDir.equals( metaVersion ) )
+ {
+ if ( artifact != null )
+ {
+ metadata = new SnapshotArtifactRepositoryMetadata( artifact );
+ }
+ }
+ else if ( tmpDir != null && tmpDir.equals( metaArtifactId ) )
+ {
+ // artifactMetadata
+ if ( artifact != null )
+ {
+ metadata = new ArtifactRepositoryMetadata( artifact );
+ }
+ else
+ {
+ artifact = artifactFactory.createProjectArtifact( metaGroupId, metaArtifactId, "1.0" );
+ metadata = new ArtifactRepositoryMetadata( artifact );
+ }
+ }
+ else
+ {
+ String groupDir = "";
+ int ctr = 0;
+ for ( it = pathParts.iterator(); it.hasNext(); )
+ {
+ String path = (String) it.next();
+ if ( ctr == 0 )
+ {
+ groupDir = path;
+ }
+ else
+ {
+ groupDir = path + "." + groupDir;
+ }
+ ctr++;
+ }
+
+ // groupMetadata
+ if ( metaGroupId != null && metaGroupId.equals( groupDir ) )
+ {
+ metadata = new GroupRepositoryMetadata( metaGroupId );
+ }
+ }
+
+ return metadata;
+ }
+
+ public void setLastCheckedTime( ArtifactRepository repository, String operation, Date date )
+ throws IOException
+ {
+ // see notes in resetLastCheckedTime
+
+ File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+
+ Xpp3Dom dom = readDom( file );
+
+ String dateString = new SimpleDateFormat( DATE_FMT, Locale.US ).format( date );
+
+ setEntry( getLastMetadataDiscoveryDom( dom ), operation, dateString );
+
+ saveDom( file, dom );
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/Discoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/Discoverer.java
new file mode 100644
index 000000000..b0896bcad
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/Discoverer.java
@@ -0,0 +1,64 @@
+package org.apache.maven.repository.discovery;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Iterator;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public interface Discoverer
+{
+ /**
+ * Get the list of paths kicked out during the discovery process.
+ *
+ * @return the paths as Strings.
+ */
+ Iterator getKickedOutPathsIterator();
+
+ /**
+ * Get the list of paths excluded during the discovery process.
+ *
+ * @return the paths as Strings.
+ */
+ Iterator getExcludedPathsIterator();
+
+ /**
+ * Reset the time in the repository that indicates the last time a check was performed.
+ *
+ * @param repository the location of the repository
+ * @param operation the operation to record the timestamp for
+ * @throws java.io.IOException if there is a non-recoverable problem reading or writing the metadata
+ */
+ void resetLastCheckedTime( ArtifactRepository repository, String operation )
+ throws IOException;
+
+ /**
+ * Set the time in the repository that indicates the last time a check was performed.
+ *
+ * @param repository the location of the repository
+ * @param operation the operation to record the timestamp for
+ * @param date the date to set the last check to
+ * @throws java.io.IOException if there is a non-recoverable problem reading or writing the metadata
+ */
+ void setLastCheckedTime( ArtifactRepository repository, String operation, Date date )
+ throws IOException;
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java
new file mode 100644
index 000000000..02e45e699
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererException.java
@@ -0,0 +1,34 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DiscovererException
+ extends Exception
+{
+ public DiscovererException( String message )
+ {
+ super( message );
+ }
+
+ public DiscovererException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
new file mode 100644
index 000000000..ae2ecee73
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
@@ -0,0 +1,49 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DiscovererPath
+{
+ /**
+ * The path discovered.
+ */
+ private final String path;
+
+ /**
+ * A comment about why the path is being processed.
+ */
+ private final String comment;
+
+ public DiscovererPath( String path, String comment )
+ {
+ this.path = path;
+ this.comment = comment;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java
new file mode 100644
index 000000000..9a8f7fc22
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/LegacyArtifactDiscoverer.java
@@ -0,0 +1,282 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+
+/**
+ * Artifact discoverer for the legacy repository layout (Maven 1.x).
+ * Method used to build an artifact object using a relative path from a repository base directory. An artifactId
+ * having the words "DEV", "PRE", "RC", "ALPHA", "BETA", "DEBUG", "UNOFFICIAL", "CURRENT", "LATEST", "FCS",
+ * "RELEASE", "NIGHTLY", "SNAPSHOT" and "TEST" (not case-sensitive) will most likely make this method fail as
+ * they are reserved for version usage.
+ *
+ * @author John Casey
+ * @author Brett Porter
+ * @plexus.component role="org.apache.maven.repository.discovery.ArtifactDiscoverer" role-hint="legacy"
+ */
+public class LegacyArtifactDiscoverer
+ extends AbstractArtifactDiscoverer
+{
+ /**
+ * @see org.apache.maven.repository.discovery.ArtifactDiscoverer#buildArtifact(String)
+ */
+ public Artifact buildArtifact( String path )
+ throws DiscovererException
+ {
+ StringTokenizer tokens = new StringTokenizer( path, "/\\" );
+
+ 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( ".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 ) )
+ {
+ lastAvceToken = lastAvceToken.substring( 0, extPos );
+
+ avceTokenList.addLast( lastAvceToken );
+ }
+ else
+ {
+ throw new DiscovererException( "Path type does not match the extension" );
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "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 DiscovererException( "Path filename version is empty" );
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "Path filename artifactId is empty" );
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "Path artifact type does not corresspond to an artifact type" );
+ }
+ }
+ else
+ {
+ throw new DiscovererException( "Path does not match a legacy repository path for an artifact" );
+ }
+
+ return result;
+ }
+}
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java
new file mode 100644
index 000000000..3877c7723
--- /dev/null
+++ b/archiva-discoverer/src/main/java/org/apache/maven/repository/discovery/MetadataDiscoverer.java
@@ -0,0 +1,41 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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 java.util.List;
+
+/**
+ * Interface for discovering metadata files.
+ */
+public interface MetadataDiscoverer
+ extends Discoverer
+{
+ String ROLE = MetadataDiscoverer.class.getName();
+
+ /**
+ * Search for metadata files in the repository.
+ *
+ * @param repository The repository.
+ * @param operation the operation being performed (used for timestamp comparison)
+ * @param blacklistedPatterns Patterns that are to be excluded from the discovery process.
+ * @return the list of artifacts found
+ */
+ List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns )
+ throws DiscovererException;
+}
diff --git a/archiva-discoverer/src/site/apt/design.apt b/archiva-discoverer/src/site/apt/design.apt
new file mode 100644
index 000000000..6a482e0ab
--- /dev/null
+++ b/archiva-discoverer/src/site/apt/design.apt
@@ -0,0 +1,37 @@
+ -----
+ Discoverer Design
+ -----
+ Brett Porter
+ -----
+ 24 July 2006
+ -----
+
+Discoverer Design
+
+ The artifact discoverer is designed to traverse the paths in the repository and identify files that are part of
+ a legitimate artifact.
+
+ There are two plexus components available:
+
+ * {{{../apidocs/org/apache/maven/repository/discovery/ArtifactDiscoverer.html} ArtifactDiscoverer}}
+
+ * {{{../apidocs/org/apache/maven/repository/discovery/MetadataDiscoverer.html} MetadataDiscoverer}}
+
+ Each of these components currently have an implementation for the both <<<legacy>>> and <<<default>>> repository
+ layouts.
+
+ The artifact discoverer will find all artifacts in the repository, while metadata discovery finds any
+ <<<maven-metadata.xml>>> files (both remote and local repository formats).
+
+ * Limitations
+
+ * In the artifact discoverer, POMs will be identified as separate artifacts to their related artifacts, as will each
+ individual derivative artifact at present. Later, these will be linked - see
+ {{{http://jira.codehaus.org/browse/MRM-40} MRM-40}}.
+
+ * Currently, deleted artifacts are not tracked. This requires a separate event - see
+ {{{http://jira.codehaus.org/browse/MRM-37} MRM-37}}.
+
+ * Currently, all artifacts are discovered instead of just those changed since the last discovery for a particular
+ operation - see {{{http://jira.codehaus.org/browse/MRM-125} MRM-125}}.
+
diff --git a/archiva-discoverer/src/site/site.xml b/archiva-discoverer/src/site/site.xml
new file mode 100644
index 000000000..245a0bf34
--- /dev/null
+++ b/archiva-discoverer/src/site/site.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<project>
+ <body>
+ <menu name="Design Documentation">
+ <item name="Discoverer Design" href="/design.html"/>
+ </menu>
+ </body>
+</project>
diff --git a/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/AbstractArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/AbstractArtifactDiscovererTest.java
new file mode 100644
index 000000000..c016fe0bc
--- /dev/null
+++ b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/AbstractArtifactDiscovererTest.java
@@ -0,0 +1,254 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.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 org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Edwin Punzalan
+ */
+public abstract class AbstractArtifactDiscovererTest
+ extends PlexusTestCase
+{
+ protected ArtifactDiscoverer discoverer;
+
+ private ArtifactFactory factory;
+
+ protected ArtifactRepository repository;
+
+ protected static final String TEST_OPERATION = "test";
+
+ protected abstract String getLayout();
+
+ protected abstract File getRepositoryFile();
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, getLayout() );
+
+ factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+ repository = getRepository();
+
+ removeTimestampMetadata();
+ }
+
+ protected ArtifactRepository getRepository()
+ throws Exception
+ {
+ File basedir = getRepositoryFile();
+
+ ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+
+ ArtifactRepositoryLayout layout =
+ (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, getLayout() );
+
+ return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version )
+ {
+ Artifact artifact = factory.createArtifact( groupId, artifactId, version, null, "jar" );
+ artifact.setFile( new File( repository.getBasedir(), repository.pathOf( artifact ) ) );
+ artifact.setRepository( repository );
+ return artifact;
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
+ {
+ return factory.createArtifact( groupId, artifactId, version, null, type );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version, String type,
+ String classifier )
+ {
+ return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+ }
+
+ public void testUpdatedInRepository()
+ throws ComponentLookupException, DiscovererException, ParseException, IOException
+ {
+ // Set repository time to 1-1-2000, a time in the distant past so definitely updated
+ discoverer.setLastCheckedTime( repository, "update",
+ new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" ) );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-updated", "1.0" ) ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-updated", "1.0" ) ) );
+ }
+
+ public void testNotUpdatedInRepository()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ // Set repository time to now, which is after any artifacts, so definitely not updated
+ discoverer.setLastCheckedTime( repository, "update", new Date() );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscovery()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+ }
+
+ public void testUpdatedInRepositoryBlackout()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ Artifact artifact = createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" );
+ artifact.getFile().setLastModified( System.currentTimeMillis() );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included", artifacts.contains( artifact ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included", artifacts.contains( artifact ) );
+ }
+
+ public void testUpdatedInRepositoryNotBlackout()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ Artifact artifact = createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" );
+ artifact.getFile().setLastModified( System.currentTimeMillis() - 61000 );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included", artifacts.contains( artifact ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included", artifacts.contains( artifact ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscoveryMetadataAlreadyExists()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.setLastCheckedTime( repository, "update", new Date() );
+
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscoveryOtherMetadataAlreadyExists()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.setLastCheckedTime( repository, "test", new Date() );
+
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+
+ // try again with the updated timestamp
+ artifacts = discoverer.discoverArtifacts( repository, "update", null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertFalse( "Check not included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" ) ) );
+ }
+
+ public void testNoRepositoryMetadata()
+ throws ComponentLookupException, DiscovererException, ParseException, IOException
+ {
+ removeTimestampMetadata();
+
+ // should find all
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check included",
+ artifacts.contains( createArtifact( "org.apache.maven.update", "test-updated", "1.0" ) ) );
+ }
+
+ private void removeTimestampMetadata()
+ {
+ // remove the metadata that tracks time
+ File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+}
diff --git a/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
new file mode 100644
index 000000000..7832c4d68
--- /dev/null
+++ b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
@@ -0,0 +1,668 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Test the default artifact discoverer.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ * @todo test location of poms, checksums
+ */
+public class DefaultArtifactDiscovererTest
+ extends AbstractArtifactDiscovererTest
+{
+
+ protected String getLayout()
+ {
+ return "default";
+ }
+
+ protected File getRepositoryFile()
+ {
+ return getTestFile( "src/test/repository" );
+ }
+
+ public void testDefaultExcludes()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ boolean b = path.indexOf( ".svn" ) >= 0;
+ if ( b )
+ {
+ found = true;
+ assertEquals( "Check comment", "Artifact was in the specified list of exclusions", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not .svn", a.getFile().getPath().indexOf( ".svn" ) >= 0 );
+ }
+ }
+
+ public void testStandardExcludes()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "KEYS".equals( path ) )
+ {
+ found = true;
+ assertEquals( "Check comment", "Artifact was in the specified list of exclusions", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not KEYS", "KEYS".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testBlacklistedExclude()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax/**", false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "javax/sql/jdbc/2.0/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check comment is about blacklisting", "Artifact was in the specified list of exclusions",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ assertFalse( "Check jdbc not included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ }
+
+ public void testKickoutWithShortPath()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path is too short to build an artifact from",
+ dPath.getComment() );
+
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not invalid-1.0.jar", "invalid-1.0.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithWrongArtifactId()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar".equals(
+ path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path filename does not correspond to an artifact",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not wrong jar",
+ "wrong-artifactId-1.0-20050611.112233-1.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithNoType()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid/1/invalid-1".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path filename does not have an extension",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-1'", "invalid-1".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithWrongVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid/1.0/invalid-2.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Built artifact version does not match path version",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-2.0.jar'", "invalid-2.0.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithLongerVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid/1.0/invalid-1.0b.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path version does not corresspond to an artifact version",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-1.0b.jar'", "invalid-1.0b.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithWrongSnapshotVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout",
+ "Failed to create a snapshot artifact: invalid:invalid:jar:1.0:runtime",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-1.0.jar'", "invalid-1.0.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithSnapshotBaseVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar".equals(
+ path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout",
+ "Built snapshot artifact base version does not match path version: invalid:invalid:jar:1.0-SNAPSHOT:runtime; should have been version: 1.0-20050611.123456-1",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-1.0-20050611-123456-1.jar'",
+ "invalid-1.0-20050611.123456-1.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0" ) ) );
+ }
+
+ public void testArtifactWithClassifier()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included",
+ artifacts.contains( createArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client" ) ) );
+ }
+
+ public void testJavaSourcesInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains(
+ createArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources" ) ) );
+ }
+
+ public void testDistributionInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check zip included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip" ) ) );
+
+ assertTrue( "Check tar.gz included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz" ) ) );
+ }
+
+ public void testSnapshotInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ assertTrue( "Check snapshot included",
+ artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1" ) ) );
+ }
+
+ public void testSnapshotInclusionWithClassifier()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check snapshot included", artifacts.contains(
+ createArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc" ) ) );
+ }
+
+ public void testSnapshotExclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ assertFalse( "Check snapshot included",
+ artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT" ) ) );
+ }
+
+ public void testFileSet()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+ assertNotNull( "Check file is set", artifact.getFile() );
+ }
+ }
+
+ public void testRepositorySet()
+ throws MalformedURLException, DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ String url = repository.getUrl();
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+ assertNotNull( "Check repository set", artifact.getRepository() );
+ assertEquals( "Check repository url is correct", url, artifact.getRepository().getUrl() );
+ }
+ }
+
+ public void testStandalonePoms()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+
+ // cull down to actual artifacts (only standalone poms will have type = pom)
+ Map keyedArtifacts = new HashMap();
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ String key = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
+ if ( !"pom".equals( a.getType() ) || !keyedArtifacts.containsKey( key ) )
+ {
+ keyedArtifacts.put( key, a );
+ }
+ }
+
+ List models = new ArrayList();
+
+ for ( Iterator i = keyedArtifacts.values().iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+
+ if ( "pom".equals( a.getType() ) )
+ {
+ models.add( a );
+ }
+ }
+
+ assertEquals( 4, models.size() );
+
+ // Define order we expect
+ Collections.sort( models );
+
+ Iterator itr = models.iterator();
+ Artifact model = (Artifact) itr.next();
+ assertEquals( "org.apache.maven", model.getGroupId() );
+ assertEquals( "B", model.getArtifactId() );
+ assertEquals( "1.0", model.getVersion() );
+ model = (Artifact) itr.next();
+ assertEquals( "org.apache.maven", model.getGroupId() );
+ assertEquals( "B", model.getArtifactId() );
+ assertEquals( "2.0", model.getVersion() );
+ model = (Artifact) itr.next();
+ assertEquals( "org.apache.maven", model.getGroupId() );
+ assertEquals( "discovery", model.getArtifactId() );
+ assertEquals( "1.0", model.getVersion() );
+ model = (Artifact) itr.next();
+ assertEquals( "org.apache.testgroup", model.getGroupId() );
+ assertEquals( "discovery", model.getArtifactId() );
+ assertEquals( "1.0", model.getVersion() );
+ }
+
+ public void testShortPath()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid-1.0.jar" );
+
+ fail( "Artifact should be null for short paths" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testWrongArtifactId()
+ throws ComponentLookupException
+ {
+
+ try
+ {
+ discoverer.buildArtifact( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
+
+ fail( "Artifact should be null for wrong ArtifactId" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testNoType()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1/invalid-1" );
+
+ fail( "Artifact should be null for no type" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testWrongVersion()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1.0/invalid-2.0.jar" );
+
+ fail( "Artifact should be null for wrong version" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testLongVersion()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1.0/invalid-1.0b.jar" );
+
+ fail( "Artifact should be null for long version" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testWrongSnapshotVersion()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
+
+ fail( "Artifact should be null for wrong snapshot version" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testSnapshotBaseVersion()
+ throws ComponentLookupException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
+
+ fail( "Artifact should be null for snapshot base version" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testPathWithClassifier()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client" ), artifact );
+ }
+
+ public void testWithJavaSourceInclusion()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org/apache/maven/testing/1.0/testing-1.0-sources.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources" ), artifact );
+ }
+
+ public void testDistributionArtifacts()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org/apache/maven/testing/1.0/testing-1.0.tar.gz";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz" ), artifact );
+
+ testPath = "org/apache/maven/testing/1.0/testing-1.0.zip";
+
+ artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip" ), artifact );
+ }
+
+ public void testSnapshot()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT" ), artifact );
+
+ testPath = "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar";
+
+ artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1" ), artifact );
+ }
+
+ public void testNormal()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "javax/sql/jdbc/2.0/jdbc-2.0.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "javax.sql", "jdbc", "2.0" ), artifact );
+ }
+
+ public void testSnapshotWithClassifier()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc" ),
+ artifact );
+ }
+}
diff --git a/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
new file mode 100644
index 000000000..52471ab25
--- /dev/null
+++ b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
@@ -0,0 +1,311 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * This class tests the DefaultMetadataDiscoverer class.
+ */
+public class DefaultMetadataDiscovererTest
+ extends PlexusTestCase
+{
+ private MetadataDiscoverer discoverer;
+
+ private static final String TEST_OPERATION = "test";
+
+ private ArtifactRepository repository;
+
+ private ArtifactFactory factory;
+
+ /**
+ *
+ */
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ discoverer = (MetadataDiscoverer) lookup( MetadataDiscoverer.ROLE, "default" );
+
+ factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+ repository = getRepository();
+
+ removeTimestampMetadata();
+ }
+
+ protected ArtifactRepository getRepository()
+ throws Exception
+ {
+ File basedir = getTestFile( "src/test/repository" );
+
+ ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+
+ ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
+
+ return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
+ }
+
+ /**
+ *
+ */
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ discoverer = null;
+ }
+
+ /**
+ * Test if metadata file in wrong directory was added to the kickedOutPaths.
+ */
+ public void testKickoutWrongDirectory()
+ throws DiscovererException
+ {
+ discoverer.discoverMetadata( repository, TEST_OPERATION, null );
+ Iterator iter = discoverer.getKickedOutPathsIterator();
+ boolean found = false;
+ while ( iter.hasNext() && !found )
+ {
+ DiscovererPath dPath = (DiscovererPath) iter.next();
+ String dir = dPath.getPath();
+
+ String normalizedDir = dir.replace( '\\', '/' );
+ if ( "javax/maven-metadata.xml".equals( normalizedDir ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Unable to build a repository metadata from path",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( found );
+ }
+
+ /**
+ * Test if blank metadata file was added to the kickedOutPaths.
+ */
+ public void testKickoutBlankMetadata()
+ throws DiscovererException
+ {
+ discoverer.discoverMetadata( repository, TEST_OPERATION, null );
+ Iterator iter = discoverer.getKickedOutPathsIterator();
+ boolean found = false;
+ while ( iter.hasNext() && !found )
+ {
+ DiscovererPath dPath = (DiscovererPath) iter.next();
+ String dir = dPath.getPath();
+
+ String normalizedDir = dir.replace( '\\', '/' );
+ if ( "org/apache/maven/some-ejb/1.0/maven-metadata.xml".equals( normalizedDir ) )
+ {
+ found = true;
+ assertTrue( "Check reason for kickout", dPath.getComment().matches(
+ "Error reading metadata file '(.*)': input contained no data" ) );
+ }
+ }
+ assertTrue( found );
+ }
+
+ private void removeTimestampMetadata()
+ throws IOException
+ {
+ // remove the metadata that tracks time
+ File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+ System.gc(); // for Windows
+ file.delete();
+ assertFalse( file.exists() );
+ }
+
+ public void testDiscoverMetadata()
+ throws DiscovererException
+ {
+ List metadataPaths = discoverer.discoverMetadata( repository, TEST_OPERATION, null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.testgroup", "discovery" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ metadata =
+ new SnapshotArtifactRepositoryMetadata( createArtifact( "org.apache.testgroup", "discovery", "1.0" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ metadata = new GroupRepositoryMetadata( "org.apache.maven" );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ public void testUpdatedInRepository()
+ throws ComponentLookupException, DiscovererException, ParseException, IOException
+ {
+ // Set repository time to 1-1-2000, a time in the distant past so definitely updated
+ discoverer.setLastCheckedTime( repository, "update",
+ new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" ) );
+
+ List metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-updated" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ // try again with the updated timestamp
+ metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ assertFalse( "Check not included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ private boolean containsMetadata( List metadataPaths, RepositoryMetadata metadata )
+ {
+ for ( Iterator i = metadataPaths.iterator(); i.hasNext(); )
+ {
+ RepositoryMetadata m = (RepositoryMetadata) i.next();
+
+ if ( m.getGroupId().equals( metadata.getGroupId() ) )
+ {
+ if ( m.getArtifactId() == null && metadata.getArtifactId() == null )
+ {
+ return true;
+ }
+ else if ( m.getArtifactId() != null && m.getArtifactId().equals( metadata.getArtifactId() ) )
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public void testNotUpdatedInRepository()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ // Set repository time to now, which is after any artifacts, so definitely not updated
+ discoverer.setLastCheckedTime( repository, "update", new Date() );
+
+ List metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-not-updated" ) );
+ assertFalse( "Check not included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscovery()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-not-updated" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ // try again with the updated timestamp
+ metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ assertFalse( "Check not included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscoveryMetadataAlreadyExists()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.setLastCheckedTime( repository, "update", new Date() );
+
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-not-updated" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ // try again with the updated timestamp
+ metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ assertFalse( "Check not included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ public void testNotUpdatedInRepositoryForcedDiscoveryOtherMetadataAlreadyExists()
+ throws ComponentLookupException, DiscovererException, IOException
+ {
+ discoverer.setLastCheckedTime( repository, "test", new Date() );
+
+ discoverer.resetLastCheckedTime( repository, "update" );
+
+ List metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-not-updated" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+
+ // try again with the updated timestamp
+ metadataPaths = discoverer.discoverMetadata( repository, "update", null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ assertFalse( "Check not included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ public void testNoRepositoryMetadata()
+ throws ComponentLookupException, DiscovererException, ParseException, IOException
+ {
+ removeTimestampMetadata();
+
+ // should find all
+ List metadataPaths = discoverer.discoverMetadata( repository, TEST_OPERATION, null );
+ assertNotNull( "Check metadata not null", metadataPaths );
+
+ RepositoryMetadata metadata =
+ new ArtifactRepositoryMetadata( createArtifact( "org.apache.maven.update", "test-updated" ) );
+ assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId )
+ {
+ return createArtifact( groupId, artifactId, "1.0" );
+ }
+
+ private Artifact createArtifact( String groupId, String artifactId, String version )
+ {
+ return factory.createArtifact( groupId, artifactId, version, null, "jar" );
+ }
+}
diff --git a/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
new file mode 100644
index 000000000..88cc07ad1
--- /dev/null
+++ b/archiva-discoverer/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
@@ -0,0 +1,479 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Test the legacy artifact discoverer.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class LegacyArtifactDiscovererTest
+ extends AbstractArtifactDiscovererTest
+{
+ protected String getLayout()
+ {
+ return "legacy";
+ }
+
+ protected File getRepositoryFile()
+ {
+ return getTestFile( "src/test/legacy-repository" );
+ }
+
+ public void testDefaultExcludes()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( path.indexOf( ".svn" ) >= 0 )
+ {
+ found = true;
+ assertEquals( "Check comment", "Artifact was in the specified list of exclusions", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not .svn", a.getFile().getPath().indexOf( ".svn" ) >= 0 );
+ }
+ }
+
+ public void testStandardExcludes()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "KEYS".equals( path ) )
+ {
+ found = true;
+ assertEquals( "Check comment", "Artifact was in the specified list of exclusions", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not KEYS", "KEYS".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testBlacklistedExclude()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax.sql/**", false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "javax.sql/jars/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check comment is about blacklisting", "Artifact was in the specified list of exclusions",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check exclusion was found", found );
+
+ assertFalse( "Check jdbc not included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ }
+
+ public void testKickoutWithShortPath()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout",
+ "Path does not match a legacy repository path for an artifact", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not invalid-1.0.jar", "invalid-1.0.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithLongPath()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/jars/1.0/invalid-1.0.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout",
+ "Path does not match a legacy repository path for an artifact", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not invalid-1.0.jar", "invalid-1.0.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithInvalidType()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/foo/invalid-1.0.foo".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path artifact type does not corresspond to an artifact type",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not invalid-1.0.foo", "invalid-1.0.foo".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithNoExtension()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/jars/no-extension".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path filename does not have an extension",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'no-extension'", "no-extension".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithWrongExtension()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/jars/invalid-1.0.rar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path type does not match the extension",
+ dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid-1.0.rar'", "invalid-1.0.rar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testKickoutWithNoVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+ boolean found = false;
+ for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
+ {
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
+
+ if ( "invalid/jars/invalid.jar".equals( path.replace( '\\', '/' ) ) )
+ {
+ found = true;
+ assertEquals( "Check reason for kickout", "Path filename version is empty", dPath.getComment() );
+ }
+ }
+ assertTrue( "Check kickout was found", found );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact a = (Artifact) i.next();
+ assertFalse( "Check not 'invalid.jar'", "invalid.jar".equals( a.getFile().getName() ) );
+ }
+ }
+
+ public void testInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0" ) ) );
+ }
+
+ public void testTextualVersion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "UNKNOWN" ) ) );
+ }
+
+ public void testArtifactWithClassifier()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included",
+ artifacts.contains( createArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client" ) ) );
+ }
+
+ public void testJavaSourcesInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains(
+ createArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources" ) ) );
+ }
+
+ public void testDistributionInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check zip included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip" ) ) );
+
+ assertTrue( "Check tar.gz included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz" ) ) );
+ }
+
+ public void testSnapshotInclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ assertTrue( "Check snapshot included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0-20050611.112233-1" ) ) );
+ }
+
+ public void testSnapshotExclusion()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, false );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
+ assertFalse( "Check snapshot included",
+ artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0-20050611.112233-1" ) ) );
+ }
+
+ public void testFileSet()
+ throws DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+ assertNotNull( "Check file is set", artifact.getFile() );
+ }
+ }
+
+ public void testRepositorySet()
+ throws MalformedURLException, DiscovererException
+ {
+ List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, null, true );
+ assertNotNull( "Check artifacts not null", artifacts );
+
+ String url = repository.getUrl();
+ for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ {
+ Artifact artifact = (Artifact) i.next();
+ assertNotNull( "Check repository set", artifact.getRepository() );
+ assertEquals( "Check repository url is correct", url, artifact.getRepository().getUrl() );
+ }
+ }
+
+ public void testWrongArtifactPackaging()
+ throws ComponentLookupException, DiscovererException
+ {
+ try
+ {
+ discoverer.buildArtifact( "org.apache.maven.test/jars/artifactId-1.0.jar.md5" );
+
+ fail( "Artifact should be null for wrong package extension" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testNoArtifactId()
+ throws DiscovererException
+ {
+ try
+ {
+ discoverer.buildArtifact( "groupId/jars/-1.0.jar" );
+
+ fail( "Artifact should be null when artifactId is missing" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+
+ try
+ {
+ discoverer.buildArtifact( "groupId/jars/1.0.jar" );
+
+ fail( "Artifact should be null when artifactId is missing" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testNoType()
+ throws ComponentLookupException, DiscovererException
+ {
+ try
+ {
+ discoverer.buildArtifact( "invalid/invalid/1/invalid-1" );
+
+ fail( "Artifact should be null for no type" );
+ }
+ catch ( DiscovererException e )
+ {
+ // excellent
+ }
+ }
+
+ public void testSnapshot()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org.apache.maven.test/jars/maven-model-1.0-SNAPSHOT.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven.test", "maven-model", "1.0-SNAPSHOT" ), artifact );
+ }
+
+ public void testFinal()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "org.apache.maven.test/jars/maven-model-1.0-final-20060606.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "org.apache.maven.test", "maven-model", "1.0-final-20060606" ), artifact );
+ }
+
+ public void testNormal()
+ throws ComponentLookupException, DiscovererException
+ {
+ String testPath = "javax.sql/jars/jdbc-2.0.jar";
+
+ Artifact artifact = discoverer.buildArtifact( testPath );
+
+ assertEquals( createArtifact( "javax.sql", "jdbc", "2.0" ), artifact );
+ }
+}
diff --git a/archiva-discoverer/src/test/legacy-repository/KEYS b/archiva-discoverer/src/test/legacy-repository/KEYS
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/KEYS
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-discoverer/src/test/legacy-repository/invalid/foo/invalid-1.0.foo
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/foo/invalid-1.0.foo
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/invalid-1.0.jar b/archiva-discoverer/src/test/legacy-repository/invalid/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/invalid-1.0.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-discoverer/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid-1.0.rar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid-1.0.rar
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid.jar b/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/jars/invalid.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/invalid/jars/no-extension b/archiva-discoverer/src/test/legacy-repository/invalid/jars/no-extension
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/invalid/jars/no-extension
diff --git a/archiva-discoverer/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-discoverer/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip
diff --git a/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.pom
new file mode 100644
index 000000000..411d77c7d
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>A</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>war</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.war b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/A/1.0/A-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/1.0/B-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/1.0/B-1.0.pom
new file mode 100644
index 000000000..35641a048
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/1.0/B-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>B</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/2.0/B-2.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/2.0/B-2.0.pom
new file mode 100644
index 000000000..6ab1e498b
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/B/2.0/B-2.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>B</artifactId>
+ <version>2.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.pom
new file mode 100644
index 000000000..867de41f0
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>war</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.war b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/C/1.0/C-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..4dfd1f4e5
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>discovery</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
new file mode 100644
index 000000000..51d5e433c
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- default packaging is jar -->
+ <!--packaging>jar</packaging-->
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
new file mode 100644
index 000000000..c6f89f932
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- specified packaging -->
+ <packaging>jar</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/pom-artifacts/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-discoverer/src/test/pom-artifacts/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..ac5ca14b3
--- /dev/null
+++ b/archiva-discoverer/src/test/pom-artifacts/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.testgroup</groupId>
+ <artifactId>discovery</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/KEYS b/archiva-discoverer/src/test/repository/KEYS
new file mode 100644
index 000000000..d3b34d5ad
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/KEYS
@@ -0,0 +1 @@
+test KEYS file \ No newline at end of file
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid-1.0.jar b/archiva-discoverer/src/test/repository/invalid/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid-1.0.jar
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/archiva-discoverer/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/archiva-discoverer/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar b/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar b/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar
diff --git a/archiva-discoverer/src/test/repository/invalid/invalid/1/invalid-1 b/archiva-discoverer/src/test/repository/invalid/invalid/1/invalid-1
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/invalid/invalid/1/invalid-1
diff --git a/archiva-discoverer/src/test/repository/javax/maven-metadata.xml b/archiva-discoverer/src/test/repository/javax/maven-metadata.xml
new file mode 100644
index 000000000..17775863b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/javax/maven-metadata.xml
@@ -0,0 +1,21 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<metadata>
+ <groupId>javax.sql</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>2.0</version>
+</metadata>
diff --git a/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar
diff --git a/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml
new file mode 100644
index 000000000..17775863b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml
@@ -0,0 +1,21 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<metadata>
+ <groupId>javax.sql</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>2.0</version>
+</metadata>
diff --git a/archiva-discoverer/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-discoverer/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml
new file mode 100644
index 000000000..214b7dc28
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml
@@ -0,0 +1,26 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<metadata>
+ <groupId>javax.sql</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>2.0</version>
+ <versioning>
+ <versions>
+ <version>2.0</version>
+ </versions>
+ </versioning>
+</metadata>
diff --git a/archiva-discoverer/src/test/repository/javax/sql/maven-metadata-repository.xml b/archiva-discoverer/src/test/repository/javax/sql/maven-metadata-repository.xml
new file mode 100644
index 000000000..17775863b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/javax/sql/maven-metadata-repository.xml
@@ -0,0 +1,21 @@
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<metadata>
+ <groupId>javax.sql</groupId>
+ <artifactId>jdbc</artifactId>
+ <version>2.0</version>
+</metadata>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom
new file mode 100644
index 000000000..411d77c7d
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>A</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>war</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/A/1.0/A-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom
new file mode 100644
index 000000000..35641a048
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>B</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom
new file mode 100644
index 000000000..6ab1e498b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>B</artifactId>
+ <version>2.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom
new file mode 100644
index 000000000..867de41f0
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>war</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.war
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/C/1.0/C-1.0.war
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..4dfd1f4e5
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>discovery</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/maven/maven-metadata.xml
new file mode 100644
index 000000000..22f46c19b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/maven-metadata.xml
@@ -0,0 +1,3 @@
+<metadata>
+ <groupId>org.apache.maven</groupId>
+</metadata> \ No newline at end of file
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
new file mode 100644
index 000000000..51d5e433c
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- default packaging is jar -->
+ <!--packaging>jar</packaging-->
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
new file mode 100644
index 000000000..c6f89f932
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>C</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- specified packaging -->
+ <packaging>jar</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom
new file mode 100644
index 000000000..21bef0276
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.update</groupId>
+ <artifactId>test-not-updated</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- default packaging is jar -->
+ <!--packaging>jar</packaging-->
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml
new file mode 100644
index 000000000..71fc9790f
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml
@@ -0,0 +1,4 @@
+<metadata>
+ <groupId>org.apache.maven.update</groupId>
+ <artifactId>test-not-updated</artifactId>
+</metadata> \ No newline at end of file
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar
new file mode 100644
index 000000000..54d190b23
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar
@@ -0,0 +1 @@
+dummy content. sample file only.
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom
new file mode 100644
index 000000000..5f88c44df
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom
@@ -0,0 +1,10 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.update</groupId>
+ <artifactId>test-updated</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <!-- default packaging is jar -->
+ <!--packaging>jar</packaging-->
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml
new file mode 100644
index 000000000..fc17a16d7
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml
@@ -0,0 +1,4 @@
+<metadata>
+ <groupId>org.apache.maven.update</groupId>
+ <artifactId>test-updated</artifactId>
+</metadata> \ No newline at end of file
diff --git a/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
new file mode 100644
index 000000000..ac5ca14b3
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.testgroup</groupId>
+ <artifactId>discovery</artifactId>
+ <version>1.0</version>
+ <name>Maven Test Repository Artifact Discovery</name>
+ <packaging>pom</packaging>
+</project>
diff --git a/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml
new file mode 100644
index 000000000..9bb9b5a58
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml
@@ -0,0 +1,5 @@
+<metadata>
+ <groupId>org.apache.testgroup</groupId>
+ <artifactId>discovery</artifactId>
+ <version>1.0</version>
+</metadata> \ No newline at end of file
diff --git a/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml
new file mode 100644
index 000000000..50215f42b
--- /dev/null
+++ b/archiva-discoverer/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml
@@ -0,0 +1,4 @@
+<metadata>
+ <groupId>org.apache.testgroup</groupId>
+ <artifactId>discovery</artifactId>
+</metadata> \ No newline at end of file