]> source.dussan.org Git - archiva.git/commitdiff
move to last easymock 3.2
authorOlivier Lamy <olamy@apache.org>
Wed, 13 Nov 2013 06:31:24 +0000 (06:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 13 Nov 2013 06:31:24 +0000 (06:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1541399 13f79535-47bb-0310-9956-ffa450edef68

22 files changed:
archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurgeTest.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractMavenRepositorySearch.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchOSGITest.java
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/MavenRepositorySearchTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MockConfiguration.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessorTest.java
archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/ArchivaServletAuthenticatorTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/RepositoryServletSecurityTest.java
archiva-modules/plugins/audit/src/test/java/org/apache/archiva/audit/AuditManagerTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/conf/MockConfiguration.java
archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
pom.xml

index 51380cc98c4cf862a694c444587ba8cee963b23f..e4604476ba2dcfa063a3fc2eb8ed370f9a4e3d49 100644 (file)
@@ -19,18 +19,11 @@ package org.apache.archiva.configuration;
  * under the License.
  */
 
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Map;
-import javax.inject.Inject;
 import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.redback.components.registry.RegistryException;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.custommonkey.xmlunit.XMLAssert;
-import org.easymock.MockControl;
-import static org.junit.Assert.*;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -40,6 +33,15 @@ import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.annotation.DirtiesContext.ClassMode;
 import org.springframework.test.context.ContextConfiguration;
 
+import javax.inject.Inject;
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.List;
+import java.util.Map;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 /**
  * Test the configuration store.
  */
@@ -215,18 +217,21 @@ public class ArchivaConfigurationTest
         configuration.getWebapp().getUi().setAppletFindEnabled( false );
 
         // add a change listener
-        MockControl control = createConfigurationListenerMockControl();
-        ConfigurationListener listener = (ConfigurationListener) control.getMock();
+        //MockControl control = createConfigurationListenerMockControl();
+        ConfigurationListener listener = createMock( ConfigurationListener.class );// (ConfigurationListener) control.getMock();
         archivaConfiguration.addListener( listener );
 
         listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) );
-        control.setVoidCallable();
+        //control.setVoidCallable();
+
 
-        control.replay();
+        //control.replay();
+        replay( listener );
 
         archivaConfiguration.save( configuration );
 
-        control.verify();
+        //control.verify();
+        verify( listener );
 
         assertTrue( "Check file exists", file.exists() );
 
@@ -242,9 +247,9 @@ public class ArchivaConfigurationTest
         assertFalse( "check value", configuration.getWebapp().getUi().isAppletFindEnabled() );
     }
 
-    private static MockControl createConfigurationListenerMockControl()
+    private static ConfigurationListener createConfigurationListenerMockControl()
     {
-        return MockControl.createControl( ConfigurationListener.class );
+        return createMock( ConfigurationListener.class );// MockControl.createControl( ConfigurationListener.class );
     }
 
     @Test
@@ -301,19 +306,24 @@ public class ArchivaConfigurationTest
         configuration.getWebapp().getUi().setAppletFindEnabled( false );
 
         // add a change listener
-        MockControl control = createConfigurationListenerMockControl();
-        ConfigurationListener listener = (ConfigurationListener) control.getMock();
+        //MockControl control = createConfigurationListenerMockControl();
+        //ConfigurationListener listener = (ConfigurationListener) control.getMock();
+        ConfigurationListener listener = createConfigurationListenerMockControl();
         archivaConfiguration.addListener( listener );
 
         listener.configurationEvent( new ConfigurationEvent( ConfigurationEvent.SAVED ) );
 
-        control.setVoidCallable( 1 );
+        //control.setVoidCallable( 1 );
 
-        control.replay();
+        //control.replay();
+
+        replay( listener );
 
         archivaConfiguration.save( configuration );
 
-        control.verify();
+        //control.verify();
+
+        verify( listener );
 
         assertTrue( "Check file exists", userFile.exists() );
         assertFalse( "Check file not created", baseFile.exists() );
index b218980a4c7769a4cbd3fd760eadd8e85287f39e..2dc0c46db085c437effad7eed9b828ac8616007a 100644 (file)
@@ -32,7 +32,8 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
-import org.easymock.MockControl;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
 import org.junit.After;
 import static org.junit.Assert.*;
 import org.junit.Before;
@@ -82,7 +83,7 @@ public abstract class AbstractRepositoryPurgeTest
 
     protected RepositoryPurge repoPurge;
 
-    protected MockControl listenerControl;
+    protected IMocksControl listenerControl;
 
     protected RepositoryListener listener;
 
@@ -104,9 +105,9 @@ public abstract class AbstractRepositoryPurgeTest
     
         removeMavenIndexes();
 
-        listenerControl = MockControl.createControl( RepositoryListener.class );
+        listenerControl = EasyMock.createControl( );
 
-        listener = (RepositoryListener) listenerControl.getMock();
+        listener = listenerControl.createMock( RepositoryListener.class );
 
         repositorySession = mock( RepositorySession.class );
         metadataRepository = mock( MetadataRepository.class );
@@ -195,7 +196,7 @@ public abstract class AbstractRepositoryPurgeTest
         throws Exception
     {
         removeMavenIndexes();
-        File testDir = new File( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().getAbsolutePath() ) ) ;// AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot() );
+        File testDir = new File( AbstractRepositoryPurgeTest.fixPath( getTestRepoRoot().getAbsolutePath() ) );
         FileUtils.deleteDirectory( testDir );
         File sourceDir = new File ( new File( "target/test-classes/" + TEST_REPO_ID).getAbsolutePath() );
         FileUtils.copyDirectory( sourceDir, testDir );
index 6f672dee1b7e72770657494df978f22011dac730..5909657db3c46e4150bcd9a3a3e2e908bdd96763 100644 (file)
@@ -19,11 +19,6 @@ package org.apache.archiva.consumers.core.repository;
  * under the License.
  */
 
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.List;
-import javax.inject.Inject;
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
 import org.apache.archiva.configuration.ArchivaConfiguration;
@@ -32,12 +27,19 @@ import org.apache.archiva.repository.events.RepositoryListener;
 import org.apache.archiva.repository.metadata.MetadataTools;
 import org.apache.commons.io.FileUtils;
 import org.custommonkey.xmlunit.XMLAssert;
-import org.easymock.MockControl;
-import static org.junit.Assert.*;
+import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 import org.springframework.test.context.ContextConfiguration;
 
+import javax.inject.Inject;
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
 
 /**
  */
@@ -76,9 +78,9 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
         archivaConfiguration =
             applicationContext.getBean( "archivaConfiguration#cleanup-released-snapshots", ArchivaConfiguration.class );
 
-        listenerControl = MockControl.createControl( RepositoryListener.class );
+        listenerControl = EasyMock.createControl( );
 
