bodewig 00/07/25 01:44:16
Modified: . build.xml
src/testcases/org/apache/tools/ant AllJUnitTests.java
src/testcases/org/apache/tools/ant/types AllJUnitTests.java
CommandlineJavaTest.java
Added: src/testcases/org/apache/tools/ant/types
EnumeratedAttributeTest.java PathTest.java
Removed: src/testcases/org/apache/tools/ant
EnumeratedAttributeTest.java PathTest.java
Log:
Changed testcases to reflect the new packages of Path and
EnumeratedAttribute.
Revision Changes Path
1.47 +2 -0 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- build.xml 2000/07/25 08:30:36 1.46
+++ build.xml 2000/07/25 08:44:08 1.47
@@ -259,6 +259,8 @@
<exclude name="**/EnumeratedAttributeTest.java" unless="junit.present"
/>
<exclude name="**/IntrospectionHelperTest.java" unless="junit.present"
/>
<exclude name="**/PathTest.java" unless="junit.present" />
+ <exclude name="**/CommandlineTest.java" unless="junit.present" />
+ <exclude name="**/CommandlineJavaTest.java" unless="junit.present" />
</javac>
</target>
1.4 +0 -2
jakarta-ant/src/testcases/org/apache/tools/ant/AllJUnitTests.java
Index: AllJUnitTests.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/AllJUnitTests.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AllJUnitTests.java 2000/07/19 13:00:44 1.3
+++ AllJUnitTests.java 2000/07/25 08:44:09 1.4
@@ -71,8 +71,6 @@
public static Test suite() {
TestSuite suite = new TestSuite(IntrospectionHelperTest.class);
- suite.addTest(new TestSuite(EnumeratedAttributeTest.class));
- suite.addTest(new TestSuite(PathTest.class));
suite.addTest(org.apache.tools.ant.types.AllJUnitTests.suite());
return suite;
}
1.2 +2 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/AllJUnitTests.java
Index: AllJUnitTests.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/AllJUnitTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AllJUnitTests.java 2000/07/19 13:00:46 1.1
+++ AllJUnitTests.java 2000/07/25 08:44:12 1.2
@@ -72,6 +72,8 @@
public static Test suite() {
TestSuite suite = new TestSuite(CommandlineTest.class);
suite.addTest(new TestSuite(CommandlineJavaTest.class));
+ suite.addTest(new TestSuite(EnumeratedAttributeTest.class));
+ suite.addTest(new TestSuite(PathTest.class));
return suite;
}
}
1.2 +11 -2
jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java
Index: CommandlineJavaTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommandlineJavaTest.java 2000/07/19 13:00:46 1.1
+++ CommandlineJavaTest.java 2000/07/25 08:44:12 1.2
@@ -54,6 +54,8 @@
package org.apache.tools.ant.types;
+import org.apache.tools.ant.Project;
+
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
@@ -70,6 +72,13 @@
super(name);
}
+ private Project project;
+
+ public void setUp() {
+ project = new Project();
+ project.setBasedir(".");
+ }
+
public void testGetCommandline() {
CommandlineJava c = new CommandlineJava();
c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest");
@@ -83,8 +92,8 @@
assertEquals("no classpath",
"org.apache.tools.ant.CommandlineJavaTest", s[3]);
- c.createClasspath().setLocation("junit.jar");
- c.createClasspath().setLocation("ant.jar");
+ c.createClasspath(project).setLocation("junit.jar");
+ c.createClasspath(project).setLocation("ant.jar");
s = c.getCommandline();
assertEquals("with classpath", 6, s.length);
assertEquals("with classpath", "java", s[0]);
1.1
jakarta-ant/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java
Index: EnumeratedAttributeTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.types;
import org.apache.tools.ant.BuildException;
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
/**
* JUnit 3 testcases for org.apache.tools.ant.EnumeratedAttribute.
*
* @author Stefan Bodewig <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
*/
public class EnumeratedAttributeTest extends TestCase {
private static String[] expected = {"a", "b", "c"};
public EnumeratedAttributeTest(String name) {
super(name);
}
public void testContains() {
EnumeratedAttribute t1 = new TestNormal();
for (int i=0; i<expected.length; i++) {
assert(expected[i]+" is in TestNormal",
t1.containsValue(expected[i]));
assert(expected[i].toUpperCase()+" is in TestNormal",
!t1.containsValue(expected[i].toUpperCase()));
}
assert("TestNormal doesn\'t have \"d\" attribute",
!t1.containsValue("d"));
assert("TestNull doesn\'t have \"d\" attribute and doesn\'t die",
!(new TestNull()).containsValue("d"));
}
public void testExceptions() {
EnumeratedAttribute t1 = new TestNormal();
for (int i=0; i<expected.length; i++) {
try {
t1.setValue(expected[i]);
} catch (BuildException be) {
fail("unexpected exception for value "+expected[i]);
}
}
try {
t1.setValue("d");
fail("expected exception for value \"d\"");
} catch (BuildException be) {
}
try {
(new TestNull()).setValue("d");
fail("expected exception for value \"d\" in TestNull");
} catch (BuildException be) {
} catch (Throwable other) {
fail("unexpected death of TestNull: "+other.getMessage());
}
}
public static class TestNormal extends EnumeratedAttribute {
public String[] getValues() {
return expected;
}
}
public static class TestNull extends EnumeratedAttribute {
public String[] getValues() {
return null;
}
}
}
1.1
jakarta-ant/src/testcases/org/apache/tools/ant/types/PathTest.java
Index: PathTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.types;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
import java.io.File;
/**
* JUnit 3 testcases for org.apache.tools.ant.Path
*
* @author Stefan Bodewig <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
*/
public class PathTest extends TestCase {
public static boolean isUnixStyle = File.pathSeparatorChar == ':';
private Project project;
public PathTest(String name) {
super(name);
}
public void setUp() {
project = new Project();
project.setBasedir(".");
}
// actually tests constructor as well as setPath
public void testConstructor() {
Path p = new Path(project, "/a:/b");
String[] l = p.list();
assertEquals("two items, Unix style", 2, l.length);
if (isUnixStyle) {
assertEquals("/a", l[0]);
assertEquals("/b", l[1]);
} else {
assertEquals("\\a", l[0]);
assertEquals("\\b", l[1]);
}
p = new Path(project, "\\a;\\b");
l = p.list();
assertEquals("two items, DOS style", 2, l.length);
if (isUnixStyle) {
assertEquals("/a", l[0]);
assertEquals("/b", l[1]);
} else {
assertEquals("\\a", l[0]);
assertEquals("\\b", l[1]);
}
p = new Path(project, "\\a;\\b:/c");
l = p.list();
assertEquals("three items, mixed style", 3, l.length);
if (isUnixStyle) {
assertEquals("/a", l[0]);
assertEquals("/b", l[1]);
assertEquals("/c", l[2]);
} else {
assertEquals("\\a", l[0]);
assertEquals("\\b", l[1]);
assertEquals("\\c", l[2]);
}
p = new Path(project, "c:\\test");
l = p.list();
if (isUnixStyle) {
assertEquals("no drives on Unix", 2, l.length);
assertEquals("c", l[0]);
assertEquals("/test", l[1]);
} else {
assertEquals("drives on DOS", 1, l.length);
assertEquals("c:\\test", l[0]);
}
p = new Path(project, "c:/test");
l = p.list();
if (isUnixStyle) {
assertEquals("no drives on Unix", 2, l.length);
assertEquals("c", l[0]);
assertEquals("/test", l[1]);
} else {
assertEquals("drives on DOS", 1, l.length);
assertEquals("c:\\test", l[0]);
}
}
public void testSetLocation() {
Path p = new Path(project);
p.setLocation("/a");
String[] l = p.list();
if (isUnixStyle) {
assertEquals(1, l.length);
assertEquals("/a", l[0]);
} else {
assertEquals(1, l.length);
assertEquals("\\a", l[0]);
}
p = new Path(project);
p.setLocation("\\a");
l = p.list();
if (isUnixStyle) {
assertEquals(1, l.length);
assertEquals("/a", l[0]);
} else {
assertEquals(1, l.length);
assertEquals("\\a", l[0]);
}
}
public void testAppending() {
Path p = new Path(project, "/a:/b");
String[] l = p.list();
assertEquals("2 after construction", 2, l.length);
p.setLocation("/c");
l = p.list();
assertEquals("3 after setLocation", 3, l.length);
p.setPath("\\d;\\e");
l = p.list();
assertEquals("5 after setPath", 5, l.length);
p.append(new Path(project, "\\f"));
l = p.list();
assertEquals("6 after append", 6, l.length);
}
public void testEmpyPath() {
Path p = new Path(project, "");
String[] l = p.list();
assertEquals("0 after construction", 0, l.length);
p.setLocation("");
l = p.list();
assertEquals("0 after setLocation", 0, l.length);
p.setPath("");
l = p.list();
assertEquals("0 after setPath", 0, l.length);
p.append(new Path(project));
l = p.list();
assertEquals("0 after append", 0, l.length);
}
public void testUnique() {
Path p = new Path(project, "/a:/a");
String[] l = p.list();
assertEquals("1 after construction", 1, l.length);
p.setLocation("\\a");
l = p.list();
assertEquals("1 after setLocation", 1, l.length);
p.setPath("\\a;/a");
l = p.list();
assertEquals("1 after setPath", 1, l.length);
p.append(new Path(project, "/a;\\a:\\a"));
l = p.list();
assertEquals("1 after append", 1, l.length);
}
}