* 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;
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
{
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()
protected void setObservableRepos( List<String> repoIds )
{
//(UserRepositoriesStub) lookup( UserRepositories.class );
+ UserRepositoriesStub repos = applicationContext.getBean( "userRepositories#test", UserRepositoriesStub.class );
repos.setObservableRepositoryIds( repoIds );
}
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;
}
public static String getBasedir()
{
- String basedir = System.getProperty( "basedir" );
+ String basedir = System.getProperty( "basedir" );
if ( basedir == null )
{
basedir = new File( "" ).getAbsolutePath();
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;
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()
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 );
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 );
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