mirror of https://github.com/apache/archiva.git
[MRM-1511] api to configure LegacyArtifactPath : use it in webapp
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1166883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1bb10ee01e
commit
146c63dd72
|
@ -19,17 +19,14 @@ package org.apache.maven.archiva.web.action.admin.legacy;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
|
||||||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
|
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
|
||||||
import org.apache.maven.archiva.model.ArtifactReference;
|
|
||||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
|
||||||
import org.codehaus.plexus.registry.RegistryException;
|
|
||||||
|
|
||||||
import com.opensymphony.xwork2.Preparable;
|
import com.opensymphony.xwork2.Preparable;
|
||||||
import com.opensymphony.xwork2.Validateable;
|
import com.opensymphony.xwork2.Validateable;
|
||||||
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
|
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
||||||
|
import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.maven.archiva.model.ArtifactReference;
|
||||||
|
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -50,7 +47,7 @@ public class AddLegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ArchivaConfiguration archivaConfiguration;
|
private ArchivaAdministration archivaAdministration;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named( value = "managedRepositoryContent#legacy" )
|
@Named( value = "managedRepositoryContent#legacy" )
|
||||||
|
@ -82,8 +79,8 @@ public class AddLegacyArtifactPathAction
|
||||||
|
|
||||||
public String commit()
|
public String commit()
|
||||||
{
|
{
|
||||||
this.legacyArtifactPath.setArtifact( this.groupId + ":" + this.artifactId + ":" + this.version + ":" +
|
this.legacyArtifactPath.setArtifact(
|
||||||
this.classifier + ":" + this.type );
|
this.groupId + ":" + this.artifactId + ":" + this.version + ":" + this.classifier + ":" + this.type );
|
||||||
|
|
||||||
// Check the proposed Artifact macthes the path
|
// Check the proposed Artifact macthes the path
|
||||||
ArtifactReference artifact = new ArtifactReference();
|
ArtifactReference artifact = new ArtifactReference();
|
||||||
|
@ -101,9 +98,17 @@ public class AddLegacyArtifactPathAction
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
try
|
||||||
configuration.addLegacyArtifactPath( legacyArtifactPath );
|
{
|
||||||
return saveConfiguration( configuration );
|
getArchivaAdministration().addLegacyArtifactPath( legacyArtifactPath );
|
||||||
|
}
|
||||||
|
catch ( RepositoryAdminException e )
|
||||||
|
{
|
||||||
|
log.error( e.getMessage(), e );
|
||||||
|
addActionError( "Error occured " + e.getMessage() );
|
||||||
|
return INPUT;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyArtifactPath getLegacyArtifactPath()
|
public LegacyArtifactPath getLegacyArtifactPath()
|
||||||
|
@ -122,27 +127,6 @@ public class AddLegacyArtifactPathAction
|
||||||
trimAllRequestParameterValues();
|
trimAllRequestParameterValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String saveConfiguration( Configuration configuration )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
archivaConfiguration.save( configuration );
|
|
||||||
addActionMessage( "Successfully saved configuration" );
|
|
||||||
}
|
|
||||||
catch ( IndeterminateConfigurationException e )
|
|
||||||
{
|
|
||||||
addActionError( e.getMessage() );
|
|
||||||
return INPUT;
|
|
||||||
}
|
|
||||||
catch ( RegistryException e )
|
|
||||||
{
|
|
||||||
addActionError( "Configuration Registry Exception: " + e.getMessage() );
|
|
||||||
return INPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void trimAllRequestParameterValues()
|
private void trimAllRequestParameterValues()
|
||||||
{
|
{
|
||||||
if ( StringUtils.isNotEmpty( legacyArtifactPath.getPath() ) )
|
if ( StringUtils.isNotEmpty( legacyArtifactPath.getPath() ) )
|
||||||
|
@ -225,4 +209,14 @@ public class AddLegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArchivaAdministration getArchivaAdministration()
|
||||||
|
{
|
||||||
|
return archivaAdministration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
|
||||||
|
{
|
||||||
|
this.archivaAdministration = archivaAdministration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,13 @@ package org.apache.maven.archiva.web.action.admin.legacy;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
||||||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
|
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
|
||||||
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
||||||
import org.codehaus.plexus.registry.RegistryException;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a LegacyArtifactPath to archiva configuration
|
* Delete a LegacyArtifactPath to archiva configuration
|
||||||
|
@ -43,44 +39,22 @@ public class DeleteLegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ArchivaConfiguration archivaConfiguration;
|
private ArchivaAdministration archivaAdministration;
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
public String delete()
|
public String delete()
|
||||||
{
|
{
|
||||||
log.info( "remove [" + path + "] from legacy artifact path resolution" );
|
log.info( "remove [" + path + "] from legacy artifact path resolution" );
|
||||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
|
||||||
for ( Iterator<LegacyArtifactPath> iterator = configuration.getLegacyArtifactPaths().iterator();
|
|
||||||
iterator.hasNext(); )
|
|
||||||
{
|
|
||||||
LegacyArtifactPath legacyArtifactPath = (LegacyArtifactPath) iterator.next();
|
|
||||||
if ( legacyArtifactPath.match( path ) )
|
|
||||||
{
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return saveConfiguration( configuration );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String saveConfiguration( Configuration configuration )
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
archivaConfiguration.save( configuration );
|
getArchivaAdministration().deleteLegacyArtifactPath( path );
|
||||||
addActionMessage( "Successfully saved configuration" );
|
|
||||||
}
|
}
|
||||||
catch ( IndeterminateConfigurationException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
addActionError( e.getMessage() );
|
log.error( e.getMessage(), e );
|
||||||
return INPUT;
|
addActionError( "Exception during delete " + e.getMessage() );
|
||||||
}
|
}
|
||||||
catch ( RegistryException e )
|
|
||||||
{
|
|
||||||
addActionError( "Configuration Registry Exception: " + e.getMessage() );
|
|
||||||
return INPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,4 +67,14 @@ public class DeleteLegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArchivaAdministration getArchivaAdministration()
|
||||||
|
{
|
||||||
|
return archivaAdministration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
|
||||||
|
{
|
||||||
|
this.archivaAdministration = archivaAdministration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ package org.apache.maven.archiva.web.action.admin.legacy;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.opensymphony.xwork2.Preparable;
|
import com.opensymphony.xwork2.Preparable;
|
||||||
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
|
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
||||||
|
import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
|
||||||
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
|
||||||
import org.apache.archiva.web.util.ContextUtils;
|
import org.apache.archiva.web.util.ContextUtils;
|
||||||
|
import org.apache.maven.archiva.web.action.AbstractActionSupport;
|
||||||
import org.apache.struts2.interceptor.ServletRequestAware;
|
import org.apache.struts2.interceptor.ServletRequestAware;
|
||||||
import org.codehaus.plexus.redback.rbac.Resource;
|
import org.codehaus.plexus.redback.rbac.Resource;
|
||||||
import org.codehaus.redback.integration.interceptor.SecureAction;
|
import org.codehaus.redback.integration.interceptor.SecureAction;
|
||||||
|
@ -52,7 +52,7 @@ public class LegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ArchivaConfiguration archivaConfiguration;
|
private ArchivaAdministration archivaAdministration;
|
||||||
|
|
||||||
private List<LegacyArtifactPath> legacyArtifactPaths;
|
private List<LegacyArtifactPath> legacyArtifactPaths;
|
||||||
|
|
||||||
|
@ -79,10 +79,9 @@ public class LegacyArtifactPathAction
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare()
|
public void prepare()
|
||||||
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
Configuration config = archivaConfiguration.getConfiguration();
|
legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( getArchivaAdministration().getLegacyArtifactPaths() );
|
||||||
|
|
||||||
legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( config.getLegacyArtifactPaths() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LegacyArtifactPath> getLegacyArtifactPaths()
|
public List<LegacyArtifactPath> getLegacyArtifactPaths()
|
||||||
|
@ -94,4 +93,14 @@ public class LegacyArtifactPathAction
|
||||||
{
|
{
|
||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArchivaAdministration getArchivaAdministration()
|
||||||
|
{
|
||||||
|
return archivaAdministration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
|
||||||
|
{
|
||||||
|
this.archivaAdministration = archivaAdministration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,18 @@ package org.apache.maven.archiva.web.action.admin.legacy;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.opensymphony.xwork2.validator.ActionValidatorManager;
|
import com.opensymphony.xwork2.validator.ActionValidatorManager;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.archiva.admin.repository.admin.LegacyArtifactPath;
|
||||||
|
import org.apache.archiva.web.validator.utils.ValidatorUtil;
|
||||||
|
import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
public class AddLegacyArtifactPathActionTest
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
extends TestCase
|
||||||
import org.apache.maven.archiva.web.action.admin.repositories.DefaultActionValidatorManagerFactory;
|
|
||||||
import org.apache.archiva.web.validator.utils.ValidatorUtil;
|
|
||||||
|
|
||||||
public class AddLegacyArtifactPathActionTest extends TestCase
|
|
||||||
{
|
{
|
||||||
private static final String EMPTY_STRING = "";
|
private static final String EMPTY_STRING = "";
|
||||||
|
|
||||||
|
@ -66,7 +67,8 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
private ActionValidatorManager actionValidatorManager;
|
private ActionValidatorManager actionValidatorManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
addLegacyArtifactPathAction = new AddLegacyArtifactPathAction();
|
addLegacyArtifactPathAction = new AddLegacyArtifactPathAction();
|
||||||
|
|
||||||
|
@ -75,11 +77,13 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
actionValidatorManager = factory.createDefaultActionValidatorManager();
|
actionValidatorManager = factory.createDefaultActionValidatorManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStruts2ValidationFrameworkWithNullInputs() throws Exception
|
public void testStruts2ValidationFrameworkWithNullInputs()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// prep
|
// prep
|
||||||
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( null );
|
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( null );
|
||||||
populateAddLegacyArtifactPathActionFields(addLegacyArtifactPathAction, legacyArtifactPath, null, null, null, null, null);
|
populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, null, null, null,
|
||||||
|
null, null );
|
||||||
|
|
||||||
// test
|
// test
|
||||||
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
||||||
|
@ -116,11 +120,13 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStruts2ValidationFrameworkWithBlankInputs() throws Exception
|
public void testStruts2ValidationFrameworkWithBlankInputs()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// prep
|
// prep
|
||||||
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( EMPTY_STRING );
|
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( EMPTY_STRING );
|
||||||
populateAddLegacyArtifactPathActionFields(addLegacyArtifactPathAction, legacyArtifactPath, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING);
|
populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath, EMPTY_STRING,
|
||||||
|
EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
|
||||||
|
|
||||||
// test
|
// test
|
||||||
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
||||||
|
@ -157,11 +163,15 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStruts2ValidationFrameworkWithInvalidInputs() throws Exception
|
public void testStruts2ValidationFrameworkWithInvalidInputs()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// prep
|
// prep
|
||||||
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT );
|
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_INVALID_INPUT );
|
||||||
populateAddLegacyArtifactPathActionFields(addLegacyArtifactPathAction, legacyArtifactPath, GROUP_ID_INVALID_INPUT, ARTIFACT_ID_INVALID_INPUT, VERSION_INVALID_INPUT, CLASSIFIER_INVALID_INPUT, TYPE_INVALID_INPUT);
|
populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
|
||||||
|
GROUP_ID_INVALID_INPUT, ARTIFACT_ID_INVALID_INPUT,
|
||||||
|
VERSION_INVALID_INPUT, CLASSIFIER_INVALID_INPUT,
|
||||||
|
TYPE_INVALID_INPUT );
|
||||||
|
|
||||||
// test
|
// test
|
||||||
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
||||||
|
@ -176,37 +186,46 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
|
|
||||||
// populate
|
// populate
|
||||||
List<String> expectedErrorMessages = new ArrayList<String>();
|
List<String> expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Legacy path must only contain alphanumeric characters, forward-slashes(/), back-slashes(\\), underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
|
expectedFieldErrors.put( "legacyArtifactPath.path", expectedErrorMessages );
|
||||||
|
|
||||||
expectedErrorMessages = new ArrayList<String>();
|
expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "groupId", expectedErrorMessages );
|
expectedFieldErrors.put( "groupId", expectedErrorMessages );
|
||||||
|
|
||||||
expectedErrorMessages = new ArrayList<String>();
|
expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "artifactId", expectedErrorMessages );
|
expectedFieldErrors.put( "artifactId", expectedErrorMessages );
|
||||||
|
|
||||||
expectedErrorMessages = new ArrayList<String>();
|
expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Version must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "version", expectedErrorMessages );
|
expectedFieldErrors.put( "version", expectedErrorMessages );
|
||||||
|
|
||||||
expectedErrorMessages = new ArrayList<String>();
|
expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Classifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "classifier", expectedErrorMessages );
|
expectedFieldErrors.put( "classifier", expectedErrorMessages );
|
||||||
|
|
||||||
expectedErrorMessages = new ArrayList<String>();
|
expectedErrorMessages = new ArrayList<String>();
|
||||||
expectedErrorMessages.add("Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
expectedErrorMessages.add(
|
||||||
|
"Type must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||||
expectedFieldErrors.put( "type", expectedErrorMessages );
|
expectedFieldErrors.put( "type", expectedErrorMessages );
|
||||||
|
|
||||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStruts2ValidationFrameworkWithValidInputs() throws Exception
|
public void testStruts2ValidationFrameworkWithValidInputs()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// prep
|
// prep
|
||||||
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT );
|
LegacyArtifactPath legacyArtifactPath = createLegacyArtifactPath( LEGACY_ARTIFACT_PATH_PATH_VALID_INPUT );
|
||||||
populateAddLegacyArtifactPathActionFields(addLegacyArtifactPathAction, legacyArtifactPath, GROUP_ID_VALID_INPUT, ARTIFACT_ID_VALID_INPUT, VERSION_VALID_INPUT, CLASSIFIER_VALID_INPUT, TYPE_VALID_INPUT);
|
populateAddLegacyArtifactPathActionFields( addLegacyArtifactPathAction, legacyArtifactPath,
|
||||||
|
GROUP_ID_VALID_INPUT, ARTIFACT_ID_VALID_INPUT, VERSION_VALID_INPUT,
|
||||||
|
CLASSIFIER_VALID_INPUT, TYPE_VALID_INPUT );
|
||||||
|
|
||||||
// test
|
// test
|
||||||
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
actionValidatorManager.validate( addLegacyArtifactPathAction, EMPTY_STRING );
|
||||||
|
@ -222,7 +241,10 @@ public class AddLegacyArtifactPathActionTest extends TestCase
|
||||||
return legacyArtifactPath;
|
return legacyArtifactPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateAddLegacyArtifactPathActionFields(AddLegacyArtifactPathAction addLegacyArtifactPathAction, LegacyArtifactPath legacyArtifactPath, String groupId, String artifactId, String version, String classifier, String type)
|
private void populateAddLegacyArtifactPathActionFields( AddLegacyArtifactPathAction addLegacyArtifactPathAction,
|
||||||
|
LegacyArtifactPath legacyArtifactPath, String groupId,
|
||||||
|
String artifactId, String version, String classifier,
|
||||||
|
String type )
|
||||||
{
|
{
|
||||||
addLegacyArtifactPathAction.setLegacyArtifactPath( legacyArtifactPath );
|
addLegacyArtifactPathAction.setLegacyArtifactPath( legacyArtifactPath );
|
||||||
addLegacyArtifactPathAction.setGroupId( groupId );
|
addLegacyArtifactPathAction.setGroupId( groupId );
|
||||||
|
|
Loading…
Reference in New Issue