-        listener = (RepositoryListener) listenerControl.getMock();
+        listener = listenerControl.createMock( RepositoryListener.class );
         List<RepositoryListener> listeners = Collections.singletonList( listener );
         repoPurge = new CleanupReleasedSnapshotsRepositoryPurge( getRepository(), metadataTools,
                                                                  applicationContext.getBean(
index ef81635f5a38ded0877cc4d5e711fc00b9219f64..c129fe936860f1109f13faaa91d92d1b573433e3 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.index.ArtifactContext;
@@ -36,7 +37,8 @@ import org.apache.maven.index.ArtifactScanningListener;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.ScanningResult;
 import org.apache.maven.index.context.IndexingContext;
-import org.easymock.MockControl;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -47,7 +49,6 @@ import org.springframework.test.context.ContextConfiguration;
 import javax.inject.Inject;
 import java.io.File;
 import java.util.List;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 
 /**
  * @author Olivier Lamy
@@ -73,7 +74,7 @@ public abstract class AbstractMavenRepositorySearch
 
     ArtifactContextProducer artifactContextProducer;
 
-    MockControl archivaConfigControl;
+    IMocksControl archivaConfigControl;
 
     Configuration config;
 
@@ -97,9 +98,9 @@ public abstract class AbstractMavenRepositorySearch
         FileUtils.deleteDirectory( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ) );
         assertFalse( new File( FileUtil.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer" ).exists() );
 
-        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfigControl = EasyMock.createControl( );
 
-        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
+        archivaConfig = archivaConfigControl.createMock( ArchivaConfiguration.class );
 
         DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
         defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
index ca59d65d2e072b9cd4a9011cc232ab3e24393a04..e9c10474b4653193d8c706d9d917f5e5d9fa0426 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.archiva.indexer.search;
  * under the License.
  */
 
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
@@ -43,7 +44,7 @@ public class MavenRepositorySearchOSGITest
         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();
 
index 9cfc01eeb6f9e6c6ccddd3d4b7be7dd98718942d..8fc288064fad8d22b2d40b4c4b45da69da87cadb 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.indexer.util.SearchUtil;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.codehaus.plexus.util.FileUtils;
+import org.easymock.EasyMock;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
@@ -104,7 +105,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
         // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -124,7 +126,8 @@ public class MavenRepositorySearchTest
         archivaConfigControl.reset();
 
         // search groupId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -147,7 +150,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
         // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -167,7 +171,8 @@ public class MavenRepositorySearchTest
         archivaConfigControl.reset();
 
         // search groupId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -191,7 +196,8 @@ public class MavenRepositorySearchTest
         selectedRepos.add( TEST_REPO_1 );
 
         // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -221,7 +227,8 @@ public class MavenRepositorySearchTest
         selectedRepos.add( TEST_REPO_1 );
 
         // search artifactId
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -257,7 +264,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<String>();
         selectedRepos.add( TEST_REPO_1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null );
@@ -281,7 +289,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( 0 );
         limits.setPageSize( 1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -301,7 +310,8 @@ public class MavenRepositorySearchTest
         limits = new SearchResultLimits( 1 );
         limits.setPageSize( 1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -336,7 +346,8 @@ public class MavenRepositorySearchTest
 
         config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 );
 
         archivaConfigControl.replay();
 
@@ -371,7 +382,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<String>();
         selectedRepos.add( TEST_REPO_1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -390,7 +402,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<String>();
         selectedRepos.add( TEST_REPO_1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -408,7 +421,8 @@ public class MavenRepositorySearchTest
         List<String> selectedRepos = new ArrayList<String>();
         selectedRepos.add( "non-existing-repo" );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -431,7 +445,8 @@ public class MavenRepositorySearchTest
         List<String> previousSearchTerms = new ArrayList<String>();
         previousSearchTerms.add( "archiva-test" );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -469,7 +484,8 @@ public class MavenRepositorySearchTest
         searchFields.setVersion( "1.0" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -504,7 +520,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( 0 );
         limits.setPageSize( 1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -522,7 +539,8 @@ public class MavenRepositorySearchTest
         limits = new SearchResultLimits( 1 );
         limits.setPageSize( 1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -554,7 +572,8 @@ public class MavenRepositorySearchTest
         searchFields.setArtifactId( "artifactid-numeric" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -597,7 +616,8 @@ public class MavenRepositorySearchTest
 
         try
         {
-            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+            //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+            EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
             archivaConfigControl.replay();
 
@@ -631,7 +651,8 @@ public class MavenRepositorySearchTest
 
         try
         {
-            archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+            //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+            EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
             archivaConfigControl.replay();
 
@@ -664,7 +685,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "org.apache.archiva.test.App" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -695,7 +717,8 @@ public class MavenRepositorySearchTest
         searchFields.setPackaging( "jar" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -723,7 +746,8 @@ public class MavenRepositorySearchTest
         searchFields.setPackaging( "war" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
+        //archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
         archivaConfigControl.replay();
 
         SearchResults results = search.search( "user", searchFields, null );
@@ -746,7 +770,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "com.classname.search.App" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -774,7 +799,8 @@ public class MavenRepositorySearchTest
         searchFields.setGroupId( "org.apache.archiva" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -798,7 +824,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "SomeClass" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -819,7 +846,8 @@ public class MavenRepositorySearchTest
 
         List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 0, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 0, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 0, 2 );
 
         archivaConfigControl.replay();
 
@@ -847,7 +875,8 @@ public class MavenRepositorySearchTest
         searchFields.setClassName( "SomeClass" );
         searchFields.setRepositories( selectedRepos );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 2 );
 
         archivaConfigControl.replay();
 
@@ -877,7 +906,8 @@ public class MavenRepositorySearchTest
         SearchResultLimits limits = new SearchResultLimits( 0 );
         limits.setPageSize( 300 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+        //archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
+        EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 );
 
         archivaConfigControl.replay();
 
index ddefd39ec8d398dd8198e8d4194d399db180323c..ca6d94a3734c5f6e6437e333854694d123fd72c0 100644 (file)
@@ -42,8 +42,8 @@ import org.apache.commons.lang.ArrayUtils;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.wagon.Wagon;
-import org.easymock.ArgumentsMatcher;
-import org.easymock.MockControl;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runner.RunWith;
@@ -110,7 +110,7 @@ public abstract class AbstractProxyTestCase
 
     protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
 
-    protected MockControl wagonMockControl;
+    protected IMocksControl wagonMockControl;
 
     protected Wagon wagonMock;
 
@@ -205,8 +205,8 @@ public abstract class AbstractProxyTestCase
         proxyHandler = applicationContext.getBean( "repositoryProxyConnectors#test", RepositoryProxyConnectors.class );
 
         // Setup the wagon mock.
-        wagonMockControl = MockControl.createNiceControl( Wagon.class );
-        wagonMock = (Wagon) wagonMockControl.getMock();
+        wagonMockControl = EasyMock.createNiceControl( );
+        wagonMock = wagonMockControl.createMock( Wagon.class );
 
         delegate = (WagonDelegate) applicationContext.getBean( "wagon#test", Wagon.class );
 
@@ -236,7 +236,7 @@ public abstract class AbstractProxyTestCase
         }
     }
 
-
+    /*
     protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
     {
 
@@ -288,7 +288,7 @@ public abstract class AbstractProxyTestCase
             return ArrayUtils.toString( arguments );
         }
     };
-
+    */
 
     protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
         throws Exception
index 5d1a4e2b918be6a03521f5818709eef16522ef46..1b7933489a0f6bea8718ab86020832fefff149c8 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.archiva.policies.ReleasesPolicy;
 import org.apache.archiva.policies.SnapshotsPolicy;
 import org.apache.archiva.policies.urlcache.UrlFailureCache;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
@@ -46,6 +47,9 @@ public class CacheFailuresTransferTest
     // TODO: test some hard failures (eg TransferFailedException)
     // TODO: test the various combinations of fetchFrom* (note: need only test when caching is enabled)
 
+    @Inject
+    UrlFailureCache urlFailureCache;
+
     @Test
     public void testGetWithCacheFailuresOn()
         throws Exception
@@ -68,11 +72,14 @@ 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" ) );
+        //wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
+        //wagonMockControl.setMatcher( customWagonGetMatcher );
+        //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
 
-        wagonMockControl.setMatcher( customWagonGetMatcher );
+        wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
+
+        EasyMock.expectLastCall().andThrow( new ResourceDoesNotExistException( "resource does not exist." ) ).times( 2 );
 
-        wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
 
         wagonMockControl.replay();
 
@@ -112,10 +119,12 @@ 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" ) );
+        //wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
+        //wagonMockControl.setMatcher( customWagonGetMatcher );
+        //wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
 
-        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 );
 
         wagonMockControl.replay();
 
@@ -125,10 +134,15 @@ 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( 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 );
+
         wagonMockControl.replay();
 
         downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
@@ -171,13 +185,9 @@ public class CacheFailuresTransferTest
         assertNoTempFiles( expectedFile );
     }
 
-    @Inject
-    UrlFailureCache urlFailureCache;
-
     protected UrlFailureCache lookupUrlFailureCache()
         throws Exception
     {
-        //UrlFailureCache urlFailureCache = (UrlFailureCache) lookup( "urlFailureCache" );
         assertNotNull( "URL Failure Cache cannot be null.", urlFailureCache );
         return urlFailureCache;
     }
index 8db42609666d3bc3e5b2502c7c4c898d02cff18a..ce6edd3fed6d1144c8e1cd6c72bbd59af5288b44 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.archiva.policies.ChecksumPolicy;
 import org.apache.archiva.policies.ReleasesPolicy;
 import org.apache.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
@@ -435,15 +436,25 @@ 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( path + ".sha1", new File( expectedFile.getAbsolutePath() + ".sha1.tmp" ) );
-        wagonMockControl.setMatcher( customWagonGetMatcher );
-        wagonMockControl.setVoidCallable();
-        wagonMock.get( path + ".md5", new File( expectedFile.getAbsolutePath() + ".md5.tmp" ) );
-        wagonMockControl.setMatcher( customWagonGetMatcher );
-        wagonMockControl.setThrowable( new ResourceDoesNotExistException( "Resource does not exist." ) );
+        //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();
+
         wagonMockControl.replay();
 
         File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
index 6d5139c52c0b2ece238e42bfb8be525396438113..4a5c2471a560703301f6020c06d42e47b79fbe56 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.archiva.repository.layout.LayoutException;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
@@ -565,17 +566,21 @@ 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( path, createExpectedTempFile( expectedFile ) );
+        //wagonMockControl.setMatcher(customWagonGetMatcher);
+        //wagonMockControl.setThrowable( throwable, 1 );
+        wagonMock.get( EasyMock.eq( path ), EasyMock.anyObject( File.class ));
+        EasyMock.expectLastCall().andThrow(throwable );
     }
 
     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( 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 );
     }
 
     private File createExpectedTempFile( File expectedFile )
index ed739f1865a48a1eed890053e668f5979a64be91..c2a6f906361a13ad0d501435e1795b02a3e0f50c 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.archiva.policies.SnapshotsPolicy;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import java.io.File;
@@ -398,9 +399,12 @@ 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( 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();
 
         // Configure Connector (usually done within archiva.xml configuration)
@@ -438,15 +442,18 @@ public class ManagedDefaultTransferTest
         saveConnector( ID_DEFAULT_MANAGED, "badproxied2", false );
 
         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( path, tmpFile );
 
-        wagonMockControl.setMatcher( customWagonGetMatcher );
-        wagonMockControl.setThrowable( 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." ) );
+
+        //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." ) );
 
         wagonMockControl.replay();
 
index a14089067b28306d35301eace5fec3746b763f49..056c5799dc976ce536934caf1087a7d851bb2201 100644 (file)
@@ -35,9 +35,11 @@ import org.apache.archiva.repository.metadata.MetadataTools;
 import org.apache.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
 import org.apache.commons.lang.StringUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.custommonkey.xmlunit.DetailedDiff;
 import org.custommonkey.xmlunit.Diff;
+import org.easymock.EasyMock;
 import org.junit.Test;
 
 import javax.inject.Inject;
@@ -154,11 +156,13 @@ public class MetadataTransferTest
         // ensure that a hard failure in the first proxy connector is skipped and the second repository checked
         File expectedFile = new File( managedDefaultDir.getAbsoluteFile(),
                                       metadataTools.getRepositorySpecificName( "badproxied1", requestedResource ) );
-        wagonMock.get( requestedResource, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
 
-        wagonMockControl.setMatcher( customWagonGetMatcher );
+        //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" ) );
 
-        wagonMockControl.setThrowable( new TransferFailedException( "can't connect" ) );
 
         wagonMockControl.replay();
 
index 8397a56ceacdedc076386913384cccb25b7d962f..20490acf5dd54f8f361f921785ded8ffd12be206 100644 (file)
@@ -28,7 +28,8 @@ import org.apache.archiva.configuration.RepositoryScanningConfiguration;
 import org.apache.archiva.redback.components.registry.Registry;
 import org.apache.archiva.redback.components.registry.RegistryException;
 import org.apache.archiva.redback.components.registry.RegistryListener;
-import org.easymock.MockControl;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
 import org.springframework.stereotype.Service;
 
 import java.util.Collections;
@@ -53,14 +54,14 @@ public class MockConfiguration
 
     private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
 
-    private MockControl registryControl;
+    private IMocksControl registryControl;
 
     private Registry registryMock;
 
     public MockConfiguration()
     {
-        registryControl = MockControl.createNiceControl( org.apache.archiva.redback.components.registry.Registry.class );
-        registryMock = (org.apache.archiva.redback.components.registry.Registry) registryControl.getMock();
+        registryControl = EasyMock.createNiceControl( );
+        registryMock = registryControl.createMock( Registry.class );
     }
 
     @PostConstruct
index b1ab0a7274b111a36638d1abd78dce167cc3fcdf..7d23630d1cdce51f41bf4bb217181c0dbcafdd08 100644 (file)
@@ -26,7 +26,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.commons.lang.SystemUtils;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.BeansException;
@@ -53,6 +53,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import static org.easymock.EasyMock.*;
 
 /**
  * RepositoryContentConsumersTest
@@ -243,24 +244,32 @@ public class RepositoryContentConsumersTest
     public void testExecution( )
         throws Exception
     {
-        MockControl knownControl = MockControl.createNiceControl( KnownRepositoryContentConsumer.class );
+        IMocksControl knownControl = createNiceControl( );
+
         RepositoryContentConsumers consumers = lookupRepositoryConsumers( );
-        KnownRepositoryContentConsumer selectedKnownConsumer = (KnownRepositoryContentConsumer) knownControl.getMock( );
-        KnownRepositoryContentConsumer unselectedKnownConsumer =
-            (KnownRepositoryContentConsumer) MockControl.createNiceControl(
-                KnownRepositoryContentConsumer.class ).getMock( );
+        KnownRepositoryContentConsumer selectedKnownConsumer = knownControl.createMock( KnownRepositoryContentConsumer.class );
+
+        //KnownRepositoryContentConsumer unselectedKnownConsumer =
+        //    (KnownRepositoryContentConsumer) MockControl.createNiceControl(
+        //        KnownRepositoryContentConsumer.class ).getMock( );
+
+        KnownRepositoryContentConsumer unselectedKnownConsumer = createNiceControl().createMock( KnownRepositoryContentConsumer.class );
+
 
         consumers.setApplicationContext(
             new MockApplicationContext( Arrays.asList( selectedKnownConsumer, unselectedKnownConsumer ), null ) );
 
         consumers.setSelectedKnownConsumers( Collections.singletonList( selectedKnownConsumer ) );
 
-        MockControl invalidControl = MockControl.createControl( InvalidRepositoryContentConsumer.class );
-        InvalidRepositoryContentConsumer selectedInvalidConsumer =
-            (InvalidRepositoryContentConsumer) invalidControl.getMock( );
-        InvalidRepositoryContentConsumer unselectedInvalidConsumer =
-            (InvalidRepositoryContentConsumer) MockControl.createControl(
-                InvalidRepositoryContentConsumer.class ).getMock( );
+        IMocksControl invalidControl = createControl();
+
+        InvalidRepositoryContentConsumer selectedInvalidConsumer = invalidControl.createMock( InvalidRepositoryContentConsumer.class );
+
+        //InvalidRepositoryContentConsumer unselectedInvalidConsumer =
+        //    (InvalidRepositoryContentConsumer) MockControl.createControl(
+        //        InvalidRepositoryContentConsumer.class ).getMock( );
+
+        InvalidRepositoryContentConsumer unselectedInvalidConsumer = createControl().createMock( InvalidRepositoryContentConsumer.class );
 
         consumers.setApplicationContext(
             new MockApplicationContext( null, Arrays.asList( selectedInvalidConsumer, unselectedInvalidConsumer ) ) );
@@ -274,11 +283,9 @@ public class RepositoryContentConsumersTest
         startTime.setTime( 12345678 );
 
         selectedKnownConsumer.beginScan( repo, startTime, false );
-        selectedKnownConsumer.getExcludes( );
-        knownControl.setReturnValue( Collections.EMPTY_LIST );
-        selectedKnownConsumer.getIncludes( );
-        knownControl.setReturnValue( Collections.singletonList( "**/*.txt" ) );
+        expect( selectedKnownConsumer.getIncludes( ) ).andReturn( Collections.singletonList( "**/*.txt" ) );
         selectedKnownConsumer.processFile( _OS( "path/to/test-file.txt" ), false );
+
         //        knownConsumer.completeScan();
         knownControl.replay( );
 
@@ -286,28 +293,34 @@ public class RepositoryContentConsumersTest
         //        invalidConsumer.completeScan();
         invalidControl.replay( );
 
+
         consumers.executeConsumers( repo, testFile, true );
 
         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 );
-        selectedKnownConsumer.getIncludes( );
-        knownControl.setReturnValue( Collections.singletonList( "**/*.txt" ) );
+        //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 );
-        selectedInvalidConsumer.getId( );
-        invalidControl.setReturnValue( "invalid" );
+        expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" );
         //        invalidConsumer.completeScan();
         invalidControl.replay( );
 
@@ -322,15 +335,13 @@ public class RepositoryContentConsumersTest
         File excludedTestFile = new File( "target/test-repo/path/to/test-file.txt" );
 
         selectedKnownConsumer.beginScan( repo, startTime, false );
-        selectedKnownConsumer.getExcludes( );
-        knownControl.setReturnValue( Collections.singletonList( "**/test-file.txt" ) );
+        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 );
-        selectedInvalidConsumer.getId( );
-        invalidControl.setReturnValue( "invalid" );
+        expect( selectedInvalidConsumer.getId() ).andReturn( "invalid" );
         //        invalidConsumer.completeScan();
         invalidControl.replay( );
 
index f0562af0658cb0e73c98c164efff864af8747cb0..bd1ee6770f4755939316ba725a87d55206d0197d 100644 (file)
@@ -25,7 +25,8 @@ import junit.framework.TestCase;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.rss.RssFeedGenerator;
-import org.easymock.MockControl;
+import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
+import org.easymock.IMocksControl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,9 +37,11 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
 
-@RunWith( ArchivaBlockJUnit4ClassRunner.class )
+import static org.easymock.EasyMock.createControl;
+import static org.easymock.EasyMock.expect;
+
+@RunWith(ArchivaBlockJUnit4ClassRunner.class)
 public class NewVersionsOfArtifactRssFeedProcessorTest
     extends TestCase
 {
@@ -50,7 +53,7 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
 
     private static final String ARTIFACT_ID = "artifact-two";
 
-    private MockControl metadataRepositoryControl;
+    private IMocksControl metadataRepositoryControl;
 
     private MetadataRepository metadataRepository;
 
@@ -63,11 +66,11 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
         newVersionsProcessor = new NewVersionsOfArtifactRssFeedProcessor();
         newVersionsProcessor.setGenerator( new RssFeedGenerator() );
 
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+        metadataRepositoryControl = createControl();
+        metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class );
     }
 
-    @SuppressWarnings( "unchecked" )
+    @SuppressWarnings("unchecked")
     @Test
     public void testProcess()
         throws Exception
@@ -85,20 +88,29 @@ 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 ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO, GROUP_ID,
-                                                                                          ARTIFACT_ID ), 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 ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID,
-                                                                                    "1.0.2" ),
-                                                   Collections.singletonList( artifact2 ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO, GROUP_ID, ARTIFACT_ID,
-                                                                                    "1.0.3-SNAPSHOT" ),
-                                                   Collections.singletonList( artifact3 ) );
+        //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();
 
         SyndFeed feed = newVersionsProcessor.process( reqParams, metadataRepository );
@@ -113,8 +125,8 @@ public class NewVersionsOfArtifactRssFeedProcessorTest
 
         assertEquals( 2, entries.size() );
 
-        assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGathered, entries.get(
-            0 ).getTitle() );
+        assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGathered,
+                      entries.get( 0 ).getTitle() );
         assertEquals( whenGathered, entries.get( 0 ).getPublishedDate() );
 
         assertEquals( "New Versions of Artifact 'org.apache.archiva:artifact-two' as of " + whenGatheredNext,
index baf48b2cfc28cfcb353049a52fe01d74ea6924a7..3c63337ec856a985cfb38f729f98805edd95d072 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.archiva.security;
  * under the License.
  */
 
-import org.apache.archiva.redback.users.User;
-import org.apache.archiva.redback.users.UserManager;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
 import org.apache.archiva.redback.authentication.AuthenticationException;
 import org.apache.archiva.redback.authentication.AuthenticationResult;
 import org.apache.archiva.redback.authorization.UnauthorizedException;
 import org.apache.archiva.redback.system.DefaultSecuritySession;
 import org.apache.archiva.redback.system.SecuritySession;
-import org.easymock.MockControl;
+import org.apache.archiva.redback.users.User;
+import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -45,7 +46,7 @@ public class ArchivaServletAuthenticatorTest
     @Named( value = "servletAuthenticator#test" )
     private ServletAuthenticator servletAuth;
 
-    private MockControl httpServletRequestControl;
+    private IMocksControl httpServletRequestControl;
 
     private HttpServletRequest request;
 
@@ -55,8 +56,8 @@ public class ArchivaServletAuthenticatorTest
     {
         super.setUp();
 
-        httpServletRequestControl = MockControl.createControl( HttpServletRequest.class );
-        request = (HttpServletRequest) httpServletRequestControl.getMock();
+        httpServletRequestControl = EasyMock.createControl( );
+        request = httpServletRequestControl.createMock( HttpServletRequest.class );
 
         setupRepository( "corporate" );
     }
@@ -123,7 +124,8 @@ public class ArchivaServletAuthenticatorTest
 
         assignRepositoryObserverRole( USER_ALPACA, "corporate" );
 
-        httpServletRequestControl.expectAndReturn( request.getRemoteAddr(), "192.168.111.111" );
+        //httpServletRequestControl.expectAndReturn( request.getRemoteAddr(), "192.168.111.111" );
+        EasyMock.expect( request.getRemoteAddr() ).andReturn( "192.168.111.111" );
 
         UserManager userManager = securitySystem.getUserManager();
         User user = userManager.findUser( USER_ALPACA );
index 2190c195c44ba549f174f8a7abc2aa8f68f518b8..4ef1ff4d3ec35f468d2533c6e2de798e4b71305a 100644 (file)
@@ -44,8 +44,8 @@ import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletRequest;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
+
+import org.easymock.IMocksControl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -59,6 +59,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import static org.easymock.EasyMock.*;
+
 /**
  * ArchivaDavResourceFactoryTest
  */
@@ -79,25 +81,25 @@ public class ArchivaDavResourceFactoryTest
 
     private OverridingArchivaDavResourceFactory resourceFactory;
 
-    private MockControl requestControl;
+    private IMocksControl requestControl;
 
     private DavServletRequest request;
 
-    private MockControl repoRequestControl;
+    private IMocksControl repoRequestControl;
 
     private RepositoryRequest repoRequest;
 
-    private MockControl responseControl;
+    private IMocksControl responseControl;
 
     private DavServletResponse response;
 
-    private MockControl archivaConfigurationControl;
+    private IMocksControl archivaConfigurationControl;
 
     private ArchivaConfiguration archivaConfiguration;
 
     private Configuration config;
 
-    private MockControl repoContentFactoryControl;
+    private IMocksControl repoContentFactoryControl;
 
     private RepositoryContentFactory repoFactory;
 
@@ -124,21 +126,23 @@ public class ArchivaDavResourceFactoryTest
     {
         super.setUp();
 
-        requestControl = MockControl.createControl( DavServletRequest.class );
-        request = (DavServletRequest) requestControl.getMock();
+        requestControl = createControl();
+        request = requestControl.createMock( DavServletRequest.class );
 
-        responseControl = MockControl.createControl( DavServletResponse.class );
-        response = (DavServletResponse) responseControl.getMock();
-        responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        responseControl = createControl();
+        response = responseControl.createMock( DavServletResponse.class );
+        //responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
 
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        archivaConfigurationControl = createControl();
+        archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class );
 
         config = new Configuration();
-        archivaConfiguration.getConfiguration();
-        archivaConfigurationControl.setReturnValue( config, 5, 20 );
+        //archivaConfiguration.getConfiguration();
+        //archivaConfigurationControl.setReturnValue( config, 5, 20 );
+        expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 5, 20 );
         archivaConfiguration.save( config );
-        archivaConfigurationControl.setVoidCallable( 1, 4 );
+        //archivaConfigurationControl.setVoidCallable( 1, 4 );
+        expectLastCall().times( 1, 4 );
         archivaConfigurationControl.replay();
 
         defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfiguration );
