diff options
author | Olivier Lamy <olamy@apache.org> | 2013-11-13 06:31:24 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-11-13 06:31:24 +0000 |
commit | ab6f5bde33f4ab6899557733fac009497053952e (patch) | |
tree | 87f9bc0ff11f7429ffbead336649d57ece92e4ac /archiva-modules/plugins/repository-statistics | |
parent | 16b6da8bf0942336143734e6992d3a81b3b977df (diff) | |
download | archiva-ab6f5bde33f4ab6899557733fac009497053952e.tar.gz archiva-ab6f5bde33f4ab6899557733fac009497053952e.zip |
move to last easymock 3.2
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1541399 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/repository-statistics')
-rw-r--r-- | archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java | 548 |
1 files changed, 311 insertions, 237 deletions
diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java index 8c39e402b..61ced3a38 100644 --- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java +++ b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java @@ -23,8 +23,16 @@ import junit.framework.TestCase; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet; import org.apache.archiva.metadata.repository.MetadataRepository; -import org.easymock.MockControl; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; +import org.easymock.IMocksControl; + +import static org.easymock.EasyMock.*; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import javax.jcr.Session; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -34,11 +42,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; -import javax.jcr.Session; -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; @RunWith( ArchivaBlockJUnit4ClassRunner.class ) public class RepositoryStatisticsManagerTest @@ -48,7 +51,7 @@ public class RepositoryStatisticsManagerTest private static final String TEST_REPO_ID = "test-repo"; - private MockControl metadataRepositoryControl; + private IMocksControl metadataRepositoryControl; private MetadataRepository metadataRepository; @@ -76,8 +79,8 @@ public class RepositoryStatisticsManagerTest repositoryStatisticsManager = new DefaultRepositoryStatisticsManager(); - metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); - metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); + metadataRepositoryControl = createControl(); + metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class ); } @Test @@ -97,12 +100,17 @@ public class RepositoryStatisticsManagerTest stats.setTotalGroupCount( 529 ); stats.setTotalFileCount( 56229 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - SECOND_TEST_SCAN ), stats ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, + // RepositoryStatistics.FACET_ID ), + // Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, + // RepositoryStatistics.FACET_ID, + // SECOND_TEST_SCAN ), stats ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + SECOND_TEST_SCAN ) ).andReturn( stats ); + metadataRepositoryControl.replay(); stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); @@ -124,9 +132,11 @@ public class RepositoryStatisticsManagerTest public void testGetLatestStatsWhenEmpty() throws Exception { - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Collections.emptyList() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), + // Collections.emptyList() ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Collections.<String>emptyList() ); metadataRepositoryControl.replay(); RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ); @@ -147,13 +157,18 @@ public class RepositoryStatisticsManagerTest walkRepository( 1 ); metadataRepository.addMetadataFacet( TEST_REPO_ID, stats ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Arrays.asList( stats.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - stats.getName() ), stats ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), + // Arrays.asList( stats.getName() ) ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Arrays.asList( stats.getName() ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, stats.getName() ), + // stats ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + stats.getName() ) ).andReturn( stats ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ); metadataRepositoryControl.replay(); @@ -190,20 +205,25 @@ public class RepositoryStatisticsManagerTest RepositoryStatistics stats2 = createTestStats( startTime2, current ); metadataRepository.addMetadataFacet( TEST_REPO_ID, stats2 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Arrays.asList( stats1.getName(), stats2.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - stats2.getName() ), stats2 ); - + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), + // Arrays.asList( stats1.getName(), stats2.getName() ) ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Arrays.asList( stats1.getName(), stats2.getName() ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, stats2.getName() ), + // stats2 ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, + stats2.getName() ) ).andReturn( stats2 ); metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Collections.emptyList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 2 ); - + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), + // Collections.emptyList() ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Collections.<String>emptyList() ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 2 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 2 ); metadataRepositoryControl.replay(); repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime1, @@ -224,9 +244,11 @@ public class RepositoryStatisticsManagerTest public void testDeleteStatsWhenEmpty() throws Exception { - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - Collections.emptyList(), 2 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), + // Collections.emptyList(), 2 ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( + Collections.<String>emptyList() ).times( 2 ); metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ); metadataRepositoryControl.replay(); @@ -253,17 +275,20 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 1000 ), current ); ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - keys ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); // only match the middle one String key = keys.get( 1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); + + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -274,9 +299,10 @@ public class RepositoryStatisticsManagerTest 45 ); } - List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, - TEST_REPO_ID, new Date( - current.getTime() - 4000 ), new Date( current.getTime() - 2000 ) ); + List<RepositoryStatistics> list = + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID, + new Date( current.getTime() - 4000 ), + new Date( current.getTime() - 2000 ) ); assertEquals( 1, list.size() ); assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() ); @@ -296,22 +322,27 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) ); addStats( new Date( current.getTime() - 1000 ), current ); - ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - keys ); + List<String> keys = new ArrayList<String>( statsCreated.keySet() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); + key = keys.get( 2 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); + + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -322,9 +353,9 @@ public class RepositoryStatisticsManagerTest 45 ); } - List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, - TEST_REPO_ID, new Date( - current.getTime() - 4000 ), current ); + List<RepositoryStatistics> list = + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID, + new Date( current.getTime() - 4000 ), current ); assertEquals( 2, list.size() ); assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() ); @@ -345,22 +376,25 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) ); addStats( new Date( current.getTime() - 1000 ), current ); - ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - keys ); + List<String> keys = new ArrayList<String>( statsCreated.keySet() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 0 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); key = keys.get( 1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -371,9 +405,10 @@ public class RepositoryStatisticsManagerTest 45 ); } - List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, - TEST_REPO_ID, new Date( - current.getTime() - 20000 ), new Date( current.getTime() - 2000 ) ); + List<RepositoryStatistics> list = + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID, + new Date( current.getTime() - 20000 ), + new Date( current.getTime() - 2000 ) ); assertEquals( 2, list.size() ); assertEquals( new Date( current.getTime() - 12345 ), list.get( 1 ).getScanStartTime() ); @@ -395,26 +430,30 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 1000 ), current ); ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - keys ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); String key = keys.get( 0 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); key = keys.get( 1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); key = keys.get( 2 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - RepositoryStatistics.FACET_ID, - key ), statsCreated.get( - key ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ), + // statsCreated.get( key ) ); + expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn( + statsCreated.get( key ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -425,9 +464,9 @@ public class RepositoryStatisticsManagerTest 45 ); } - List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, - TEST_REPO_ID, new Date( - current.getTime() - 20000 ), current ); + List<RepositoryStatistics> list = + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID, + new Date( current.getTime() - 20000 ), current ); assertEquals( 3, list.size() ); assertEquals( new Date( current.getTime() - 12345 ), list.get( 2 ).getScanStartTime() ); @@ -450,10 +489,11 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 1000 ), current ); ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - RepositoryStatistics.FACET_ID ), - keys ); - metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys ); + expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 ); + expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 ); metadataRepositoryControl.replay(); @@ -464,9 +504,10 @@ public class RepositoryStatisticsManagerTest 45 ); } - List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository, - TEST_REPO_ID, new Date( - current.getTime() - 20000 ), new Date( current.getTime() - 16000 ) ); + List<RepositoryStatistics> list = + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID, + new Date( current.getTime() - 20000 ), + new Date( current.getTime() - 16000 ) ); assertEquals( 0, list.size() ); @@ -521,134 +562,167 @@ public class RepositoryStatisticsManagerTest { for ( int i = 0; i < count; i++ ) { - metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ), - Arrays.asList( "com", "org" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ), - Arrays.asList( "example" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ), - Arrays.asList( "example-project" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID, - "com.example", - "example-project" ), - Arrays.asList( "1.0", "1.1" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", - "example-project", "1.0" ), - Arrays.asList( createArtifact( "com.example", "example-project", - "1.0", "jar" ), createArtifact( - "com.example", "example-project", "1.0", "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", - "example-project", "1.1" ), - Arrays.asList( createArtifact( "com.example", "example-project", - "1.1", "jar" ), createArtifact( - "com.example", "example-project", "1.1", "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ), - Arrays.asList( "apache", "codehaus" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ), - Arrays.asList( "archiva", "maven" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, - "org.apache.archiva" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, - "org.apache.archiva" ), - Arrays.asList( "metadata-repository-api", "metadata-model" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID, - "org.apache.archiva", - "metadata-repository-api" ), - Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.apache.archiva", - "metadata-repository-api", - "1.3-SNAPSHOT" ), Arrays.asList( - createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ), - createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.apache.archiva", - "metadata-repository-api", - "1.3" ), Arrays.asList( - createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), createArtifact( - "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID, - "org.apache.archiva", - "metadata-model" ), - Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.apache.archiva", - "metadata-model", - "1.3-SNAPSHOT" ), Arrays.asList( - createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), createArtifact( - "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.apache.archiva", - "metadata-model", "1.3" ), - Arrays.asList( createArtifact( "org.apache.archiva", - "metadata-model", "1.3", "jar" ), - createArtifact( "org.apache.archiva", - "metadata-model", "1.3", - "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, - "org.apache.maven" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, - "org.apache.maven" ), - Arrays.asList( "maven-model" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID, - "org.apache.maven", - "maven-model" ), - Arrays.asList( "2.2.1" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.apache.maven", - "maven-model", "2.2.1" ), - Arrays.asList( createArtifact( "org.apache.archiva", - "maven-model", "2.2.1", "jar" ), - createArtifact( "org.apache.archiva", - "maven-model", "2.2.1", - "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ), - Arrays.asList( "plexus" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, - "org.codehaus.plexus" ), - Arrays.asList() ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, - "org.codehaus.plexus" ), - Arrays.asList( "plexus-spring" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring" ), - Arrays.asList( "1.0", "1.1", "1.2" ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", "1.0" ), - Arrays.asList( createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.0", "jar" ), - createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.0", - "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", "1.1" ), - Arrays.asList( createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.1", "jar" ), - createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.1", - "pom" ) ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", "1.2" ), - Arrays.asList( createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.2", "jar" ), - createArtifact( "org.codehaus.plexus", - "plexus-spring", "1.2", - "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ), + // Arrays.asList( "com", "org" ) ); + expect( metadataRepository.getRootNamespaces( TEST_REPO_ID ) ).andReturn( Arrays.asList( "com", "org" ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ), + // Arrays.asList() ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "com" ) ).andReturn( Arrays.<String>asList() ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ), + // Arrays.asList( "example" ) ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList( "example" ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ), + // Arrays.asList() ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ) ).andReturn( + Arrays.<String>asList() ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ), + // Arrays.asList( "example-project" ) ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ) ).andReturn( + Arrays.asList( "example-project" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjectVersions( TEST_REPO_ID, "com.example", "example-project" ), + // Arrays.asList( "1.0", "1.1" ) ); + expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "com.example", "example-project" ) ).andReturn( + Arrays.asList( "1.0", "1.1" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.0" ), + // Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ), + // createArtifact( "com.example", "example-project", "1.0", "pom" ) ) ); + expect( + metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.0" ) ).andReturn( + Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ), + createArtifact( "com.example", "example-project", "1.0", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.1" ), + // Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ), + // createArtifact( "com.example", "example-project", "1.1", "pom" ) ) ); + expect( + metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.1" ) ).andReturn( + Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ), + createArtifact( "com.example", "example-project", "1.1", "pom" ) ) ); + + //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ), + // Arrays.asList( "apache", "codehaus" ) ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( "apache", "codehaus" ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ), + // Arrays.asList( "archiva", "maven" ) ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList( "archiva", "maven" ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ), + // Arrays.asList() ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.<String>asList() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ), Arrays.asList() ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.<String>asList() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjects( TEST_REPO_ID, "org.apache.archiva" ), + /// Arrays.asList( "metadata-repository-api", "metadata-model" ) ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList( "metadata-repository-api", "metadata-model" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ), + // Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); + expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ) ) + .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", + // "1.3-SNAPSHOT" ), + // Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ), + // createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", + // "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT" ) ) + .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ), + createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", + "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ), + // Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), + // createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ) ) + .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), + createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-model" ), + // Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); + expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-model" ) ) + .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ), + // Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), + // createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ) ) + .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), + createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ), + // Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ), + // createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ) ) + .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ), + createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList() ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ) ).andReturn( Arrays.<String>asList() ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjects( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList( "maven-model" ) ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache.maven" ) ) + .andReturn( Arrays.asList( "maven-model" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.maven", "maven-model" ), + // Arrays.asList( "2.2.1" ) ); + expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.maven", "maven-model" ) ) + .andReturn( Arrays.asList( "2.2.1" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ), + // Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ), + // createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ) ) + .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ), + createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ), + // Arrays.asList( "plexus" ) ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ).andReturn( Arrays.asList( "plexus" ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ), + // Arrays.asList() ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org" ) ).andReturn( Arrays.<String>asList( ) ); + //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ), + // Arrays.asList() ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ) ) + .andReturn( Arrays.<String>asList( ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ), Arrays.asList() ); + expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) ) + .andReturn( Arrays.<String>asList( ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus.plexus" ), + // Arrays.asList( "plexus-spring" ) ); + expect( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus.plexus" ) ) + .andReturn( Arrays.asList( "plexus-spring" ) ); + + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getProjectVersions( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ), + // Arrays.asList( "1.0", "1.1", "1.2" ) ); + expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ) ) + .andReturn( Arrays.asList( "1.0", "1.1", "1.2" ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ), + // Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ), + // createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ) ) + .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ), + createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ), + // Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ), + // createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ) ) + .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ), + createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) ) ); + //metadataRepositoryControl.expectAndReturn( + // metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ), + // Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ), + // createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) ) ); + expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ) ) + .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ), + createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) ) ); } } } |