o Extended model validation to support distinction between warnings and errors

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@790131 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-07-01 11:56:44 +00:00
parent b91f837e12
commit 22516c9fa7
7 changed files with 220 additions and 136 deletions

View File

@ -44,7 +44,7 @@ public class DefaultModelValidator
ModelBuildingRequest request = new DefaultModelBuildingRequest().setLenientValidation( false );
for ( String message : modelValidator.validateEffectiveModel( model, request ).getMessages() )
for ( String message : modelValidator.validateEffectiveModel( model, request ).getErrors() )
{
result.addMessage( message );
}

View File

@ -19,12 +19,77 @@ package org.apache.maven.project.validation;
* under the License.
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
*/
public class ModelValidationResult
extends org.apache.maven.model.validation.ModelValidationResult
{
/** */
private final static String NEWLINE = System.getProperty( "line.separator" );
/** */
private List<String> messages;
public ModelValidationResult()
{
messages = new ArrayList<String>();
}
public int getMessageCount()
{
return messages.size();
}
public String getMessage( int i )
{
return messages.get( i );
}
public List<String> getMessages()
{
return Collections.unmodifiableList( messages );
}
public void addMessage( String message )
{
messages.add( message );
}
public String toString()
{
return render( "" );
}
public String render( String indentation )
{
if ( messages.size() == 0 )
{
return indentation + "There were no validation errors.";
}
StringBuffer message = new StringBuffer();
// if ( messages.size() == 1 )
// {
// message.append( "There was 1 validation error: " );
// }
// else
// {
// message.append( "There was " + messages.size() + " validation errors: " + NEWLINE );
// }
//
for ( int i = 0; i < messages.size(); i++ )
{
message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE );
}
return message.toString();
}
}

View File

@ -138,7 +138,15 @@ public abstract class AbstractMavenProjectTestCase
if ( e instanceof InvalidProjectModelException )
{
ModelValidationResult validationResult = ( (InvalidProjectModelException) e ).getValidationResult();
String message = "In: " + pom + "(" + ( (ProjectBuildingException) e ).getProjectId() + ")\n\n" + validationResult.render( " " );
String message = "In: " + pom + "(" + ( (ProjectBuildingException) e ).getProjectId() + ")\n\n";
for ( String error : validationResult.getErrors() )
{
message += " [ERROR] " + error + "\n";
}
for ( String warning : validationResult.getWarnings() )
{
message += " [WARNING] " + warning + "\n";
}
System.out.println( message );
fail( message );
}

View File