@@ -167,11 +171,11 @@ public class ArchivaDavResourceFactoryTest
             defaultRepositoryGroupAdmin.addRepositoryGroup( repoGroupConfig, null );
         }
 
-        repoContentFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
-        repoFactory = (RepositoryContentFactory) repoContentFactoryControl.getMock();
+        repoContentFactoryControl = createControl();
+        repoFactory = repoContentFactoryControl.createMock( RepositoryContentFactory.class );
 
-        repoRequestControl = MockClassControl.createControl( RepositoryRequest.class );
-        repoRequest = (RepositoryRequest) repoRequestControl.getMock();
+        repoRequestControl = createControl();
+        repoRequest = repoRequestControl.createMock( RepositoryRequest.class );
 
         resourceFactory =
             new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration );
@@ -224,33 +228,51 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
-            requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
-                                                       releasesRepo );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
-
-            repoRequestControl.expectAndReturn(
-                repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+            //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.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
-                null );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
-                                          internalRepo ),
+            //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 );
-            repoRequestControl.expectAndReturn(
-                    repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
-                    false );
-
+            //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();
             requestControl.replay();
             repoContentFactoryControl.replay();
@@ -296,32 +318,51 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
-            requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
-                                                       internalRepo );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( RELEASES_REPO ),
-                                                       releasesRepo );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
-            repoRequestControl.expectAndReturn(
-                repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
+            //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.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
-                null );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
-                                          internalRepo ),
+            //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 );
 
