dion 2003/08/18 21:45:37
Modified: src/test/java/org/apache/maven MavenUtilsTest.java
src/test/extend project-child.xml
src/test/java/org/apache/maven/util MavenToolTest.java
MD5SumTest.java DVSLPathToolTest.java
EnhancedStringTokenizerTest.java
src/test/touchstone-build/src/test/org/apache/maven/touchstone
TouchstoneTest.java
src/test/extend/child_project project-child2.xml
src/test/java/org/apache/maven/project BuildTest.java
BaseObjectTest.java DependencyTest.java
ProjectInheritanceTest.java
src/test/java/org/apache/maven/app MavenTest.java
src/test/touchstone-build/src/reactor-build/resources
maven.xml
src/test/touchstone-build project.xml maven.xml
src/test/java/org/apache/maven/jelly/tags/maven
DependencyResolverTest.java
Added: src/test/java/org/apache/maven/plugin PluginManagerTest.java
maven-java-plugin-1.3.jar
PluginCacheManagerTest.java forehead.conf
src/test/basedir project.xml
src/test/java/org/apache/maven/plugin/maven.home/plugins
maven-clean-plugin-1.1-SNAPSHOT.jar
src/test/java/org/apache/maven/project BasedirTest.java
src/test/basedir/extend-1 project.xml
src/test/basedir/extend-2 project.xml
Removed: src/test/java/org/apache/maven
DefaultProjectUnmarshallerTest.java
src/test/java/org/apache/maven/plugin
DefaultPluginCacheManagerTest.java
src/test/java/org/apache/maven/project TestResourceTest.java
Log:
Switch stable branch back to HEAD
Revision Changes Path
1.12 +68 -13 maven/src/test/java/org/apache/maven/MavenUtilsTest.java
Index: MavenUtilsTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/MavenUtilsTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MavenUtilsTest.java 29 Jul 2003 00:28:43 -0000 1.11
+++ MavenUtilsTest.java 19 Aug 2003 04:45:37 -0000 1.12
@@ -58,13 +58,22 @@
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
+import java.io.File;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.maven.jelly.MavenJellyContext;
+/**
+ * Test cases for various MavenUtils methods.
+ *
+ * @author Brett Porter <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
+ * @author others
+ * @version $Id$
+ */
public class MavenUtilsTest
- extends TestCase
+ extends TestCase
{
public MavenUtilsTest( String testName )
{
@@ -212,7 +221,7 @@
projectProperties.setProperty( "maven.repo.remote", mavenRepoRemote );
String basedir = "/home/jvanzyl/projects/maven";
-
+
// Driver properties
driverProperties.setProperty( "basedir", basedir );
driverProperties.setProperty( "maven.build.src", "${basedir}/src" );
@@ -222,7 +231,7 @@
driverProperties.setProperty( "maven.final.name", "maven-1.0" );
driverProperties.setProperty( "maven.repo.remote.enabled", "true" );
driverProperties.setProperty( "maven.repo.local",
"${maven.home}/repository" );
-
+
Map result = MavenUtils.mergeMaps( new Map[]
{
systemProperties,
@@ -232,28 +241,74 @@
driverProperties
} );
+ MavenJellyContext context = new MavenJellyContext();
+ MavenUtils.integrateMapInContext( result, context );
+
// Values that should be taken from systemProperties.
- assertEquals( "/projects/maven", (String) result.get( "maven.home" ) );
+ assertEquals( "/projects/maven", ( String ) context.getVariable(
"maven.home" ) );
// Values that should be taken from userBuildProperties.
- assertEquals( "/opt/maven/repository", (String) result.get(
"maven.repo.local" ) );
- assertEquals( "false", (String) result.get( "maven.repo.remote.enabled" ) );
- assertEquals( "jvanzyl", (String) result.get( "maven.username" ) );
-
+ assertEquals( "/opt/maven/repository", ( String ) context.getVariable(
"maven.repo.local" ) );
+ assertEquals( "false", ( String ) context.getVariable(
"maven.repo.remote.enabled" ) );
+ assertEquals( "jvanzyl", ( String ) context.getVariable( "maven.username" )
);
+
// Values take from projectBuildProperties.
- assertEquals( "maven", (String) result.get( "maven.final.name" ) );
+ assertEquals( "maven", ( String ) context.getVariable( "maven.final.name" )
);
// Values take from projectProperties.
- assertEquals( mavenRepoRemote, (String) result.get( "maven.repo.remote" ) );
+ assertEquals( mavenRepoRemote, ( String ) context.getVariable(
"maven.repo.remote" ) );
// Values taken from driver properties.
- assertEquals( basedir + "/target", (String) result.get( "maven.build.dir" )
);
- assertEquals( basedir + "/src", (String) result.get( "maven.build.src" ) );
- assertEquals( basedir + "/target/classes", (String) result.get(
"maven.build.dest" ) );
+ assertEquals( basedir + "/target", ( String ) context.getVariable(
"maven.build.dir" ) );
+ assertEquals( basedir + "/src", ( String ) context.getVariable(
"maven.build.src" ) );
+ assertEquals( basedir + "/target/classes", ( String ) context.getVariable(
"maven.build.dest" ) );
}
public void testLocalSelector()
{
System.out.println( Locale.getDefault() );
+ }
+
+ /**
+ * Test makeAbsolutePath.
+ * @throws Exception if there was a problem
+ */
+ public void testMakeAbsolutePath() throws Exception
+ {
+ String basedir = System.getProperty( "basedir" );
+ File basedirFile = new File( basedir ).getCanonicalFile();
+ assertEquals( "Check relative path", new File( basedir + "/project.xml"
).getCanonicalPath(),
+ MavenUtils.makeAbsolutePath( basedirFile, "project.xml" ) );
+ assertEquals( "Check unix relative path", new File( basedir +
"/src/test/basedir/project.xml" ).getCanonicalPath(),
+ MavenUtils.makeAbsolutePath( basedirFile,
"src/test/basedir/project.xml" ) );
+ assertEquals( "Check windows relative path", new File( basedir +
"\\src\\test\\basedir\\project.xml" ).getCanonicalPath(),
+ MavenUtils.makeAbsolutePath( basedirFile,
"src/test/basedir/project.xml" ) );
+ assertEquals( "Check absolute path outside basedir", new File(
"/www/docs/index.html" ).getCanonicalPath(),
+ MavenUtils.makeAbsolutePath( basedirFile, new File(
"/www/docs/index.html" ).getCanonicalPath() ) );
+ }
+
+ /**
+ * Test makeRelativePath.
+ * @throws Exception if there was a problem
+ */
+ public void testMakeRelativePath() throws Exception
+ {
+ String basedir = new File( System.getProperty( "basedir" )
).getCanonicalPath();
+ File basedirFile = new File( basedir ).getCanonicalFile();
+ assertEquals( "Check relative path", "project.xml",
+ MavenUtils.makeRelativePath( basedirFile,
+ new File( basedir +
"/project.xml" ).getCanonicalPath() ) );
+ assertEquals( "Check unix relative path",
+ "src" + File.separatorChar + "test" + File.separatorChar +
"basedir" + File.separatorChar +
+ "project.xml",
+ MavenUtils.makeRelativePath( basedirFile,
+ new File( basedir +
"/src/test/basedir/project.xml" ).getCanonicalPath() ) );
+ assertEquals( "Check windows relative path",
+ "src" + File.separatorChar + "test" + File.separatorChar +
"basedir" + File.separatorChar +
+ "project.xml",
+ MavenUtils.makeRelativePath( basedirFile,
+ new File( basedir +
"\\src\\test\\basedir\\project.xml" ).getCanonicalPath() ) );
+ assertEquals( "Check absolute path outside basedir", new File(
"/www/docs/index.html" ).getCanonicalPath(),
+ MavenUtils.makeRelativePath( basedirFile, new File(
"/www/docs/index.html" ).getCanonicalPath() ) );
}
}
1.3 +112 -93
maven/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
1.2 +21 -0
maven/src/test/java/org/apache/maven/plugin/maven-java-plugin-1.3.jar
<<Binary file>>
1.5 +0 -0
maven/src/test/java/org/apache/maven/plugin/PluginCacheManagerTest.java
1.2 +10 -0 maven/src/test/java/org/apache/maven/plugin/forehead.conf
1.7 +4 -6 maven/src/test/extend/project-child.xml
Index: project-child.xml
===================================================================
RCS file: /home/cvs/maven/src/test/extend/project-child.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- project-child.xml 27 Jul 2003 23:34:00 -0000 1.6
+++ project-child.xml 19 Aug 2003 04:45:37 -0000 1.7
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
- <!-- We're using maven's descriptor itself -->
<extend>${basedir}/../../../project.xml</extend>
-
+
<id>super-extendo</id>
<groupId>maven</groupId>
<name>Super Extendo</name>
+ <siteAddress>theSiteAddress</siteAddress>
+ <siteDirectory>theSiteDirectory</siteDirectory>
+
<dependencies>
<dependency>
<id>child-dep1</id>
@@ -36,9 +38,5 @@
</sourceModifications>
</build>
-
- <properties>
- <key>value</key>
- </properties>
</project>
1.2 +2 -2 maven/src/test/java/org/apache/maven/util/MavenToolTest.java
Index: MavenToolTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/util/MavenToolTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MavenToolTest.java 30 Jul 2003 00:50:37 -0000 1.1
+++ MavenToolTest.java 19 Aug 2003 04:45:37 -0000 1.2
@@ -70,7 +70,7 @@
{
/** fragment to be resolved */
private static final String NEEDLE =
- "org/apache/maven/MavenTool.java";
+ "org/apache/maven/util/MavenTool.java";
/** where to search for the fragment */
private static final String[] HAYSTACK =
{
1.7 +4 -2 maven/src/test/java/org/apache/maven/util/MD5SumTest.java
Index: MD5SumTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/util/MD5SumTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MD5SumTest.java 13 Apr 2003 00:56:02 -0000 1.6
+++ MD5SumTest.java 19 Aug 2003 04:45:37 -0000 1.7
@@ -92,7 +92,9 @@
throws Exception
{
MD5Sum md5 = new MD5Sum();
- md5.setFile( new File( "src/test/checksum/input.jar" ) );
+ String basedir = System.getProperty("basedir");
+ assertNotNull("basedir not provided", basedir);
+ md5.setFile( new File( basedir + "/src/test/checksum/input.jar" ) );
md5.execute();
String checksum = md5.getChecksum();
1.2 +2 -2 maven/src/test/java/org/apache/maven/util/DVSLPathToolTest.java
Index: DVSLPathToolTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/util/DVSLPathToolTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
1.4 +9 -15
maven/src/test/java/org/apache/maven/util/EnhancedStringTokenizerTest.java
Index: EnhancedStringTokenizerTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/java/org/apache/maven/util/EnhancedStringTokenizerTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EnhancedStringTokenizerTest.java 27 Jul 2003 23:34:01 -0000 1.3
+++ EnhancedStringTokenizerTest.java 19 Aug 2003 04:45:37 -0000 1.4
@@ -35,6 +35,14 @@
public void testSimple() {
EnhancedStringTokenizer tok = new
EnhancedStringTokenizer("a,b,c,d,,e,,,f,,,,,g", ",");
+ checkTokens(tok);
+ }
+
+ /**
+ * @param tok The tokenizer to check
+ */
+ private void checkTokens(EnhancedStringTokenizer tok)
+ {
assertEquals("Token 1", "a", tok.nextToken());
assertEquals("Token 2", "b", tok.nextToken());
assertEquals("Token 3", "c", tok.nextToken());
@@ -54,21 +62,7 @@
public void testSimpleTab() {
EnhancedStringTokenizer tok = new
EnhancedStringTokenizer("a\tb\tc\td\t\te\t\t\tf\t\t\t\t\tg", "\t");
- assertEquals("Token 1", "a", tok.nextToken());
- assertEquals("Token 2", "b", tok.nextToken());
- assertEquals("Token 3", "c", tok.nextToken());
- assertEquals("Token 4", "d", tok.nextToken());
- assertEquals("Token 5", "", tok.nextToken());
- assertEquals("Token 6", "e", tok.nextToken());
- assertEquals("Token 7", "", tok.nextToken());
- assertEquals("Token 8", "", tok.nextToken());
- assertEquals("Token 9", "f", tok.nextToken());
- assertEquals("Token 10", "", tok.nextToken());
- assertEquals("Token 11", "", tok.nextToken());
- assertEquals("Token 12", "", tok.nextToken());
- assertEquals("Token 13", "", tok.nextToken());
- assertEquals("Token 14", "g", tok.nextToken());
- assertEquals("tok.hasMoreTokens()", false, tok.hasMoreTokens());
+ checkTokens(tok);
}
public void testNoDelim() {
1.2 +24 -0 maven/src/test/basedir/project.xml
1.3 +2 -3
maven/src/test/touchstone-build/src/test/org/apache/maven/touchstone/TouchstoneTest.java
Index: TouchstoneTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/touchstone-build/src/test/org/apache/maven/touchstone/TouchstoneTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TouchstoneTest.java 27 Jul 2003 23:34:01 -0000 1.2
+++ TouchstoneTest.java 19 Aug 2003 04:45:37 -0000 1.3
@@ -58,7 +58,7 @@
import junit.framework.TestCase;
-import org.apache.maven.Maven;
+import org.apache.maven.MavenUtils;
import org.apache.maven.project.Project;
/**
@@ -84,8 +84,7 @@
public void testTouchstone()
throws Exception
{
- Maven maven = new Maven();
- Project p = maven.getProject( new File( basedir, "project.xml" ) );
+ Project p = MavenUtils.getProject( new File( basedir, "project.xml" ) );
// A value that is specified in project.properties is interpolated into the
// project.xml file so that when we access the connection value we get the
1.3 +1 -2 maven/src/test/extend/child_project/project-child2.xml
Index: project-child2.xml
===================================================================
RCS file: /home/cvs/maven/src/test/extend/child_project/project-child2.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project-child2.xml 25 Jul 2003 14:47:50 -0000 1.2
+++ project-child2.xml 19 Aug 2003 04:45:37 -0000 1.3
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
- <!-- XXX ../project-child.xml should work, but doesn't -->
- <extend>src/test/extend/project-child.xml</extend>
+ <extend>${basedir}/../project-child.xml</extend>
<id>child</id>
<name>Child Project</name>
1.2 +18 -0
maven/src/test/java/org/apache/maven/plugin/maven.home/plugins/maven-clean-plugin-1.1-SNAPSHOT.jar
<<Binary file>>
1.3 +0 -52 maven/src/test/java/org/apache/maven/project/BuildTest.java
Index: BuildTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/project/BuildTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BuildTest.java 7 Dec 2002 02:19:08 -0000 1.2
+++ BuildTest.java 19 Aug 2003 04:45:37 -0000 1.3
@@ -52,32 +52,6 @@
// JUnitDoclet end method testcase.tearDown
}
- public void testSetGetIntegrationUnitTestSourceDirectory() throws Exception
- {
- // JUnitDoclet begin method setIntegrationUnitTestSourceDirectory
getIntegrationUnitTestSourceDirectory
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
-
- for ( int i = 0; i < tests.length; i++ )
- {
- build.setIntegrationUnitTestSourceDirectory( tests[i] );
- assertEquals( tests[i], build.getIntegrationUnitTestSourceDirectory() );
- }
- // JUnitDoclet end method setIntegrationUnitTestSourceDirectory
getIntegrationUnitTestSourceDirectory
- }
-
- public void testSetGetUnitTestSourceDirectory() throws Exception
- {
- // JUnitDoclet begin method setUnitTestSourceDirectory
getUnitTestSourceDirectory
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
-
- for ( int i = 0; i < tests.length; i++ )
- {
- build.setUnitTestSourceDirectory( tests[i] );
- assertEquals( tests[i], build.getUnitTestSourceDirectory() );
- }
- // JUnitDoclet end method setUnitTestSourceDirectory
getUnitTestSourceDirectory
- }
-
public void testAddJarResource() throws Exception
{
// JUnitDoclet begin method addJarResource
@@ -106,32 +80,6 @@
{
// JUnitDoclet begin method getSourceModifications
// JUnitDoclet end method getSourceModifications
- }
-
- public void testSetGetSourceDirectory() throws Exception
- {
- // JUnitDoclet begin method setSourceDirectory getSourceDirectory
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
-
- for ( int i = 0; i < tests.length; i++ )
- {
- build.setSourceDirectory( tests[i] );
- assertEquals( tests[i], build.getSourceDirectory() );
- }
- // JUnitDoclet end method setSourceDirectory getSourceDirectory
- }
-
- public void testSetGetAspectSourceDirectory() throws Exception
- {
- // JUnitDoclet begin method setAspectSourceDirectory
getAspectSourceDirectory
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
-
- for ( int i = 0; i < tests.length; i++ )
- {
- build.setAspectSourceDirectory( tests[i] );
- assertEquals( tests[i], build.getAspectSourceDirectory() );
- }
- // JUnitDoclet end method setAspectSourceDirectory getAspectSourceDirectory
}
public void testSetGetNagEmailAddress() throws Exception
1.3 +17 -4 maven/src/test/java/org/apache/maven/project/BaseObjectTest.java
Index: BaseObjectTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/java/org/apache/maven/project/BaseObjectTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseObjectTest.java 27 Jul 2003 23:34:00 -0000 1.2
+++ BaseObjectTest.java 19 Aug 2003 04:45:37 -0000 1.3
@@ -55,7 +55,7 @@
public void testSetGetName() throws Exception
{
// JUnitDoclet begin method setName getName
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
for ( int i = 0; i < tests.length; i++ )
{
@@ -67,15 +67,15 @@
public void testSetGetId() throws Exception
{
- // JUnitDoclet begin method setVar getVar
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n"};
+ // JUnitDoclet begin method setId getId
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n"};
for ( int i = 0; i < tests.length; i++ )
{
baseobject.setId( tests[i] );
assertEquals( tests[i], baseobject.getId() );
}
- // JUnitDoclet end method setVar getVar
+ // JUnitDoclet end method setId getId
}
public void testAddProperty() throws Exception
@@ -88,6 +88,19 @@
{
// JUnitDoclet begin method getProperty
// JUnitDoclet end method getProperty
+ }
+
+ public void testSetGetProperties() throws Exception
+ {
+ // JUnitDoclet begin method setProperties getProperties
+ java.util.List[] tests = {new java.util.ArrayList(), null};
+
+ for ( int i = 0; i < tests.length; i++ )
+ {
+ baseobject.setProperties( tests[i] );
+ assertEquals( tests[i], baseobject.getProperties() );
+ }
+ // JUnitDoclet end method setProperties getProperties
}
public void testResolvedProperties() throws Exception
1.6 +6 -6 maven/src/test/java/org/apache/maven/project/DependencyTest.java
Index: DependencyTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/java/org/apache/maven/project/DependencyTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DependencyTest.java 27 Jul 2003 23:34:00 -0000 1.5
+++ DependencyTest.java 19 Aug 2003 04:45:37 -0000 1.6
@@ -60,14 +60,14 @@
public void testSetId() throws Exception
{
- // JUnitDoclet begin method setVar
- // JUnitDoclet end method setVar
+ // JUnitDoclet begin method setId
+ // JUnitDoclet end method setId
}
public void testSetGetGroupId() throws Exception
{
// JUnitDoclet begin method setGroupId getGroupId
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
for ( int i = 0; i < tests.length; i++ )
{
@@ -101,7 +101,7 @@
public void testSetGetVersion() throws Exception
{
// JUnitDoclet begin method setVersion getVersion
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
for ( int i = 0; i < tests.length; i++ )
{
@@ -114,7 +114,7 @@
public void testSetGetUrl() throws Exception
{
// JUnitDoclet begin method setUrl getUrl
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
for ( int i = 0; i < tests.length; i++ )
{
@@ -127,7 +127,7 @@
public void testSetGetType() throws Exception
{
// JUnitDoclet begin method setType getType
- java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
+ java.lang.String[] tests = {"", " ", "a", "A", "�", "�", "0123456789",
"012345678901234567890", "\n", null};
for ( int i = 0; i < tests.length; i++ )
{
1.36 +49 -39
maven/src/test/java/org/apache/maven/project/ProjectInheritanceTest.java
Index: ProjectInheritanceTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/java/org/apache/maven/project/ProjectInheritanceTest.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ProjectInheritanceTest.java 27 Jul 2003 23:34:00 -0000 1.35
+++ ProjectInheritanceTest.java 19 Aug 2003 04:45:37 -0000 1.36
@@ -57,7 +57,8 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.maven.Maven;
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.MavenUtils;
import java.io.File;
import java.util.List;
@@ -66,8 +67,10 @@
extends TestCase
{
private String TEST_DOCUMENT = null;
- private String basedir;
-
+ private String TEST_DOCUMENT2 = null;
+ private String baseDir;
+ private String FS = "/"; // note: same on windows and others
+
public ProjectInheritanceTest( String testName )
{
super( testName );
@@ -75,36 +78,35 @@
public static Test suite()
{
- // Disabled:
-
return new TestSuite( ProjectInheritanceTest.class );
-
- // return new TestSuite(ProjectInheritanceTest.class);
}
protected void setUp() throws Exception
{
super.setUp();
- basedir = System.getProperty( "basedir" );
- assertNotNull( "The system property basedir was not defined.", basedir );
+ baseDir = System.getProperty( "basedir" );
+ assertNotNull( "The system property basedir was not defined.", baseDir );
String fs = System.getProperty( "file.separator" );
assertNotNull( "The system property file.separator was not defined.", fs );
- TEST_DOCUMENT = basedir + "/src/test/extend/project-child.xml";
+ TEST_DOCUMENT = baseDir + "/src/test/extend/project-child.xml";
+ TEST_DOCUMENT2 = baseDir +
"/src/test/extend/child_project/project-child2.xml";
}
public void testProjectMapping() throws Exception
{
- Maven maven = new Maven();
-
- Project p = maven.getProject( new File( TEST_DOCUMENT ) );
-
+ Project p = MavenUtils.getProject( new File( TEST_DOCUMENT ) );
+
// Make sure the groupId is inherited correctly.
assertEquals( "maven", p.getGroupId() );
-
+
assertEquals( "Super Extendo", p.getName() );
assertEquals( "maven:super-extendo", p.getId() );
assertEquals( "Apache Software Foundation", p.getOrganization().getName() );
assertEquals( "http://jakarta.apache.org/", p.getOrganization().getUrl() );
+
+ //Test siteAddress / siteDirectory
+ assertEquals( "theSiteAddress", p.getSiteAddress());
+ assertEquals( "theSiteDirectory", p.getSiteDirectory());
// Test Dependencies
assertEquals( "child-dep1:child-dep1",
@@ -115,24 +117,23 @@
assertEquals( "dom4j:dom4j",
( (Dependency) p.getDependencies().get( 1 ) ).getId() );
- assertEquals( "1.4-dev-8",
+ assertEquals( "1.4",
( (Dependency) p.getDependencies().get( 1 ) ).getVersion() );
-
- // This probably looks a little odd but this is what we're doing:
- //
- // The basedir is the top-level directory of maven. This is where the tests
are
- // started from. When we inherit a POM the parent is merged into the child
prior
- // to interpolation. This is to make sure that things like ${basedir} are
interpolated
- // the childs version is used and not the parents.
-
+
+ baseDir = p.getContext().findVariable("basedir").toString();
// Test Source Directories
- assertTrue( pathsEqual( basedir + "/src/test/extend/src/java",
p.getBuild().getSourceDirectory() ) );
+ assertEquals( baseDir + FS + "src/java", p.getBuild().getSourceDirectory()
);
// Unit Test Source Directories
- assertTrue( pathsEqual( basedir + "/src/test/extend/src/test/java",
p.getBuild().getUnitTestSourceDirectory() ) );
+ assertEquals( baseDir + FS + "src/test/java",
p.getBuild().getUnitTestSourceDirectory() );
+ // Test Aspect Source Directories
+ //assertEquals("src/aspect", p.getBuild().getAspectSourceDirectory());
+
+ // Test Test Source Directories ;-)
+ assertEquals( baseDir + FS + "src/test/java",
p.getBuild().getUnitTestSourceDirectory() );
String iuSrc = p.getBuild().getIntegrationUnitTestSourceDirectory();
assertTrue( "Should be empty in maven's project descriptor: [" + iuSrc +
"]",
- org.apache.plexus.util.StringUtils.isEmpty( iuSrc ) );
+ StringUtils.isEmpty( iuSrc ) );
// Unit Test patterns
List unitTestIncludes = p.getBuild().getUnitTest().getIncludes();
@@ -153,23 +154,32 @@
assertEquals( "MAVEN_1_0_B1", v0.getTag() );
// Test the version map
- Version v4 = p.getVersionById( "b4" );
+ Version v4 = (Version) p.getVersionById( "b4" );
assertEquals( "b4", v4.getId() );
assertEquals( "1.0-b4", v4.getName() );
assertEquals( "MAVEN_1_0_B4", v4.getTag() );
-
- assertEquals( "value", p.getProperty( "key") );
}
-
- private boolean pathsEqual( String f1, String f2 )
- throws Exception
+
+ public void testProjectMappingExtends() throws Exception
{
- String s1 = new File( f1 ).getCanonicalPath();
- String s2 = new File( f2 ).getCanonicalPath();
-
- System.out.println( s1 + " ---> " + s2 );
-
- return s1.equals( s2 );
+ Project p = MavenUtils.getProject( new File( TEST_DOCUMENT2 ) );
+
+ // Make sure the groupId is inherited correctly.
+ assertEquals( "maven", p.getGroupId() );
+
+ assertEquals( "Child Project", p.getName() );
+ assertEquals( "maven:child", p.getId() );
+
+ // Test organization inheritance. These should pass, but don't
+ if ( false ) {
+ assertNotNull( p.getOrganization() );
+ assertEquals( "Apache Software Foundation", p.getOrganization().getName()
);
+ assertEquals( "http://jakarta.apache.org/", p.getOrganization().getUrl()
);
+ }
+
+ // Test siteAddress / siteDirectory
+ assertEquals( "theSiteAddress", p.getSiteAddress());
+ assertEquals( "theSiteDirectory", p.getSiteDirectory());
}
}
1.2 +151 -0 maven/src/test/java/org/apache/maven/project/BasedirTest.java
1.2 +25 -0 maven/src/test/basedir/extend-1/project.xml
1.7 +3 -3 maven/src/test/java/org/apache/maven/app/MavenTest.java
Index: MavenTest.java
===================================================================
RCS file: /home/cvs/maven/src/test/java/org/apache/maven/app/MavenTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MavenTest.java 27 Jul 2003 23:34:00 -0000 1.6
+++ MavenTest.java 19 Aug 2003 04:45:37 -0000 1.7
@@ -19,7 +19,7 @@
// JUnitDoclet end extends_implements
{
// JUnitDoclet begin class
- org.apache.maven.Maven maven = null;
+ org.apache.maven.MavenSession maven = null;
// JUnitDoclet end class
public MavenTest( String name )
@@ -29,10 +29,10 @@
// JUnitDoclet end method MavenTest
}
- public org.apache.maven.Maven createInstance() throws Exception
+ public org.apache.maven.MavenSession createInstance() throws Exception
{
// JUnitDoclet begin method testcase.createInstance
- return new org.apache.maven.Maven();
+ return new org.apache.maven.MavenSession();
// JUnitDoclet end method testcase.createInstance
}
1.2 +48 -26
maven/src/test/touchstone-build/src/reactor-build/resources/maven.xml
Index: maven.xml
===================================================================
RCS file:
/home/cvs/maven/src/test/touchstone-build/src/reactor-build/resources/maven.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- maven.xml 28 Jan 2003 17:19:50 -0000 1.1
+++ maven.xml 19 Aug 2003 04:45:37 -0000 1.2
@@ -1,26 +1,48 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project default="run"
- xmlns:j="jelly:core"
- xmlns:maven="jelly:maven"
- xmlns:util="jelly:util">
-
- <goal name="run">
- <delete dir="subproject/target" quiet="true"/>
-
- <maven:reactor
- basedir="${basedir}"
- includes="*/project.xml"
- goals="java:jar-resources"
- banner="Building"
- ignoreFailures="false"
- />
-
- <util:available file="subproject/target/classes/test.properties">
- <j:set var="resourcesCopied" value="true"/>
- </util:available>
- <j:if test="${resourcesCopied != 'true'}">
- <fail>resource:copy fails for subproject</fail>
- </j:if>
- </goal>
-
-</project>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="run"
+ xmlns:j="jelly:core"
+ xmlns:maven="jelly:maven"
+ xmlns:util="jelly:util">
+
+ <goal name="run">
+ <attainGoal name="run-maven" />
+ <attainGoal name="run-reactor" />
+ </goal>
+
+ <goal name="run-maven">
+ <delete dir="subproject/target" quiet="true"/>
+
+ <maven:maven
+ descriptor="subproject/project.xml"
+ goals="java:jar-resources"
+ ignoreFailures="false"
+ />
+
+ <util:available file="subproject/target/classes/test.properties">
+ <j:set var="resourcesCopied" value="true"/>
+ </util:available>
+ <j:if test="${resourcesCopied != 'true'}">
+ <fail>resource:copy fails for subproject using maven:maven</fail>
+ </j:if>
+ </goal>
+
+ <goal name="run-reactor">
+ <delete dir="subproject/target" quiet="true"/>
+
+ <maven:reactor
+ basedir="${basedir}"
+ includes="*/project.xml"
+ goals="java:jar-resources"
+ banner="Building"
+ ignoreFailures="false"
+ />
+
+ <util:available file="subproject/target/classes/test.properties">
+ <j:set var="resourcesCopied" value="true"/>
+ </util:available>
+ <j:if test="${resourcesCopied != 'true'}">
+ <fail>resource:copy fails for subproject using maven:reactor</fail>
+ </j:if>
+ </goal>
+
+</project>
1.2 +25 -0 maven/src/test/basedir/extend-2/project.xml
1.34 +1 -1 maven/src/test/touchstone-build/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven/src/test/touchstone-build/project.xml,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- project.xml 27 Jul 2003 23:34:01 -0000 1.33
+++ project.xml 19 Aug 2003 04:45:37 -0000 1.34
@@ -148,7 +148,7 @@
<dependency>
<id>commons-jelly</id>
- <version>20030211.141339</version>
+ <version>20030724.033229</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
1.39 +117 -27 maven/src/test/touchstone-build/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/maven/src/test/touchstone-build/maven.xml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- maven.xml 31 Jul 2003 03:00:34 -0000 1.38
+++ maven.xml 19 Aug 2003 04:45:37 -0000 1.39
@@ -1,6 +1,7 @@
<project
default="jar:jar"
xmlns:j="jelly:core"
+ xmlns:ant="jelly:ant"
xmlns:u="jelly:util"
xmlns:i="jelly:interaction"
xmlns:maven="jelly:maven"
@@ -53,14 +54,8 @@
<goal name="touchstone-tests">
<attainGoal name="touchstone-goal-A"/>
- <j:set var="checkValue"
value="${pluginContexts.touchstone.getVariable('touchstone_goal_A_from_plugin')}"/>
- <echo>
- The checkValue should not be set because the goal has been overridden
- in this maven.xml file. The original goal set the checkValue to 'true'
- while the overridden goal does nothing.
- </echo>
- <echo>checkValue = ${checkValue}</echo>
- <j:if test="${checkValue}">
+ <j:set var="checkValue"
value="${pom.getPluginContext('maven-touchstone-plugin').getVariable('touchstone_goal_A_from_plugin')}"/>
+ <j:if test="${checkValue == 'true'}">
<fail message="">
Goal should have been overriden. We have an internal error
processing goals.
@@ -68,9 +63,8 @@
</j:if>
<attainGoal name="touchstone-goal-B"/>
- <j:set var="checkValue"
value="${pluginContexts.touchstone.getVariable('touchstone_goal_B_from_plugin')}"/>
- <echo>checkValue = ${checkValue}</echo>
- <j:if test="${!checkValue}">
+ <j:set var="checkValue"
value="${pom.getPluginContext('maven-touchstone-plugin').getVariable('touchstone_goal_B_from_plugin')}"/>
+ <j:if test="${checkValue != 'true'}">
<fail message="">
Goal should be used from the touchstone plugin. We have an internal
error processing goals.
@@ -78,24 +72,32 @@
</j:if>
<attainGoal name="test-addPath"/>
-
- <echo>pom.compileSourceRoots = ${pom.compileSourceRoots}</echo>
-
- <!--
- <j:if test="${context.antProject.getReferences().get('testPath') !=
resultantPath}">
+ <j:choose>
+ <j:when test="${systemScope['os.name'].startsWith('Windows')}">
+ <property name="testPath1Prop" refid="testPath1" />
+ <property name="testPath2Prop" refid="testPath2" />
+ <j:set var="resultantPath"
value="${testPath1Prop}${systemScope['path.separator']}${testPath2Prop}"/>
+ </j:when>
+ <j:otherwise>
+ <j:set var="resultantPath" value="/path1:/path2"/>
+ </j:otherwise>
+ </j:choose>
+
+ <j:if test="${pom.antProject.getReferences().get('testPath') != resultantPath}">
<property name="testPathProp" refid="testPath" />
<property name="testPath1Prop" refid="testPath1" />
<property name="testPath2Prop" refid="testPath2" />
<fail message="">
Paths were not correctly appended. Internal error in the maven:addPath tag.
- testPath = ${context.antProject.getReferences().get('testPath')}
+ testPath = ${pom.antProject.getReferences().get('testPath')}
resultantPath = ${resultantPath}
testPath1 = ${testPath1Prop}
testPath2 = ${testPath2Prop}
</fail>
</j:if>
- -->
+ <attainGoal name="test-make-absolute-path" />
+ <attainGoal name="test-make-relative-path" />
<attainGoal name="test-plugin-property-override"/>
<j:set var="mavenTouchstoneA" value="${maven.touchstone.A}"/>
@@ -133,10 +135,9 @@
|
-->
<attainGoal name="touchstone-goal-C"/>
- <j:set var="checkValue"
value="${plugins.get('touchstone-partner').get('touchstone_partner_preGoal_C')}"/>
- <echo>checkValue = ${checkValue}</echo>
- <maven:display var="checkValue"/>
- <j:if test="${!checkValue}">
+ <j:set var="checkValue"
value="${pom.getPluginContext('maven-touchstone-partner-plugin').getVariable('touchstone_partner_preGoal_C')}"/>
+ <echo>checkValue = ${checkValue}</echo>
+ <j:if test="${checkValue != 'true'}">
<fail message="">
Inter-plugin preGoals are not being dealt with correctly.
@@ -150,10 +151,9 @@
|
-->
<attainGoal name="touchstone-goal-D"/>
- <j:set var="checkValue"
value="${plugins.get('touchstone-partner').get('touchstone_partner_preGoal_D')}"/>
+ <j:set var="checkValue"
value="${pom.getPluginContext('maven-touchstone-partner-plugin').getVariable('touchstone_partner_preGoal_D')}"/>
<echo>checkValue = ${checkValue}</echo>
- <maven:display var="checkValue"/>
- <j:if test="${!checkValue}">
+ <j:if test="${checkValue != 'true'}">
<fail message="">
Inter-plugin preGoals are not being dealt with correctly.
@@ -161,6 +161,18 @@
</fail>
</j:if>
+ <attainGoal name="test-mavenjellyscope"/>
+ <j:if test="${context.findVariable('test-mavenjellyscope') != 'success'}">
+ <fail>
+ Problem with scope factory method - $${test-mavenjellyscope} should have
been set to 'success'
+ but was set to '${test-mavenjellyscope}'.
+ </fail>
+ </j:if>
+
+ <!--
+ <attainGoal name="test-reactor-maven-username"/>
+ -->
+
</goal>
<!--
@@ -232,8 +244,19 @@
-->
<goal name="test-addPath">
- <maven:addPath id="maven.compile.src.set" path="/path1"/>
- <maven:addPath id="maven.compile.src.set" path="/path2"/>
+ <path id="testPath1">
+ <pathelement location="/path1"/>
+ </path>
+
+ <path id="testPath2">
+ <pathelement location="/path2"/>
+ </path>
+
+ <path id="testPath">
+ </path>
+
+ <maven:addPath id="testPath" refid="testPath1"/>
+ <maven:addPath id="testPath" refid="testPath2"/>
</goal>
@@ -282,6 +305,28 @@
</echo>
</goal>
+ <goal
+ xmlns:testmavenjellyscope="test-mavenjellyscope"
+ name="test-mavenjellyscope"
+ description="throws a ClassCastException when loading the jelly script from a
nested maven session.">
+ <!--
+ |
+ | The purpose of this defined tag is to get jelly to create a new scope from
the one it has.
+ | If the factory methods aren't defined, then the scope is not the correct
type, and
+ | BaseTagSupport.getMavenContext throws a ClassCastException.
+ -->
+ <define:taglib uri="test-mavenjellyscope">
+ <define:tag name="runmaven">
+ <maven:maven descriptor="${basedir}/project.xml"
goals="test-mavenjellyscope-helper" />
+ </define:tag>
+ </define:taglib>
+ <testmavenjellyscope:runmaven/>
+ </goal>
+
+ <goal name="test-mavenjellyscope-helper">
+ <j:set var="test-mavenjellyscope" scope="parent" value="success"/>
+ </goal>
+
<!--
| This preGoal test does NOT work at the moment. This is just a
| reminder for me to get it working.
@@ -304,6 +349,51 @@
A defined property with dots in the name is wrongly treated as null
even though the value is ${dot.property}
</fail>
+ </j:if>
+ </goal>
+
+ <!--
+ | Test the make-absolute-path tag
+ |-->
+ <goal name="test-make-absolute-path">
+ <maven:make-absolute-path var="testVar" basedir="${basedir}" path="project.xml"
/>
+ <u:file var="testVar2" name="${basedir}/project.xml" />
+ <j:if test="${testVar != testVar2.canonicalPath}">
+ <ant:fail>
+ make-absolute-path:
+ testVar = '${testVar}'; should be: '${testVar2}'
+ </ant:fail>
+ </j:if>
+
+ <maven:make-absolute-path var="testVar" basedir="${basedir}" path="src/main" />
+ <u:file var="testVar2" name="${basedir}/src/main"/>
+ <j:if test="${testVar != testVar2.canonicalPath}">
+ <ant:fail>
+ make-absolute-path:
+ testVar = '${testVar}'; should be: '${testVar2}'
+ </ant:fail>
+ </j:if>
+ </goal>
+
+ <!--
+ | Test the make-relative-path tag
+ |-->
+ <goal name="test-make-relative-path">
+ <maven:make-relative-path var="testVar" basedir="${basedir}"
path="${basedir}/project.xml" />
+ <j:if test="${testVar != 'project.xml'}">
+ <ant:fail>
+ make-relative-path:
+ testVar = '${testVar}'; should be: 'project.xml'
+ </ant:fail>
+ </j:if>
+
+ <maven:make-relative-path var="testVar" basedir="${basedir}"
path="${basedir}/src/main" />
+ <j:set var="testVar2" value="src${file.separator}main"/>
+ <j:if test="${testVar != testVar2}">
+ <ant:fail>
+ make-relative-path:
+ testVar = '${testVar}'; should be: '${testVar2}'
+ </ant:fail>
</j:if>
</goal>
1.7 +15 -3
maven/src/test/java/org/apache/maven/jelly/tags/maven/DependencyResolverTest.java
Index: DependencyResolverTest.java
===================================================================
RCS file:
/home/cvs/maven/src/test/java/org/apache/maven/jelly/tags/maven/DependencyResolverTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DependencyResolverTest.java 6 Aug 2003 10:42:44 -0000 1.6
+++ DependencyResolverTest.java 19 Aug 2003 04:45:37 -0000 1.7
@@ -72,8 +72,10 @@
public void testSimple1() throws Exception {
List projects = DependencyResolverTestData.getTestSimple1();
- testSimple1(new GraphDependencyResolver(), projects);
- testSimple1(new WerkzDependencyResolver(), projects);
+ testSimple1Source(new GraphDependencyResolver(), projects);
+ testSimple1Binary(new GraphDependencyResolver(), projects);
+ testSimple1Source(new WerkzDependencyResolver(), projects);
+ testSimple1Binary(new WerkzDependencyResolver(), projects);
}
public void testSimple2() throws Exception {
@@ -118,7 +120,7 @@
}
}
- public void testSimple1(DependencyResolverInterface dri, List projects) throws
Exception {
+ public void testSimple1Source(DependencyResolverInterface dri, List projects)
throws Exception {
DependencyResolver dr = new DependencyResolver(dri);
dr.setProjects(projects);
@@ -135,6 +137,16 @@
assertEquals("test1.sorted", "b:b,e:e,n:n",
listify(dri.getSortedDependencies(n, true)));
Project j = DependencyResolver.getProject(projects, "j:j");
assertEquals("test1.sorted", "b:b,e:e,n:n,j:j",
listify(dri.getSortedDependencies(j, true)));
+ }
+
+ /**
+ * @todo THIS IS A DUPLICATE of testSimple1Source
+ * @param dri dependency resolver
+ * @param projects list of projects to resolve
+ * @throws Exception when anything happens
+ */
+ public void testSimple1Binary(DependencyResolverInterface dri, List projects)
throws Exception {
+ testSimple1Source(dri, projects);
}
public void testSimple2(DependencyResolverInterface dri, List projects) throws
Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]