@ -278,15 +278,21 @@ public class DefaultModelBuilder
private void addProblems( Model model, ModelValidationResult result, List<ModelProblem> problems )
{
if ( result.getMessageCount() > 0 )
if ( !result.getWarnings().isEmpty() || !result.getErrors().isEmpty() )
{
String source = toSourceHint( model );
for ( int i = 0; i < result.getMessageCount(); i++ )
for ( String message : result.getWarnings() )
{
problems.add( new ModelProblem( "Invalid POM " + source + ": " + result.getMessage( i ),
problems.add( new ModelProblem( "Invalid POM " + source + ": " + message,
ModelProblem.Severity.WARNING, source ) );
}
for ( String message : result.getErrors() )
{
problems.add( new ModelProblem( "Invalid POM " + source + ": " + message, ModelProblem.Severity.ERROR,
source ) );
}
}
}

View File

@ -57,16 +57,16 @@ public class DefaultModelValidator
Parent parent = model.getParent();
if ( parent != null )
{
validateStringNotEmpty( "parent.groupId", result, parent.getGroupId() );
validateStringNotEmpty( "parent.groupId", result, false, parent.getGroupId() );
validateStringNotEmpty( "parent.artifactId", result, parent.getArtifactId() );
validateStringNotEmpty( "parent.artifactId", result, false, parent.getArtifactId() );
validateStringNotEmpty( "parent.version", result, parent.getVersion() );
validateStringNotEmpty( "parent.version", result, false, parent.getVersion() );
if ( parent.getGroupId().equals( model.getGroupId() )
&& parent.getArtifactId().equals( model.getArtifactId() ) )
{
result.addMessage( "The parent element cannot have the same ID as the project." );
addViolation( result, false, "The parent element cannot have the same ID as the project." );
}
}
@ -110,17 +110,17 @@ public class DefaultModelValidator
{
ModelValidationResult result = new ModelValidationResult();
validateStringNotEmpty( "modelVersion", result, model.getModelVersion() );
validateStringNotEmpty( "modelVersion", result, false, model.getModelVersion() );
validateId( "groupId", result, model.getGroupId() );
validateId( "artifactId", result, model.getArtifactId() );
validateStringNotEmpty( "packaging", result, model.getPackaging() );
validateStringNotEmpty( "packaging", result, false, model.getPackaging() );
if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) )
{
result.addMessage( "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " +
addViolation( result, false, "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " +
"require 'pom' as packaging." );
}
@ -130,11 +130,11 @@ public class DefaultModelValidator
if ( parent.getGroupId().equals( model.getGroupId() ) &&
parent.getArtifactId().equals( model.getArtifactId() ) )
{
result.addMessage( "The parent element cannot have the same ID as the project." );
addViolation( result, false, "The parent element cannot have the same ID as the project." );
}
}
validateStringNotEmpty( "version", result, model.getVersion() );
validateStringNotEmpty( "version", result, false, model.getVersion() );
for ( Dependency d : model.getDependencies() )
{
@ -142,9 +142,9 @@ public class DefaultModelValidator
validateId( "dependencies.dependency.groupId", result, d.getGroupId() );
validateStringNotEmpty( "dependencies.dependency.type", result, d.getType(), d.getManagementKey() );
validateStringNotEmpty( "dependencies.dependency.type", result, false, d.getType(), d.getManagementKey() );
validateStringNotEmpty( "dependencies.dependency.version", result, d.getVersion(),
validateStringNotEmpty( "dependencies.dependency.version", result, false, d.getVersion(),
d.getManagementKey() );
if ( "system".equals( d.getScope() ) )
@ -153,20 +153,20 @@ public class DefaultModelValidator
if ( StringUtils.isEmpty( systemPath ) )
{
result.addMessage( "For dependency " + d + ": system-scoped dependency must specify systemPath." );
addViolation( result, false, "For dependency " + d + ": system-scoped dependency must specify systemPath." );
}
else
{
if ( !new File( systemPath ).isAbsolute() )
{
result.addMessage( "For dependency " + d + ": system-scoped dependency must " +
addViolation( result, false, "For dependency " + d + ": system-scoped dependency must " +
"specify an absolute path systemPath." );
}
}
}
else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
{
result.addMessage(
addViolation( result, false,
"For dependency " + d + ": only dependency with system scope can specify systemPath." );
}
}
@ -188,21 +188,21 @@ public class DefaultModelValidator
if ( StringUtils.isEmpty( systemPath ) )
{
result.addMessage(
addViolation( result, false,
"For managed dependency " + d + ": system-scoped dependency must specify systemPath." );
}
else
{
if ( !new File( systemPath ).isAbsolute() )
{
result.addMessage( "For managed dependency " + d + ": system-scoped dependency must " +
addViolation( result, false, "For managed dependency " + d + ": system-scoped dependency must " +
"specify an absolute path systemPath." );
}
}
}
else if ( StringUtils.isNotEmpty( d.getSystemPath() ) )
{
result.addMessage(
addViolation( result, false,
"For managed dependency " + d + ": only dependency with system scope can specify systemPath." );
}
}
@ -215,11 +215,11 @@ public class DefaultModelValidator
{
for ( Plugin p : build.getPlugins() )
{
validateStringNotEmpty( "build.plugins.plugin.artifactId", result, p.getArtifactId() );
validateStringNotEmpty( "build.plugins.plugin.artifactId", result, false, p.getArtifactId() );
validateStringNotEmpty( "build.plugins.plugin.groupId", result, p.getGroupId() );
validateStringNotEmpty( "build.plugins.plugin.groupId", result, false, p.getGroupId() );
validateStringNotEmpty( "build.plugins.plugin.version", result, p.getVersion(), p.getKey() );
validateStringNotEmpty( "build.plugins.plugin.version", result, false, p.getVersion(), p.getKey() );
}
validateResources( result, build.getResources(), "build.resources.resource" );
@ -232,11 +232,11 @@ public class DefaultModelValidator
{
for ( ReportPlugin p : reporting.getPlugins() )
{
validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, p.getArtifactId() );
validateStringNotEmpty( "reporting.plugins.plugin.artifactId", result, false, p.getArtifactId() );
validateStringNotEmpty( "reporting.plugins.plugin.groupId", result, p.getGroupId() );
validateStringNotEmpty( "reporting.plugins.plugin.groupId", result,false, p.getGroupId() );
validateStringNotEmpty( "reporting.plugins.plugin.version", result, p.getVersion(), p.getKey() );
validateStringNotEmpty( "reporting.plugins.plugin.version", result, false, p.getVersion(), p.getKey() );
}
}
@ -248,7 +248,7 @@ public class DefaultModelValidator
private boolean validateId( String fieldName, ModelValidationResult result, String id )
{
if ( !validateStringNotEmpty( fieldName, result, id ) )
if ( !validateStringNotEmpty( fieldName, result, false, id ) )
{
return false;
}
@ -257,7 +257,7 @@ public class DefaultModelValidator
boolean match = id.matches( ID_REGEX );
if ( !match )
{
result.addMessage( "'" + fieldName + "' with value '" + id + "' does not match a valid id pattern." );
addViolation( result, false, "'" + fieldName + "' with value '" + id + "' does not match a valid id pattern." );
}
return match;
}
@ -275,7 +275,7 @@ public class DefaultModelValidator
if ( existing != null )
{
result.addMessage( "'" + prefix + ".(groupId:artifactId:type:classifier)' must be unique: " + key
addViolation( result, false, "'" + prefix + ".(groupId:artifactId:type:classifier)' must be unique: " + key
+ " -> " + existing.getVersion() + " vs " + dependency.getVersion() );
}
else
@ -291,9 +291,9 @@ public class DefaultModelValidator
for ( Repository repository : repositories )
{
validateStringNotEmpty( prefix + ".id", result, repository.getId() );
validateStringNotEmpty( prefix + ".id", result, false, repository.getId() );
validateStringNotEmpty( prefix + ".url", result, repository.getUrl() );
validateStringNotEmpty( prefix + ".url", result, false, repository.getUrl() );
String key = repository.getId();
@ -301,7 +301,7 @@ public class DefaultModelValidator
if ( existing != null )
{
result.addMessage( "'" + prefix + ".id' must be unique: " + repository.getId() + " -> "
addViolation( result, false, "'" + prefix + ".id' must be unique: " + repository.getId() + " -> "
+ existing.getUrl() + " vs " + repository.getUrl() );
}
else
@ -315,7 +315,7 @@ public class DefaultModelValidator
{
for ( Resource resource : resources )
{
validateStringNotEmpty( prefix + ".directory", result, resource.getDirectory() );
validateStringNotEmpty( prefix + ".directory", result, false, resource.getDirectory() );
}
}
@ -338,7 +338,7 @@ public class DefaultModelValidator
}
catch ( IllegalStateException collisionException )
{
result.addMessage( collisionException.getMessage() );
addViolation( result, false, collisionException.getMessage() );
}
}
}
@ -349,23 +349,23 @@ public class DefaultModelValidator
// Field validation
// ----------------------------------------------------------------------
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, String string )
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, boolean warning, String string )
{
return validateStringNotEmpty( fieldName, result, string, null );
return validateStringNotEmpty( fieldName, result, warning, string, null );
}
/**
* Asserts:
* <p/>
* <ul>
* <li><code>string.length != null</code>
* <li><code>string != null</code>
* <li><code>string.length > 0</code>
* </ul>
*/
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, String string,
String sourceHint )
private boolean validateStringNotEmpty( String fieldName, ModelValidationResult result, boolean warning,
String string, String sourceHint )
{
if ( !validateNotNull( fieldName, result, string, sourceHint ) )
if ( !validateNotNull( fieldName, result, warning, string, sourceHint ) )
{
return false;
}
@ -377,11 +377,11 @@ public class DefaultModelValidator
if ( sourceHint != null )
{
result.addMessage( "'" + fieldName + "' is missing for " + sourceHint );
addViolation( result, false, "'" + fieldName + "' is missing for " + sourceHint );
}
else
{
result.addMessage( "'" + fieldName + "' is missing." );
addViolation( result, false, "'" + fieldName + "' is missing." );
}
return false;
@ -391,7 +391,7 @@ public class DefaultModelValidator
* Asserts:
* <p/>
* <ul>
* <li><code>string.length != null</code>
* <li><code>string != null</code>
* <li><code>string.length > 0</code>
* </ul>
*/
@ -408,7 +408,7 @@ public class DefaultModelValidator
return true;
}
result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
addViolation( result, false, "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
return false;
}
@ -420,7 +420,7 @@ public class DefaultModelValidator
* <li><code>string != null</code>
* </ul>
*/
private boolean validateNotNull( String fieldName, ModelValidationResult result, Object object, String sourceHint )
private boolean validateNotNull( String fieldName, ModelValidationResult result, boolean warning, Object object, String sourceHint )
{
if ( object != null )
{
@ -429,11 +429,11 @@ public class DefaultModelValidator
if ( sourceHint != null )
{
result.addMessage( "'" + fieldName + "' is missing for " + sourceHint );
addViolation( result, warning, "'" + fieldName + "' is missing for " + sourceHint );
}
else
{
result.addMessage( "'" + fieldName + "' is missing." );
addViolation( result, warning, "'" + fieldName + "' is missing." );
}
return false;
@ -454,9 +454,21 @@ public class DefaultModelValidator
return true;
}
result.addMessage( "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
addViolation( result, false, "In " + subElementInstance + ":\n\n -> '" + fieldName + "' is missing." );
return false;
}
private void addViolation( ModelValidationResult result, boolean warning, String message )
{
if ( warning )
{
result.addWarning( message );
}
else
{
result.addError( message );
}
}
}

View File

@ -20,74 +20,67 @@ package org.apache.maven.model.validation;
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
* Collects the warnings and errors from the model validator.
*
* @author Benjamin Bentmann
*/
public class ModelValidationResult
{
/** */
private final static String NEWLINE = System.getProperty( "line.separator" );
/** */
private List<String> messages;
private List<String> warnings;
private List<String> errors;
/**
* Creates a new validation result.
*/
public ModelValidationResult()
{
messages = new ArrayList<String>();
warnings = new ArrayList<String>();
errors = new ArrayList<String>();
}
public int getMessageCount()
/**
* Gets the warnings from the validator.
*
* @return The warnings from the validator, can be empty but never {@code null}.
*/
public List<String> getWarnings()
{
return messages.size();
return warnings;
}
public String getMessage( int i )
/**
* Records the specified warning.
*
* @param message The detail message about the validation warning.
*/
public void addWarning( String message )
{
return messages.get( i );
warnings.add( message );
}
public List<String> getMessages()
/**
* Gets the errors from the validator.
*
* @return The errors from the validator, can be empty but never {@code null}.
*/
public List<String> getErrors()
{
return Collections.unmodifiableList( messages );
return errors;
}
public void addMessage( String message )
/**
* Records the specified error.
*
* @param message The detail message about the validation error.
*/
public void addError( String message )
{
messages.add( message );
errors.add( message );
}
public String toString()
{
return render( "" );
}
public String render( String indentation )
{
if ( messages.size() == 0 )
{
return indentation + "There were no validation errors.";
}
StringBuffer message = new StringBuffer();
// if ( messages.size() == 1 )
// {
// message.append( "There was 1 validation error: " );
// }
// else
// {
// message.append( "There was " + messages.size() + " validation errors: " + NEWLINE );
// }
//
for ( int i = 0; i < messages.size(); i++ )
{
message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE );
}
return message.toString();
}
}

