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:
Olivier Lamy 2013-09-17 10:21:20 +00:00
parent 42bba84b44
commit 5e6e9f630f
1 changed files with 80 additions and 59 deletions

View File

@ -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,11 +263,13 @@ 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);
ManagedRepositoryConfiguration managedRepositoryConfiguration =
createManagedRepositoryConfiguration( null, null, null, null );
action.setRepository( managedRepositoryConfiguration );
// test
@ -296,11 +299,13 @@ public class EditManagedRepositoryActionTest
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);
ManagedRepositoryConfiguration managedRepositoryConfiguration =
createManagedRepositoryConfiguration( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING );
action.setRepository( managedRepositoryConfiguration );
// test
@ -330,10 +335,15 @@ public class EditManagedRepositoryActionTest
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);
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
@ -349,19 +359,23 @@ public class EditManagedRepositoryActionTest
// populate
List<String> expectedErrorMessages = new ArrayList<String>();
expectedErrorMessages.add("Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-).");
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(-).");
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(-).");
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(-).");
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>();
@ -375,10 +389,15 @@ public class EditManagedRepositoryActionTest
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);
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
@ -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() );