+            //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();
             requestControl.replay();
             repoContentFactoryControl.replay();
@@ -370,39 +411,58 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 4 );
-            requestControl.expectAndReturn( request.getPathInfo(), "org/apache/archiva", 0, 2 );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
-                                                       internalRepo );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LOCAL_MIRROR_REPO ),
-                                                       localMirrorRepo );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 4 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 4 );
-            repoRequestControl.expectAndReturn(
-                repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false,
-                2 );
-            repoRequestControl.expectAndReturn(
-                repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), false, 2 );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toArtifactReference( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
-                null, 2 );
-            repoRequestControl.expectAndReturn(
-                repoRequest.toNativePath( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar",
-                                          internalRepo ),
+            //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() );
-
-            repoRequestControl.expectAndReturn(
-                    repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ),
-                    false , 2);
-
+            //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();
             repoContentFactoryControl.replay();
@@ -442,24 +502,32 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
-                                                       internalRepo );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 3 );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 3 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
-            requestControl.expectAndReturn( request.getRequestURI(),
-                                            "http://localhost:8080/archiva/repository/" + INTERNAL_REPO
-                                                + "/eclipse/jdtcore/maven-metadata.xml" );
+            //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();
+            //responseControl.setVoidCallable();
+            expectLastCall();
 
             response.setHeader( "Cache-Control", "no-cache" );
-            responseControl.setVoidCallable();
+            //responseControl.setVoidCallable();
+            expectLastCall();
 
-            long date = 2039842134;
-            response.setDateHeader( "last-modified", date );
-            responseControl.setVoidCallable();
+            //long date = 2039842134;
+            response.setDateHeader( eq("Last-Modified"), anyLong() );
+            //responseControl.setVoidCallable();
+            expectLastCall();
 
             archivaConfigurationControl.replay();
             repoContentFactoryControl.replay();
