@@ -87,13 +87,18 @@ public class XmlPropertyTest extends BuildFileTest {
executeTarget("test");
executeTarget("test");
assertEquals("true", getProject().getProperty("root-tag(myattr)"));
assertEquals("true", getProject().getProperty("root-tag(myattr)"));
assertEquals("Text", getProject().getProperty("root-tag.inner-tag"));
assertEquals("Text", getProject().getProperty("root-tag.inner-tag"));
assertEquals("val",
assertEquals("val",
getProject().getProperty("root-tag.inner-tag(someattr)"));
getProject().getProperty("root-tag.inner-tag(someattr)"));
assertEquals("false", getProject().getProperty("root-tag.a2.a3.a4"));
assertEquals("false", getProject().getProperty("root-tag.a2.a3.a4"));
assertEquals("CDATA failed",
assertEquals("CDATA failed",
"<test>", getProject().getProperty("root-tag.cdatatag"));
"<test>", getProject().getProperty("root-tag.cdatatag"));
}
}
public void testDTD() {
executeTarget("testdtd");
assertEquals("Text", getProject().getProperty("root-tag.inner-tag"));
}
public void testNone () {
public void testNone () {
doTest("testNone", false, false, false, false, false);
doTest("testNone", false, false, false, false, false);
}
}
@@ -144,7 +149,7 @@ public class XmlPropertyTest extends BuildFileTest {
*/
*/
private void doTest(String msg, boolean keepRoot, boolean collapse,
private void doTest(String msg, boolean keepRoot, boolean collapse,
boolean semantic, boolean include, boolean localRoot) {
boolean semantic, boolean include, boolean localRoot) {
Enumeration iter =
Enumeration iter =
getFiles(new File("src/etc/testcases/taskdefs/xmlproperty/inputs"));
getFiles(new File("src/etc/testcases/taskdefs/xmlproperty/inputs"));
while (iter.hasMoreElements()) {
while (iter.hasMoreElements()) {
File inputFile = (File) iter.nextElement();
File inputFile = (File) iter.nextElement();
@@ -162,8 +167,8 @@ public class XmlPropertyTest extends BuildFileTest {
File propertyFile = getGoldfile(inputFile, keepRoot, collapse,
File propertyFile = getGoldfile(inputFile, keepRoot, collapse,
semantic, include, localRoot);
semantic, include, localRoot);
if (!propertyFile.exists()) {
if (!propertyFile.exists()) {
// System.out.println("Skipping as "
// + propertyFile.getAbsolutePath()
// System.out.println("Skipping as "
// + propertyFile.getAbsolutePath()
// + ") doesn't exist.");
// + ") doesn't exist.");
continue;
continue;
}
}
@@ -209,15 +214,15 @@ public class XmlPropertyTest extends BuildFileTest {
* but some other properties may get set in the XmlProperty due
* but some other properties may get set in the XmlProperty due
* to generic Project/Task configuration.
* to generic Project/Task configuration.
*/
*/
private static void ensureProperties (String msg, File inputFile,
File workingDir, Project project,
private static void ensureProperties (String msg, File inputFile,
File workingDir, Project project,
Properties properties) {
Properties properties) {
Hashtable xmlproperties = project.getProperties();
Hashtable xmlproperties = project.getProperties();
// Every key identified by the Properties must have been loaded.
// Every key identified by the Properties must have been loaded.
Enumeration propertyKeyEnum = properties.propertyNames();
Enumeration propertyKeyEnum = properties.propertyNames();
while(propertyKeyEnum.hasMoreElements()){
while(propertyKeyEnum.hasMoreElements()){
String currentKey = propertyKeyEnum.nextElement().toString();
String currentKey = propertyKeyEnum.nextElement().toString();
String assertMsg = msg + "-" + inputFile.getName()
String assertMsg = msg + "-" + inputFile.getName()
+ " Key=" + currentKey;
+ " Key=" + currentKey;
String propertyValue = properties.getProperty(currentKey);
String propertyValue = properties.getProperty(currentKey);
@@ -238,11 +243,11 @@ public class XmlPropertyTest extends BuildFileTest {
}
}
// What is the property supposed to be?
// What is the property supposed to be?
propertyValue =
propertyValue =
propertyValue.substring(3, propertyValue.length());
propertyValue.substring(3, propertyValue.length());
if (propertyValue.equals("path")) {
if (propertyValue.equals("path")) {
if (!(obj instanceof Path)) {
if (!(obj instanceof Path)) {
fail(assertMsg + " Path ID is a "
fail(assertMsg + " Path ID is a "
+ obj.getClass().getName());
+ obj.getClass().getName());
}
}
} else {
} else {
@@ -255,7 +260,7 @@ public class XmlPropertyTest extends BuildFileTest {
// The property is the name of a file. We are testing
// The property is the name of a file. We are testing
// a location attribute, so we need to resolve the given
// a location attribute, so we need to resolve the given
// file name in the provided folder.
// file name in the provided folder.
String fileName =
String fileName =
propertyValue.substring(5, propertyValue.length());
propertyValue.substring(5, propertyValue.length());
File f = new File(workingDir, fileName);
File f = new File(workingDir, fileName);
propertyValue = f.getAbsolutePath();
propertyValue = f.getAbsolutePath();
@@ -274,7 +279,7 @@ public class XmlPropertyTest extends BuildFileTest {
Enumeration keyEnum = xmlproperties.keys();
Enumeration keyEnum = xmlproperties.keys();
while (keyEnum.hasMoreElements()) {
while (keyEnum.hasMoreElements()) {
String currentKey = keyEnum.nextElement().toString();
String currentKey = keyEnum.nextElement().toString();
System.out.println(currentKey + " = "
System.out.println(currentKey + " = "
+ xmlproperties.get(currentKey));
+ xmlproperties.get(currentKey));
}
}
}
}
@@ -282,7 +287,7 @@ public class XmlPropertyTest extends BuildFileTest {
/**
/**
* Ensure all references loaded by the project are valid.
* Ensure all references loaded by the project are valid.
*/
*/
private static void ensureReferences (String msg, File inputFile,
private static void ensureReferences (String msg, File inputFile,
Hashtable references) {
Hashtable references) {
Enumeration referenceKeyEnum = references.keys();
Enumeration referenceKeyEnum = references.keys();
while(referenceKeyEnum.hasMoreElements()){
while(referenceKeyEnum.hasMoreElements()){
@@ -293,7 +298,7 @@ public class XmlPropertyTest extends BuildFileTest {
} else if (currentValue instanceof String) {
} else if (currentValue instanceof String) {
} else {
} else {
if( ! currentKey.startsWith("ant.") ) {
if( ! currentKey.startsWith("ant.") ) {
fail(msg + "-" + inputFile.getName() + " Key="
fail(msg + "-" + inputFile.getName() + " Key="
+ currentKey + " is not a recognized type.");
+ currentKey + " is not a recognized type.");
}
}
}
}
@@ -304,16 +309,16 @@ public class XmlPropertyTest extends BuildFileTest {
* Munge the name of the input file to find an appropriate goldfile,
* Munge the name of the input file to find an appropriate goldfile,
* based on hardwired naming conventions.
* based on hardwired naming conventions.
*/
*/
private static File getGoldfile (File input, boolean keepRoot,
boolean collapse, boolean semantic,
private static File getGoldfile (File input, boolean keepRoot,
boolean collapse, boolean semantic,
boolean include, boolean localRoot) {
boolean include, boolean localRoot) {
// Substitute .xml with .properties
// Substitute .xml with .properties
String baseName = input.getName().toLowerCase();
String baseName = input.getName().toLowerCase();
if (baseName.endsWith(".xml")) {
if (baseName.endsWith(".xml")) {
baseName = baseName.substring(0, baseName.length() - 4)
baseName = baseName.substring(0, baseName.length() - 4)
+ ".properties";
+ ".properties";
}
}
File dir = fileUtils.getParentFile(fileUtils.getParentFile(input));
File dir = fileUtils.getParentFile(fileUtils.getParentFile(input));
String goldFileFolder = "goldfiles/";
String goldFileFolder = "goldfiles/";