diff options
15 files changed, 228 insertions, 627 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index e4604476b..b6a678e95 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -45,8 +45,8 @@ import static org.junit.Assert.*; /** * Test the configuration store. */ -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith(ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" }) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class ArchivaConfigurationTest { @@ -75,7 +75,7 @@ public class ArchivaConfigurationTest { ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-defaults" ); Configuration configuration = archivaConfiguration.getConfiguration(); - + assertConfiguration( configuration, 2, 1, 1 ); assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); @@ -88,7 +88,7 @@ public class ArchivaConfigurationTest assertEquals( "check managed repositories", "default", repository.getLayout() ); assertTrue( "check managed repositories", repository.isScanned() ); } - + @Test public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() throws Exception @@ -217,20 +217,15 @@ public class ArchivaConfigurationTest configuration.getWebapp().getUi().setAppletFindEnabled( false ); // add a change listener - //MockControl control = createConfigurationListenerMockControl(); - ConfigurationListener listener = createMock( ConfigurationListener.class );// (ConfigurationListener) control.getMock(); + ConfigurationListener listener = createMock( ConfigurationListener.class ); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); - //control.setVoidCallable(); - - //control.replay(); replay( listener ); archivaConfiguration.save( configuration ); - //control.verify(); verify( listener ); assertTrue( "Check file exists", file.exists() ); @@ -265,7 +260,7 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); @@ -306,23 +301,15 @@ public class ArchivaConfigurationTest configuration.getWebapp().getUi().setAppletFindEnabled( false ); // add a change listener - //MockControl control = createConfigurationListenerMockControl(); - //ConfigurationListener listener = (ConfigurationListener) control.getMock(); ConfigurationListener listener = createConfigurationListenerMockControl(); archivaConfiguration.addListener( listener ); listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) ); - //control.setVoidCallable( 1 ); - - //control.replay(); - replay( listener ); archivaConfiguration.save( configuration ); - //control.verify(); - verify( listener ); assertTrue( "Check file exists", userFile.exists() ); @@ -361,7 +348,7 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user-fallback" ); @@ -396,13 +383,12 @@ public class ArchivaConfigurationTest assertFalse( userFile.exists() ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -415,10 +401,10 @@ public class ArchivaConfigurationTest assertTrue( "Check file exists", baseFile.exists() ); assertEquals( "Check base file is unchanged", "<configuration/>", - FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) ); + FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); assertTrue( "Check file exists", userFile.exists() ); assertFalse( "Check base file is changed", - "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) ); + "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -441,10 +427,9 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-user.xml" ), userFile ); baseFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( baseFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -457,10 +442,10 @@ public class ArchivaConfigurationTest assertTrue( "Check file exists", baseFile.exists() ); assertEquals( "Check base file is unchanged", "<configuration/>", - FileUtils.readFileToString( baseFile, Charset.forName("UTF-8") ) ); + FileUtils.readFileToString( baseFile, Charset.forName( "UTF-8" ) ) ); assertTrue( "Check file exists", userFile.exists() ); assertFalse( "Check base file is changed", - "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ) ) ); + "<configuration/>".equals( FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ) ) ); // check it configuration = archivaConfiguration.getConfiguration(); @@ -483,10 +468,9 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-base.xml" ), baseFile ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-save-user" ); + ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-save-user" ); archivaConfiguration.reload(); @@ -636,9 +620,6 @@ public class ArchivaConfigurationTest // Save the file. archivaConfiguration.save( configuration ); - // Release existing - //release( archivaConfiguration ); - // Reload. archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); configuration = archivaConfiguration.getConfiguration(); @@ -650,7 +631,7 @@ public class ArchivaConfigurationTest assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - String actualXML = FileUtils.readFileToString( userFile, Charset.forName("UTF-8") ); + String actualXML = FileUtils.readFileToString( userFile, Charset.forName( "UTF-8" ) ); XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML ); } @@ -758,7 +739,7 @@ public class ArchivaConfigurationTest FileUtils.copyFile( getTestFile( "src/test/conf/conf-single-list-elements.xml" ), baseFile ); userFile.getParentFile().mkdirs(); - FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName("UTF-8") ); + FileUtils.writeStringToFile( userFile, "<configuration/>", Charset.forName( "UTF-8" ) ); ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-remove-central" ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java index 2dc0c46db..9412ac73c 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java @@ -19,8 +19,6 @@ package org.apache.archiva.consumers.core.repository; * under the License. */ -import java.io.File; -import javax.inject.Inject; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.metadata.repository.MetadataRepository; @@ -35,19 +33,24 @@ import org.apache.maven.index.context.IndexingContext; import org.easymock.EasyMock; import org.easymock.IMocksControl; import org.junit.After; -import static org.junit.Assert.*; import org.junit.Before; import org.junit.runner.RunWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; +import javax.inject.Inject; +import java.io.File; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + /** */ -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith(ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" }) public abstract class AbstractRepositoryPurgeTest { public static final String TEST_REPO_ID = "test-repo"; @@ -102,10 +105,10 @@ public abstract class AbstractRepositoryPurgeTest public void setUp() throws Exception { - + removeMavenIndexes(); - listenerControl = EasyMock.createControl( ); + listenerControl = EasyMock.createControl(); listener = listenerControl.createMock( RepositoryListener.class ); @@ -114,7 +117,6 @@ public abstract class AbstractRepositoryPurgeTest when( repositorySession.getRepository() ).thenReturn( metadataRepository ); - } @After @@ -137,25 +139,25 @@ public abstract class AbstractRepositoryPurgeTest } } - protected static String fixPath( String path ) + protected static String fixPath( String path ) { if ( path.contains( " " ) ) { - LoggerFactory.getLogger(AbstractRepositoryPurgeTest.class.getName()).error( - "You are building and testing with a path: \n " - + path + " containing space. Consider relocating."); - return path.replaceAll(" ", "&20"); + LoggerFactory.getLogger( AbstractRepositoryPurgeTest.class.getName() ).error( + "You are building and testing with a path: \n " + path + " containing space. Consider relocating." ); + return path.replaceAll( " ", "&20" ); } return path; } - + public ManagedRepository getRepoConfiguration( String repoId, String repoName ) { config = new ManagedRepository(); config.setId( repoId ); config.setName( repoName ); config.setDaysOlder( TEST_DAYS_OLDER ); - String path = AbstractRepositoryPurgeTest.fixPath( new File( "target/test-" + getName() + "/" + repoId ).getAbsolutePath() ); + String path = AbstractRepositoryPurgeTest.fixPath( + new File( "target/test-" + getName() + "/" + repoId ).getAbsolutePath() ); config.setLocation( path ); config.setReleases( true ); config.setSnapshots( true ); @@ -198,13 +200,15 @@ public abstract class AbstractRepositoryPurgeTest removeMavenIndexes(); File testDir = new File( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().getAbsolutePath() ) ); FileUtils.deleteDirectory( testDir ); - File sourceDir = new File ( new File( "target/test-classes/" + TEST_REPO_ID).getAbsolutePath() ); + File sourceDir = new File( new File( "target/test-classes/" + TEST_REPO_ID ).getAbsolutePath() ); FileUtils.copyDirectory( sourceDir, testDir ); - File releasesTestDir = new File( AbstractRepositoryPurgeTest.fixPath( new File( "target/test-" + getName() + "/" + RELEASES_TEST_REPO_ID ).getAbsolutePath() ) ); - + File releasesTestDir = new File( AbstractRepositoryPurgeTest.fixPath( + new File( "target/test-" + getName() + "/" + RELEASES_TEST_REPO_ID ).getAbsolutePath() ) ); + FileUtils.deleteDirectory( releasesTestDir ); - File sourceReleasesDir = new File ( new File( "target/test-classes/" + RELEASES_TEST_REPO_ID).getAbsolutePath() ); + File sourceReleasesDir = + new File( new File( "target/test-classes/" + RELEASES_TEST_REPO_ID ).getAbsolutePath() ); FileUtils.copyDirectory( sourceReleasesDir, releasesTestDir ); return AbstractRepositoryPurgeTest.fixPath( testDir.getAbsolutePath() ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java index 8fc288064..c80700fdd 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java @@ -105,7 +105,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); // search artifactId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -126,7 +125,6 @@ public class MavenRepositorySearchTest archivaConfigControl.reset(); // search groupId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -150,7 +148,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); // search artifactId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -171,7 +168,6 @@ public class MavenRepositorySearchTest archivaConfigControl.reset(); // search groupId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -196,7 +192,6 @@ public class MavenRepositorySearchTest selectedRepos.add( TEST_REPO_1 ); // search artifactId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -227,7 +222,6 @@ public class MavenRepositorySearchTest selectedRepos.add( TEST_REPO_1 ); // search artifactId - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -264,7 +258,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -289,7 +282,6 @@ public class MavenRepositorySearchTest SearchResultLimits limits = new SearchResultLimits( 0 ); limits.setPageSize( 1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -310,7 +302,6 @@ public class MavenRepositorySearchTest limits = new SearchResultLimits( 1 ); limits.setPageSize( 1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -346,7 +337,6 @@ public class MavenRepositorySearchTest config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 ); archivaConfigControl.replay(); @@ -382,7 +372,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -402,7 +391,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -421,7 +409,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( "non-existing-repo" ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -445,7 +432,6 @@ public class MavenRepositorySearchTest List<String> previousSearchTerms = new ArrayList<String>(); previousSearchTerms.add( "archiva-test" ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -484,7 +470,6 @@ public class MavenRepositorySearchTest searchFields.setVersion( "1.0" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -520,7 +505,6 @@ public class MavenRepositorySearchTest SearchResultLimits limits = new SearchResultLimits( 0 ); limits.setPageSize( 1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -539,7 +523,6 @@ public class MavenRepositorySearchTest limits = new SearchResultLimits( 1 ); limits.setPageSize( 1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -572,7 +555,6 @@ public class MavenRepositorySearchTest searchFields.setArtifactId( "artifactid-numeric" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -616,7 +598,6 @@ public class MavenRepositorySearchTest try { - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -651,7 +632,6 @@ public class MavenRepositorySearchTest try { - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -685,7 +665,6 @@ public class MavenRepositorySearchTest searchFields.setClassName( "org.apache.archiva.test.App" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -717,7 +696,6 @@ public class MavenRepositorySearchTest searchFields.setPackaging( "jar" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -746,7 +724,6 @@ public class MavenRepositorySearchTest searchFields.setPackaging( "war" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -770,7 +747,6 @@ public class MavenRepositorySearchTest searchFields.setClassName( "com.classname.search.App" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -799,7 +775,6 @@ public class MavenRepositorySearchTest searchFields.setGroupId( "org.apache.archiva" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -824,7 +799,6 @@ public class MavenRepositorySearchTest searchFields.setClassName( "SomeClass" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -846,7 +820,6 @@ public class MavenRepositorySearchTest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 0, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 0, 2 ); archivaConfigControl.replay(); @@ -875,7 +848,6 @@ public class MavenRepositorySearchTest searchFields.setClassName( "SomeClass" ); searchFields.setRepositories( selectedRepos ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 ); archivaConfigControl.replay(); @@ -906,7 +878,6 @@ public class MavenRepositorySearchTest SearchResultLimits limits = new SearchResultLimits( 0 ); limits.setPageSize( 300 ); - //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 ); EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 ); archivaConfigControl.replay(); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java index ca6d94a37..991b57135 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java @@ -184,7 +184,6 @@ public abstract class AbstractProxyTestCase repoConfig = managedLegacyRepository.getRepository(); - //config.getConfiguration().addManagedRepository( repoConfig ); applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null ); // Setup target (proxied to) repository. diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java index 1b7933489..e668db8eb 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java @@ -72,10 +72,6 @@ public class CacheFailuresTransferTest saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false ); - //wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 ); - wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 ); @@ -119,10 +115,6 @@ public class CacheFailuresTransferTest saveConnector( ID_DEFAULT_MANAGED, "badproxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false ); - //wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 ); - wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 ); @@ -135,11 +127,6 @@ public class CacheFailuresTransferTest // Second attempt to download same artifact DOES NOT use cache wagonMockControl.reset(); - - //wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 ); - wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java index ce6edd3fe..c1ebf9cf4 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java @@ -436,22 +436,12 @@ public class ChecksumTransferTest saveConnector( ID_DEFAULT_MANAGED, "badproxied", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false ); - //wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setVoidCallable(); wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().once(); - //wagonMock.get( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setVoidCallable(); wagonMock.get( EasyMock.eq( path + ".sha1" ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().once(); - //wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) ); - wagonMock.get( EasyMock.eq( path + ".md5" ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Resource does not exist." ) ).once(); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java index 4a5c2471a..69c5c3a72 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java @@ -566,9 +566,6 @@ public class ErrorHandlingTest private void simulateGetError( String path, File expectedFile, Exception throwable ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { - //wagonMock.get( path, createExpectedTempFile( expectedFile ) ); - //wagonMockControl.setMatcher(customWagonGetMatcher); - //wagonMockControl.setThrowable( throwable, 1 ); wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow(throwable ); } @@ -576,9 +573,6 @@ public class ErrorHandlingTest private void simulateGetIfNewerError( String path, File expectedFile, TransferFailedException exception ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { - //wagonMock.getIfNewer( path, createExpectedTempFile( expectedFile ), expectedFile.lastModified() ); - //wagonMockControl.setMatcher(customWagonGetIfNewerMatcher); - //wagonMockControl.setThrowable( exception, 1 ); wagonMock.getIfNewer( EasyMock.eq( path ), EasyMock.anyObject( File.class ), EasyMock.eq( expectedFile.lastModified() )); EasyMock.expectLastCall().andThrow( exception ); } diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java index c2a6f9063..5e6d31e4e 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java @@ -399,10 +399,6 @@ public class ManagedDefaultTransferTest // Configure Repository (usually done within archiva.xml configuration) saveRemoteRepositoryConfig( "badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default" ); - //wagonMock.get( path, new File( expectedFile.getAbsolutePath() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "transfer failed" ) ); - wagonMock.get( EasyMock.eq( path), EasyMock.anyObject( File.class ) ); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "transfer failed" ) ); wagonMockControl.replay(); @@ -443,15 +439,9 @@ public class ManagedDefaultTransferTest File tmpFile = new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ); - //wagonMock.get( path, tmpFile ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Can't find resource." ) ); wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) ); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Can't find resource." ) ); - //wagonMock.get( path, tmpFile ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Can't find resource." ) ); wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ) ); EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "Can't find resource." ) ); diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java index 056c5799d..ed7f04b48 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java @@ -157,9 +157,6 @@ public class MetadataTransferTest File expectedFile = new File( managedDefaultDir.getAbsoluteFile(), metadataTools.getRepositorySpecificName( "badproxied1", requestedResource ) ); - //wagonMock.get( requestedResource, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) ); - //wagonMockControl.setMatcher( customWagonGetMatcher ); - //wagonMockControl.setThrowable( new TransferFailedException( "can't connect" ) ); wagonMock.get( EasyMock.eq( requestedResource ), EasyMock.anyObject( File.class )); EasyMock.expectLastCall().andThrow( new TransferFailedException( "can't connect" ) ); diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java index 7d23630d1..b246a2a7b 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java +++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java @@ -249,10 +249,6 @@ public class RepositoryContentConsumersTest RepositoryContentConsumers consumers = lookupRepositoryConsumers( ); KnownRepositoryContentConsumer selectedKnownConsumer = knownControl.createMock( KnownRepositoryContentConsumer.class ); - //KnownRepositoryContentConsumer unselectedKnownConsumer = - // (KnownRepositoryContentConsumer) MockControl.createNiceControl( - // KnownRepositoryContentConsumer.class ).getMock( ); - KnownRepositoryContentConsumer unselectedKnownConsumer = createNiceControl().createMock( KnownRepositoryContentConsumer.class ); @@ -265,10 +261,6 @@ public class RepositoryContentConsumersTest InvalidRepositoryContentConsumer selectedInvalidConsumer = invalidControl.createMock( InvalidRepositoryContentConsumer.class ); - //InvalidRepositoryContentConsumer unselectedInvalidConsumer = - // (InvalidRepositoryContentConsumer) MockControl.createControl( - // InvalidRepositoryContentConsumer.class ).getMock( ); - InvalidRepositoryContentConsumer unselectedInvalidConsumer = createControl().createMock( InvalidRepositoryContentConsumer.class ); consumers.setApplicationContext( @@ -286,11 +278,9 @@ public class RepositoryContentConsumersTest expect( selectedKnownConsumer.getIncludes( ) ).andReturn( Collections.singletonList( "**/*.txt" ) ); selectedKnownConsumer.processFile( _OS( "path/to/test-file.txt" ), false ); - // knownConsumer.completeScan(); knownControl.replay( ); selectedInvalidConsumer.beginScan( repo, startTime, false ); - // invalidConsumer.completeScan(); invalidControl.replay( ); @@ -298,30 +288,22 @@ public class RepositoryContentConsumersTest knownControl.verify( ); invalidControl.verify( ); - //verify( in ); knownControl.reset( ); invalidControl.reset( ); - File notIncludedTestFile = new File( "target/test-repo/path/to/test-file.xml" ); selectedKnownConsumer.beginScan( repo, startTime, false ); - //selectedKnownConsumer.getExcludes( ); - //knownControl.setReturnValue( Collections.EMPTY_LIST ); expect( selectedKnownConsumer.getExcludes() ).andReturn( Collections.<String>emptyList() ); - //selectedKnownConsumer.getIncludes( ); - //knownControl.setReturnValue( Collections.singletonList( "**/*.txt" ) ); expect( selectedKnownConsumer.getIncludes( ) ).andReturn( Collections.singletonList( "**/*.txt" ) ); - // knownConsumer.completeScan(); knownControl.replay( ); selectedInvalidConsumer.beginScan( repo, startTime, false ); selectedInvalidConsumer.processFile( _OS( "path/to/test-file.xml" ), false ); expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" ); - // invalidConsumer.completeScan(); invalidControl.replay( ); consumers.executeConsumers( repo, notIncludedTestFile, true ); @@ -336,13 +318,11 @@ public class RepositoryContentConsumersTest selectedKnownConsumer.beginScan( repo, startTime, false ); expect( selectedKnownConsumer.getExcludes() ).andReturn( Collections.singletonList( "**/test-file.txt" ) ); - // knownConsumer.completeScan(); knownControl.replay( ); selectedInvalidConsumer.beginScan( repo, startTime, false ); selectedInvalidConsumer.processFile( _OS( "path/to/test-file.txt" ), false ); expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" ); - // invalidConsumer.completeScan(); invalidControl.replay( ); consumers.executeConsumers( repo, excludedTestFile, true ); diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java index bd1ee6770..45d07e897 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java @@ -88,27 +88,13 @@ public class NewVersionsOfArtifactRssFeedProcessorTest reqParams.put( RssFeedProcessor.KEY_GROUP_ID, GROUP_ID ); reqParams.put( RssFeedProcessor.KEY_ARTIFACT_ID, ARTIFACT_ID ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getRepositories(), Collections.singletonList( - // TEST_REPO ) ); expect( metadataRepository.getRepositories() ).andReturn( Collections.singletonList( TEST_REPO ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO, GROUP_ID, - // ARTIFACT_ID ), Arrays.asList( - // "1.0.1", "1.0.2", "1.0.3-SNAPSHOT" ) ); expect( metadataRepository.getProjectVersions( TEST_REPO, GROUP_ID, ARTIFACT_ID ) ).andReturn( Arrays.asList( "1.0.1", "1.0.2", "1.0.3-SNAPSHOT" ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, - // "1.0.1" ), - // Collections.singletonList( artifact1 ) ); expect( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.1" ) ).andReturn( Collections.singletonList( artifact1 ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, - // "1.0.2" ), - // Collections.singletonList( artifact2 ) ); expect( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.2" ) ).andReturn( Collections.singletonList( artifact2 ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, - // "1.0.3-SNAPSHOT" ), - // Collections.singletonList( artifact3 ) ); expect( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID, "1.0.3-SNAPSHOT" ) ).andReturn( Collections.singletonList( artifact3 ) ); metadataRepositoryControl.replay(); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java index 4ef1ff4d3..e0ea0753a 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java @@ -137,11 +137,9 @@ public class ArchivaDavResourceFactoryTest archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class ); config = new Configuration(); - //archivaConfiguration.getConfiguration(); - //archivaConfigurationControl.setReturnValue( config, 5, 20 ); expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 5, 20 ); archivaConfiguration.save( config ); - //archivaConfigurationControl.setVoidCallable( 1, 4 ); + expectLastCall().times( 1, 4 ); archivaConfigurationControl.replay(); @@ -228,49 +226,36 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 2 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 2 ); - //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 ); + expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ), - // releasesRepo ); + expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 ); - //repoRequestControl.expectAndReturn( - // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // false ); expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( true ); - //repoRequestControl.expectAndReturn( - // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false ); + expect( repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ); - //repoRequestControl.expectAndReturn( - // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // null ); + expect( repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null ); - //repoRequestControl.expectAndReturn( - // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ), - // new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), - // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ) ).andReturn( new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), - // internalRepo ); + expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo ); - //repoRequestControl.expectAndReturn( - // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // false ); + expect( repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ); archivaConfigurationControl.replay(); @@ -318,49 +303,37 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 2 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 2 ); - //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 ); + expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), - // internalRepo ); + expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ), - // releasesRepo ); + expect( repoFactory.getManagedRepositoryContent( RELEASES_REPO ) ).andReturn( releasesRepo ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 ); - //repoRequestControl.expectAndReturn( - // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // false ); + expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ); - //repoRequestControl.expectAndReturn( - // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false ); + expect( repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ); - //repoRequestControl.expectAndReturn( - // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // null ); + expect( repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null ); - //repoRequestControl.expectAndReturn( - // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ), - // new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), - // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ) ).andReturn( new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); - //repoRequestControl.expectAndReturn( - // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // false ); + expect( repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ); archivaConfigurationControl.replay(); @@ -411,57 +384,41 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 4 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 4 ); - //requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 ); + expect( request.getPathInfo() ).andReturn( "org/apache/archiva" ).times( 0, 2 ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), - // internalRepo ); + expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ), - // localMirrorRepo ); + expect( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ) ).andReturn( localMirrorRepo ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 4 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 4 ); - //repoRequestControl.expectAndReturn( - // repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, - // 2 ); + expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 ); - //repoRequestControl.expectAndReturn( - // repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 ); + expect( repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 ); - //repoRequestControl.expectAndReturn( - // repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // null, 2 ); + expect( repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( null ).times( 2 ); - //repoRequestControl.expectAndReturn( - //repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", - // internalRepo ), - //new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), - // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", internalRepo ) ).andReturn( new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); - //repoRequestControl.expectAndReturn( - // repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", localMirrorRepo ), - // new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(), - // "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + expect( repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", localMirrorRepo ) ) .andReturn( new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); - //repoRequestControl.expectAndReturn( - // repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), - // false, 2 ); + expect( repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 ); archivaConfigurationControl.replay(); requestControl.replay(); @@ -502,31 +459,27 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), - // internalRepo ); + expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 3 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 3 ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 ); - //requestControl.expectAndReturn( request.getRequestURI(), - // "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" ); + expect( request.getRequestURI() ).andReturn( "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" ); response.setHeader( "Pragma", "no-cache" ); - //responseControl.setVoidCallable(); + expectLastCall(); response.setHeader( "Cache-Control", "no-cache" ); - //responseControl.setVoidCallable(); + expectLastCall(); - //long date = 2039842134; response.setDateHeader( eq("Last-Modified"), anyLong() ); - //responseControl.setVoidCallable(); expectLastCall(); archivaConfigurationControl.replay(); @@ -565,16 +518,15 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), - // internalRepo ); + expect( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ) ).andReturn( internalRepo ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 2 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 2 ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 ); archivaConfigurationControl.replay(); @@ -615,16 +567,15 @@ public class ArchivaDavResourceFactoryTest try { archivaConfigurationControl.reset(); - //archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ); - //repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ), - // legacyRepo ); + expect( repoFactory.getManagedRepositoryContent( LEGACY_REPO ) ).andReturn( legacyRepo ); - //requestControl.expectAndReturn( request.getMethod(), "GET", 2 ); + expect( request.getMethod() ).andReturn( "GET" ).times( 2 ); - //requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 ); + expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 2 ); - //requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 ); + expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 ); archivaConfigurationControl.replay(); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java index 15345225b..fe16eea99 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java @@ -132,13 +132,12 @@ public class RepositoryServletSecurityTest sr.registerServlet( "/repository/*", RepositoryServlet.class.getName() ); sc = sr.newClient(); - servletAuthControl = EasyMock.createControl();// MockControl.createControl( ServletAuthenticator.class ); - //servletAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); + servletAuthControl = EasyMock.createControl(); + servletAuth = servletAuthControl.createMock( ServletAuthenticator.class ); httpAuthControl = EasyMock.createControl(); - //MockClassControl.createControl( HttpBasicAuthentication.class, HttpBasicAuthentication.class.getMethods() ); - //httpAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); + httpAuth = httpAuthControl.createMock( HttpAuthenticator.class ); davSessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth ); @@ -218,18 +217,16 @@ public class RepositoryServletSecurityTest servlet.setDavSessionProvider( davSessionProvider ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ), - // new AuthenticationException( "Authentication error" ) ); + servletAuth.isAuthenticated( EasyMock.anyObject( HttpServletRequest.class ), EasyMock.anyObject( AuthenticationResult.class ) ); EasyMock.expectLastCall().andThrow( new AuthenticationException( "Authentication error" ) ); servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER ); - //servletAuthControl.setThrowable( new UnauthorizedException( "'guest' has no write access to repository" ) ); + EasyMock.expectLastCall().andThrow( new UnauthorizedException( "'guest' has no write access to repository" ) ); httpAuthControl.replay(); @@ -240,7 +237,7 @@ public class RepositoryServletSecurityTest httpAuthControl.verify(); servletAuthControl.verify(); - // assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode()); + //assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getResponseCode()); } // test deploy with invalid user, but guest has write access to repo @@ -267,38 +264,29 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ), - // new AuthenticationException( "Authentication error" ) ); EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andThrow( new AuthenticationException( "Authentication error" ) ); - //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER ); - //servletAuthControl.setReturnValue( true ); EasyMock.expect(servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD )).andReturn( true ); // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, result ), - // new AuthenticationException( "Authentication error" ) ); + EasyMock.expect(servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) )).andThrow( new AuthenticationException( "Authentication error" ) ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null ); EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( null ); // check if guest has write access - //servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - //servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER ); - //servletAuthControl.setReturnValue( true ); EasyMock.expect( servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ) ).andReturn( true ); @@ -337,28 +325,26 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true ); // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ) ).andReturn( session ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() ); + EasyMock.expect( httpAuth.getSessionUser( ic.getRequest().getSession() ) ).andReturn( new SimpleUser() ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq( result ) ) ).andReturn( true ); - //servletAuthControl.expectAndThrow( - // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ), - // new UnauthorizedException( "User not authorized" ) ); + EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"), eq(ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD) ) ).andThrow( new UnauthorizedException( "User not authorized" ) ); @@ -400,10 +386,10 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class) )).andReturn( result ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true ); @@ -412,19 +398,17 @@ public class RepositoryServletSecurityTest // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult(anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ) ).andReturn( session ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), user ); + EasyMock.expect( httpAuth.getSessionUser( ic.getRequest().getSession() ) ).andReturn( user ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn( true ); - //servletAuthControl.expectAndReturn( - // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ), - // true ); + EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"), eq(ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD) ) ).andReturn( true ); @@ -467,34 +451,29 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ) .andReturn( result ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ), - // new AuthenticationException( "Authentication error" ) ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andThrow( new AuthenticationException( "Authentication error" ) ); - //servletAuthControl.expectAndReturn( - // servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ), - // true ); + EasyMock.expect( servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ).andReturn( true ); // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null ); + EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( null ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn( true ); - //servletAuthControl.expectAndReturn( - // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ), - // true ); + EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"), eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andReturn( true ); @@ -529,15 +508,12 @@ public class RepositoryServletSecurityTest servlet.setDavSessionProvider( davSessionProvider ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ), - // new AuthenticationException( "Authentication error" ) ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andThrow( new AuthenticationException( "Authentication error" ) ); - //servletAuthControl.expectAndReturn( - // servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ), - // false ); + EasyMock.expect( servletAuth.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ).andReturn( false ); @@ -577,24 +553,22 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true ); // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class ) ) ).andReturn( session ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() ); + EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class ) ) ).andReturn( new SimpleUser() ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn( true ); - //servletAuthControl.expectAndReturn( - // servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ), - // true ); + EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"), eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andReturn( true ); @@ -636,24 +610,23 @@ public class RepositoryServletSecurityTest servlet.setResourceFactory( archivaDavResourceFactory ); AuthenticationResult result = new AuthenticationResult(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), anyObject( AuthenticationResult.class ) ) ).andReturn( true ); // ArchivaDavResourceFactory#isAuthorized() SecuritySession session = new DefaultSecuritySession(); - //httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result ); + EasyMock.expect( httpAuth.getAuthenticationResult( anyObject( HttpServletRequest.class ), anyObject( HttpServletResponse.class ) ) ).andReturn( result ); - //httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session ); + EasyMock.expect( httpAuth.getSecuritySession( anyObject( HttpSession.class) ) ).andReturn( session ); - //httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() ); + EasyMock.expect( httpAuth.getSessionUser( anyObject( HttpSession.class) ) ).andReturn( new SimpleUser() ); - //servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true ); + EasyMock.expect( servletAuth.isAuthenticated( anyObject( HttpServletRequest.class ), eq(result) ) ).andReturn( true ); - //servletAuthControl.expectAndThrow( servletAuth.isAuthorized( null, session, "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ), - // new UnauthorizedException( "User not authorized to read repository." ) ); + EasyMock.expect( servletAuth.isAuthorized( anyObject( HttpServletRequest.class ), eq(session), eq("internal"), eq(ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS) ) ).andThrow( new UnauthorizedException( "User not authorized to read repository." ) ); diff --git a/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java index 0deec674c..e377346ca 100644 --- a/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java +++ b/archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java @@ -103,17 +103,11 @@ public class AuditManagerTest expectedEvents.add( event ); } - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // getEventNames( expectedEvents ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( getEventNames( expectedEvents ) ); for ( AuditEvent event : expectedEvents.subList( 1, expectedEvents.size() ) ) { - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // event.getName() ), event ); EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, event.getName() ) ).andReturn( event ); @@ -146,16 +140,10 @@ public class AuditManagerTest expectedEvents.add( createEvent( AUDIT_EVENT_BASE + MILLIS_FORMAT.format( i ) ) ); } - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // getEventNames( expectedEvents ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( getEventNames( expectedEvents ) ); for ( AuditEvent event : expectedEvents ) { - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // event.getName() ), event ); EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, event.getName() ) ).andReturn( event ); @@ -195,22 +183,13 @@ public class AuditManagerTest eventNames.get( repositoryId ).add( event.getName() ); } - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // eventNames.get( TEST_REPO_ID ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( eventNames.get( TEST_REPO_ID ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID_2, - // AuditEvent.FACET_ID ), - // eventNames.get( TEST_REPO_ID_2 ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID_2, AuditEvent.FACET_ID ) ).andReturn( eventNames.get( TEST_REPO_ID_2 ) ); for ( AuditEvent event : events.subList( 1, events.size() ) ) { - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( event.getRepositoryId(), - // AuditEvent.FACET_ID, - // event.getName() ), event ); EasyMock.expect( metadataRepository.getMetadataFacet( event.getRepositoryId(), AuditEvent.FACET_ID, event.getName() ) ).andReturn( event ); } @@ -237,9 +216,7 @@ public class AuditManagerTest throws Exception { - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Collections.emptyList() ); + EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Collections.<String>emptyList() ); metadataRepositoryControl.replay(); @@ -308,18 +285,10 @@ public class AuditManagerTest AuditEvent expectedEvent = createEvent( expectedTimestamp ); AuditEvent event3 = createEvent( new Date( current.getTime() - 1000 ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( event1.getName(), expectedEvent.getName(), - // event3.getName() ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( event1.getName(), expectedEvent.getName(), event3.getName() ) ); // only match the middle one - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent.getName() ), - // expectedEvent ); EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent.getName() ) ).andReturn( expectedEvent ); @@ -348,23 +317,11 @@ public class AuditManagerTest Date ts3 = new Date( current.getTime() - 1000 ); AuditEvent expectedEvent3 = createEvent( ts3 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( event1.getName(), expectedEvent2.getName(), - // expectedEvent3.getName() ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( event1.getName(), expectedEvent2.getName(), expectedEvent3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent2.getName() ), - // expectedEvent2 ); EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ) ).andReturn( expectedEvent2 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent3.getName() ), - // expectedEvent3 ); EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ) ).andReturn( expectedEvent3 ); metadataRepositoryControl.replay(); @@ -392,22 +349,12 @@ public class AuditManagerTest AuditEvent expectedEvent2 = createEvent( expectedTimestamp ); AuditEvent event3 = createEvent( new Date( current.getTime() - 1000 ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), - // event3.getName() ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), event3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent1.getName() ), - // expectedEvent1 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ) ).andReturn( expectedEvent1 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent2.getName() ), - // expectedEvent2 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ) ).andReturn( expectedEvent2 ); @@ -438,28 +385,15 @@ public class AuditManagerTest Date ts3 = new Date( current.getTime() - 1000 ); AuditEvent expectedEvent3 = createEvent( ts3 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), - // expectedEvent3.getName() ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), expectedEvent3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent1.getName() ), - // expectedEvent1 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ) ).andReturn( expectedEvent1 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent2.getName() ), - // expectedEvent2 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ) ).andReturn( expectedEvent2 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent3.getName() ), - // expectedEvent3 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ) ).andReturn( expectedEvent3 ); metadataRepositoryControl.replay(); @@ -490,29 +424,17 @@ public class AuditManagerTest Date ts3 = new Date( current.getTime() - 1000 ); AuditEvent expectedEvent3 = createEvent( ts3 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), - // expectedEvent3.getName() ) ); + EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), expectedEvent3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent1.getName() ), - // expectedEvent1 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ) ).andReturn( expectedEvent1 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent2.getName() ), - // expectedEvent2 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ) ).andReturn( expectedEvent2 ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID, - // AuditEvent.FACET_ID, - // expectedEvent3.getName() ), - // expectedEvent3 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ) ).andReturn( expectedEvent3 ); metadataRepositoryControl.replay(); @@ -540,24 +462,15 @@ public class AuditManagerTest expectedEvent2.setResource( "different-resource" ); AuditEvent expectedEvent3 = createEvent( new Date( current.getTime() - 1000 ) ); - //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID, - // AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), - // expectedEvent3.getName() ) ); + EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ).andReturn( Arrays.asList( expectedEvent1.getName(), expectedEvent2.getName(), expectedEvent3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ), - // expectedEvent1 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ) ).andReturn( expectedEvent1 ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ), - // expectedEvent2 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent2.getName() ) ).andReturn( expectedEvent2 ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ), - // expectedEvent3 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ) ).andReturn( expectedEvent3 ); metadataRepositoryControl.replay(); @@ -585,30 +498,20 @@ public class AuditManagerTest Date ts3 = new Date( current.getTime() - 1000 ); AuditEvent expectedEvent3 = createEvent( ts3 ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent1.getName(), expectedEvent3.getName() ) ); + EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ) .andReturn( Arrays.asList( expectedEvent1.getName(), expectedEvent3.getName() ) ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacets( TEST_REPO_ID_2, AuditEvent.FACET_ID ), - // Arrays.asList( expectedEvent2.getName() ) ); + EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID_2, AuditEvent.FACET_ID ) ) .andReturn( Arrays.asList( expectedEvent2.getName() ) ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ), - // expectedEvent1 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent1.getName() ) ) .andReturn( expectedEvent1 ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID_2, AuditEvent.FACET_ID, expectedEvent2.getName() ), - // expectedEvent2 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID_2, AuditEvent.FACET_ID, expectedEvent2.getName() ) ) .andReturn( expectedEvent2 ); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ), - // expectedEvent3 ); + EasyMock.expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, AuditEvent.FACET_ID, expectedEvent3.getName() ) ) .andReturn( expectedEvent3 ); @@ -638,9 +541,6 @@ public class AuditManagerTest String name2 = createEvent( expectedTimestamp ).getName(); String name3 = createEvent( new Date( current.getTime() - 1000 ) ).getName(); - //metadataRepositoryControl.expectAndReturn( - // metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ), - // Arrays.asList( name1, name2, name3 ) ); EasyMock.expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, AuditEvent.FACET_ID ) ) .andReturn( Arrays.asList( name1, name2, name3 ) ); 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 61ced3a38..c0632261f 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 @@ -100,14 +100,10 @@ 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 ) ); + 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 ); @@ -132,9 +128,7 @@ public class RepositoryStatisticsManagerTest public void testGetLatestStatsWhenEmpty() throws Exception { - //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(); @@ -157,17 +151,13 @@ 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() ) ); + 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(); @@ -205,24 +195,17 @@ 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() ) ); + 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() ); 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(); @@ -244,9 +227,7 @@ public class RepositoryStatisticsManagerTest public void testDeleteStatsWhenEmpty() throws Exception { - //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 ); @@ -275,19 +256,15 @@ 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 ); + 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 ) ); + 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(); @@ -323,25 +300,19 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 1000 ), current ); 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 ) ); + 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 ) ); + 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(); @@ -377,23 +348,18 @@ public class RepositoryStatisticsManagerTest addStats( new Date( current.getTime() - 1000 ), current ); 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 ) ); + 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 ) ); + 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(); @@ -430,29 +396,22 @@ 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 ); + 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 ) ); + 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 ) ); + 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 ) ); + 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(); @@ -489,10 +448,9 @@ 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 ); + 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(); @@ -562,164 +520,104 @@ public class RepositoryStatisticsManagerTest { for ( int i = 0; i < count; i++ ) { - //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" ) ) ); |