@@ -497,12 +565,17 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ),
-                                                       internalRepo );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+            //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();
             repoContentFactoryControl.replay();
@@ -542,12 +615,17 @@ public class ArchivaDavResourceFactoryTest
         try
         {
             archivaConfigurationControl.reset();
-            archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config );
-            repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( LEGACY_REPO ),
-                                                       legacyRepo );
-            requestControl.expectAndReturn( request.getMethod(), "GET", 2 );
-            requestControl.expectAndReturn( request.getRemoteAddr(), "http://localhost:8080", 2 );
-            requestControl.expectAndReturn( request.getDavSession(), new ArchivaDavSession(), 2 );
+            //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();
             repoContentFactoryControl.replay();
index c818b09db33a9addca93504a3ff148445d0beae0..15345225b0eac3dd4369d9d80c22d737ca21a9c1 100644 (file)
@@ -29,25 +29,26 @@ import com.meterware.servletunit.ServletRunner;
 import com.meterware.servletunit.ServletUnitClient;
 import junit.framework.TestCase;
 import net.sf.ehcache.CacheManager;
-import org.apache.archiva.redback.authentication.AuthenticationException;
-import org.apache.archiva.redback.users.User;
-import org.apache.archiva.repository.audit.TestAuditListener;
-import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.io.FileUtils;
-import org.apache.jackrabbit.webdav.DavSessionProvider;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.security.ServletAuthenticator;
+import org.apache.archiva.redback.authentication.AuthenticationException;
 import org.apache.archiva.redback.authentication.AuthenticationResult;
 import org.apache.archiva.redback.authorization.UnauthorizedException;
+import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
 import org.apache.archiva.redback.system.DefaultSecuritySession;
 import org.apache.archiva.redback.system.SecuritySession;
+import org.apache.archiva.redback.users.User;
 import org.apache.archiva.redback.users.memory.SimpleUser;
-import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
-import org.apache.archiva.redback.integration.filter.authentication.basic.HttpBasicAuthentication;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
+import org.apache.archiva.repository.audit.TestAuditListener;
+import org.apache.archiva.security.ServletAuthenticator;
+import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.webdav.DavSessionProvider;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.*;
+import org.easymock.IMocksControl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -56,19 +57,17 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
 
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-
 /**
  * RepositoryServletSecurityTest Test the flow of the authentication and authorization checks. This does not necessarily
  * perform redback security checking.
- * 
- *
  */
 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
@@ -87,11 +86,11 @@ public class RepositoryServletSecurityTest
 
     private DavSessionProvider davSessionProvider;
 
-    private MockControl servletAuthControl;
+    private IMocksControl servletAuthControl;
 
     private ServletAuthenticator servletAuth;
 
-    private MockClassControl httpAuthControl;
+    private IMocksControl httpAuthControl;
 
     private HttpAuthenticator httpAuth;
 
@@ -106,7 +105,8 @@ public class RepositoryServletSecurityTest
     {
         super.setUp();
 
-        String appserverBase =  System.getProperty( "appserver.base", new File( "target/appserver-base" ).getAbsolutePath() );
+        String appserverBase =
+            System.getProperty( "appserver.base", new File( "target/appserver-base" ).getAbsolutePath() );
 
         File testConf = new File( "src/test/resources/repository-archiva.xml" );
         File testConfDest = new File( appserverBase, "conf/archiva.xml" );
@@ -117,9 +117,10 @@ public class RepositoryServletSecurityTest
         archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class );
         Configuration config = archivaConfiguration.getConfiguration();
 
-        if (!config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ))
+        if ( !config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ) )
         {
-            config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
+            config.addManagedRepository(
+                createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
         }
         saveConfiguration( archivaConfiguration );
 
@@ -131,14 +132,14 @@ public class RepositoryServletSecurityTest
         sr.registerServlet( "/repository/*", RepositoryServlet.class.getName() );
         sc = sr.newClient();
 
-        servletAuthControl = MockControl.createControl( ServletAuthenticator.class );
-        servletAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-        servletAuth = (ServletAuthenticator) servletAuthControl.getMock();
+        servletAuthControl = EasyMock.createControl();// MockControl.createControl( ServletAuthenticator.class );
+        //servletAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
+        servletAuth = servletAuthControl.createMock( ServletAuthenticator.class );
 
-        httpAuthControl =
-            MockClassControl.createControl( HttpBasicAuthentication.class, HttpBasicAuthentication.class.getMethods() );
-        httpAuthControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
-        httpAuth = (HttpAuthenticator) httpAuthControl.getMock();
+        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 );
     }
@@ -217,13 +218,19 @@ public class RepositoryServletSecurityTest
         servlet.setDavSessionProvider( davSessionProvider );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
-                                           new AuthenticationException( "Authentication error" ) );
+        //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" ) );
+        //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();
         servletAuthControl.replay();
@@ -260,27 +267,41 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
-                                           new AuthenticationException( "Authentication error" ) );
+        //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.isAuthorized( "guest", "internal", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD );
-        servletAuthControl.setMatcher( MockControl.EQUALS_MATCHER );
-        servletAuthControl.setReturnValue( true );
+        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 );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, result ),
-                                           new AuthenticationException( "Authentication error" ) );
-
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null );
+        //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 );
+        //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 );
 
         httpAuthControl.replay();
         servletAuthControl.replay();
@@ -316,20 +337,31 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+        //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 );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
-        servletAuthControl.expectAndThrow(
-                                           servletAuth.isAuthorized( null, session, "internal",
-                                                                     ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
-                                           new UnauthorizedException( "User not authorized" ) );
-
+        //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" ) );
         httpAuthControl.replay();
         servletAuthControl.replay();
 
@@ -368,22 +400,34 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+        //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 );
 
         User user = new SimpleUser();
         user.setUsername( "admin" );
-        
+
         // ArchivaDavResourceFactory#isAuthorized()
         SecuritySession session = new DefaultSecuritySession();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), user );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
-        servletAuthControl.expectAndReturn(
-                                            servletAuth.isAuthorized( null, session, "internal",
-                                                                      ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
-                                            true );
+        //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 );
 
         httpAuthControl.replay();
         servletAuthControl.replay();
@@ -409,7 +453,7 @@ public class RepositoryServletSecurityTest
         File artifactFile = new File( repoRootInternal, commonsLangJar );
         artifactFile.getParentFile().mkdirs();
 
-        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset()  );
+        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset() );
 
         WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
         InvocationContext ic = sc.newInvocation( request );
@@ -423,25 +467,37 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
-                                           new AuthenticationException( "Authentication error" ) );
-        servletAuthControl.expectAndReturn(
-                                            servletAuth.isAuthorized( "guest", "internal",
-                                                                      ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ),
-                                            true );
+        //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 );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), null );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
-        servletAuthControl.expectAndReturn(
-                                            servletAuth.isAuthorized( null, session, "internal",
-                                                                      ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
-                                            true );
-
+        //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 );
         httpAuthControl.replay();
         servletAuthControl.replay();
 
@@ -465,7 +521,7 @@ public class RepositoryServletSecurityTest
         File artifactFile = new File( repoRootInternal, commonsLangJar );
         artifactFile.getParentFile().mkdirs();
 
-        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset()  );
+        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset() );
 
         WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
         InvocationContext ic = sc.newInvocation( request );
@@ -473,14 +529,18 @@ public class RepositoryServletSecurityTest
         servlet.setDavSessionProvider( davSessionProvider );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndThrow( servletAuth.isAuthenticated( null, null ),
-                                           new AuthenticationException( "Authentication error" ) );
-        servletAuthControl.expectAndReturn(
-                                            servletAuth.isAuthorized( "guest", "internal",
-                                                                      ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ),
-                                            false );
-
+        //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 );
         httpAuthControl.replay();
         servletAuthControl.replay();
 
@@ -503,7 +563,7 @@ public class RepositoryServletSecurityTest
         File artifactFile = new File( repoRootInternal, commonsLangJar );
         artifactFile.getParentFile().mkdirs();
 
-        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset()  );
+        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset() );
 
         WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
         InvocationContext ic = sc.newInvocation( request );
@@ -517,19 +577,27 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
-
+        //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 );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
-        servletAuthControl.expectAndReturn(
-                                            servletAuth.isAuthorized( null, session, "internal",
-                                                                      ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
-                                            true );
+        //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 );
 
         httpAuthControl.replay();
         servletAuthControl.replay();
@@ -554,7 +622,7 @@ public class RepositoryServletSecurityTest
         File artifactFile = new File( repoRootInternal, commonsLangJar );
         artifactFile.getParentFile().mkdirs();
 
-        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset()  );
+        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset() );
 
         WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangJar );
         InvocationContext ic = sc.newInvocation( request );
@@ -568,20 +636,27 @@ public class RepositoryServletSecurityTest
         servlet.setResourceFactory( archivaDavResourceFactory );
 
         AuthenticationResult result = new AuthenticationResult();