View File

@ -90,9 +90,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-modelVersion-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'modelVersion' is missing.", result.getMessage( 0 ) );
assertEquals( "'modelVersion' is missing.", result.getErrors().get( 0 ) );
}
public void testMissingArtifactId()
@ -100,9 +100,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-artifactId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'artifactId' is missing.", result.getMessage( 0 ) );
assertEquals( "'artifactId' is missing.", result.getErrors().get( 0 ) );
}
public void testMissingGroupId()
@ -110,9 +110,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-groupId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'groupId' is missing.", result.getMessage( 0 ) );
assertEquals( "'groupId' is missing.", result.getErrors().get( 0 ) );
}
public void testInvalidIds()
@ -120,11 +120,11 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "invalid-ids-pom.xml" );
assertEquals( 2, result.getMessageCount() );
assertEquals( 2, result.getErrors().size() );
assertEquals( "'groupId' with value 'o/a/m' does not match a valid id pattern.", result.getMessage( 0 ) );
assertEquals( "'groupId' with value 'o/a/m' does not match a valid id pattern.", result.getErrors().get( 0 ) );
assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", result.getMessage( 1 ) );
assertEquals( "'artifactId' with value 'm$-do$' does not match a valid id pattern.", result.getErrors().get( 1 ) );
}
public void testMissingType()
@ -132,9 +132,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-type-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'packaging' is missing.", result.getMessage( 0 ) );
assertEquals( "'packaging' is missing.", result.getErrors().get( 0 ) );
}
public void testMissingVersion()
@ -142,9 +142,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-version-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'version' is missing.", result.getMessage( 0 ) );
assertEquals( "'version' is missing.", result.getErrors().get( 0 ) );
}
public void testInvalidAggregatorPackaging()
@ -152,9 +152,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "invalid-aggregator-packaging-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf( "Aggregator projects require 'pom' as packaging." ) > -1 );
assertTrue( result.getErrors().get( 0 ).indexOf( "Aggregator projects require 'pom' as packaging." ) > -1 );
}
public void testMissingDependencyArtifactId()
@ -162,9 +162,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-dependency-artifactId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.artifactId' is missing." ) > -1 );
assertTrue( result.getErrors().get( 0 ).indexOf( "'dependencies.dependency.artifactId' is missing." ) > -1 );
}
public void testMissingDependencyGroupId()
@ -172,9 +172,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-dependency-groupId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.groupId' is missing." ) > -1 );
assertTrue( result.getErrors().get( 0 ).indexOf( "'dependencies.dependency.groupId' is missing." ) > -1 );
}
public void testMissingDependencyVersion()
@ -182,9 +182,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-dependency-version-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf( "'dependencies.dependency.version' is missing" ) > -1 );
assertTrue( result.getErrors().get( 0 ).indexOf( "'dependencies.dependency.version' is missing" ) > -1 );
}
public void testMissingDependencyManagementArtifactId()
@ -192,9 +192,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-dependency-mgmt-artifactId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf(
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencyManagement.dependencies.dependency.artifactId' is missing." ) > -1 );
}
@ -203,9 +203,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-dependency-mgmt-groupId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertTrue( result.getMessage( 0 ).indexOf(
assertTrue( result.getErrors().get( 0 ).indexOf(
"'dependencyManagement.dependencies.dependency.groupId' is missing." ) > -1 );
}
@ -214,9 +214,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-1-pom.xml" );
assertEquals( 4, result.getMessageCount() );
assertEquals( 4, result.getErrors().size() );
List<String> messages = result.getMessages();
List<String> messages = result.getErrors();
assertTrue( messages.contains( "\'modelVersion\' is missing." ) );
assertTrue( messages.contains( "\'groupId\' is missing." ) );
@ -230,9 +230,9 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-plugin-artifactId-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getMessage( 0 ) );
assertEquals( "'build.plugins.plugin.artifactId' is missing.", result.getErrors().get( 0 ) );
}
public void testMissingPluginVersion()
@ -240,10 +240,10 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-plugin-version-pom.xml" );
assertEquals( 1, result.getMessageCount() );
assertEquals( 1, result.getErrors().size() );
assertEquals( "'build.plugins.plugin.version' is missing for org.apache.maven.plugins:maven-it-plugin",
result.getMessage( 0 ) );
result.getErrors().get( 0 ) );
}
public void testMissingRepositoryId()
@ -251,15 +251,15 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-repository-id-pom.xml", true, false );
assertEquals( 4, result.getMessageCount() );
assertEquals( 4, result.getErrors().size() );
assertEquals( "'repositories.repository.id' is missing.", result.getMessage( 0 ) );
assertEquals( "'repositories.repository.id' is missing.", result.getErrors().get( 0 ) );
assertEquals( "'repositories.repository.url' is missing.", result.getMessage( 1 ) );
assertEquals( "'repositories.repository.url' is missing.", result.getErrors().get( 1 ) );
assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getMessage( 2 ) );
assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getErrors().get( 2 ) );
assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) );
assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getErrors().get( 3 ) );
}
public void testMissingResourceDirectory()
@ -267,11 +267,11 @@ public class DefaultModelValidatorTest
{
ModelValidationResult result = validate( "missing-resource-directory-pom.xml" );
assertEquals( 2, result.getMessageCount() );
assertEquals( 2, result.getErrors().size() );
assertEquals( "'build.resources.resource.directory' is missing.", result.getMessage( 0 ) );
assertEquals( "'build.resources.resource.directory' is missing.", result.getErrors().get( 0 ) );
assertEquals( "'build.testResources.testResource.directory' is missing.", result.getMessage( 1 ) );
assertEquals( "'build.testResources.testResource.directory' is missing.", result.getErrors().get( 1 ) );
}
}