* 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;
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.
*/
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() );
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
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() );
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;
protected RepositoryPurge repoPurge;
- protected MockControl listenerControl;
+ protected IMocksControl listenerControl;
protected RepositoryListener listener;
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 );
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 );
* 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;
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;
+
/**
*/
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(
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;
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;
import javax.inject.Inject;
import java.io.File;
import java.util.List;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
/**
* @author Olivier Lamy
ArtifactContextProducer artifactContextProducer;
- MockControl archivaConfigControl;
+ IMocksControl archivaConfigControl;
Configuration config;
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 );
* under the License.
*/
+import org.easymock.EasyMock;
import org.junit.Test;
import java.io.File;
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();
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;
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();
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();
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();
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();
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();
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();
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 );
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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 );
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();
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();
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();
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();
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();
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();
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;
protected static final String REPOPATH_LEGACY_MANAGED_TARGET = "target/test-repository/legacy-managed";
- protected MockControl wagonMockControl;
+ protected IMocksControl wagonMockControl;
protected Wagon wagonMock;
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 );
}
}
-
+ /*
protected static final ArgumentsMatcher customWagonGetIfNewerMatcher = new ArgumentsMatcher()
{
return ArrayUtils.toString( arguments );
}
};
-
+ */
protected void assertChecksums( File expectedFile, String expectedSha1Contents, String expectedMd5Contents )
throws Exception
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;
// 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
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();
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();
// 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 );
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;
}
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;
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 );
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;
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 )
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;
// 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)
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();
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;
// 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();
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;
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
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;
import java.util.Locale;
import java.util.Map;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
+import static org.easymock.EasyMock.*;
/**
* 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 ) ) );
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( );
// 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( );
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( );
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;
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
{
private static final String ARTIFACT_ID = "artifact-two";
- private MockControl metadataRepositoryControl;
+ private IMocksControl metadataRepositoryControl;
private MetadataRepository metadataRepository;
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
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 );
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,
* 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;
@Named( value = "servletAuthenticator#test" )
private ServletAuthenticator servletAuth;
- private MockControl httpServletRequestControl;
+ private IMocksControl httpServletRequestControl;
private HttpServletRequest request;
{
super.setUp();
- httpServletRequestControl = MockControl.createControl( HttpServletRequest.class );
- request = (HttpServletRequest) httpServletRequestControl.getMock();
+ httpServletRequestControl = EasyMock.createControl( );
+ request = httpServletRequestControl.createMock( HttpServletRequest.class );
setupRepository( "corporate" );
}
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 );
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;
import java.util.ArrayList;
import java.util.List;
+import static org.easymock.EasyMock.*;
+
/**
* 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;
{
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 );
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 );
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();
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();
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();
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();
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();
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();
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;
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" } )
private DavSessionProvider davSessionProvider;
- private MockControl servletAuthControl;
+ private IMocksControl servletAuthControl;
private ServletAuthenticator servletAuth;
- private MockClassControl httpAuthControl;
+ private IMocksControl httpAuthControl;
private HttpAuthenticator httpAuth;
{
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" );
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 );
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 );
}
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();
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();
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();
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();
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 );
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();
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 );
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();
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 );
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();
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 );
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();
*/
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;
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;
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
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;
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;
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;
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();
}
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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 )
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
*
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 )
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;
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
private static final String TEST_REPO_ID = "test-repo";
- private MockControl metadataRepositoryControl;
+ private IMocksControl metadataRepositoryControl;
private MetadataRepository metadataRepository;
repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
- metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
- metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
+ metadataRepositoryControl = createControl();
+ metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class );
}
@Test
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 );
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 );
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();
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,
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();
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();
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() );
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();
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() );
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();
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() );
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();
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() );
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();
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() );
{
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" ) ) );
}
}
}
<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>