]> source.dussan.org Git - archiva.git/commitdiff
fix junit BrowseActionTest
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Jun 2011 17:24:30 +0000 (17:24 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Jun 2011 17:24:30 +0000 (17:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1135711 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

index 8c6934ee65caeebc0cd9b398181d0668bd014ce5..c5c2da070e71cfaa625a71695dcb0a854da7e671 100644 (file)
@@ -19,11 +19,6 @@ 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;
-
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationManager;
@@ -41,10 +36,14 @@ import org.apache.archiva.metadata.model.Scm;
 import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectParent;
-import org.apache.maven.archiva.security.UserRepositories;
 import org.apache.maven.archiva.security.UserRepositoriesStub;
 import org.apache.struts2.StrutsSpringTestCase;
 
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 public abstract class AbstractActionTestCase
     extends StrutsSpringTestCase
 {
@@ -95,12 +94,10 @@ public abstract class AbstractActionTestCase
     protected static final String TEST_SCM_DEV_CONNECTION = "scmDevConnection";
 
     protected static final String TEST_SCM_URL = "scmUrl";
-    
+
     protected static final String TEST_GENERIC_METADATA_PROPERTY_NAME = "rating";
-    
-    protected static final String TEST_GENERIC_METADATA_PROPERTY_VALUE = "5 stars";
 
-    UserRepositoriesStub repos = new UserRepositoriesStub();
+    protected static final String TEST_GENERIC_METADATA_PROPERTY_VALUE = "5 stars";
 
     @Override
     protected String[] getContextLocations()
@@ -111,6 +108,7 @@ public abstract class AbstractActionTestCase
     protected void setObservableRepos( List<String> repoIds )
     {
         //(UserRepositoriesStub) lookup( UserRepositories.class );
+        UserRepositoriesStub repos = applicationContext.getBean( "userRepositories#test", UserRepositoriesStub.class );
         repos.setObservableRepositoryIds( repoIds );
     }
 
@@ -199,13 +197,13 @@ public abstract class AbstractActionTestCase
         parent.setVersion( TEST_PARENT_VERSION );
         mavenProjectFacet.setParent( parent );
         model.addFacet( mavenProjectFacet );
-        
+
         GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
-        Map<String, String> props = new HashMap<String,String>();
-        props.put( TEST_GENERIC_METADATA_PROPERTY_NAME, TEST_GENERIC_METADATA_PROPERTY_VALUE );        
+        Map<String, String> props = new HashMap<String, String>();
+        props.put( TEST_GENERIC_METADATA_PROPERTY_NAME, TEST_GENERIC_METADATA_PROPERTY_VALUE );
         genericMetadataFacet.setAdditionalProperties( props );
         model.addFacet( genericMetadataFacet );
-        
+
         return model;
     }
 
@@ -227,7 +225,7 @@ public abstract class AbstractActionTestCase
 
     public static String getBasedir()
     {
-       String basedir = System.getProperty( "basedir" );
+        String basedir = System.getProperty( "basedir" );
         if ( basedir == null )
         {
             basedir = new File( "" ).getAbsolutePath();
index 3008a68f16af47970ea2747579e816c707927207..394d04e773481359dd3e0d3bf36422e1b14c9463 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.maven.archiva.web.action;
 import com.opensymphony.xwork2.Action;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;
 import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
 import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
 
@@ -40,14 +39,15 @@ public class BrowseActionTest
 
     private BrowseAction action;
 
-    private static final List<String> GROUPS = Arrays.asList( "org.apache.archiva", "commons-lang", "org.apache.maven",
-                                                              "com.sun", "com.oracle", "repeat.repeat" );
+    private static final List<String> GROUPS =
+        Arrays.asList( "org.apache.archiva", "commons-lang", "org.apache.maven", "com.sun", "com.oracle",
+                       "repeat.repeat" );
 
     private static final String OTHER_TEST_REPO = "other-repo";
 
     public void testInstantiation()
     {
-        assertFalse( action == (BrowseAction) getActionProxy( "browse.action" ).getAction() );
+        assertFalse( action == (BrowseAction) getActionProxy( "/browse.action" ).getAction() );
     }
 
     public void testBrowse()
@@ -286,14 +286,14 @@ public class BrowseActionTest
         String selectedArtifactId = "apache";
 
         List<String> versions = Arrays.asList( "1", "2", "3", "4" );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "1" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "2" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "3" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "4" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
 
         action.setGroupId( selectedGroupId );
         action.setArtifactId( selectedArtifactId );
@@ -320,18 +320,18 @@ public class BrowseActionTest
         String selectedArtifactId = "apache";
 
         List<String> versions = Arrays.asList( "1", "2", "3", "4-SNAPSHOT", "4", "5-SNAPSHOT" );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "1" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "2" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "3" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "4-SNAPSHOT" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "4" ) );
-        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId, createProjectModel(
-            selectedGroupId, selectedArtifactId, "5-SNAPSHOT" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "1" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "2" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "3" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4-SNAPSHOT" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "4" ) );
+        metadataResolver.setProjectVersion( TEST_REPO, selectedGroupId, selectedArtifactId,
+                                            createProjectModel( selectedGroupId, selectedArtifactId, "5-SNAPSHOT" ) );
 
         action.setGroupId( selectedGroupId );
         action.setArtifactId( selectedArtifactId );
@@ -395,8 +395,8 @@ public class BrowseActionTest
         metadataResolver = new TestMetadataResolver();
         RepositorySession repositorySession = mock( RepositorySession.class );
         when( repositorySession.getResolver() ).thenReturn( metadataResolver );
-        TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class  );
-        //TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
+        TestRepositorySessionFactory factory =
+            applicationContext.getBean( "repositorySessionFactory#test", TestRepositorySessionFactory.class );
         factory.setRepositorySession( repositorySession );
     }
 }
\ No newline at end of file