From c6b5ed48181c499137f9c2cef8ab9cfe9316aced Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Jun 2011 12:17:34 +0000 Subject: [PATCH] fix some test compilation issues in webapp module : will fix unit later, must compile at least ! git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134584 13f79535-47bb-0310-9956-ffa450edef68 --- .../DeleteManagedRepositoryAction.java | 2 +- .../EditManagedRepositoryAction.java | 2 +- .../interceptor/ConfigurationInterceptor.java | 2 +- .../web/startup/SecuritySynchronization.java | 2 +- .../web/action/AbstractActionTestCase.java | 12 + .../web/action/DeleteArtifactActionTest.java | 22 +- .../archiva/web/action/SearchActionTest.java | 17 +- .../web/action/ShowArtifactActionTest.java | 12 +- .../archiva/web/action/UploadActionTest.java | 1 - .../AbstractOrganizationInfoActionTest.java | 27 +-- .../EditOrganizationInfoActionTest.java | 138 ++++++------ .../OrganizationInfoActionTest.java | 37 ++-- .../DisableProxyConnectorActionTest.java | 27 ++- .../proxy/ProxyConnectorsActionTest.java | 4 +- .../proxy/SortProxyConnectorsActionTest.java | 22 +- .../DeleteRemoteRepositoryActionTest.java | 34 +-- .../DeleteRepositoryGroupActionTest.java | 49 ++-- .../EditRemoteRepositoryActionTest.java | 14 +- .../RepositoryGroupsActionTest.java | 15 +- .../RepositoryScanningActionTest.java | 7 +- .../reports/GenerateReportActionTest.java | 209 +++++++++--------- archiva-modules/pom.xml | 15 -- pom.xml | 14 -- 23 files changed, 349 insertions(+), 335 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java index bd72df542..7fc927b6d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java @@ -42,7 +42,7 @@ import java.util.Map; * DeleteManagedRepositoryAction * * @version $Id$ - * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteManagedRepositoryAction" instantiation-strategy="per-lookup" + * plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteManagedRepositoryAction" instantiation-strategy="per-lookup" */ @Controller( "deleteManagedRepositoryAction" ) @Scope( "prototype" ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java index 0937d82a4..88233b278 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryAction.java @@ -41,7 +41,7 @@ import java.io.IOException; * AddManagedRepositoryAction * * @version $Id$ - * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editManagedRepositoryAction" instantiation-strategy="per-lookup" + * plexus.component role="com.opensymphony.xwork2.Action" role-hint="editManagedRepositoryAction" instantiation-strategy="per-lookup" */ @Controller( "editManagedRepositoryAction" ) @Scope( "prototype" ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/ConfigurationInterceptor.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/ConfigurationInterceptor.java index b498c82f9..050c68e73 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/ConfigurationInterceptor.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/interceptor/ConfigurationInterceptor.java @@ -32,7 +32,7 @@ import javax.servlet.ServletContext; /** * An interceptor that makes the configuration bits available, both to the application and the webapp * - * @plexus.component role="com.opensymphony.xwork2.interceptor.Interceptor" + * plexus.component role="com.opensymphony.xwork2.interceptor.Interceptor" * role-hint="configurationInterceptor" */ @Service( "configurationInterceptor" ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java index 6f59721d5..df510e80e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/SecuritySynchronization.java @@ -76,7 +76,7 @@ public class SecuritySynchronization private RBACManager rbacManager; /** - * @plexus.requirement role="org.codehaus.plexus.redback.system.check.EnvironmentCheck" + * plexus.requirement role="org.codehaus.plexus.redback.system.check.EnvironmentCheck" */ private Map checkers; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java index d4115e7cd..8c6934ee6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java @@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.action; * under the License. */ +import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -223,4 +224,15 @@ public abstract class AbstractActionTestCase stack.getContext().put( ActionContext.CONTAINER, container ); ActionContext.setContext( new ActionContext( stack.getContext() ) ); } + + public static String getBasedir() + { + String basedir = System.getProperty( "basedir" ); + if ( basedir == null ) + { + basedir = new File( "" ).getAbsolutePath(); + } + + return basedir; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java index 0d14c6cb3..e64593c49 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.java @@ -32,7 +32,7 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.apache.struts2.StrutsSpringTestCase; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; @@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class DeleteArtifactActionTest - extends PlexusInSpringTestCase + extends StrutsSpringTestCase { private DeleteArtifactAction action; @@ -67,7 +67,13 @@ public class DeleteArtifactActionTest private static final String VERSION = "1.0"; - private static final String REPO_LOCATION = getBasedir() + "/target/test-classes/test-repo"; + private static final String REPO_LOCATION = "target/test-classes/test-repo"; + + @Override + protected String[] getContextLocations() + { + return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" }; + } @Override protected void setUp() @@ -75,7 +81,8 @@ public class DeleteArtifactActionTest { super.setUp(); - action = (DeleteArtifactAction) lookup( Action.class.getName(), "deleteArtifactAction" ); + //action = (DeleteArtifactAction) lookup( Action.class.getName(), "deleteArtifactAction" ); + action = (DeleteArtifactAction) getActionProxy( "/deleteArtifact" ).getAction(); assertNotNull( action ); configurationControl = MockControl.createControl( ArchivaConfiguration.class ); @@ -90,8 +97,11 @@ public class DeleteArtifactActionTest RepositorySession repositorySession = mock( RepositorySession.class ); when( repositorySession.getRepository() ).thenReturn( metadataRepository ); - TestRepositorySessionFactory repositorySessionFactory = (TestRepositorySessionFactory) lookup( - RepositorySessionFactory.class ); + //TestRepositorySessionFactory repositorySessionFactory = (TestRepositorySessionFactory) lookup( + // RepositorySessionFactory.class ); + + TestRepositorySessionFactory repositorySessionFactory = new TestRepositorySessionFactory(); + repositorySessionFactory.setRepositorySession( repositorySession ); action.setConfiguration( configuration ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java index 352d52449..ba8994c33 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java @@ -29,11 +29,9 @@ import org.apache.archiva.indexer.util.SearchUtil; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.security.UserRepositories; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import java.util.ArrayList; @@ -77,7 +75,8 @@ public class SearchActionTest action = new SearchAction(); session = mock( RepositorySession.class ); - TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class ); + //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class ); + TestRepositorySessionFactory factory = new TestRepositorySessionFactory(); factory.setRepositorySession( session ); action.setRepositorySessionFactory( factory ); @@ -425,8 +424,8 @@ public class SearchActionTest control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), Collections.singletonList( artifact ) ); - userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), Collections.singletonList( - TEST_REPO ) ); + userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), + Collections.singletonList( TEST_REPO ) ); control.replay(); userReposControl.replay(); @@ -453,8 +452,8 @@ public class SearchActionTest createArtifact( "archiva-indexer", "1.0" ) ); control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), artifacts ); - userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), Collections.singletonList( - TEST_REPO ) ); + userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), + Collections.singletonList( TEST_REPO ) ); control.replay(); userReposControl.replay(); @@ -490,8 +489,8 @@ public class SearchActionTest control.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, TEST_CHECKSUM ), Collections.emptyList() ); - userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), Collections.singletonList( - TEST_REPO ) ); + userReposControl.expectAndReturn( userRepos.getObservableRepositoryIds( GUEST ), + Collections.singletonList( TEST_REPO ) ); control.replay(); userReposControl.replay(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java index abbcf4f9b..480b318ee 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java @@ -39,6 +39,7 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; +import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -72,7 +73,7 @@ public class ShowArtifactActionTest public void testInstantiation() { - assertFalse( action == lookup( Action.class, ACTION_HINT ) ); + assertFalse( action == getActionProxy( "/showArtifact" ).getAction() ); } public void testGetArtifactUniqueRelease() @@ -630,15 +631,16 @@ public class ShowArtifactActionTest throws Exception { super.setUp(); - action = (ShowArtifactAction) lookup( Action.class, ACTION_HINT ); + action = (ShowArtifactAction) getActionProxy( "/showArtifact" ).getAction(); metadataResolver = new TestMetadataResolver(); MetadataRepository repo = mock( MetadataRepository.class ); RepositorySession repositorySession = mock( RepositorySession.class ); when( repositorySession.getResolver() ).thenReturn( metadataResolver ); when( repositorySession.getRepository() ).thenReturn( repo ); - TestRepositorySessionFactory repositorySessionFactory = (TestRepositorySessionFactory) lookup( - RepositorySessionFactory.class ); + //TestRepositorySessionFactory repositorySessionFactory = (TestRepositorySessionFactory) lookup( + // RepositorySessionFactory.class ); + TestRepositorySessionFactory repositorySessionFactory = new TestRepositorySessionFactory(); repositorySessionFactory.setRepositorySession( repositorySession ); RepositoryContentFactory factory = mock( RepositoryContentFactory.class ); @@ -646,7 +648,7 @@ public class ShowArtifactActionTest ManagedRepositoryConfiguration config = new ManagedRepositoryConfiguration(); config.setId( TEST_REPO ); - config.setLocation( getTestFile( "target/test-repo" ).getAbsolutePath() ); + config.setLocation( new File( "target/test-repo" ).getAbsolutePath() ); ManagedRepositoryContent content = new ManagedDefaultRepositoryContent(); content.setRepository( config ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java index 029110110..c8930ab66 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java @@ -39,7 +39,6 @@ import org.apache.maven.archiva.repository.RepositoryNotFoundException; import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; import org.apache.maven.archiva.repository.metadata.MetadataTools; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java index e0e93b403..b4132eacd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/AbstractOrganizationInfoActionTest.java @@ -7,16 +7,17 @@ import org.easymock.MockControl; /** */ -public abstract class AbstractOrganizationInfoActionTest extends AbstractWebworkTestCase +public abstract class AbstractOrganizationInfoActionTest + extends AbstractWebworkTestCase { protected MockControl archivaConfigurationControl; - + protected ArchivaConfiguration configuration; - + protected AbstractAppearanceAction action; - + protected Configuration config; - + protected abstract AbstractAppearanceAction getAction(); @Override @@ -24,20 +25,20 @@ public abstract class AbstractOrganizationInfoActionTest extends AbstractWebwork throws Exception { super.setUp(); - + config = new Configuration(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); configuration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); - + configuration.getConfiguration(); - archivaConfigurationControl.setReturnValue(config, 1, 2); - - configuration.save(config); - archivaConfigurationControl.setVoidCallable(1, 2); - + archivaConfigurationControl.setReturnValue( config, 1, 2 ); + + configuration.save( config ); + archivaConfigurationControl.setVoidCallable( 1, 2 ); + archivaConfigurationControl.replay(); } - + protected void reloadAction() { action = getAction(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java index 7aff5f7cc..41223bda7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganizationInfoActionTest.java @@ -19,22 +19,20 @@ package org.apache.maven.archiva.web.action.admin.appearance; * under the License. */ -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.validator.ActionValidatorManager; +import org.apache.maven.archiva.configuration.OrganisationInformation; +import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory; +import org.apache.maven.archiva.web.validator.utils.ValidatorUtil; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.opensymphony.xwork2.validator.DefaultActionValidatorManager; -import org.apache.maven.archiva.configuration.OrganisationInformation; -import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory; -import org.apache.maven.archiva.web.validator.utils.ValidatorUtil; - /** */ -public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActionTest +public class EditOrganizationInfoActionTest + extends AbstractOrganizationInfoActionTest { private static final String EMPTY_STRING = ""; @@ -56,7 +54,8 @@ public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActi private ActionValidatorManager actionValidatorManager; @Override - public void setUp() throws Exception + public void setUp() + throws Exception { super.setUp(); @@ -68,44 +67,45 @@ public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActi public void testOrganisationInfoSaves() throws Exception { - config.setOrganisationInfo(new OrganisationInformation()); + config.setOrganisationInfo( new OrganisationInformation() ); OrganisationInformation orginfo = config.getOrganisationInfo(); - orginfo.setLogoLocation("LOGO"); - orginfo.setName("NAME"); - orginfo.setUrl("URL"); - - configuration.save(config); - + orginfo.setLogoLocation( "LOGO" ); + orginfo.setName( "NAME" ); + orginfo.setUrl( "URL" ); + + configuration.save( config ); + reloadAction(); - + action.prepare(); - - assertEquals("LOGO", action.getOrganisationLogo()); - assertEquals("NAME", action.getOrganisationName()); - assertEquals("URL", action.getOrganisationUrl()); - - action.setOrganisationLogo("LOGO1"); - action.setOrganisationName("NAME1"); - action.setOrganisationUrl("URL1"); - + + assertEquals( "LOGO", action.getOrganisationLogo() ); + assertEquals( "NAME", action.getOrganisationName() ); + assertEquals( "URL", action.getOrganisationUrl() ); + + action.setOrganisationLogo( "LOGO1" ); + action.setOrganisationName( "NAME1" ); + action.setOrganisationUrl( "URL1" ); + action.execute(); - - assertEquals("LOGO1", orginfo.getLogoLocation()); - assertEquals("NAME1", orginfo.getName()); - assertEquals("URL1", orginfo.getUrl()); + + assertEquals( "LOGO1", orginfo.getLogoLocation() ); + assertEquals( "NAME1", orginfo.getName() ); + assertEquals( "URL1", orginfo.getUrl() ); } - public void testStruts2ValidationFrameworkWithNullInputs() throws Exception + public void testStruts2ValidationFrameworkWithNullInputs() + throws Exception { // prep action = getAction(); - populateOrganisationValues(action, null, null, null); + populateOrganisationValues( action, null, null, null ); // test - actionValidatorManager.validate(action, EMPTY_STRING); + actionValidatorManager.validate( action, EMPTY_STRING ); // verify - assertTrue(action.hasFieldErrors()); + assertTrue( action.hasFieldErrors() ); Map> fieldErrors = action.getFieldErrors(); @@ -114,23 +114,24 @@ public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActi // populate List expectedErrorMessages = new ArrayList(); - expectedErrorMessages.add("You must enter a name"); - expectedFieldErrors.put("organisationName", expectedErrorMessages); + expectedErrorMessages.add( "You must enter a name" ); + expectedFieldErrors.put( "organisationName", expectedErrorMessages ); - ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors); + ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors ); } - public void testStruts2ValidationFrameworkWithBlankInputs() throws Exception + public void testStruts2ValidationFrameworkWithBlankInputs() + throws Exception { // prep action = getAction(); - populateOrganisationValues(action, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING); + populateOrganisationValues( action, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING ); // test - actionValidatorManager.validate(action, EMPTY_STRING); + actionValidatorManager.validate( action, EMPTY_STRING ); // verify - assertTrue(action.hasFieldErrors()); + assertTrue( action.hasFieldErrors() ); Map> fieldErrors = action.getFieldErrors(); @@ -139,23 +140,25 @@ public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActi // populate List expectedErrorMessages = new ArrayList(); - expectedErrorMessages.add("You must enter a name"); - expectedFieldErrors.put("organisationName", expectedErrorMessages); + expectedErrorMessages.add( "You must enter a name" ); + expectedFieldErrors.put( "organisationName", expectedErrorMessages ); - ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors); + ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors ); } - public void testStruts2ValidationFrameworkWithInvalidInputs() throws Exception + public void testStruts2ValidationFrameworkWithInvalidInputs() + throws Exception { // prep action = getAction(); - populateOrganisationValues(action, ORGANISATION_NAME_INVALID_INPUT, ORGANISATION_URL_INVALID_INPUT, ORGANISATION_LOGO_INVALID_INPUT); + populateOrganisationValues( action, ORGANISATION_NAME_INVALID_INPUT, ORGANISATION_URL_INVALID_INPUT, + ORGANISATION_LOGO_INVALID_INPUT ); // test - actionValidatorManager.validate(action, EMPTY_STRING); + actionValidatorManager.validate( action, EMPTY_STRING ); // verify - assertTrue(action.hasFieldErrors()); + assertTrue( action.hasFieldErrors() ); Map> fieldErrors = action.getFieldErrors(); @@ -164,43 +167,48 @@ public class EditOrganizationInfoActionTest extends AbstractOrganizationInfoActi // populate List expectedErrorMessages = new ArrayList(); - expectedErrorMessages.add("Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)."); - expectedFieldErrors.put("organisationName", expectedErrorMessages); + expectedErrorMessages.add( + "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." ); + expectedFieldErrors.put( "organisationName", expectedErrorMessages ); expectedErrorMessages = new ArrayList(); - expectedErrorMessages.add("You must enter a URL"); - expectedFieldErrors.put("organisationUrl", expectedErrorMessages); + expectedErrorMessages.add( "You must enter a URL" ); + expectedFieldErrors.put( "organisationUrl", expectedErrorMessages ); expectedErrorMessages = new ArrayList(); - expectedErrorMessages.add("You must enter a URL"); - expectedFieldErrors.put("organisationLogo", expectedErrorMessages); + expectedErrorMessages.add( "You must enter a URL" ); + expectedFieldErrors.put( "organisationLogo", expectedErrorMessages ); - ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors); + ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors ); } - public void testStruts2ValidationFrameworkWithValidInputs() throws Exception + public void testStruts2ValidationFrameworkWithValidInputs() + throws Exception { // prep action = getAction(); - populateOrganisationValues(action, ORGANISATION_NAME_VALID_INPUT, ORGANISATION_URL_VALID_INPUT, ORGANISATION_LOGO_VALID_INPUT); + populateOrganisationValues( action, ORGANISATION_NAME_VALID_INPUT, ORGANISATION_URL_VALID_INPUT, + ORGANISATION_LOGO_VALID_INPUT ); // test - actionValidatorManager.validate(action, EMPTY_STRING); + actionValidatorManager.validate( action, EMPTY_STRING ); // verify - assertFalse(action.hasFieldErrors()); + assertFalse( action.hasFieldErrors() ); } - private void populateOrganisationValues(AbstractAppearanceAction abstractAppearanceAction , String name, String url, String logo) + private void populateOrganisationValues( AbstractAppearanceAction abstractAppearanceAction, String name, String url, + String logo ) { - abstractAppearanceAction.setOrganisationName(name); - abstractAppearanceAction.setOrganisationUrl(url); - abstractAppearanceAction.setOrganisationLogo(logo); + abstractAppearanceAction.setOrganisationName( name ); + abstractAppearanceAction.setOrganisationUrl( url ); + abstractAppearanceAction.setOrganisationLogo( logo ); } @Override - protected AbstractAppearanceAction getAction() + protected AbstractAppearanceAction getAction() { - return (EditOrganisationInfoAction) lookup( Action.class.getName(), "editOrganisationInfo" ); + //return (EditOrganisationInfoAction) lookup( Action.class.getName(), "editOrganisationInfo" ); + return (EditOrganisationInfoAction) getActionProxy( "/admin/editOrganisationInfo" ).getAction(); } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java index 336f1097f..2682bc21e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/appearance/OrganizationInfoActionTest.java @@ -21,35 +21,36 @@ package org.apache.maven.archiva.web.action.admin.appearance; import org.apache.maven.archiva.configuration.OrganisationInformation; -import com.opensymphony.xwork2.Action; - /** */ -public class OrganizationInfoActionTest extends AbstractOrganizationInfoActionTest -{ +public class OrganizationInfoActionTest + extends AbstractOrganizationInfoActionTest +{ public void testOrganisationInfoLoads() throws Exception { - config.setOrganisationInfo(new OrganisationInformation()); + config.setOrganisationInfo( new OrganisationInformation() ); OrganisationInformation orginfo = config.getOrganisationInfo(); - orginfo.setLogoLocation("LOGO"); - orginfo.setName("NAME"); - orginfo.setUrl("URL"); - - configuration.save(config); - + orginfo.setLogoLocation( "LOGO" ); + orginfo.setName( "NAME" ); + orginfo.setUrl( "URL" ); + + configuration.save( config ); + reloadAction(); - + action.prepare(); - - assertEquals("URL", action.getOrganisationUrl()); - assertEquals("NAME", action.getOrganisationName()); - assertEquals("LOGO", action.getOrganisationLogo()); + + assertEquals( "URL", action.getOrganisationUrl() ); + assertEquals( "NAME", action.getOrganisationName() ); + assertEquals( "LOGO", action.getOrganisationLogo() ); } @Override - protected AbstractAppearanceAction getAction() + protected AbstractAppearanceAction getAction() { - return (OrganisationInfoAction) lookup( Action.class.getName(), "organisationInfo" ); + //return (OrganisationInfoAction) lookup( Action.class.getName(), "organisationInfo" ); + + return (OrganisationInfoAction) getActionProxy( "/admin/organisationInfo" ).getAction(); } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java index becbd156e..a71901893 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java @@ -25,22 +25,23 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.web.action.AbstractWebworkTestCase; -import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.easymock.MockControl; -public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase +public class DisableProxyConnectorActionTest + extends AbstractWebworkTestCase { private static final String TEST_TARGET_ID = "central"; private static final String TEST_SOURCE_ID = "corporate"; - + private DisableProxyConnectorAction action; - + private MockControl archivaConfigurationControl; private ArchivaConfiguration archivaConfiguration; - + public void testConfirmDisableBadSourceOrTarget() throws Exception { @@ -132,8 +133,9 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase // Test the configuration. assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() ); - ProxyConnectorConfiguration config = (ProxyConnectorConfiguration)archivaConfiguration.getConfiguration().getProxyConnectors().get(0); - assertTrue(config.isDisabled()); + ProxyConnectorConfiguration config = + (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 ); + assertTrue( config.isDisabled() ); } public void testSecureActionBundle() @@ -146,7 +148,7 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase assertTrue( bundle.requiresAuthentication() ); assertEquals( 1, bundle.getAuthorizationTuples().size() ); } - + public void testConfirmEnable() throws Exception { @@ -161,7 +163,7 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase assertEquals( Action.INPUT, status ); assertNoErrors( action ); } - + private Configuration createInitialConfiguration() { Configuration config = new Configuration(); @@ -182,8 +184,8 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration(); connector.setSourceRepoId( TEST_SOURCE_ID ); connector.setTargetRepoId( TEST_TARGET_ID ); - - connector.setDisabled(false); + + connector.setDisabled( false ); config.addProxyConnector( connector ); @@ -210,7 +212,8 @@ public class DisableProxyConnectorActionTest extends AbstractWebworkTestCase { super.setUp(); - action = (DisableProxyConnectorAction) lookup( Action.class.getName(), "disableProxyConnectorAction" ); + //action = (DisableProxyConnectorAction) lookup( Action.class.getName(), "disableProxyConnectorAction" ); + action = (DisableProxyConnectorAction) getActionProxy( "/admin/disableProxyConnector" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java index 5fde0bbc2..519350759 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java @@ -58,7 +58,9 @@ public class ProxyConnectorsActionTest { super.setUp(); - action = (ProxyConnectorsAction) lookup( Action.class.getName(), "proxyConnectorsAction" ); + //action = (ProxyConnectorsAction) lookup( Action.class.getName(), "proxyConnectorsAction" ); + + action = (ProxyConnectorsAction) getActionProxy("/admin/proxyConnectors" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java index fa9b969b9..dcfff827e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork2.Action; - import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -30,15 +29,15 @@ import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator; import org.apache.maven.archiva.web.action.AbstractWebworkTestCase; -import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.easymock.MockControl; import java.util.Collections; import java.util.List; /** - * SortProxyConnectorsActionTest + * SortProxyConnectorsActionTest * * @version $Id$ */ @@ -81,7 +80,7 @@ public class SortProxyConnectorsActionTest String status = action.sortDown(); assertEquals( Action.SUCCESS, status ); - assertOrder( new String[] { JAVAX, CENTRAL, CODEHAUS } ); + assertOrder( new String[]{ JAVAX, CENTRAL, CODEHAUS } ); } public void testSortDownPastEnd() @@ -97,7 +96,7 @@ public class SortProxyConnectorsActionTest assertEquals( Action.SUCCESS, status ); // No order change. - assertOrder( new String[] { CENTRAL, JAVAX, CODEHAUS } ); + assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } ); } public void testSortUp() @@ -111,11 +110,11 @@ public class SortProxyConnectorsActionTest String status = action.sortUp(); assertEquals( Action.SUCCESS, status ); - assertOrder( new String[] { CENTRAL, CODEHAUS, JAVAX } ); + assertOrder( new String[]{ CENTRAL, CODEHAUS, JAVAX } ); } public void testSortUpPastBeginning() - throws Exception + throws Exception { expectConfigurationRequests( 7 ); archivaConfigurationControl.replay(); @@ -127,7 +126,7 @@ public class SortProxyConnectorsActionTest assertEquals( Action.SUCCESS, status ); // No order change. - assertOrder( new String[] { CENTRAL, JAVAX, CODEHAUS } ); + assertOrder( new String[]{ CENTRAL, JAVAX, CODEHAUS } ); } private void assertOrder( String[] targetRepoOrder ) @@ -137,8 +136,8 @@ public class SortProxyConnectorsActionTest for ( ProxyConnectorConfiguration connector : connectors ) { - assertEquals( "All connectors in list should have the same source id (in this test)", CORPORATE, connector - .getSourceRepoId() ); + assertEquals( "All connectors in list should have the same source id (in this test)", CORPORATE, + connector.getSourceRepoId() ); } assertEquals( targetRepoOrder.length, connectors.size() ); @@ -243,7 +242,8 @@ public class SortProxyConnectorsActionTest { super.setUp(); - action = (SortProxyConnectorsAction) lookup( Action.class.getName(), "sortProxyConnectorsAction" ); + //action = (SortProxyConnectorsAction) lookup( Action.class.getName(), "sortProxyConnectorsAction" ); + action = (SortProxyConnectorsAction) getActionProxy( "/admin/sortProxyConnectors" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java index fdd0fa1ee..ea03dc1af 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRemoteRepositoryActionTest.java @@ -28,13 +28,12 @@ import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.web.action.AbstractActionTestCase; import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import java.util.Collections; /** - * DeleteRemoteRepositoryActionTest + * DeleteRemoteRepositoryActionTest * * @version $Id$ */ @@ -54,7 +53,8 @@ public class DeleteRemoteRepositoryActionTest { super.setUp(); - action = (DeleteRemoteRepositoryAction) lookup( Action.class.getName(), "deleteRemoteRepositoryAction" ); + //action = (DeleteRemoteRepositoryAction) lookup( Action.class.getName(), "deleteRemoteRepositoryAction" ); + action = (DeleteRemoteRepositoryAction) getActionProxy( "/admin/deleteRemoteRepository" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); @@ -90,26 +90,28 @@ public class DeleteRemoteRepositoryActionTest throws RegistryException, IndeterminateConfigurationException { Configuration configuration = createConfigurationForEditing( createRepository() ); - configuration.addManagedRepository( createManagedRepository( "internal", getTestPath( "target/repo/internal" ) ) ); - configuration.addManagedRepository( createManagedRepository( "snapshots", getTestPath( "target/repo/snapshots" ) ) ); - configuration.addProxyConnector( createProxyConnector( "internal", REPO_ID) ); - + configuration.addManagedRepository( + createManagedRepository( "internal", "target/repo/internal" )); + configuration.addManagedRepository( + createManagedRepository( "snapshots", "target/repo/snapshots" ) ); + configuration.addProxyConnector( createProxyConnector( "internal", REPO_ID ) ); + archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration, 4 ); - + archivaConfiguration.save( configuration ); archivaConfigurationControl.replay(); - + action.setRepoid( REPO_ID ); - + action.prepare(); assertEquals( REPO_ID, action.getRepoid() ); RemoteRepositoryConfiguration repository = action.getRepository(); assertNotNull( repository ); assertRepositoryEquals( repository, createRepository() ); - + assertEquals( 1, configuration.getProxyConnectors().size() ); - + String status = action.delete(); assertEquals( Action.SUCCESS, status ); @@ -151,7 +153,7 @@ public class DeleteRemoteRepositoryActionTest configuration.addRemoteRepository( repositoryConfiguration ); return configuration; } - + private RemoteRepositoryConfiguration createRepository() { RemoteRepositoryConfiguration r = new RemoteRepositoryConfiguration(); @@ -159,7 +161,7 @@ public class DeleteRemoteRepositoryActionTest populateRepository( r ); return r; } - + private void assertRepositoryEquals( RemoteRepositoryConfiguration expectedRepository, RemoteRepositoryConfiguration actualRepository ) { @@ -168,7 +170,7 @@ public class DeleteRemoteRepositoryActionTest assertEquals( expectedRepository.getUrl(), actualRepository.getUrl() ); assertEquals( expectedRepository.getName(), actualRepository.getName() ); } - + private ManagedRepositoryConfiguration createManagedRepository( String string, String testPath ) { ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration(); @@ -202,6 +204,6 @@ public class DeleteRemoteRepositoryActionTest repository.setUrl( "url" ); repository.setLayout( "default" ); } - + // TODO: what about removing proxied content if a proxy is removed? } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java index 7a03e676a..bc5c5a972 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java @@ -19,25 +19,21 @@ package org.apache.maven.archiva.web.action.admin.repositories; * under the License. */ -import java.util.Collections; - +import com.opensymphony.xwork2.Action; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; import org.apache.maven.archiva.web.action.AbstractActionTestCase; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.redback.integration.interceptor.SecureActionException; import org.easymock.MockControl; -import com.opensymphony.xwork2.Action; +import java.util.Collections; /** * DeleteRepositoryGroupActionTest - * - * @version */ -public class DeleteRepositoryGroupActionTest +public class DeleteRepositoryGroupActionTest extends AbstractActionTestCase { private static final String REPO_GROUP_ID = "repo-group-ident"; @@ -52,21 +48,22 @@ public class DeleteRepositoryGroupActionTest throws Exception { super.setUp(); - - action = (DeleteRepositoryGroupAction) lookup ( Action.class.getName(), "deleteRepositoryGroupAction" ); - + + //action = (DeleteRepositoryGroupAction) lookup ( Action.class.getName(), "deleteRepositoryGroupAction" ); + action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup" ).getAction(); + archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); action.setArchivaConfiguration( archivaConfiguration ); } - + public void testSecureActionBundle() throws SecureActionException - { + { archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( new Configuration() ); archivaConfigurationControl.replay(); - + action.prepare(); SecureActionBundle bundle = action.getSecureActionBundle(); assertTrue( bundle.requiresAuthentication() ); @@ -78,11 +75,11 @@ public class DeleteRepositoryGroupActionTest { RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup(); Configuration configuration = createConfigurationForEditing( origRepoGroup ); - + archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration ); archivaConfigurationControl.replay(); - + action.setRepoGroupId( REPO_GROUP_ID ); action.prepare(); @@ -97,20 +94,20 @@ public class DeleteRepositoryGroupActionTest throws Exception { Configuration configuration = createConfigurationForEditing( createRepositoryGroup() ); - + archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration, 3 ); archivaConfiguration.save( configuration ); archivaConfigurationControl.replay(); - + action.setRepoGroupId( REPO_GROUP_ID ); - + action.prepare(); assertEquals( REPO_GROUP_ID, action.getRepoGroupId() ); RepositoryGroupConfiguration repoGroup = action.getRepositoryGroup(); assertNotNull( repoGroup ); assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); - + String status = action.delete(); assertEquals( Action.SUCCESS, status ); assertTrue( configuration.getRepositoryGroups().isEmpty() ); @@ -120,21 +117,21 @@ public class DeleteRepositoryGroupActionTest throws Exception { RepositoryGroupConfiguration origRepoGroup = createRepositoryGroup(); - Configuration configuration = createConfigurationForEditing ( origRepoGroup ); - + Configuration configuration = createConfigurationForEditing( origRepoGroup ); + archivaConfiguration.getConfiguration(); archivaConfigurationControl.setReturnValue( configuration, 2 ); archivaConfiguration.save( configuration ); archivaConfigurationControl.replay(); - + action.setRepoGroupId( REPO_GROUP_ID ); - + action.prepare(); assertEquals( REPO_GROUP_ID, action.getRepoGroupId() ); RepositoryGroupConfiguration repoGroup = action.getRepositoryGroup(); assertNotNull( repoGroup ); - + String status = action.execute(); assertEquals( Action.SUCCESS, status ); assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); @@ -146,12 +143,12 @@ public class DeleteRepositoryGroupActionTest configuration.addRepositoryGroup( repoGroup ); return configuration; } - + private RepositoryGroupConfiguration createRepositoryGroup() { RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration(); repoGroup.setId( REPO_GROUP_ID ); - + return repoGroup; } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java index 1e27bd04f..dface6a7c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditRemoteRepositoryActionTest.java @@ -23,9 +23,9 @@ import com.opensymphony.xwork2.Action; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.struts2.StrutsSpringTestCase; import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.redback.integration.interceptor.SecureActionException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import java.util.Collections; @@ -36,7 +36,7 @@ import java.util.Collections; * @version $Id$ */ public class EditRemoteRepositoryActionTest - extends PlexusInSpringTestCase + extends StrutsSpringTestCase { private static final String REPO_ID = "remote-repo-ident"; @@ -46,6 +46,12 @@ public class EditRemoteRepositoryActionTest private ArchivaConfiguration archivaConfiguration; + @Override + protected String[] getContextLocations() + { + return new String[]{ "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" }; + } + public void testEditRemoteRepository() throws Exception { @@ -147,7 +153,9 @@ public class EditRemoteRepositoryActionTest { super.setUp(); - action = (EditRemoteRepositoryAction) lookup( Action.class.getName(), "editRemoteRepositoryAction" ); + //action = (EditRemoteRepositoryAction) lookup( Action.class.getName(), "editRemoteRepositoryAction" ); + + action = (EditRemoteRepositoryAction) getActionProxy( "editRemoteRepository" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java index c339e1f26..3e8f28b84 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsActionTest.java @@ -19,9 +19,9 @@ package org.apache.maven.archiva.web.action.admin.repositories; * under the License. */ -import java.util.Collections; -import java.util.List; - +import com.meterware.servletunit.ServletRunner; +import com.meterware.servletunit.ServletUnitClient; +import com.opensymphony.xwork2.Action; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; @@ -29,12 +29,10 @@ import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; import org.apache.maven.archiva.web.action.AbstractActionTestCase; import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.redback.integration.interceptor.SecureActionException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; -import com.meterware.servletunit.ServletRunner; -import com.meterware.servletunit.ServletUnitClient; -import com.opensymphony.xwork2.Action; +import java.util.Collections; +import java.util.List; /** * RepositoryGroupsActionTest @@ -61,7 +59,8 @@ public class RepositoryGroupsActionTest { super.setUp(); - action = (RepositoryGroupsAction) lookup( Action.class.getName(), "repositoryGroupsAction" ); + //action = (RepositoryGroupsAction) lookup( Action.class.getName(), "repositoryGroupsAction" ); + action = (RepositoryGroupsAction) getActionProxy( "/admin/repositoryGroups" ); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java index 99a6afc69..e53a8be0b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningActionTest.java @@ -1,15 +1,14 @@ package org.apache.maven.archiva.web.action.admin.scanning; -import java.util.ArrayList; -import java.util.List; - import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.web.action.AbstractActionTestCase; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; +import java.util.ArrayList; +import java.util.List; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java index d19c24c9d..6eb06565d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java @@ -23,7 +23,6 @@ import com.opensymphony.xwork2.Action; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory; import org.apache.archiva.metadata.repository.stats.RepositoryStatistics; import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; @@ -74,16 +73,9 @@ public class GenerateReportActionTest { super.setUp(); - try - { - action = (GenerateReportAction) lookup( Action.class, "generateReport" ); - } - catch ( Exception e ) - { - // clean up cache - TODO: move handling to plexus-spring - applicationContext.close(); - throw e; - } + //action = (GenerateReportAction) lookup( Action.class, "generateReport" ); + + action = (GenerateReportAction) getActionProxy( "/admin/generateReport" ).getAction(); repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class ); repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock(); @@ -95,7 +87,9 @@ public class GenerateReportActionTest RepositorySession repositorySession = mock( RepositorySession.class ); when( repositorySession.getRepository() ).thenReturn( metadataRepository ); - TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class ); + //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class ); + + TestRepositorySessionFactory factory = new TestRepositorySessionFactory(); factory.setRepositorySession( repositorySession ); } @@ -189,8 +183,9 @@ public class GenerateReportActionTest public void testGenerateStatisticsSingleRepo() throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.singletonList( createDefaultStats() ) ); repositoryStatisticsManagerControl.replay(); prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) ); @@ -204,8 +199,9 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.emptyList() ); repositoryStatisticsManagerControl.replay(); prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) ); @@ -220,8 +216,9 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.singletonList( createDefaultStats() ) ); repositoryStatisticsManagerControl.replay(); action.setPage( 2 ); prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) ); @@ -236,10 +233,12 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.emptyList() ); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.emptyList() ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.emptyList() ); @@ -256,10 +255,12 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) ); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.singletonList( createDefaultStats() ) ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.emptyList() ); @@ -273,8 +274,9 @@ public class GenerateReportActionTest throws Exception { Date date = new Date(); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createStats( date ) ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.singletonList( createStats( date ) ) ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) ); @@ -285,18 +287,20 @@ public class GenerateReportActionTest assertFalse( action.hasFieldErrors() ); assertEquals( - "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" + - date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) ); + "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" + + date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) ); repositoryStatisticsManagerControl.verify(); } public void testDownloadStatisticsMultipleRepos() throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) ); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.singletonList( createDefaultStats() ) ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.emptyList() ); @@ -367,8 +371,9 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.emptyList() ); repositoryStatisticsManagerControl.replay(); prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) ); @@ -393,10 +398,12 @@ public class GenerateReportActionTest throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.emptyList() ); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.emptyList() ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.emptyList() ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.emptyList() ); @@ -411,10 +418,12 @@ public class GenerateReportActionTest public void testDownloadStatisticsMultipleRepoInStrutsFormat() throws Exception { - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) ); - repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange( - metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, SNAPSHOTS, null, null ), + Collections.singletonList( createDefaultStats() ) ); + repositoryStatisticsManagerControl.expectAndReturn( + repositoryStatisticsManager.getStatisticsInRange( metadataRepository, INTERNAL, null, null ), + Collections.singletonList( createDefaultStats() ) ); repositoryStatisticsManagerControl.replay(); prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.emptyList() ); @@ -434,17 +443,15 @@ public class GenerateReportActionTest RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL ); RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem1.getName(), problem2.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem1.getName() ), - problem1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem2.getName() ), - problem2 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem1.getName(), problem2.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ), + problem1 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ), + problem2 ); metadataRepositoryControl.replay(); action.setRepositoryId( INTERNAL ); @@ -483,20 +490,18 @@ public class GenerateReportActionTest { RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL ); RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem1.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( SNAPSHOTS, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem2.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem1.getName() ), - problem1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( SNAPSHOTS, - RepositoryProblemFacet.FACET_ID, - problem2.getName() ), - problem2 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem1.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem2.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ), + problem1 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ), + problem2 ); metadataRepositoryControl.replay(); action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES ); @@ -506,8 +511,8 @@ public class GenerateReportActionTest String result = action.execute(); assertSuccessResult( result ); - assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), new ArrayList( - action.getRepositoriesMap().keySet() ) ); + assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), + new ArrayList( action.getRepositoriesMap().keySet() ) ); assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) ); assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) ); @@ -519,17 +524,15 @@ public class GenerateReportActionTest { RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL ); RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem1.getName(), problem2.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem1.getName() ), - problem1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem2.getName() ), - problem2 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem1.getName(), problem2.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ), + problem1 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem2.getName() ), + problem2 ); metadataRepositoryControl.replay(); action.setGroupId( GROUP_ID ); @@ -551,20 +554,18 @@ public class GenerateReportActionTest { RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL ); RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem1.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( SNAPSHOTS, - RepositoryProblemFacet.FACET_ID ), - Arrays.asList( problem2.getName() ) ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL, - RepositoryProblemFacet.FACET_ID, - problem1.getName() ), - problem1 ); - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( SNAPSHOTS, - RepositoryProblemFacet.FACET_ID, - problem2.getName() ), - problem2 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem1.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( SNAPSHOTS, RepositoryProblemFacet.FACET_ID ), + Arrays.asList( problem2.getName() ) ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( INTERNAL, RepositoryProblemFacet.FACET_ID, problem1.getName() ), + problem1 ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacet( SNAPSHOTS, RepositoryProblemFacet.FACET_ID, problem2.getName() ), + problem2 ); metadataRepositoryControl.replay(); action.setGroupId( GROUP_ID ); @@ -575,8 +576,8 @@ public class GenerateReportActionTest String result = action.execute(); assertSuccessResult( result ); - assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), new ArrayList( - action.getRepositoriesMap().keySet() ) ); + assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), + new ArrayList( action.getRepositoriesMap().keySet() ) ); assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) ); assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) ); @@ -586,9 +587,9 @@ public class GenerateReportActionTest public void testHealthReportSingleRepoByIncorrectGroupId() throws Exception { - metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL, - RepositoryProblemFacet.FACET_ID ), - Collections.emptyList() ); + metadataRepositoryControl.expectAndReturn( + metadataRepository.getMetadataFacets( INTERNAL, RepositoryProblemFacet.FACET_ID ), + Collections.emptyList() ); metadataRepositoryControl.replay(); action.setGroupId( "not.it" ); @@ -608,9 +609,9 @@ public class GenerateReportActionTest throws IOException { assertEquals( - "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" + - "snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n", IOUtils.toString( - action.getInputStream() ) ); + "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" + + "snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n", + IOUtils.toString( action.getInputStream() ) ); } private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId ) diff --git a/archiva-modules/pom.xml b/archiva-modules/pom.xml index 4eae4ba24..f38236274 100644 --- a/archiva-modules/pom.xml +++ b/archiva-modules/pom.xml @@ -139,21 +139,6 @@ true private - - plexus.component - t - Component definition: - - - plexus.configuration - f - Configuration: - - - plexus.requirement - f - Requirement: - todo a diff --git a/pom.xml b/pom.xml index a902ef057..58a3647a3 100644 --- a/pom.xml +++ b/pom.xml @@ -1199,20 +1199,6 @@ - - org.codehaus.plexus - plexus-component-metadata - 1.0-beta-3.0.5 - - - generate - generate-resources - - generate-metadata - - - - -- 2.39.5