-        httpAuthControl.expectAndReturn( httpAuth.getAuthenticationResult( null, null ), result );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, null ), true );
+        //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 );
-        httpAuthControl.expectAndReturn( httpAuth.getSecuritySession( ic.getRequest().getSession( true ) ), session );
-        httpAuthControl.expectAndReturn( httpAuth.getSessionUser( ic.getRequest().getSession() ), new SimpleUser() );
-        servletAuthControl.expectAndReturn( servletAuth.isAuthenticated( null, result ), true );
-        servletAuthControl.expectAndThrow(
-                                           servletAuth.isAuthorized( null, session, "internal",
-                                                                     ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ),
-                                           new UnauthorizedException( "User not authorized to read repository." ) );
-
+        //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." ) );
         httpAuthControl.replay();
         servletAuthControl.replay();
 
index 6b5b7e9f54eb0bbb36c20007cf23735ca27e1e36..0deec674cce2ee2b76cd2bd137a2bfeb090f8d3e 100644 (file)
@@ -20,9 +20,14 @@ package org.apache.archiva.audit;
  */
 
 import junit.framework.TestCase;
-import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.easymock.MockControl;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import java.text.DecimalFormat;
 import java.text.ParseException;
@@ -35,18 +40,14 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
-import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith( ArchivaBlockJUnit4ClassRunner.class )
+@RunWith(ArchivaBlockJUnit4ClassRunner.class)
 public class AuditManagerTest
     extends TestCase
 {
     private DefaultAuditManager auditManager;
 
-    private MockControl metadataRepositoryControl;
+    private IMocksControl metadataRepositoryControl;
 
     private MetadataRepository metadataRepository;
 
@@ -82,14 +83,14 @@ public class AuditManagerTest
 
         auditManager = new DefaultAuditManager();
 
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+        metadataRepositoryControl = EasyMock.createControl();
+        metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class );
 
         ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
         repository.setId( TEST_REPO_ID );
         repository.setLocation( "" );
     }
-    
+
     @Test
     public void testGetMostRecentEvents()
         throws Exception
@@ -102,20 +103,25 @@ public class AuditManagerTest
             expectedEvents.add( event );
         }
 
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         AuditEvent.FACET_ID ),
-                                                   getEventNames( expectedEvents ) );
+        //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 );
+            //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 );
         }
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ) );
+        List<AuditEvent> events =
+            auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList( TEST_REPO_ID ) );
         assertNotNull( events );
         assertEquals( numEvents - 1, events.size() );
         int expectedTimestampCounter = numEvents - 1;
@@ -140,20 +146,24 @@ 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 ) );
-
+        //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 );
+            //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 );
         }
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ) );
+        List<AuditEvent> events =
+            auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList( TEST_REPO_ID ) );
         assertNotNull( events );
         assertEquals( numEvents, events.size() );
         int expectedTimestampCounter = numEvents - 1;
@@ -185,23 +195,29 @@ public class AuditManagerTest
             eventNames.get( repositoryId ).add( event.getName() );
         }
 
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         AuditEvent.FACET_ID ),
-                                                   eventNames.get( TEST_REPO_ID ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID_2,
-                                                                                         AuditEvent.FACET_ID ),
-                                                   eventNames.get( TEST_REPO_ID_2 ) );
+        //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 );
+            //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 );
         }
         metadataRepositoryControl.replay();
 
-        events = auditManager.getMostRecentAuditEvents( metadataRepository, Arrays.asList( TEST_REPO_ID,
-                                                                                           TEST_REPO_ID_2 ) );
+        events =
+            auditManager.getMostRecentAuditEvents( metadataRepository, Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ) );
         assertNotNull( events );
         assertEquals( numEvents - 1, events.size() );
         int expectedTimestampCounter = numEvents - 1;
@@ -221,13 +237,15 @@ public class AuditManagerTest
         throws Exception
 
     {
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         AuditEvent.FACET_ID ),
-                                                   Collections.emptyList() );
+        //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();
 
-        assertTrue( auditManager.getMostRecentAuditEvents( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ) ).isEmpty() );
+        assertTrue( auditManager.getMostRecentAuditEvents( metadataRepository,
+                                                           Collections.singletonList( TEST_REPO_ID ) ).isEmpty() );
 
         metadataRepositoryControl.verify();
     }
@@ -290,21 +308,27 @@ 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() ) );
+        //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 );
+        //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 );
 
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), new Date( current.getTime() - 4000 ), new Date( current.getTime() - 2000 ) );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                new Date( current.getTime() - 4000 ),
+                                                new Date( current.getTime() - 2000 ) );
 
         assertEquals( 1, events.size() );
         assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( expectedTimestamp ), expectedEvent.getResource() );
@@ -324,24 +348,30 @@ 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() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent3.getName() ),
-                                                   expectedEvent3 );
-
+        //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();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), new Date( current.getTime() - 4000 ), current );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                new Date( current.getTime() - 4000 ), current );
 
         assertEquals( 2, events.size() );
         assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -362,24 +392,31 @@ 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() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent1.getName() ),
-                                                   expectedEvent1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
+        //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 );
 
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), new Date( current.getTime() - 20000 ), new Date( current.getTime() - 2000 ) );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                new Date( current.getTime() - 20000 ),
+                                                new Date( current.getTime() - 2000 ) );
 
         assertEquals( 2, events.size() );
         assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( expectedTimestamp ), expectedEvent2.getResource() );
@@ -401,28 +438,35 @@ 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() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent1.getName() ),
-                                                   expectedEvent1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent3.getName() ),
-                                                   expectedEvent3 );
-
+        //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();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), new Date( current.getTime() - 20000 ), current );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                new Date( current.getTime() - 20000 ), current );
 
         assertEquals( 3, events.size() );
         assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -446,28 +490,36 @@ 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() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent1.getName() ),
-                                                   expectedEvent1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent3.getName() ),
-                                                   expectedEvent3 );
-
+        //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();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), TEST_RESOURCE_BASE, new Date( current.getTime() - 20000 ), current );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                TEST_RESOURCE_BASE, new Date( current.getTime() - 20000 ), current );
 
         assertEquals( 2, events.size() );
         assertTestEvent( events.get( 0 ), TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -488,28 +540,31 @@ 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() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent1.getName() ),
-                                                   expectedEvent1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent3.getName() ),
-                                                   expectedEvent3 );
+        //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();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), "foo", new Date( current.getTime() - 20000 ), current );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ), "foo",
+                                                new Date( current.getTime() - 20000 ), current );
 
         assertEquals( 0, events.size() );
 
@@ -530,32 +585,38 @@ 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() ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID_2,
-                                                                                         AuditEvent.FACET_ID ),
-                                                   Arrays.asList( expectedEvent2.getName() ) );
-
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent1.getName() ),
-                                                   expectedEvent1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID_2,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent2.getName() ),
-                                                   expectedEvent2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        AuditEvent.FACET_ID,
-                                                                                        expectedEvent3.getName() ),
-                                                   expectedEvent3 );
+        //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 );
 
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Arrays.asList( TEST_REPO_ID,
-                                                                                                         TEST_REPO_ID_2 ),
-                                                                      new Date( current.getTime() - 20000 ), current );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Arrays.asList( TEST_REPO_ID, TEST_REPO_ID_2 ),
+                                                new Date( current.getTime() - 20000 ), current );
 
         assertEquals( 3, events.size() );
         assertTestEvent( events.get( 0 ), TEST_REPO_ID, TIMESTAMP_FORMAT.format( ts3 ), expectedEvent3.getResource() );
@@ -577,14 +638,18 @@ 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 ) );
+        //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 ) );
 
         metadataRepositoryControl.replay();
 
-        List<AuditEvent> events = auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList(
-            TEST_REPO_ID ), new Date( current.getTime() - 20000 ), new Date( current.getTime() - 16000 ) );
+        List<AuditEvent> events =
+            auditManager.getAuditEventsInRange( metadataRepository, Collections.singletonList( TEST_REPO_ID ),
+                                                new Date( current.getTime() - 20000 ),
+                                                new Date( current.getTime() - 16000 ) );
 
         assertEquals( 0, events.size() );
 
@@ -605,9 +670,8 @@ public class AuditManagerTest
     private static AuditEvent createEvent( String ts )
         throws ParseException
     {
-        return createEvent( TEST_REPO_ID, ts, getDefaultTestResourceName( ts.substring( AUDIT_EVENT_BASE.length(),
-                                                                                        AUDIT_EVENT_BASE.length() +
-                                                                                            3 ) ) );
+        return createEvent( TEST_REPO_ID, ts, getDefaultTestResourceName(
+            ts.substring( AUDIT_EVENT_BASE.length(), AUDIT_EVENT_BASE.length() + 3 ) ) );
     }
 
     private static AuditEvent createEvent( String repositoryId, String timestamp, String resource )
index db62852079356b28d58b468f800513aad1a79ed7..c953e9512399c968146339384a9b3d15ff8b0245 100755 (executable)
@@ -25,12 +25,14 @@ import org.apache.archiva.configuration.ConfigurationListener;
 import org.apache.archiva.redback.components.registry.Registry;
 import org.apache.archiva.redback.components.registry.RegistryException;
 import org.apache.archiva.redback.components.registry.RegistryListener;
