factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
repository = getRepository();
-
- // TODO!
-// removeTimestampMetadata();
}
protected ArtifactRepository getRepository()
{
return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
}
-
-/* TODO!
- 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_OPERATION,
- new SimpleDateFormat( "yyyy-MM-dd", Locale.US ).parse( "2000-01-01" ) );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- 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 = discoverUpdateArtifactsWithSnapshots();
- 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_OPERATION, new Date() );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- 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_OPERATION );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- 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 = discoverUpdateArtifactsWithSnapshots();
- 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_OPERATION );
-
- Artifact artifact = createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" );
- artifact.getFile().setLastModified( System.currentTimeMillis() );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- assertNotNull( "Check artifacts not null", artifacts );
-
- assertFalse( "Check not included", artifacts.contains( artifact ) );
-
- // try again with the updated timestamp
- artifacts = discoverUpdateArtifactsWithSnapshots();
- assertNotNull( "Check artifacts not null", artifacts );
-
- assertFalse( "Check not included", artifacts.contains( artifact ) );
- }
-
- public void testUpdatedInRepositoryNotBlackout()
- throws ComponentLookupException, DiscovererException, IOException
- {
- discoverer.resetLastCheckedTime( repository, UPDATE_OPERATION );
-
- Artifact artifact = createArtifact( "org.apache.maven.update", "test-not-updated", "1.0" );
- artifact.getFile().setLastModified( System.currentTimeMillis() - 61000 );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- assertNotNull( "Check artifacts not null", artifacts );
-
- assertTrue( "Check included", artifacts.contains( artifact ) );
-
- // try again with the updated timestamp
- artifacts = discoverUpdateArtifactsWithSnapshots();
- assertNotNull( "Check artifacts not null", artifacts );
-
- assertFalse( "Check not included", artifacts.contains( artifact ) );
- }
-
- public void testNotUpdatedInRepositoryForcedDiscoveryMetadataAlreadyExists()
- throws ComponentLookupException, DiscovererException, IOException
- {
- discoverer.setLastCheckedTime( repository, UPDATE_OPERATION, new Date() );
-
- discoverer.resetLastCheckedTime( repository, UPDATE_OPERATION );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- 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 = discoverUpdateArtifactsWithSnapshots();
- 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_OPERATION );
-
- List artifacts = discoverUpdateArtifactsWithSnapshots();
- 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 = discoverUpdateArtifactsWithSnapshots();
- 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 = discoverArtifactsWithSnapshots();
- assertNotNull( "Check artifacts not null", artifacts );
-
- assertTrue( "Check included",
- artifacts.contains( createArtifact( "org.apache.maven.update", "test-updated", "1.0" ) ) );
- }
-
- private List discoverUpdateArtifactsWithSnapshots()
- throws DiscovererException
- {
- return discoverer.discoverArtifacts( repository, UPDATE_OPERATION, null, new AcceptAllArtifactFilter() );
- }
-
- private List discoverArtifactsWithSnapshots()
- throws DiscovererException
- {
- return discoverer.discoverArtifacts( repository, TEST_OPERATION, null, new AcceptAllArtifactFilter() );
- }
-
- private void removeTimestampMetadata()
- {
- // remove the metadata that tracks time
- File file = new File( repository.getBasedir(), "maven-metadata.xml" );
- file.delete();
- assertFalse( file.exists() );
- }
-*/
}
assertTrue( "Check included", containsMetadata( metadataPaths, metadata ) );
}
-/* TODO!
- 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 ) );
- }
-
- 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" );