]> source.dussan.org Git - archiva.git/commitdiff
fix junit BrowseActionTest and RepositoriesActionTest
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Jun 2011 21:46:04 +0000 (21:46 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Jun 2011 21:46:04 +0000 (21:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135814 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/BrowseActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesActionTest.java

index c5c2da070e71cfaa625a71695dcb0a854da7e671..9a95ce5469313e1000cb8ae0267ec555b9aec6df 100644 (file)
@@ -107,8 +107,7 @@ public abstract class AbstractActionTestCase
 
     protected void setObservableRepos( List<String> repoIds )
     {
-        //(UserRepositoriesStub) lookup( UserRepositories.class );
-        UserRepositoriesStub repos = applicationContext.getBean( "userRepositories#test", UserRepositoriesStub.class );
+        UserRepositoriesStub repos = applicationContext.getBean( "userRepositories", UserRepositoriesStub.class );
         repos.setObservableRepositoryIds( repoIds );
     }
 
index 394d04e773481359dd3e0d3bf36422e1b14c9463..2b5c6c025afa0849ac2e96be0941eb29bfe4a6f8 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.web.action;
  * under the License.
  */
 
+import com.google.common.collect.Lists;
 import com.opensymphony.xwork2.Action;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.RepositorySession;
@@ -390,6 +391,7 @@ public class BrowseActionTest
         throws Exception
     {
         super.setUp();
+        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
         //action = (BrowseAction) lookup( Action.class, ACTION_HINT );
         action = (BrowseAction) getActionProxy( "/browse.action" ).getAction();
         metadataResolver = new TestMetadataResolver();
@@ -399,4 +401,11 @@ public class BrowseActionTest
             applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
         factory.setRepositorySession( repositorySession );
     }
+
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        setObservableRepos( Lists.<String>newArrayList( "test-repo" ) );
+    }
 }
\ No newline at end of file
index 2a489e6e6db062529ee65c2bef59787dd168a253..b21e0e5d125a8d4460bacdb65a7d25e7b85a6d29 100644 (file)
@@ -50,7 +50,7 @@ public class RepositoriesActionTest
         super.setUp();
 
         //action = (RepositoriesAction) lookup( Action.class.getName(), "repositoriesAction" );
-        action = (RepositoriesAction) getActionProxy( "/admin/index.action"  ).getAction();
+        action = (RepositoriesAction) getActionProxy( "/admin/index.action" ).getAction();
 
     }
 
@@ -67,20 +67,20 @@ public class RepositoriesActionTest
         MetadataRepository metadataRepository = (MetadataRepository) control.getMock();
         control.expectAndReturn( metadataRepository.getMetadataFacets( "internal", RepositoryStatistics.FACET_ID ),
                                  Arrays.asList( "20091125.123456.678" ) );
-        control.expectAndReturn( metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID,
-                                                                      "20091125.123456.678" ),
-                                 new RepositoryStatistics() );
+        control.expectAndReturn(
+            metadataRepository.getMetadataFacet( "internal", RepositoryStatistics.FACET_ID, "20091125.123456.678" ),
+            new RepositoryStatistics() );
         control.expectAndReturn( metadataRepository.getMetadataFacets( "snapshots", RepositoryStatistics.FACET_ID ),
                                  Arrays.asList( "20091112.012345.012" ) );
-        control.expectAndReturn( metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID,
-                                                                      "20091112.012345.012" ),
-                                 new RepositoryStatistics() );
+        control.expectAndReturn(
+            metadataRepository.getMetadataFacet( "snapshots", RepositoryStatistics.FACET_ID, "20091112.012345.012" ),
+            new RepositoryStatistics() );
         control.replay();
 
         RepositorySession session = mock( RepositorySession.class );
         when( session.getRepository() ).thenReturn( metadataRepository );
-        //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
-        TestRepositorySessionFactory factory = new TestRepositorySessionFactory();
+        TestRepositorySessionFactory factory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
         factory.setRepositorySession( session );
 
         ServletRunner sr = new ServletRunner();