-import org.easymock.MockControl;
+import org.easymock.IMocksControl;
 import org.springframework.stereotype.Service;
 
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.easymock.EasyMock.createNiceControl;
+
 /**
  * MockConfiguration 
  *
@@ -46,14 +48,14 @@ public class MockConfiguration
     private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
     private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
 
-    private MockControl registryControl;
+    private IMocksControl registryControl;
 
     private Registry registryMock;
 
     public MockConfiguration()
     {
-        registryControl = MockControl.createNiceControl( Registry.class );
-        registryMock = (Registry) registryControl.getMock();
+        registryControl = createNiceControl();
+        registryMock = registryControl.createMock( Registry.class );
     }
 
     public void addChangeListener( RegistryListener listener )
index 8c39e402be18ab744c275c5eaf0f37a66b1c9491..61ced3a38f2ace45cd2a655068fd26a6a270dad9 100644 (file)
@@ -23,8 +23,16 @@ import junit.framework.TestCase;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
 import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.easymock.MockControl;
+import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
+import org.easymock.IMocksControl;
+
+import static org.easymock.EasyMock.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
+import javax.jcr.Session;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,11 +42,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
-import javax.jcr.Session;
-import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
 
 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
 public class RepositoryStatisticsManagerTest
@@ -48,7 +51,7 @@ public class RepositoryStatisticsManagerTest
 
     private static final String TEST_REPO_ID = "test-repo";
 
-    private MockControl metadataRepositoryControl;
+    private IMocksControl metadataRepositoryControl;
 
     private MetadataRepository metadataRepository;
 
@@ -76,8 +79,8 @@ public class RepositoryStatisticsManagerTest
 
         repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
 
-        metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
-        metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+        metadataRepositoryControl = createControl();
+        metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class );
     }
 
     @Test
@@ -97,12 +100,17 @@ public class RepositoryStatisticsManagerTest
         stats.setTotalGroupCount( 529 );
         stats.setTotalFileCount( 56229 );
 
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        SECOND_TEST_SCAN ), stats );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
+        //                                                                                 RepositoryStatistics.FACET_ID ),
+        //                                                   Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
+        //                                                                                RepositoryStatistics.FACET_ID,
+        //                                                                                SECOND_TEST_SCAN ), stats );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID,
+                                                     SECOND_TEST_SCAN ) ).andReturn( stats );
+
         metadataRepositoryControl.replay();
 
         stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
@@ -124,9 +132,11 @@ public class RepositoryStatisticsManagerTest
     public void testGetLatestStatsWhenEmpty()
         throws Exception
     {
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Collections.emptyList() );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
+        //    Collections.emptyList() );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Collections.<String>emptyList() );
         metadataRepositoryControl.replay();
 
         RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
@@ -147,13 +157,18 @@ public class RepositoryStatisticsManagerTest
         walkRepository( 1 );
 
         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Arrays.asList( stats.getName() ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        stats.getName() ), stats );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
+        //    Arrays.asList( stats.getName() ) );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Arrays.asList( stats.getName() ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, stats.getName() ),
+        //    stats );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID,
+                                                     stats.getName() ) ).andReturn( stats );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false );
 
         metadataRepositoryControl.replay();
 
@@ -190,20 +205,25 @@ public class RepositoryStatisticsManagerTest
         RepositoryStatistics stats2 = createTestStats( startTime2, current );
         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats2 );
 
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Arrays.asList( stats1.getName(), stats2.getName() ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        stats2.getName() ), stats2 );
-
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
+        //    Arrays.asList( stats1.getName(), stats2.getName() ) );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Arrays.asList( stats1.getName(), stats2.getName() ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, stats2.getName() ),
+        //    stats2 );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID,
+                                                     stats2.getName() ) ).andReturn( stats2 );
         metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID );
 
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Collections.emptyList() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 2 );
-
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
+        //    Collections.emptyList() );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Collections.<String>emptyList() );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 2 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 2 );
         metadataRepositoryControl.replay();
 
         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime1,
@@ -224,9 +244,11 @@ public class RepositoryStatisticsManagerTest
     public void testDeleteStatsWhenEmpty()
         throws Exception
     {
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   Collections.emptyList(), 2 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
+        //    Collections.emptyList(), 2 );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn(
+            Collections.<String>emptyList() ).times( 2 );
         metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID );
 
         metadataRepositoryControl.replay();
@@ -253,17 +275,20 @@ public class RepositoryStatisticsManagerTest
         addStats( new Date( current.getTime() - 1000 ), current );
 
         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   keys );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys );
 
         // only match the middle one
         String key = keys.get( 1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
+
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 );
 
         metadataRepositoryControl.replay();
 
@@ -274,9 +299,10 @@ public class RepositoryStatisticsManagerTest
                                                                 45 );
         }
 
-        List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
-                                                                                            TEST_REPO_ID, new Date(
-                current.getTime() - 4000 ), new Date( current.getTime() - 2000 ) );
+        List<RepositoryStatistics> list =
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID,
+                                                              new Date( current.getTime() - 4000 ),
+                                                              new Date( current.getTime() - 2000 ) );
 
         assertEquals( 1, list.size() );
         assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() );
@@ -296,22 +322,27 @@ public class RepositoryStatisticsManagerTest
         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
         addStats( new Date( current.getTime() - 1000 ), current );
 
-        ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   keys );
+        List<String> keys = new ArrayList<String>( statsCreated.keySet() );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys );
 
         String key = keys.get( 1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
+
         key = keys.get( 2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
+
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 );
 
         metadataRepositoryControl.replay();
 
@@ -322,9 +353,9 @@ public class RepositoryStatisticsManagerTest
                                                                 45 );
         }
 
-        List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
-                                                                                            TEST_REPO_ID, new Date(
-                current.getTime() - 4000 ), current );
+        List<RepositoryStatistics> list =
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID,
+                                                              new Date( current.getTime() - 4000 ), current );
 
         assertEquals( 2, list.size() );
         assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() );
@@ -345,22 +376,25 @@ public class RepositoryStatisticsManagerTest
         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
         addStats( new Date( current.getTime() - 1000 ), current );
 
-        ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   keys );
+        List<String> keys = new ArrayList<String>( statsCreated.keySet() );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys );
 
         String key = keys.get( 0 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
         key = keys.get( 1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 );
 
         metadataRepositoryControl.replay();
 
@@ -371,9 +405,10 @@ public class RepositoryStatisticsManagerTest
                                                                 45 );
         }
 
-        List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
-                                                                                            TEST_REPO_ID, new Date(
-                current.getTime() - 20000 ), new Date( current.getTime() - 2000 ) );
+        List<RepositoryStatistics> list =
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID,
+                                                              new Date( current.getTime() - 20000 ),
+                                                              new Date( current.getTime() - 2000 ) );
 
         assertEquals( 2, list.size() );
         assertEquals( new Date( current.getTime() - 12345 ), list.get( 1 ).getScanStartTime() );
@@ -395,26 +430,30 @@ public class RepositoryStatisticsManagerTest
         addStats( new Date( current.getTime() - 1000 ), current );
 
         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   keys );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys );
 
         String key = keys.get( 0 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
         key = keys.get( 1 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
         key = keys.get( 2 );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
-                                                                                        RepositoryStatistics.FACET_ID,
-                                                                                        key ), statsCreated.get(
-            key ) );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ),
+        //    statsCreated.get( key ) );
+        expect( metadataRepository.getMetadataFacet( TEST_REPO_ID, RepositoryStatistics.FACET_ID, key ) ).andReturn(
+            statsCreated.get( key ) );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 );
 
         metadataRepositoryControl.replay();
 
@@ -425,9 +464,9 @@ public class RepositoryStatisticsManagerTest
                                                                 45 );
         }
 
-        List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
-                                                                                            TEST_REPO_ID, new Date(
-                current.getTime() - 20000 ), current );
+        List<RepositoryStatistics> list =
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID,
+                                                              new Date( current.getTime() - 20000 ), current );
 
         assertEquals( 3, list.size() );
         assertEquals( new Date( current.getTime() - 12345 ), list.get( 2 ).getScanStartTime() );
@@ -450,10 +489,11 @@ public class RepositoryStatisticsManagerTest
         addStats( new Date( current.getTime() - 1000 ), current );
 
         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
-                                                                                         RepositoryStatistics.FACET_ID ),
-                                                   keys );
-        metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        //metadataRepositoryControl.expectAndReturn(
+        //    metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ), keys );
+        expect( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ) ).andReturn( keys );
+        //metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
+        expect( metadataRepository.canObtainAccess( Session.class ) ).andReturn( false ).times( 3 );
 
         metadataRepositoryControl.replay();
 
@@ -464,9 +504,10 @@ public class RepositoryStatisticsManagerTest
                                                                 45 );
         }
 
-        List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
-                                                                                            TEST_REPO_ID, new Date(
-                current.getTime() - 20000 ), new Date( current.getTime() - 16000 ) );
+        List<RepositoryStatistics> list =
+            repositoryStatisticsManager.getStatisticsInRange( metadataRepository, TEST_REPO_ID,
+                                                              new Date( current.getTime() - 20000 ),
+                                                              new Date( current.getTime() - 16000 ) );
 
         assertEquals( 0, list.size() );
 
@@ -521,134 +562,167 @@ public class RepositoryStatisticsManagerTest
     {
         for ( int i = 0; i < count; i++ )
         {
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
-                                                       Arrays.asList( "com", "org" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
-                                                       Arrays.asList( "example" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
-                                                       Arrays.asList( "example-project" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
-                                                                                              "com.example",
-                                                                                              "example-project" ),
-                                                       Arrays.asList( "1.0", "1.1" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
-                                                                                        "example-project", "1.0" ),
-                                                       Arrays.asList( createArtifact( "com.example", "example-project",
-                                                                                      "1.0", "jar" ), createArtifact(
-                                                           "com.example", "example-project", "1.0", "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
-                                                                                        "example-project", "1.1" ),
-                                                       Arrays.asList( createArtifact( "com.example", "example-project",
-                                                                                      "1.1", "jar" ), createArtifact(
-                                                           "com.example", "example-project", "1.1", "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
-                                                       Arrays.asList( "apache", "codehaus" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
-                                                       Arrays.asList( "archiva", "maven" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
-                                                                                         "org.apache.archiva" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
-                                                                                       "org.apache.archiva" ),
-                                                       Arrays.asList( "metadata-repository-api", "metadata-model" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
-                                                                                              "org.apache.archiva",
-                                                                                              "metadata-repository-api" ),
-                                                       Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.apache.archiva",
-                                                                                        "metadata-repository-api",
-                                                                                        "1.3-SNAPSHOT" ), Arrays.asList(
-                createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
-                createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.apache.archiva",
-                                                                                        "metadata-repository-api",
-                                                                                        "1.3" ), Arrays.asList(
-                createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), createArtifact(
-                "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
-                                                                                              "org.apache.archiva",
-                                                                                              "metadata-model" ),
-                                                       Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.apache.archiva",
-                                                                                        "metadata-model",
-                                                                                        "1.3-SNAPSHOT" ), Arrays.asList(
-                createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), createArtifact(
-                "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.apache.archiva",
-                                                                                        "metadata-model", "1.3" ),
-                                                       Arrays.asList( createArtifact( "org.apache.archiva",
-                                                                                      "metadata-model", "1.3", "jar" ),
-                                                                      createArtifact( "org.apache.archiva",
-                                                                                      "metadata-model", "1.3",
-                                                                                      "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
-                                                                                         "org.apache.maven" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
-                                                                                       "org.apache.maven" ),
-                                                       Arrays.asList( "maven-model" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
-                                                                                              "org.apache.maven",
-                                                                                              "maven-model" ),
-                                                       Arrays.asList( "2.2.1" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.apache.maven",
-                                                                                        "maven-model", "2.2.1" ),
-                                                       Arrays.asList( createArtifact( "org.apache.archiva",
-                                                                                      "maven-model", "2.2.1", "jar" ),
-                                                                      createArtifact( "org.apache.archiva",
-                                                                                      "maven-model", "2.2.1",
-                                                                                      "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
-                                                       Arrays.asList( "plexus" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
-                                                                                         "org.codehaus.plexus" ),
-                                                       Arrays.asList() );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
-                                                                                       "org.codehaus.plexus" ),
-                                                       Arrays.asList( "plexus-spring" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
-                                                                                              "org.codehaus.plexus",
-                                                                                              "plexus-spring" ),
-                                                       Arrays.asList( "1.0", "1.1", "1.2" ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.codehaus.plexus",
-                                                                                        "plexus-spring", "1.0" ),
-                                                       Arrays.asList( createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.0", "jar" ),
-                                                                      createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.0",
-                                                                                      "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.codehaus.plexus",
-                                                                                        "plexus-spring", "1.1" ),
-                                                       Arrays.asList( createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.1", "jar" ),
-                                                                      createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.1",
-                                                                                      "pom" ) ) );
-            metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
-                                                                                        "org.codehaus.plexus",
-                                                                                        "plexus-spring", "1.2" ),
-                                                       Arrays.asList( createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.2", "jar" ),
-                                                                      createArtifact( "org.codehaus.plexus",
-                                                                                      "plexus-spring", "1.2",
-                                                                                      "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
+            //                                           Arrays.asList( "com", "org" ) );
+            expect( metadataRepository.getRootNamespaces( TEST_REPO_ID ) ).andReturn( Arrays.asList( "com", "org" ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
+            //                                           Arrays.asList() );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "com" ) ).andReturn( Arrays.<String>asList() );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
+            //                                           Arrays.asList( "example" ) );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList( "example" ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
+            //                                           Arrays.asList() );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ) ).andReturn(
+                Arrays.<String>asList() );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
+            //                                           Arrays.asList( "example-project" ) );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ) ).andReturn(
+                Arrays.asList( "example-project" ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjectVersions( TEST_REPO_ID, "com.example", "example-project" ),
+            //    Arrays.asList( "1.0", "1.1" ) );
+            expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "com.example", "example-project" ) ).andReturn(
+                Arrays.asList( "1.0", "1.1" ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.0" ),
+            //    Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ),
+            //                   createArtifact( "com.example", "example-project", "1.0", "pom" ) ) );
+            expect(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.0" ) ).andReturn(
+                Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ),
+                               createArtifact( "com.example", "example-project", "1.0", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.1" ),
+            //    Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ),
+            //                   createArtifact( "com.example", "example-project", "1.1", "pom" ) ) );
+            expect(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.1" ) ).andReturn(
+                Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ),
+                               createArtifact( "com.example", "example-project", "1.1", "pom" ) ) );
+
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
+            //                                           Arrays.asList( "apache", "codehaus" ) );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( "apache", "codehaus" ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
+            //                                           Arrays.asList( "archiva", "maven" ) );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList( "archiva", "maven" )  );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
+            //                                           Arrays.asList() );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.<String>asList() );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ), Arrays.asList() );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.<String>asList() );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjects( TEST_REPO_ID, "org.apache.archiva" ),
+            ///    Arrays.asList( "metadata-repository-api", "metadata-model" ) );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList( "metadata-repository-api", "metadata-model" ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ),
+            //    Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
+            expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ) )
+                .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" )  );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api",
+            //                                     "1.3-SNAPSHOT" ),
+            //    Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
+            //                   createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT",
+            //                                   "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
+                                           createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT",
+                                                           "pom" ) )  );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ),
+            //    Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ),
+            //                   createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ),
+                                           createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-model" ),
+            //    Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
+            expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-model" ) )
+                .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" )  );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ),
+            //    Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ),
+            //                   createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ),
+                                           createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ),
+            //    Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ),
+            //                   createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ),
+                                           createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList() );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ) ).andReturn( Arrays.<String>asList() );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjects( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList( "maven-model" ) );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org.apache.maven" ) )
+                .andReturn( Arrays.asList( "maven-model" )  );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.maven", "maven-model" ),
+            //    Arrays.asList( "2.2.1" ) );
+            expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.maven", "maven-model" ) )
+                .andReturn( Arrays.asList( "2.2.1" ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ),
+            //    Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ),
+            //                   createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ),
+                                           createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
+            //                                           Arrays.asList( "plexus" ) );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ).andReturn( Arrays.asList( "plexus" ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
+            //                                           Arrays.asList() );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org" ) ).andReturn( Arrays.<String>asList(  ) );
+            //metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
+            //                                           Arrays.asList() );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ) )
+                .andReturn( Arrays.<String>asList(  ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ), Arrays.asList() );
+            expect( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) )
+                .andReturn( Arrays.<String>asList(  ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus.plexus" ),
+            //    Arrays.asList( "plexus-spring" ) );
+            expect( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus.plexus" ) )
+                .andReturn( Arrays.asList( "plexus-spring" )  );
+
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getProjectVersions( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ),
+            //    Arrays.asList( "1.0", "1.1", "1.2" ) );
+            expect( metadataRepository.getProjectVersions( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ) )
+                .andReturn( Arrays.asList( "1.0", "1.1", "1.2" ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ),
+            //    Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ),
+            //                   createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ),
+                                           createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ),
+            //    Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ),
+            //                   createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ),
+                                           createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) )  );
+            //metadataRepositoryControl.expectAndReturn(
+            //    metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ),
+            //    Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ),
+            //                   createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) ) );
+            expect( metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ) )
+                .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ),
+                                           createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) )  );
         }
     }
 }
diff --git a/pom.xml b/pom.xml
index 342857664432445374fb7ed9523653b1a8833853..a0960c5ffec753269e21b2c892a9dc35ebcd8b34 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymock</artifactId>
-      <version>2.5.2</version>
+      <version>3.2</version>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.easymock</groupId>
       <artifactId>easymockclassextension</artifactId>
-      <version>2.5</version>
+      <version>3.2</version>
       <scope>test</scope>
     </dependency>
   </dependencies>