diff --git a/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
similarity index 84%
rename from maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java
rename to maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
index 35c48cf262..f76ed64a6c 100644
--- a/maven-core/src/test/java/org/apache/maven/project/validation/DefaultModelValidatorTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
@@ -1,4 +1,4 @@
-package org.apache.maven.project.validation;
+package org.apache.maven.model.validation;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -19,24 +19,55 @@ package org.apache.maven.project.validation;
* under the License.
*/
-import java.io.Reader;
+import java.io.InputStream;
import java.util.List;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.project.AbstractMavenProjectTestCase;
-import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.PlexusTestCase;
/**
* @author Trygve Laugstøl
* @version $Id$
*/
public class DefaultModelValidatorTest
- extends AbstractMavenProjectTestCase
+ extends PlexusTestCase
{
- private Model model;
- private ModelValidator validator;
+ private DefaultModelValidator validator;
+
+ private Model read( String pom )
+ throws Exception
+ {
+ String resource = "/poms/validation/" + pom;
+ InputStream is = getClass().getResourceAsStream( resource );
+ assertNotNull( "missing resource: " + resource, is );
+ return new MavenXpp3Reader().read( is );
+ }
+
+ private ModelValidationResult validate( String pom )
+ throws Exception
+ {
+ return validator.validateEffectiveModel( read( pom ), false );
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ validator = (DefaultModelValidator) lookup( ModelValidator.class );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ this.validator = null;
+
+ super.tearDown();
+ }
public void testMissingModelVersion()
throws Exception
@@ -148,7 +179,7 @@ public class DefaultModelValidatorTest
assertEquals( 1, result.getMessageCount() );
assertTrue( result.getMessage( 0 ).indexOf(
- "'dependencyManagement.dependencies.dependency.artifactId' is missing." ) > -1 );
+ "'dependencyManagement.dependencies.dependency.artifactId' is missing." ) > -1 );
}
public void testMissingDependencyManagementGroupId()
@@ -159,7 +190,7 @@ public class DefaultModelValidatorTest
assertEquals( 1, result.getMessageCount() );
assertTrue( result.getMessage( 0 ).indexOf(
- "'dependencyManagement.dependencies.dependency.groupId' is missing." ) > -1 );
+ "'dependencyManagement.dependencies.dependency.groupId' is missing." ) > -1 );
}
public void testMissingAll()
@@ -169,7 +200,7 @@ public class DefaultModelValidatorTest
assertEquals( 4, result.getMessageCount() );
- List messages = result.getMessages();
+ List messages = result.getMessages();
assertTrue( messages.contains( "\'modelVersion\' is missing." ) );
assertTrue( messages.contains( "\'groupId\' is missing." ) );
@@ -209,10 +240,6 @@ public class DefaultModelValidatorTest
assertEquals( "'repositories.repository.id' is missing.", result.getMessage( 0 ) );
assertEquals( "'repositories.repository.url' is missing.", result.getMessage( 1 ) );
-//
-// assertEquals( "'pluginRepositories.pluginRepository.id' is missing.", result.getMessage( 2 ) );
-//
-// assertEquals( "'pluginRepositories.pluginRepository.url' is missing.", result.getMessage( 3 ) );
}
public void testMissingResourceDirectory()
@@ -227,23 +254,4 @@ public class DefaultModelValidatorTest
assertEquals( "'build.testResources.testResource.directory' is missing.", result.getMessage( 1 ) );
}
- private ModelValidationResult validate( String testName )
- throws Exception
- {
- Reader input = ReaderFactory.newXmlReader( getFileForClasspathResource( "validation/" + testName ) );
-
- MavenXpp3Reader reader = new MavenXpp3Reader();
-
- validator = lookup( ModelValidator.class );
-
- model = reader.read( input );
-
- ModelValidationResult result = validator.validate( model );
-
- assertNotNull( result );
-
- input.close();
-
- return result;
- }
}
diff --git a/maven-core/src/test/resources/validation/invalid-aggregator-packaging-pom.xml b/maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/invalid-aggregator-packaging-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/invalid-aggregator-packaging-pom.xml
diff --git a/maven-core/src/test/resources/validation/invalid-ids-pom.xml b/maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/invalid-ids-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/invalid-ids-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-1-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-1-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-1-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-artifactId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-artifactId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-artifactId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-artifactId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-artifactId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-artifactId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-groupId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-groupId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-groupId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-mgmt-artifactId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-mgmt-artifactId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-artifactId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-mgmt-groupId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-mgmt-groupId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-groupId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-mgmt-version-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-mgmt-version-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-mgmt-version-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-dependency-version-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-dependency-version-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-dependency-version-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-groupId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-groupId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-groupId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-modelVersion-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-modelVersion-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-modelVersion-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-plugin-artifactId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-plugin-artifactId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-plugin-version-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-plugin-version-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-plugin-version-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-report-artifactId-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-report-artifactId-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-report-artifactId-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-repository-id-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-repository-id-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-repository-id-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-resource-directory-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-resource-directory-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-resource-directory-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-type-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-type-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-type-pom.xml
diff --git a/maven-core/src/test/resources/validation/missing-version-pom.xml b/maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml
similarity index 100%
rename from maven-core/src/test/resources/validation/missing-version-pom.xml
rename to maven-model-builder/src/test/resources/poms/validation/missing-version-pom.xml