Browse Source

whitespace and 2005

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@292278 13f79535-47bb-0310-9956-ffa450edef68
remotes/1773197322428371321/tmp_d824eac4d98e22a968974dea8f175894a989c3de
Stefan Bodewig 20 years ago
parent
commit
77cdf2de58
12 changed files with 405 additions and 405 deletions
  1. +258
    -258
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  2. +17
    -17
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  3. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  4. +23
    -23
      src/main/org/apache/tools/ant/taskdefs/Untar.java
  5. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
  6. +8
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  7. +46
    -46
      src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java
  8. +34
    -34
      src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
  9. +7
    -7
      src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java
  10. +4
    -4
      src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java
  11. +2
    -2
      src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java
  12. +2
    -2
      src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java

+ 258
- 258
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -63,7 +63,7 @@ public class AntStructure extends Task {
* @since Ant 1.7
*/
public void add(StructurePrinter p) {
printer = p;
printer = p;
}

/**
@@ -92,8 +92,8 @@ public class AntStructure extends Task {
}

printer.printHead(out, getProject(),
getProject().getTaskDefinitions(),
getProject().getDataTypeDefinitions());
getProject().getTaskDefinitions(),
getProject().getDataTypeDefinitions());

printer.printTargetDecl(out);

@@ -101,21 +101,21 @@ public class AntStructure extends Task {
while (dataTypes.hasMoreElements()) {
String typeName = (String) dataTypes.nextElement();
printer.printElementDecl(out, getProject(), typeName,
(Class) getProject().getDataTypeDefinitions().get(typeName));
(Class) getProject().getDataTypeDefinitions().get(typeName));
}

Enumeration tasks = getProject().getTaskDefinitions().keys();
while (tasks.hasMoreElements()) {
String tName = (String) tasks.nextElement();
printer.printElementDecl(out, getProject(), tName,
(Class) getProject().getTaskDefinitions().get(tName));
(Class) getProject().getTaskDefinitions().get(tName));
}

printer.printTail(out);
printer.printTail(out);

} catch (IOException ioe) {
throw new BuildException("Error writing "
+ output.getAbsolutePath(), ioe, getLocation());
+ output.getAbsolutePath(), ioe, getLocation());
} finally {
if (out != null) {
out.close();
@@ -133,293 +133,293 @@ public class AntStructure extends Task {
* each declared task and type.</p>
*/
public static interface StructurePrinter {
/**
* Prints the header of the generated output.
*
* @param out PrintWriter to write to.
* @param p Project instance for the current task
* @param tasks map (name to implementing class)
* @param types map (name to implementing class)
* data types.
*/
void printHead(PrintWriter out, Project p, Hashtable tasks,
Hashtable types);
/**
* Prints the definition for the target element.
* @param out PrintWriter to write to.
*/
void printTargetDecl(PrintWriter out);
/**
* Print the definition for a given element.
*
* @param out PrintWriter to write to.
* @param p Project instance for the current task
* @param name element name.
* @param name class of the defined element.
*/
void printElementDecl(PrintWriter out, Project p, String name,
Class element);
/**
* Prints the trailer.
* @param out PrintWriter to write to.
*/
void printTail(PrintWriter out);
/**
* Prints the header of the generated output.
*
* @param out PrintWriter to write to.
* @param p Project instance for the current task
* @param tasks map (name to implementing class)
* @param types map (name to implementing class)
* data types.
*/
void printHead(PrintWriter out, Project p, Hashtable tasks,
Hashtable types);
/**
* Prints the definition for the target element.
* @param out PrintWriter to write to.
*/
void printTargetDecl(PrintWriter out);
/**
* Print the definition for a given element.
*
* @param out PrintWriter to write to.
* @param p Project instance for the current task
* @param name element name.
* @param name class of the defined element.
*/
void printElementDecl(PrintWriter out, Project p, String name,
Class element);
/**
* Prints the trailer.
* @param out PrintWriter to write to.
*/
void printTail(PrintWriter out);
}

private static class DTDPrinter implements StructurePrinter {

private static final String BOOLEAN = "%boolean;";
private static final String TASKS = "%tasks;";
private static final String TYPES = "%types;";
private static final String BOOLEAN = "%boolean;";
private static final String TASKS = "%tasks;";
private static final String TYPES = "%types;";

private Hashtable visited = new Hashtable();
private Hashtable visited = new Hashtable();

public void printTail(PrintWriter out) {
visited.clear();
}
public void printTail(PrintWriter out) {
visited.clear();
}

public void printHead(PrintWriter out, Project p, Hashtable tasks, Hashtable types) {
printHead(out, tasks.keys(), types.keys());
}
public void printHead(PrintWriter out, Project p, Hashtable tasks, Hashtable types) {
printHead(out, tasks.keys(), types.keys());
}


/**
* Prints the header of the generated output.
*
* <p>Basically this prints the XML declaration, defines some
* entities and the project element.</p>
*/
private void printHead(PrintWriter out, Enumeration tasks,
Enumeration types) {
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">");
out.print("<!ENTITY % tasks \"");
boolean first = true;
while (tasks.hasMoreElements()) {
String tName = (String) tasks.nextElement();
if (!first) {
out.print(" | ");
} else {
first = false;
/**
* Prints the header of the generated output.
*
* <p>Basically this prints the XML declaration, defines some
* entities and the project element.</p>
*/
private void printHead(PrintWriter out, Enumeration tasks,
Enumeration types) {
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
out.println("<!ENTITY % boolean \"(true|false|on|off|yes|no)\">");
out.print("<!ENTITY % tasks \"");
boolean first = true;
while (tasks.hasMoreElements()) {
String tName = (String) tasks.nextElement();
if (!first) {
out.print(" | ");
} else {
first = false;
}
out.print(tName);
}
out.print(tName);
}
out.println("\">");
out.print("<!ENTITY % types \"");
first = true;
while (types.hasMoreElements()) {
String typeName = (String) types.nextElement();
if (!first) {
out.print(" | ");
} else {
first = false;
out.println("\">");
out.print("<!ENTITY % types \"");
first = true;
while (types.hasMoreElements()) {
String typeName = (String) types.nextElement();
if (!first) {
out.print(" | ");
} else {
first = false;
}
out.print(typeName);
}
out.print(typeName);
}
out.println("\">");

out.println("");

out.print("<!ELEMENT project (target | ");
out.print(TASKS);
out.print(" | ");
out.print(TYPES);
out.println(")*>");
out.println("<!ATTLIST project");
out.println(" name CDATA #IMPLIED");
out.println(" default CDATA #IMPLIED");
out.println(" basedir CDATA #IMPLIED>");
out.println("");
}

/**
* Prints the definition for the target element.
*/
public void printTargetDecl(PrintWriter out) {
out.print("<!ELEMENT target (");
out.print(TASKS);
out.print(" | ");
out.print(TYPES);
out.println(")*>");
out.println("");

out.println("<!ATTLIST target");
out.println(" id ID #IMPLIED");
out.println(" name CDATA #REQUIRED");
out.println(" if CDATA #IMPLIED");
out.println(" unless CDATA #IMPLIED");
out.println(" depends CDATA #IMPLIED");
out.println(" description CDATA #IMPLIED>");
out.println("");
}

/**
* Print the definition for a given element.
*/
public void printElementDecl(PrintWriter out, Project p,
String name, Class element) {

if (visited.containsKey(name)) {
return;
out.println("\">");

out.println("");

out.print("<!ELEMENT project (target | ");
out.print(TASKS);
out.print(" | ");
out.print(TYPES);
out.println(")*>");
out.println("<!ATTLIST project");
out.println(" name CDATA #IMPLIED");
out.println(" default CDATA #IMPLIED");
out.println(" basedir CDATA #IMPLIED>");
out.println("");
}
visited.put(name, "");

IntrospectionHelper ih = null;
try {
ih = IntrospectionHelper.getHelper(p, element);
} catch (Throwable t) {
/*
* XXX - failed to load the class properly.
*
* should we print a warning here?
*/
return;
/**
* Prints the definition for the target element.
*/
public void printTargetDecl(PrintWriter out) {
out.print("<!ELEMENT target (");
out.print(TASKS);
out.print(" | ");
out.print(TYPES);
out.println(")*>");
out.println("");

out.println("<!ATTLIST target");
out.println(" id ID #IMPLIED");
out.println(" name CDATA #REQUIRED");
out.println(" if CDATA #IMPLIED");
out.println(" unless CDATA #IMPLIED");
out.println(" depends CDATA #IMPLIED");
out.println(" description CDATA #IMPLIED>");
out.println("");
}

StringBuffer sb = new StringBuffer("<!ELEMENT ");
sb.append(name).append(" ");
/**
* Print the definition for a given element.
*/
public void printElementDecl(PrintWriter out, Project p,
String name, Class element) {

if (org.apache.tools.ant.types.Reference.class.equals(element)) {
sb.append("EMPTY>").append(lSep);
sb.append("<!ATTLIST ").append(name);
sb.append(lSep).append(" id ID #IMPLIED");
sb.append(lSep).append(" refid IDREF #IMPLIED");
sb.append(">").append(lSep);
out.println(sb);
return;
}
if (visited.containsKey(name)) {
return;
}
visited.put(name, "");

Vector v = new Vector();
if (ih.supportsCharacters()) {
v.addElement("#PCDATA");
}
IntrospectionHelper ih = null;
try {
ih = IntrospectionHelper.getHelper(p, element);
} catch (Throwable t) {
/*
* XXX - failed to load the class properly.
*
* should we print a warning here?
*/
return;
}

if (TaskContainer.class.isAssignableFrom(element)) {
v.addElement(TASKS);
}
StringBuffer sb = new StringBuffer("<!ELEMENT ");
sb.append(name).append(" ");

if (org.apache.tools.ant.types.Reference.class.equals(element)) {
sb.append("EMPTY>").append(lSep);
sb.append("<!ATTLIST ").append(name);
sb.append(lSep).append(" id ID #IMPLIED");
sb.append(lSep).append(" refid IDREF #IMPLIED");
sb.append(">").append(lSep);
out.println(sb);
return;
}

Enumeration e = ih.getNestedElements();
while (e.hasMoreElements()) {
v.addElement(e.nextElement());
}
Vector v = new Vector();
if (ih.supportsCharacters()) {
v.addElement("#PCDATA");
}

if (v.isEmpty()) {
sb.append("EMPTY");
} else {
sb.append("(");
final int count = v.size();
for (int i = 0; i < count; i++) {
if (i != 0) {
sb.append(" | ");
}
sb.append(v.elementAt(i));
if (TaskContainer.class.isAssignableFrom(element)) {
v.addElement(TASKS);
}
sb.append(")");
if (count > 1 || !v.elementAt(0).equals("#PCDATA")) {
sb.append("*");

Enumeration e = ih.getNestedElements();
while (e.hasMoreElements()) {
v.addElement(e.nextElement());
}
}
sb.append(">");
out.println(sb);

sb = new StringBuffer("<!ATTLIST ");
sb.append(name);
sb.append(lSep).append(" id ID #IMPLIED");

e = ih.getAttributes();
while (e.hasMoreElements()) {
String attrName = (String) e.nextElement();
if ("id".equals(attrName)) {
continue;

if (v.isEmpty()) {
sb.append("EMPTY");
} else {
sb.append("(");
final int count = v.size();
for (int i = 0; i < count; i++) {
if (i != 0) {
sb.append(" | ");
}
sb.append(v.elementAt(i));
}
sb.append(")");
if (count > 1 || !v.elementAt(0).equals("#PCDATA")) {
sb.append("*");
}
}
sb.append(">");
out.println(sb);

sb.append(lSep).append(" ").append(attrName).append(" ");
Class type = ih.getAttributeType(attrName);
if (type.equals(java.lang.Boolean.class)
|| type.equals(java.lang.Boolean.TYPE)) {
sb.append(BOOLEAN).append(" ");
} else if (Reference.class.isAssignableFrom(type)) {
sb.append("IDREF ");
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) {
try {
EnumeratedAttribute ea =
(EnumeratedAttribute) type.newInstance();
String[] values = ea.getValues();
if (values == null
|| values.length == 0
|| !areNmtokens(values)) {
sb.append("CDATA ");
} else {
sb.append("(");
for (int i = 0; i < values.length; i++) {
if (i != 0) {
sb.append(" | ");
sb = new StringBuffer("<!ATTLIST ");
sb.append(name);
sb.append(lSep).append(" id ID #IMPLIED");

e = ih.getAttributes();
while (e.hasMoreElements()) {
String attrName = (String) e.nextElement();
if ("id".equals(attrName)) {
continue;
}

sb.append(lSep).append(" ").append(attrName).append(" ");
Class type = ih.getAttributeType(attrName);
if (type.equals(java.lang.Boolean.class)
|| type.equals(java.lang.Boolean.TYPE)) {
sb.append(BOOLEAN).append(" ");
} else if (Reference.class.isAssignableFrom(type)) {
sb.append("IDREF ");
} else if (EnumeratedAttribute.class.isAssignableFrom(type)) {
try {
EnumeratedAttribute ea =
(EnumeratedAttribute) type.newInstance();
String[] values = ea.getValues();
if (values == null
|| values.length == 0
|| !areNmtokens(values)) {
sb.append("CDATA ");
} else {
sb.append("(");
for (int i = 0; i < values.length; i++) {
if (i != 0) {
sb.append(" | ");
}
sb.append(values[i]);
}
sb.append(values[i]);
sb.append(") ");
}
sb.append(") ");
} catch (InstantiationException ie) {
sb.append("CDATA ");
} catch (IllegalAccessException ie) {
sb.append("CDATA ");
}
} catch (InstantiationException ie) {
sb.append("CDATA ");
} catch (IllegalAccessException ie) {
} else {
sb.append("CDATA ");
}
} else {
sb.append("CDATA ");
sb.append("#IMPLIED");
}
sb.append("#IMPLIED");
}
sb.append(">").append(lSep);
out.println(sb);

final int count = v.size();
for (int i = 0; i < count; i++) {
String nestedName = (String) v.elementAt(i);
if (!"#PCDATA".equals(nestedName)
&& !TASKS.equals(nestedName)
&& !TYPES.equals(nestedName)) {
printElementDecl(out, p, nestedName, ih.getElementType(nestedName));
sb.append(">").append(lSep);
out.println(sb);

final int count = v.size();
for (int i = 0; i < count; i++) {
String nestedName = (String) v.elementAt(i);
if (!"#PCDATA".equals(nestedName)
&& !TASKS.equals(nestedName)
&& !TYPES.equals(nestedName)) {
printElementDecl(out, p, nestedName, ih.getElementType(nestedName));
}
}
}
}

/**
* Does this String match the XML-NMTOKEN production?
* @param s the string to test
* @return true if the string matches the XML-NMTOKEN
*/
public static final boolean isNmtoken(String s) {
final int length = s.length();
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
// XXX - we are committing CombiningChar and Extender here
if (!Character.isLetterOrDigit(c)
&& c != '.' && c != '-' && c != '_' && c != ':') {
return false;
/**
* Does this String match the XML-NMTOKEN production?
* @param s the string to test
* @return true if the string matches the XML-NMTOKEN
*/
public static final boolean isNmtoken(String s) {
final int length = s.length();
for (int i = 0; i < length; i++) {
char c = s.charAt(i);
// XXX - we are committing CombiningChar and Extender here
if (!Character.isLetterOrDigit(c)
&& c != '.' && c != '-' && c != '_' && c != ':') {
return false;
}
}
return true;
}
return true;
}

/**
* Do the Strings all match the XML-NMTOKEN production?
*
* <p>Otherwise they are not suitable as an enumerated attribute,
* for example.</p>
* @param s the array of string to test
* @return true if all the strings in the array math XML-NMTOKEN
*/
public static final boolean areNmtokens(String[] s) {
for (int i = 0; i < s.length; i++) {
if (!isNmtoken(s[i])) {
return false;
/**
* Do the Strings all match the XML-NMTOKEN production?
*
* <p>Otherwise they are not suitable as an enumerated attribute,
* for example.</p>
* @param s the array of string to test
* @return true if all the strings in the array math XML-NMTOKEN
*/
public static final boolean areNmtokens(String[] s) {
for (int i = 0; i < s.length; i++) {
if (!isNmtoken(s[i])) {
return false;
}
}
return true;
}
return true;
}
}

/**
@@ -428,7 +428,7 @@ public class AntStructure extends Task {
* @return true if the string matches the XML-NMTOKEN
*/
protected boolean isNmtoken(String s) {
return DTDPrinter.isNmtoken(s);
return DTDPrinter.isNmtoken(s);
}

/**
@@ -440,6 +440,6 @@ public class AntStructure extends Task {
* @return true if all the strings in the array math XML-NMTOKEN
*/
protected boolean areNmtokens(String[] s) {
return DTDPrinter.areNmtokens(s);
return DTDPrinter.areNmtokens(s);
}
}

+ 17
- 17
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -103,19 +103,19 @@ public class Expand extends Task {
expandFile(FILE_UTILS, source, dest);
}
}
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
if (!r.isExists()) {
continue;
}
if (r instanceof FileResource) {
expandFile(FILE_UTILS, ((FileResource) r).getFile(), dest);
} else {
expandResource(r, dest);
}
}
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
if (!r.isExists()) {
continue;
}
if (r instanceof FileResource) {
expandFile(FILE_UTILS, ((FileResource) r).getFile(), dest);
} else {
expandResource(r, dest);
}
}
}

/**
@@ -155,8 +155,8 @@ public class Expand extends Task {
* @param dir the destination directory
*/
protected void expandResource(Resource srcR, File dir) {
throw new BuildException("only filesystem based resources are"
+ " supported by this task.");
throw new BuildException("only filesystem based resources are"
+ " supported by this task.");
}

/**
@@ -338,7 +338,7 @@ public class Expand extends Task {
* @param set a file set
*/
public void addFileset(FileSet set) {
add(set);
add(set);
}

/**
@@ -347,7 +347,7 @@ public class Expand extends Task {
* @since Ant 1.7
*/
public void add(ResourceCollection rc) {
resources.add(rc);
resources.add(rc);
}

/**


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -213,11 +213,11 @@ public class Sync extends Task {
// delete them.
for (int i = dirs.length - 1; i >= 0; --i) {
File f = new File(toDir, dirs[i]);
if (f.list().length < 1) {
if (f.list().length < 1) {
log("Removing orphan directory: " + f, Project.MSG_DEBUG);
f.delete();
++removedCount[0];
}
}
}
return removedCount;
}


+ 23
- 23
src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -93,13 +93,13 @@ public class Untar extends Expand {
protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
FileInputStream fis = null;
try {
fis = new FileInputStream(srcF);
expandStream(srcF.getPath(), fis, dir);
fis = new FileInputStream(srcF);
expandStream(srcF.getPath(), fis, dir);
} catch (IOException ioe) {
throw new BuildException("Error while expanding " + srcF.getPath(),
ioe, getLocation());
} finally {
FileUtils.close(fis);
FileUtils.close(fis);
}
}

@@ -111,15 +111,15 @@ public class Untar extends Expand {
* @since Ant 1.7
*/
protected void expandResource(Resource srcR, File dir) {
InputStream i = null;
InputStream i = null;
try {
i = srcR.getInputStream();
expandStream(srcR.getName(), i, dir);
i = srcR.getInputStream();
expandStream(srcR.getName(), i, dir);
} catch (IOException ioe) {
throw new BuildException("Error while expanding " + srcR.getName(),
ioe, getLocation());
} finally {
FileUtils.close(i);
FileUtils.close(i);
}
}

@@ -127,24 +127,24 @@ public class Untar extends Expand {
* @since Ant 1.7
*/
private void expandStream(String name, InputStream stream, File dir)
throws IOException {
TarInputStream tis = null;
throws IOException {
TarInputStream tis = null;
try {
tis =
new TarInputStream(compression.decompress(name,
new BufferedInputStream(stream)));
log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
TarEntry te = null;
FileNameMapper mapper = getMapper();
while ((te = tis.getNextEntry()) != null) {
extractFile(FileUtils.getFileUtils(), null, dir, tis,
te.getName(), te.getModTime(),
te.isDirectory(), mapper);
}
log("expand complete", Project.MSG_VERBOSE);
tis =
new TarInputStream(compression.decompress(name,
new BufferedInputStream(stream)));
log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
TarEntry te = null;
FileNameMapper mapper = getMapper();
while ((te = tis.getNextEntry()) != null) {
extractFile(FileUtils.getFileUtils(), null, dir, tis,
te.getName(), te.getModTime(),
te.isDirectory(), mapper);
}
log("expand complete", Project.MSG_VERBOSE);
} finally {
FileUtils.close(tis);
}
}
}

/**
@@ -209,7 +209,7 @@ public class Untar extends Expand {
for (int i = 0; i < magic.length; i++) {
if (istream.read() != magic[i]) {
throw new BuildException(
"Invalid bz2 file." + name);
"Invalid bz2 file." + name);
}
}
return new CBZip2InputStream(istream);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java View File

@@ -390,10 +390,10 @@ public class SchemaValidate extends XMLValidateTask {
if (!file.exists()) {
throw new BuildException(ERROR_NO_FILE + file);
}
try {
schema =
FileUtils.getFileUtils().getFileURL(file).toString();
FileUtils.getFileUtils().getFileURL(file).toString();
} catch (MalformedURLException e) {
//this is almost implausible, but required handling
throw new BuildException(ERROR_NO_URL_REPRESENTATION + file,e);


+ 8
- 8
src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java View File

@@ -63,7 +63,7 @@ public final class BatchTest extends BaseTest {
* @param fs the new fileset containing the rules to get the testcases.
*/
public void addFileSet(FileSet fs) {
add(fs);
add(fs);
}


@@ -131,17 +131,17 @@ public final class BatchTest extends BaseTest {
*/
private String[] getFilenames() {
Vector v = new Vector();
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
if (r.isExists()) {
String pathname = r.getName();
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
if (r.isExists()) {
String pathname = r.getName();
if (pathname.endsWith(".java")) {
v.addElement(pathname.substring(0, pathname.length() - ".java".length()));
} else if (pathname.endsWith(".class")) {
v.addElement(pathname.substring(0, pathname.length() - ".class".length()));
}
}
}
}

String[] files = new String[v.size()];
@@ -158,7 +158,7 @@ public final class BatchTest extends BaseTest {
*/
public static final String javaToClass(String filename) {
return filename.replace(File.separatorChar, '.').replace('/', '.')
.replace('\\', '.');
.replace('\\', '.');
}

/**


+ 46
- 46
src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000,2004 The Apache Software Foundation
* Copyright 2000,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class AntStructureTest extends BuildFileTest {
}

public void tearDown() {
executeTarget("tearDown");
executeTarget("tearDown");
}

public void test1() {
@@ -44,53 +44,53 @@ public class AntStructureTest extends BuildFileTest {
}

public void testCustomPrinter() {
executeTarget("testCustomPrinter");
// can't access the booleans in MyPrinter here (even if they
// were static) since the MyPrinter instance that was used in
// the test has likely been loaded via a different classloader
// than this class. Therefore we make the printer assert its
// state and only check for the tail invocation.
assertLogContaining(MyPrinter.TAIL_CALLED);
executeTarget("testCustomPrinter");
// can't access the booleans in MyPrinter here (even if they
// were static) since the MyPrinter instance that was used in
// the test has likely been loaded via a different classloader
// than this class. Therefore we make the printer assert its
// state and only check for the tail invocation.
assertLogContaining(MyPrinter.TAIL_CALLED);
}

public static class MyPrinter implements AntStructure.StructurePrinter {
private static final String TAIL_CALLED = "tail has been called";
private boolean headCalled = false;
private boolean targetCalled = false;
private boolean tailCalled = false;
private int elementCalled = 0;
private Project p;
private static final String TAIL_CALLED = "tail has been called";
private boolean headCalled = false;
private boolean targetCalled = false;
private boolean tailCalled = false;
private int elementCalled = 0;
private Project p;

public void printHead(PrintWriter out, Project p, Hashtable tasks,
Hashtable types) {
Assert.assertTrue(!headCalled);
Assert.assertTrue(!targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertEquals(0, elementCalled);
headCalled = true;
}
public void printTargetDecl(PrintWriter out) {
Assert.assertTrue(headCalled);
Assert.assertTrue(!targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertEquals(0, elementCalled);
targetCalled = true;
}
public void printElementDecl(PrintWriter out, Project p, String name,
Class element) {
Assert.assertTrue(headCalled);
Assert.assertTrue(targetCalled);
Assert.assertTrue(!tailCalled);
elementCalled++;
this.p = p;
}
public void printTail(PrintWriter out) {
Assert.assertTrue(headCalled);
Assert.assertTrue(targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertTrue(elementCalled > 0);
tailCalled = true;
p.log(TAIL_CALLED);
}
public void printHead(PrintWriter out, Project p, Hashtable tasks,
Hashtable types) {
Assert.assertTrue(!headCalled);
Assert.assertTrue(!targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertEquals(0, elementCalled);
headCalled = true;
}
public void printTargetDecl(PrintWriter out) {
Assert.assertTrue(headCalled);
Assert.assertTrue(!targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertEquals(0, elementCalled);
targetCalled = true;
}
public void printElementDecl(PrintWriter out, Project p, String name,
Class element) {
Assert.assertTrue(headCalled);
Assert.assertTrue(targetCalled);
Assert.assertTrue(!tailCalled);
elementCalled++;
this.p = p;
}
public void printTail(PrintWriter out) {
Assert.assertTrue(headCalled);
Assert.assertTrue(targetCalled);
Assert.assertTrue(!tailCalled);
Assert.assertTrue(elementCalled > 0);
tailCalled = true;
p.log(TAIL_CALLED);
}
}
}

+ 34
- 34
src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -156,61 +156,61 @@ public class CopyTest extends BuildFileTest {
}
public void testFileResourcePlain() {
executeTarget("testFileResourcePlain");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
executeTarget("testFileResourcePlain");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
}
public void _testFileResourceWithMapper() {
executeTarget("testFileResourceWithMapper");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
executeTarget("testFileResourceWithMapper");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt.bak");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt.bak");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt.bak");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
}
public void testFileResourceWithFilter() {
executeTarget("testFileResourceWithFilter");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/fileNR.txt");
assertTrue(file1.exists());
try {
String file1Content = FILE_UTILS.readFully(new FileReader(file1));
assertEquals("This is file 42", file1Content);
} catch (IOException e) {
// no-op: not a real business error
}
executeTarget("testFileResourceWithFilter");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/fileNR.txt");
assertTrue(file1.exists());
try {
String file1Content = FILE_UTILS.readFully(new FileReader(file1));
assertEquals("This is file 42", file1Content);
} catch (IOException e) {
// no-op: not a real business error
}
}
public void testPathAsResource() {
executeTarget("testPathAsResource");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
executeTarget("testPathAsResource");
File file1 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file1.txt");
File file2 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file2.txt");
File file3 = new File(getProjectDir(), getProject().getProperty("to.dir")+"/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
}
public void _testResourcePlain() {
executeTarget("testResourcePlain");
executeTarget("testResourcePlain");
}
public void _testResourcePlainWithMapper() {
executeTarget("testResourcePlainWithMapper");
executeTarget("testResourcePlainWithMapper");
}
public void _testResourcePlainWithFilter() {
executeTarget("testResourcePlainWithFilter");
executeTarget("testResourcePlainWithFilter");
}
public void _testOnlineResources() {
executeTarget("testOnlineResources");
executeTarget("testOnlineResources");
}
}

+ 7
- 7
src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java View File

@@ -564,11 +564,11 @@ public class ExecuteOnTest extends BuildFileTest {
}

public void testLsPath() {
testLsPath("lsPath");
testLsPath("lsPath");
}

public void testLsPathParallel() {
testLsPath("lsPathParallel");
testLsPath("lsPathParallel");
}

private void testLsPath(String target) {
@@ -576,11 +576,11 @@ public class ExecuteOnTest extends BuildFileTest {
if (getProject().getProperty("ls.can.run") == null) {
return;
}
String foo = getProject().getProperty("foo");
assertNotNull(foo);
int indNoExt = foo.indexOf("ls" + LINE_SEP);
int indExe = foo.indexOf("ls.exe" + LINE_SEP);
assertTrue(indNoExt >= 0 || indExe >= 0);
String foo = getProject().getProperty("foo");
assertNotNull(foo);
int indNoExt = foo.indexOf("ls" + LINE_SEP);
int indExe = foo.indexOf("ls.exe" + LINE_SEP);
assertTrue(indNoExt >= 0 || indExe >= 0);
}

//borrowed from TokenFilterTest


+ 4
- 4
src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java View File

@@ -82,11 +82,11 @@ public class MoveTest extends BuildFileTest {
}

public void testCompleteDirectoryMove() throws IOException {
testCompleteDirectoryMove("testCompleteDirectoryMove");
testCompleteDirectoryMove("testCompleteDirectoryMove");
}

public void testCompleteDirectoryMove2() throws IOException {
testCompleteDirectoryMove("testCompleteDirectoryMove2");
testCompleteDirectoryMove("testCompleteDirectoryMove2");
}

private void testCompleteDirectoryMove(String target) throws IOException {
@@ -94,8 +94,8 @@ public class MoveTest extends BuildFileTest {
assertTrue(getProject().resolveFile("E").exists());
assertTrue(getProject().resolveFile("E/1").exists());
assertTrue(!getProject().resolveFile("A/1").exists());
// <path> swallows the basedir, it seems
//assertTrue(!getProject().resolveFile("A").exists());
// <path> swallows the basedir, it seems
//assertTrue(!getProject().resolveFile("A").exists());
}

public void testPathElementMove() throws IOException {


+ 2
- 2
src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java View File

@@ -84,11 +84,11 @@ public class StyleTest extends BuildFileTest {


public void testDefaultMapper() throws Exception {
testDefaultMapper("testDefaultMapper");
testDefaultMapper("testDefaultMapper");
}

public void testExplicitFileset() throws Exception {
testDefaultMapper("testExplicitFileset");
testDefaultMapper("testExplicitFileset");
}

public void testDefaultMapper(String target) throws Exception {


+ 2
- 2
src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java View File

@@ -60,11 +60,11 @@ public class SyncTest extends BuildFileTest {
}

public void testCopyAndRemove() {
testCopyAndRemove("copyandremove");
testCopyAndRemove("copyandremove");
}

public void testCopyAndRemoveWithFileList() {
testCopyAndRemove("copyandremove-with-filelist");
testCopyAndRemove("copyandremove-with-filelist");
}

private void testCopyAndRemove(String target) {


Loading…
Cancel
Save