jvanzyl 2004/04/16 10:01:59
Modified: maven-project/src/test/java/org/apache/maven/project
DefaultProjectBuilderTest.java
Added: maven-project/src/test/java/org/apache/maven/project
AbstractProjectTestCase.java
ProjectBaseDirectoryAlignmentTest.java
RecursiveProjectInheritanceTest.java
Removed: maven-project project.properties
Log:
o splitting up project testing in a test per category.
Revision Changes Path
1.4 +2 -204
maven-components/maven-project/src/test/java/org/apache/maven/project/DefaultProjectBuilderTest.java
Index: DefaultProjectBuilderTest.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-project/src/test/java/org/apache/maven/project/DefaultProjectBuilderTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultProjectBuilderTest.java 12 Apr 2004 14:41:31 -0000 1.3
+++ DefaultProjectBuilderTest.java 16 Apr 2004 17:01:58 -0000 1.4
@@ -1,13 +1,11 @@
package org.apache.maven.project;
import org.apache.maven.model.Build;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Resource;
import org.apache.maven.model.Model;
+import org.apache.maven.model.Resource;
import org.apache.maven.model.UnitTest;
import org.apache.maven.project.helpers.ModelTestHelper;
import org.apache.maven.project.helpers.ProjectTestHelper;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.DirectoryScanner;
import java.io.File;
@@ -15,26 +13,10 @@
import java.util.List;
public class DefaultProjectBuilderTest
- extends PlexusTestCase
+ extends AbstractProjectTestCase
{
- private String basedir;
-
- private MavenProjectBuilder projectBuilder;
-
private String dir = "src/test/java/org/apache/maven/project/";
- public void setUp()
- throws Exception
- {
- super.setUp();
-
- basedir = System.getProperty( "basedir" );
-
- projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
-
- assertNotNull( "Test projectBuilder can't be null!", projectBuilder );
- }
-
public void testDefaultsPropertiesExtraction()
throws Exception
{
@@ -165,128 +147,6 @@
}
}
- // ------------------------------------------------------------------------
- // Recursive Property Inheritance
- // ------------------------------------------------------------------------
-
- String dir2 = "src/test/input/";
-
- public void testPropertyInheritanceWithASingleLevelOfInheritance()
- throws Exception
- {
- File f = new File( basedir, dir2 + "a/project.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project cannot be null.", project );
-
- assertNotNull( project.getParent() );
-
- assertEquals( "a", project.getProperty( "name" ) );
-
- assertEquals( "canada", project.getProperty( "country" ) );
- }
-
- public void testPropertyInheritanceWithTwoLevelsOfInheritance()
- throws Exception
- {
- File f = new File( basedir, dir2 + "a/aa/project.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project cannot be null.", project );
-
- assertNotNull( project.getParent().getParent() );
-
- // Test a property value from this project.
- assertEquals( "aa", project.getProperty( "name" ) );
-
- // Test a property value from parent project.
- assertEquals( "guelph", project.getProperty( "place" ) );
-
- // Test a property value from grand parent project.
- assertEquals( "canada", project.getProperty( "country" ) );
- }
-
- // ------------------------------------------------------------------------
- // Recursive Model Inheritance
- // ------------------------------------------------------------------------
-
- public void testModelInheritanceWithTwoLevelsOfInheritance()
- throws Exception
- {
- File f = new File( basedir, dir2 + "a/aa/project.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project cannot be null.", project );
-
- assertNotNull( project.getParent().getParent() );
-
- // Get version which is set in both the parent and the grand parent. So
- // we should get "2.0" which is definted in this project.
- assertEquals( "2.0", project.getVersion() );
-
- // There are no dependencies specified in this project but there are
- // dependencies specified in the parent.
- Dependency d0 = (Dependency) project.getDependencies().get( 0 );
-
- assertNotNull( "Dependency which has been specified in the parent cannot be
null", d0 );
-
- assertEquals( "b", d0.getGroupId() );
-
- // Get the inception year from the grand parent.
- assertEquals( "2001", project.getInceptionYear() );
- }
-
- public void testModelInheritanceWithThreeLevelsOfInheritance()
- throws Exception
- {
- File f = new File( basedir, dir2 + "b/bb/bbb/project.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project cannot be null.", project );
-
- assertNotNull( project.getParent().getParent().getParent() );
-
- // Get version which is set in both the parent and the grand parent. So
- // we should get "2.0" which is definted in this project.
- assertEquals( "3.0", project.getVersion() );
-
- // Get project url from parent.
- assertEquals( "bb-url", project.getUrl() );
-
- // There are no dependencies specified in this project but there are
- // dependencies specified in the grand parent.
- Dependency d0 = (Dependency) project.getDependencies().get( 0 );
-
- assertNotNull( "Dependency which has been specified in the parent cannot be
null", d0 );
-
- assertEquals( "c", d0.getGroupId() );
-
- // Get the inception year from the great grand parent.
- assertEquals( "2001", project.getInceptionYear() );
- }
-
- // ------------------------------------------------------------------------
- // Recursive Model Inheritance with property interpolation
- // ------------------------------------------------------------------------
-
- public void
XtestModelInheritanceWithPropertyInterpolationAndThreeLevelsOfInheritance()
- throws Exception
- {
- File f = new File( basedir, dir2 + "c/cc/ccc/project.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project cannot be null.", project );
-
- assertNotNull( project.getParent().getParent().getParent() );
-
- assertEquals( "ccc", project.getShortDescription() );
- }
-
public void testProjectSorting()
throws Exception
{
@@ -312,67 +172,5 @@
List sortedProjects = projectBuilder.getSortedProjects( projects );
assertNotNull( sortedProjects );
- }
-
- public void testProjectDirectoryBaseDirectoryAlignment()
- throws Exception
- {
- File f = new File( basedir, dir +
"project-which-needs-directory-alignment.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project can't be null!", project );
-
- assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
-
- assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
-
- Build build = project.getBuild();
-
- Resource resource = (Resource) build.getResources().get( 0 );
-
- assertTrue( resource.getDirectory().startsWith( basedir ) );
- }
-
- public void testProjectDirectoryBaseDirectoryAlignmentInheritance()
- throws Exception
- {
- File f = new File( basedir, dir +
"project-which-needs-directory-alignment-child.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project can't be null!", project );
-
- assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
-
- assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
-
- Build build = project.getBuild();
-
- Resource resource = (Resource) build.getResources().get( 0 );
-
- assertTrue( resource.getDirectory().startsWith( basedir ) );
- }
-
- public void
testProjectDirectoryBaseDirectoryAlignmentInheritanceWithParentOneDirectoryUp()
- throws Exception
- {
- File f = new File( basedir, dir +
"plugins/project-which-needs-directory-alignment-child.xml" );
-
- MavenProject project = projectBuilder.build( f );
-
- assertNotNull( "Test project can't be null!", project );
-
- assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
-
- assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
-
- Build build = project.getBuild();
-
- Resource resource = (Resource) build.getResources().get( 0 );
-
- // We should not be picking up the parents values here.
-
- assertTrue( resource.getDirectory().indexOf( ".." ) < 0 );
}
}
1.1
maven-components/maven-project/src/test/java/org/apache/maven/project/AbstractProjectTestCase.java
Index: AbstractProjectTestCase.java
===================================================================
package org.apache.maven.project;
import org.apache.maven.model.Build;
import org.apache.maven.model.Resource;
import org.codehaus.plexus.PlexusTestCase;
import java.io.File;
public class AbstractProjectTestCase
extends PlexusTestCase
{
protected MavenProjectBuilder projectBuilder;
public void setUp()
throws Exception
{
super.setUp();
projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
assertNotNull( "Test projectBuilder can't be null!", projectBuilder );
}
}
1.1
maven-components/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java
Index: ProjectBaseDirectoryAlignmentTest.java
===================================================================
package org.apache.maven.project;
import org.apache.maven.model.Build;
import org.apache.maven.model.Resource;
import java.io.File;
public class ProjectBaseDirectoryAlignmentTest
extends AbstractProjectTestCase
{
private String dir = "src/test/java/org/apache/maven/project/";
public void testProjectDirectoryBaseDirectoryAlignment()
throws Exception
{
File f = new File( basedir, dir +
"project-which-needs-directory-alignment.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project can't be null!", project );
assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
Build build = project.getBuild();
Resource resource = (Resource) build.getResources().get( 0 );
assertTrue( resource.getDirectory().startsWith( basedir ) );
}
public void testProjectDirectoryBaseDirectoryAlignmentInheritance()
throws Exception
{
File f = new File( basedir, dir +
"project-which-needs-directory-alignment-child.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project can't be null!", project );
assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
Build build = project.getBuild();
Resource resource = (Resource) build.getResources().get( 0 );
assertTrue( resource.getDirectory().startsWith( basedir ) );
}
public void
testProjectDirectoryBaseDirectoryAlignmentInheritanceWithParentOneDirectoryUp()
throws Exception
{
File f = new File( basedir, dir +
"plugins/project-which-needs-directory-alignment-child.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project can't be null!", project );
assertTrue( project.getBuild().getSourceDirectory().startsWith( basedir ) );
assertTrue( project.getBuild().getUnitTestSourceDirectory().startsWith(
basedir ) );
Build build = project.getBuild();
Resource resource = (Resource) build.getResources().get( 0 );
// We should not be picking up the parents values here.
assertTrue( resource.getDirectory().indexOf( ".." ) < 0 );
}
}
1.1
maven-components/maven-project/src/test/java/org/apache/maven/project/RecursiveProjectInheritanceTest.java
Index: RecursiveProjectInheritanceTest.java
===================================================================
package org.apache.maven.project;
import org.apache.maven.model.Dependency;
import java.io.File;
public class RecursiveProjectInheritanceTest
extends AbstractProjectTestCase
{
// ------------------------------------------------------------------------
// Recursive Property Inheritance
// ------------------------------------------------------------------------
String dir2 = "src/test/input/";
public void testPropertyInheritanceWithASingleLevelOfInheritance()
throws Exception
{
File f = new File( basedir, dir2 + "a/project.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project cannot be null.", project );
assertNotNull( project.getParent() );
assertEquals( "a", project.getProperty( "name" ) );
assertEquals( "canada", project.getProperty( "country" ) );
}
public void testPropertyInheritanceWithTwoLevelsOfInheritance()
throws Exception
{
File f = new File( basedir, dir2 + "a/aa/project.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project cannot be null.", project );
assertNotNull( project.getParent().getParent() );
// Test a property value from this project.
assertEquals( "aa", project.getProperty( "name" ) );
// Test a property value from parent project.
assertEquals( "guelph", project.getProperty( "place" ) );
// Test a property value from grand parent project.
assertEquals( "canada", project.getProperty( "country" ) );
}
// ------------------------------------------------------------------------
// Recursive Model Inheritance
// ------------------------------------------------------------------------
public void testModelInheritanceWithTwoLevelsOfInheritance()
throws Exception
{
File f = new File( basedir, dir2 + "a/aa/project.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project cannot be null.", project );
assertNotNull( project.getParent().getParent() );
// Get version which is set in both the parent and the grand parent. So
// we should get "2.0" which is definted in this project.
assertEquals( "2.0", project.getVersion() );
// There are no dependencies specified in this project but there are
// dependencies specified in the parent.
Dependency d0 = (Dependency) project.getDependencies().get( 0 );
assertNotNull( "Dependency which has been specified in the parent cannot be
null", d0 );
assertEquals( "b", d0.getGroupId() );
// Get the inception year from the grand parent.
assertEquals( "2001", project.getInceptionYear() );
}
public void testModelInheritanceWithThreeLevelsOfInheritance()
throws Exception
{
File f = new File( basedir, dir2 + "b/bb/bbb/project.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project cannot be null.", project );
assertNotNull( project.getParent().getParent().getParent() );
// Get version which is set in both the parent and the grand parent. So
// we should get "2.0" which is definted in this project.
assertEquals( "3.0", project.getVersion() );
// Get project url from parent.
assertEquals( "bb-url", project.getUrl() );
// There are no dependencies specified in this project but there are
// dependencies specified in the grand parent.
Dependency d0 = (Dependency) project.getDependencies().get( 0 );
assertNotNull( "Dependency which has been specified in the parent cannot be
null", d0 );
assertEquals( "c", d0.getGroupId() );
// Get the inception year from the great grand parent.
assertEquals( "2001", project.getInceptionYear() );
}
// ------------------------------------------------------------------------
// Recursive Model Inheritance with property interpolation
// ------------------------------------------------------------------------
public void
XtestModelInheritanceWithPropertyInterpolationAndThreeLevelsOfInheritance()
throws Exception
{
File f = new File( basedir, dir2 + "c/cc/ccc/project.xml" );
MavenProject project = projectBuilder.build( f );
assertNotNull( "Test project cannot be null.", project );
assertNotNull( project.getParent().getParent().getParent() );
assertEquals( "ccc", project.getShortDescription() );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]