mirror of https://github.com/apache/archiva.git
more details on the error
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1523972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
42bba84b44
commit
5e6e9f630f
|
@ -47,6 +47,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.archiva.web.validator.utils.ValidatorUtil;
|
||||
|
||||
/**
|
||||
|
@ -262,18 +263,20 @@ public class EditManagedRepositoryActionTest
|
|||
auditLogsDaoControl.verify();
|
||||
}
|
||||
|
||||
public void testStruts2ValidationFrameworkWithNullInputs() throws Exception
|
||||
public void testStruts2ValidationFrameworkWithNullInputs()
|
||||
throws Exception
|
||||
{
|
||||
// prep
|
||||
// 0 is the default value for primitive int; null for objects
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepositoryConfiguration(null, null, null, null);
|
||||
action.setRepository(managedRepositoryConfiguration);
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
createManagedRepositoryConfiguration( null, null, null, null );
|
||||
action.setRepository( managedRepositoryConfiguration );
|
||||
|
||||
// test
|
||||
actionValidatorManager.validate(action, EMPTY_STRING);
|
||||
actionValidatorManager.validate( action, EMPTY_STRING );
|
||||
|
||||
// verify
|
||||
assertTrue(action.hasFieldErrors());
|
||||
assertTrue( action.hasFieldErrors() );
|
||||
|
||||
Map<String, List<String>> fieldErrors = action.getFieldErrors();
|
||||
|
||||
|
@ -282,32 +285,34 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
// populate
|
||||
List<String> expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a repository identifier.");
|
||||
expectedFieldErrors.put("repository.id", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a repository identifier." );
|
||||
expectedFieldErrors.put( "repository.id", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a directory.");
|
||||
expectedFieldErrors.put("repository.location", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a directory." );
|
||||
expectedFieldErrors.put( "repository.location", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a repository name.");
|
||||
expectedFieldErrors.put("repository.name", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a repository name." );
|
||||
expectedFieldErrors.put( "repository.name", expectedErrorMessages );
|
||||
|
||||
ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
|
||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||
}
|
||||
|
||||
public void testStruts2ValidationFrameworkWithBlankInputs() throws Exception
|
||||
public void testStruts2ValidationFrameworkWithBlankInputs()
|
||||
throws Exception
|
||||
{
|
||||
// prep
|
||||
// 0 is the default value for primitive int
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepositoryConfiguration(EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING);
|
||||
action.setRepository(managedRepositoryConfiguration);
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
createManagedRepositoryConfiguration( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
|
||||
action.setRepository( managedRepositoryConfiguration );
|
||||
|
||||
// test
|
||||
actionValidatorManager.validate(action, EMPTY_STRING);
|
||||
actionValidatorManager.validate( action, EMPTY_STRING );
|
||||
|
||||
// verify
|
||||
assertTrue(action.hasFieldErrors());
|
||||
assertTrue( action.hasFieldErrors() );
|
||||
|
||||
Map<String, List<String>> fieldErrors = action.getFieldErrors();
|
||||
|
||||
|
@ -316,31 +321,36 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
// populate
|
||||
List<String> expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a repository identifier.");
|
||||
expectedFieldErrors.put("repository.id", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a repository identifier." );
|
||||
expectedFieldErrors.put( "repository.id", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a directory.");
|
||||
expectedFieldErrors.put("repository.location", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a directory." );
|
||||
expectedFieldErrors.put( "repository.location", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("You must enter a repository name.");
|
||||
expectedFieldErrors.put("repository.name", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "You must enter a repository name." );
|
||||
expectedFieldErrors.put( "repository.name", expectedErrorMessages );
|
||||
|
||||
ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
|
||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||
}
|
||||
|
||||
public void testStruts2ValidationFrameworkWithInvalidInputs() throws Exception
|
||||
public void testStruts2ValidationFrameworkWithInvalidInputs()
|
||||
throws Exception
|
||||
{
|
||||
// prep
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepositoryConfiguration(REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT, REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT, REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT);
|
||||
action.setRepository(managedRepositoryConfiguration);
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
createManagedRepositoryConfiguration( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
|
||||
REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
|
||||
REPOSITORY_DAYS_OLDER_INVALID_INPUT,
|
||||
REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
|
||||
action.setRepository( managedRepositoryConfiguration );
|
||||
|
||||
// test
|
||||
actionValidatorManager.validate(action, EMPTY_STRING);
|
||||
actionValidatorManager.validate( action, EMPTY_STRING );
|
||||
|
||||
// verify
|
||||
assertTrue(action.hasFieldErrors());
|
||||
assertTrue( action.hasFieldErrors() );
|
||||
|
||||
Map<String, List<String>> fieldErrors = action.getFieldErrors();
|
||||
|
||||
|
@ -349,43 +359,52 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
// populate
|
||||
List<String> expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
|
||||
expectedFieldErrors.put("repository.id", expectedErrorMessages);
|
||||
expectedErrorMessages.add(
|
||||
"Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
||||
expectedFieldErrors.put( "repository.id", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).");
|
||||
expectedFieldErrors.put("repository.location", expectedErrorMessages);
|
||||
expectedErrorMessages.add(
|
||||
"Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
|
||||
expectedFieldErrors.put( "repository.location", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-).");
|
||||
expectedFieldErrors.put("repository.name", expectedErrorMessages);
|
||||
expectedErrorMessages.add(
|
||||
"Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
|
||||
expectedFieldErrors.put( "repository.name", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).");
|
||||
expectedFieldErrors.put("repository.indexDir", expectedErrorMessages);
|
||||
expectedErrorMessages.add(
|
||||
"Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
|
||||
expectedFieldErrors.put( "repository.indexDir", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Repository Purge By Retention Count needs to be between 1 and 100.");
|
||||
expectedFieldErrors.put("repository.retentionCount", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
|
||||
expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
|
||||
|
||||
expectedErrorMessages = new ArrayList<String>();
|
||||
expectedErrorMessages.add("Repository Purge By Days Older Than needs to be larger than 0.");
|
||||
expectedFieldErrors.put("repository.daysOlder", expectedErrorMessages);
|
||||
expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
|
||||
expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
|
||||
|
||||
ValidatorUtil.assertFieldErrors(expectedFieldErrors, fieldErrors);
|
||||
ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
|
||||
}
|
||||
|
||||
public void testStruts2ValidationFrameworkWithValidInputs() throws Exception
|
||||
public void testStruts2ValidationFrameworkWithValidInputs()
|
||||
throws Exception
|
||||
{
|
||||
// prep
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepositoryConfiguration(REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT, REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT, REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT);
|
||||
action.setRepository(managedRepositoryConfiguration);
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
createManagedRepositoryConfiguration( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
|
||||
REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
|
||||
REPOSITORY_DAYS_OLDER_VALID_INPUT,
|
||||
REPOSITORY_RETENTION_COUNT_VALID_INPUT );
|
||||
action.setRepository( managedRepositoryConfiguration );
|
||||
|
||||
// test
|
||||
actionValidatorManager.validate(action, EMPTY_STRING);
|
||||
actionValidatorManager.validate( action, EMPTY_STRING );
|
||||
|
||||
// verify
|
||||
assertFalse(action.hasFieldErrors());
|
||||
assertFalse( action.hasFieldErrors() );
|
||||
}
|
||||
|
||||
private void assertRepositoryEquals( ManagedRepositoryConfiguration expectedRepository,
|
||||
|
@ -395,7 +414,9 @@ public class EditManagedRepositoryActionTest
|
|||
assertEquals( expectedRepository.getId(), actualRepository.getId() );
|
||||
assertEquals( expectedRepository.getIndexDir(), actualRepository.getIndexDir() );
|
||||
assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
|
||||
assertEquals( expectedRepository.getLocation(), actualRepository.getLocation() );
|
||||
assertEquals(
|
||||
"expected: '" + expectedRepository.getLocation() + "' found '" + actualRepository.getLocation() + "'",
|
||||
expectedRepository.getLocation(), actualRepository.getLocation() );
|
||||
assertEquals( expectedRepository.getName(), actualRepository.getName() );
|
||||
assertEquals( expectedRepository.getRefreshCronExpression(), actualRepository.getRefreshCronExpression() );
|
||||
assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
|
||||
|
|
Loading…
Reference in New Issue