@@ -0,0 +1,13 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> | |||||
<local-check-config name="Ant Checkstyle Config" location="src/etc/checkstyle/checkstyle-config" type="project" description=""> | |||||
<property name="config.dir" value="${basedir}/src/etc/checkstyle"/> | |||||
<additional-data name="protect-config-file" value="true"/> | |||||
</local-check-config> | |||||
<fileset name="Ant Checkstyle config" enabled="true" check-config-name="Ant Checkstyle Config" local="true"> | |||||
<file-match-pattern match-pattern="^src.main.*.java$" include-pattern="true"/> | |||||
<file-match-pattern match-pattern="^src.etc.testcases.*.java$" include-pattern="true"/> | |||||
<file-match-pattern match-pattern="^src.tests.*.java$" include-pattern="true"/> | |||||
</fileset> | |||||
</fileset-config> |
@@ -1,4 +1,5 @@ | |||||
<?xml version="1.0"?> | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> | |||||
<!-- | <!-- | ||||
Licensed to the Apache Software Foundation (ASF) under one or more | Licensed to the Apache Software Foundation (ASF) under one or more | ||||
contributor license agreements. See the NOTICE file distributed with | contributor license agreements. See the NOTICE file distributed with | ||||
@@ -15,7 +16,6 @@ | |||||
See the License for the specific language governing permissions and | See the License for the specific language governing permissions and | ||||
limitations under the License. | limitations under the License. | ||||
--> | --> | ||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> | |||||
<module name="Checker"> | <module name="Checker"> | ||||
@@ -65,6 +65,7 @@ | |||||
<module name="LineLength"> | <module name="LineLength"> | ||||
<property name="max" value="100"/> | <property name="max" value="100"/> | ||||
<property name="ignorePattern" value="^ *\* *[^ ]+$"/> | <property name="ignorePattern" value="^ *\* *[^ ]+$"/> | ||||
<property name="tabWidth" value="4"/> | |||||
</module> | </module> | ||||
<module name="MethodLength"/> | <module name="MethodLength"/> | ||||
<module name="ParameterNumber"/> | <module name="ParameterNumber"/> | ||||
@@ -1,4 +1,4 @@ | |||||
/* | |||||
/* | |||||
* Licensed to the Apache Software Foundation (ASF) under one or more | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||
* contributor license agreements. See the NOTICE file distributed with | * contributor license agreements. See the NOTICE file distributed with | ||||
* this work for additional information regarding copyright ownership. | * this work for additional information regarding copyright ownership. | ||||
@@ -13,7 +13,7 @@ | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
* limitations under the License. | * limitations under the License. | ||||
* | |||||
* | |||||
*/ | */ | ||||
package test; | package test; | ||||
@@ -22,21 +22,22 @@ import org.apache.tools.ant.TaskContainer; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
import org.apache.tools.ant.taskdefs.Echo; | import org.apache.tools.ant.taskdefs.Echo; | ||||
import java.util.*; | |||||
import java.util.Enumeration; | |||||
import java.util.Vector; | |||||
public class SpecialSeq extends Task implements TaskContainer { | public class SpecialSeq extends Task implements TaskContainer { | ||||
/** Optional Vector holding the nested tasks */ | /** Optional Vector holding the nested tasks */ | ||||
private Vector nestedTasks = new Vector(); | private Vector nestedTasks = new Vector(); | ||||
private FileSet fileset; | private FileSet fileset; | ||||
private Echo nestedEcho; | private Echo nestedEcho; | ||||
/** | /** | ||||
* Add a nested task. | * Add a nested task. | ||||
* <p> | |||||
* | |||||
* @param nestedTask Nested task to execute | * @param nestedTask Nested task to execute | ||||
* <p> | |||||
*/ | */ | ||||
public void addTask(Task nestedTask) { | public void addTask(Task nestedTask) { | ||||
nestedTasks.addElement(nestedTask); | nestedTasks.addElement(nestedTask); | ||||
@@ -60,7 +61,7 @@ public class SpecialSeq extends Task implements TaskContainer { | |||||
public void addFileset(FileSet fileset) { | public void addFileset(FileSet fileset) { | ||||
this.fileset = fileset; | this.fileset = fileset; | ||||
} | } | ||||
public void addNested(Echo nestedEcho) { | public void addNested(Echo nestedEcho) { | ||||
this.nestedEcho = nestedEcho; | this.nestedEcho = nestedEcho; | ||||
} | } | ||||
@@ -31,7 +31,7 @@ public class ClassToJavadoc { | |||||
* @see java.lang.Object#toString() | * @see java.lang.Object#toString() | ||||
*/ | */ | ||||
public String toString() { return this.getClass().getName(); } | public String toString() { return this.getClass().getName(); } | ||||
/** | /** | ||||
* @return An arbitrary string. | * @return An arbitrary string. | ||||
*/ | */ | ||||
@@ -19,6 +19,5 @@ package test; | |||||
public class ContainsOnlyInner { | public class ContainsOnlyInner { | ||||
void method1() { | void method1() { | ||||
System.out.println(Outer.Inner.class); | System.out.println(Outer.Inner.class); | ||||
} | |||||
} | |||||
} | } | ||||
@@ -39,7 +39,7 @@ public class AntTimestamp implements RemoteTimestamp { | |||||
* @throws RemoteException | * @throws RemoteException | ||||
*/ | */ | ||||
public long when() throws RemoteException { | public long when() throws RemoteException { | ||||
Calendar cal=Calendar.getInstance(); | |||||
Calendar cal = Calendar.getInstance(); | |||||
return DateUtils.getPhaseOfMoon(cal); | return DateUtils.getPhaseOfMoon(cal); | ||||
} | } | ||||
} | } |
@@ -21,6 +21,6 @@ import java.rmi.RemoteException; | |||||
* this is the interface we remote | * this is the interface we remote | ||||
*/ | */ | ||||
public interface RemoteTimestamp extends Remote { | public interface RemoteTimestamp extends Remote { | ||||
long when() throws RemoteException ; | |||||
long when() throws RemoteException; | |||||
} | } | ||||
@@ -31,14 +31,14 @@ public class AssertionTest extends TestCase { | |||||
try { | try { | ||||
assert true == false; | assert true == false; | ||||
fail("expected an assertion"); | fail("expected an assertion"); | ||||
} catch(AssertionError asserto) { | |||||
} catch (AssertionError asserto) { | |||||
//if we got here, all was well | //if we got here, all was well | ||||
} | } | ||||
} | } | ||||
public void testAssertNotRaised() { | public void testAssertNotRaised() { | ||||
assert(2+2==4); | |||||
assert(2 + 2 == 4); | |||||
} | } | ||||
@@ -19,7 +19,7 @@ prop\ttwo=contains\ttab | |||||
prop\nthree=contains\nnewline | prop\nthree=contains\nnewline | ||||
prop\rfour=contains\rcarraige return | |||||
prop\rfour=contains\rcarriage return | |||||
prop\ffive=contains\fform feed | prop\ffive=contains\fform feed | ||||
@@ -6,7 +6,7 @@ | |||||
* (the "License"); you may not use this file except in compliance with | * (the "License"); you may not use this file except in compliance with | ||||
* the License. You may obtain a copy of the License at | * the License. You may obtain a copy of the License at | ||||
* | * | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | * | ||||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | ||||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | ||||
@@ -63,10 +63,10 @@ abstract public class BaseTask extends Task { | |||||
FILE_UTILS.close(outputStream); | FILE_UTILS.close(outputStream); | ||||
} | } | ||||
} | } | ||||
abstract protected void doit( | abstract protected void doit( | ||||
InputStream is, OutputStream os) throws Exception; | InputStream is, OutputStream os) throws Exception; | ||||
private void assertAttribute(File file, String attributeName) { | private void assertAttribute(File file, String attributeName) { | ||||
if (file == null) { | if (file == null) { | ||||
throw new BuildException("Required attribute " + attributeName | throw new BuildException("Required attribute " + attributeName | ||||
@@ -74,5 +74,3 @@ abstract public class BaseTask extends Task { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -28,4 +28,3 @@ public class UUDecodeTask extends BaseTask { | |||||
new UUDecoder().decodeBuffer(is, os); | new UUDecoder().decodeBuffer(is, os); | ||||
} | } | ||||
} | } | ||||
@@ -34,7 +34,8 @@ public class AntAssert { | |||||
*/ | */ | ||||
public static void assertContains(String message, String needle, String haystack) { | public static void assertContains(String message, String needle, String haystack) { | ||||
String formattedMessage = (message == null ? "" : message + " "); | String formattedMessage = (message == null ? "" : message + " "); | ||||
assertTrue(formattedMessage + String.format("expected message containing: <%s> but got: <%s>", needle, haystack), haystack.contains(needle)); | |||||
assertTrue(formattedMessage + String.format("expected message containing: <%s> but got: <%s>", | |||||
needle, haystack), haystack.contains(needle)); | |||||
} | } | ||||
/** | /** | ||||
@@ -55,7 +56,8 @@ public class AntAssert { | |||||
*/ | */ | ||||
public static void assertNotContains(String message, String needle, String haystack) { | public static void assertNotContains(String message, String needle, String haystack) { | ||||
String formattedMessage = (message == null ? "" : message + " "); | String formattedMessage = (message == null ? "" : message + " "); | ||||
assertFalse(formattedMessage + String.format("expected message not to contain: <%s> but got: <%s>", needle, haystack), haystack.contains(needle)); | |||||
assertFalse(formattedMessage + String.format("expected message not to contain: <%s> but got: <%s>", | |||||
needle, haystack), haystack.contains(needle)); | |||||
} | } | ||||
/** | /** | ||||
@@ -55,6 +55,7 @@ public class AntClassLoaderDelegationTest { | |||||
private static final String TEST_RESOURCE | private static final String TEST_RESOURCE | ||||
= "apache/tools/ant/IncludeTest.class"; | = "apache/tools/ant/IncludeTest.class"; | ||||
@SuppressWarnings("resource") | |||||
@Test | @Test | ||||
public void testFindResources() throws Exception { | public void testFindResources() throws Exception { | ||||
// This path should contain the class files for these testcases: | // This path should contain the class files for these testcases: | ||||
@@ -81,6 +82,7 @@ public class AntClassLoaderDelegationTest { | |||||
enum2List(acl.getResources(TEST_RESOURCE))); | enum2List(acl.getResources(TEST_RESOURCE))); | ||||
} | } | ||||
@SuppressWarnings("resource") | |||||
@Test | @Test | ||||
public void testFindIsolateResources() throws Exception { | public void testFindIsolateResources() throws Exception { | ||||
String buildTestcases = System.getProperty("build.tests"); | String buildTestcases = System.getProperty("build.tests"); | ||||
@@ -103,11 +105,12 @@ public class AntClassLoaderDelegationTest { | |||||
private static List enum2List(Enumeration e) { | private static List enum2List(Enumeration e) { | ||||
return Collections.list(e); | return Collections.list(e); | ||||
} | } | ||||
/** Special loader that just knows how to find TEST_RESOURCE. */ | /** Special loader that just knows how to find TEST_RESOURCE. */ | ||||
private static final class ParentLoader extends ClassLoader { | private static final class ParentLoader extends ClassLoader { | ||||
public ParentLoader() {} | |||||
public ParentLoader() { | |||||
} | |||||
protected Enumeration findResources(String name) throws IOException { | protected Enumeration findResources(String name) throws IOException { | ||||
if (name.equals(TEST_RESOURCE)) { | if (name.equals(TEST_RESOURCE)) { | ||||
@@ -118,7 +121,7 @@ public class AntClassLoaderDelegationTest { | |||||
return Collections.enumeration(Collections.EMPTY_SET); | return Collections.enumeration(Collections.EMPTY_SET); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -207,6 +207,7 @@ public class AntClassLoaderTest { | |||||
* @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=46752"> | * @see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=46752"> | ||||
* https://issues.apache.org/bugzilla/show_bug.cgi?id=46752</a> | * https://issues.apache.org/bugzilla/show_bug.cgi?id=46752</a> | ||||
*/ | */ | ||||
@SuppressWarnings("resource") | |||||
@Test | @Test | ||||
public void testGetResources() throws IOException { | public void testGetResources() throws IOException { | ||||
AntClassLoader acl = new AntClassLoader(new EmptyLoader(), null, | AntClassLoader acl = new AntClassLoader(new EmptyLoader(), null, | ||||
@@ -28,8 +28,8 @@ import org.junit.rules.ExternalResource; | |||||
/** | /** | ||||
* Provides access for JUnit tests to execute Ant targets and access execution details (i.e logs). | * Provides access for JUnit tests to execute Ant targets and access execution details (i.e logs). | ||||
* | * | ||||
* Example usage: | |||||
* <code> | |||||
* <p>Example usage:</p> | |||||
* <pre> | |||||
* public class MyTest { | * public class MyTest { | ||||
* | * | ||||
* \@Rule | * \@Rule | ||||
@@ -42,7 +42,7 @@ import org.junit.rules.ExternalResource; | |||||
* | * | ||||
* \@Test | * \@Test | ||||
* public void testSuccess() { | * public void testSuccess() { | ||||
* rule.executeTarget("passingTaget"); | |||||
* rule.executeTarget("passingTarget"); | |||||
* assertEquals("Incorrect log message", "[taskName] Action Complete", rule.getLog()); | * assertEquals("Incorrect log message", "[taskName] Action Complete", rule.getLog()); | ||||
* } | * } | ||||
* | * | ||||
@@ -57,7 +57,7 @@ import org.junit.rules.ExternalResource; | |||||
* } | * } | ||||
* | * | ||||
* } | * } | ||||
* </code> | |||||
* </pre> | |||||
*/ | */ | ||||
public class BuildFileRule extends ExternalResource { | public class BuildFileRule extends ExternalResource { | ||||
@@ -102,8 +102,7 @@ public class BuildFileRule extends ExternalResource { | |||||
/** | /** | ||||
* Gets any messages that have been logged during the current execution, unless | * Gets any messages that have been logged during the current execution, unless | ||||
* the logging level has been set above the log level defined in the message. | * the logging level has been set above the log level defined in the message. | ||||
* | |||||
* Only valid if configureProject() has been called. | |||||
* <p>Only valid if configureProject() has been called.</p> | |||||
* @return the content of the log. | * @return the content of the log. | ||||
*/ | */ | ||||
public String getFullLog() { | public String getFullLog() { | ||||
@@ -159,7 +158,7 @@ public class BuildFileRule extends ExternalResource { | |||||
File antFile = new File(System.getProperty("root"), filename); | File antFile = new File(System.getProperty("root"), filename); | ||||
project.setProperty("ant.processid", ProcessUtil.getProcessId("<Process>")); | project.setProperty("ant.processid", ProcessUtil.getProcessId("<Process>")); | ||||
project.setProperty("ant.threadname", Thread.currentThread().getName()); | project.setProperty("ant.threadname", Thread.currentThread().getName()); | ||||
project.setUserProperty("ant.file" , antFile.getAbsolutePath()); | |||||
project.setUserProperty("ant.file", antFile.getAbsolutePath()); | |||||
project.addBuildListener(new AntTestListener(logLevel)); | project.addBuildListener(new AntTestListener(logLevel)); | ||||
ProjectHelper.configureProject(project, antFile); | ProjectHelper.configureProject(project, antFile); | ||||
} | } | ||||
@@ -217,7 +216,7 @@ public class BuildFileRule extends ExternalResource { | |||||
protected static class AntOutputStream extends OutputStream { | protected static class AntOutputStream extends OutputStream { | ||||
private StringBuffer buffer; | private StringBuffer buffer; | ||||
public AntOutputStream( StringBuffer buffer ) { | |||||
public AntOutputStream(StringBuffer buffer) { | |||||
this.buffer = buffer; | this.buffer = buffer; | ||||
} | } | ||||
@@ -301,9 +300,9 @@ public class BuildFileRule extends ExternalResource { | |||||
return; | return; | ||||
} | } | ||||
if (event.getPriority() == Project.MSG_INFO || | |||||
event.getPriority() == Project.MSG_WARN || | |||||
event.getPriority() == Project.MSG_ERR) { | |||||
if (event.getPriority() == Project.MSG_INFO | |||||
|| event.getPriority() == Project.MSG_WARN | |||||
|| event.getPriority() == Project.MSG_ERR) { | |||||
logBuffer.append(event.getMessage()); | logBuffer.append(event.getMessage()); | ||||
} | } | ||||
fullLogBuffer.append(event.getMessage()); | fullLogBuffer.append(event.getMessage()); | ||||
@@ -19,6 +19,7 @@ | |||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.OutputStream; | |||||
import java.io.PrintStream; | import java.io.PrintStream; | ||||
import java.net.URL; | import java.net.URL; | ||||
@@ -139,28 +140,28 @@ public abstract class BuildFileTest extends TestCase { | |||||
/** | /** | ||||
* Assert that the given substring is in the output messages. | * Assert that the given substring is in the output messages. | ||||
* @param message Print this message if the test fails. Defaults to | |||||
* a meaningful text if <tt>null</tt> is passed. | |||||
* @param message Print this message if the test fails. Defaults to | |||||
* a meaningful text if <tt>null</tt> is passed. | |||||
* @since Ant1.7 | * @since Ant1.7 | ||||
*/ | */ | ||||
public void assertOutputContaining(String message, String substring) { | public void assertOutputContaining(String message, String substring) { | ||||
String realOutput = getOutput(); | String realOutput = getOutput(); | ||||
String realMessage = (message != null) | |||||
? message | |||||
String realMessage = (message != null) | |||||
? message | |||||
: "expecting output to contain \"" + substring + "\" output was \"" + realOutput + "\""; | : "expecting output to contain \"" + substring + "\" output was \"" + realOutput + "\""; | ||||
assertTrue(realMessage, realOutput.indexOf(substring) >= 0); | assertTrue(realMessage, realOutput.indexOf(substring) >= 0); | ||||
} | } | ||||
/** | /** | ||||
* Assert that the given substring is not in the output messages. | * Assert that the given substring is not in the output messages. | ||||
* @param message Print this message if the test fails. Defaults to | |||||
* a meaningful text if <tt>null</tt> is passed. | |||||
* @param message Print this message if the test fails. Defaults to | |||||
* a meaningful text if <tt>null</tt> is passed. | |||||
* @since Ant1.7 | * @since Ant1.7 | ||||
*/ | */ | ||||
public void assertOutputNotContaining(String message, String substring) { | public void assertOutputNotContaining(String message, String substring) { | ||||
String realOutput = getOutput(); | String realOutput = getOutput(); | ||||
String realMessage = (message != null) | |||||
? message | |||||
String realMessage = (message != null) | |||||
? message | |||||
: "expecting output to not contain \"" + substring + "\" output was \"" + realOutput + "\""; | : "expecting output to not contain \"" + substring + "\" output was \"" + realOutput + "\""; | ||||
assertFalse(realMessage, realOutput.indexOf(substring) >= 0); | assertFalse(realMessage, realOutput.indexOf(substring) >= 0); | ||||
} | } | ||||
@@ -209,7 +210,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
*/ | */ | ||||
public void assertDebuglogContaining(String substring) { | public void assertDebuglogContaining(String substring) { | ||||
String realLog = getFullLog(); | String realLog = getFullLog(); | ||||
assertTrue("expecting debug log to contain \"" + substring | |||||
assertTrue("expecting debug log to contain \"" + substring | |||||
+ "\" log was \"" | + "\" log was \"" | ||||
+ realLog + "\"", | + realLog + "\"", | ||||
realLog.indexOf(substring) >= 0); | realLog.indexOf(substring) >= 0); | ||||
@@ -268,7 +269,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
} | } | ||||
private String cleanBuffer(StringBuffer buffer) { | private String cleanBuffer(StringBuffer buffer) { | ||||
StringBuffer cleanedBuffer = new StringBuffer(); | |||||
StringBuilder cleanedBuffer = new StringBuilder(); | |||||
for (int i = 0; i < buffer.length(); i++) { | for (int i = 0; i < buffer.length(); i++) { | ||||
char ch = buffer.charAt(i); | char ch = buffer.charAt(i); | ||||
if (ch != '\r') { | if (ch != '\r') { | ||||
@@ -299,7 +300,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
project = new Project(); | project = new Project(); | ||||
project.init(); | project.init(); | ||||
File antFile = new File(System.getProperty("root"), filename); | File antFile = new File(System.getProperty("root"), filename); | ||||
project.setUserProperty("ant.file" , antFile.getAbsolutePath()); | |||||
project.setUserProperty("ant.file", antFile.getAbsolutePath()); | |||||
// set two new properties to allow to build unique names when running multithreaded tests | // set two new properties to allow to build unique names when running multithreaded tests | ||||
project.setProperty("ant.processid", ProcessUtil.getProcessId("<Process>")); | project.setProperty("ant.processid", ProcessUtil.getProcessId("<Process>")); | ||||
project.setProperty("ant.threadname", Thread.currentThread().getName()); | project.setProperty("ant.threadname", Thread.currentThread().getName()); | ||||
@@ -480,7 +481,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
* @param resource the resource to retrieve its url. | * @param resource the resource to retrieve its url. | ||||
* @throws junit.framework.AssertionFailedError if the resource is not found. | * @throws junit.framework.AssertionFailedError if the resource is not found. | ||||
*/ | */ | ||||
public URL getResource(String resource){ | |||||
public URL getResource(String resource) { | |||||
URL url = getClass().getResource(resource); | URL url = getClass().getResource(resource); | ||||
assertNotNull("Could not find resource :" + resource, url); | assertNotNull("Could not find resource :" + resource, url); | ||||
return url; | return url; | ||||
@@ -489,10 +490,10 @@ public abstract class BuildFileTest extends TestCase { | |||||
/** | /** | ||||
* an output stream which saves stuff to our buffer. | * an output stream which saves stuff to our buffer. | ||||
*/ | */ | ||||
protected static class AntOutputStream extends java.io.OutputStream { | |||||
protected static class AntOutputStream extends OutputStream { | |||||
private StringBuffer buffer; | private StringBuffer buffer; | ||||
public AntOutputStream( StringBuffer buffer ) { | |||||
public AntOutputStream(StringBuffer buffer) { | |||||
this.buffer = buffer; | this.buffer = buffer; | ||||
} | } | ||||
@@ -580,9 +581,9 @@ public abstract class BuildFileTest extends TestCase { | |||||
return; | return; | ||||
} | } | ||||
if (event.getPriority() == Project.MSG_INFO || | |||||
event.getPriority() == Project.MSG_WARN || | |||||
event.getPriority() == Project.MSG_ERR) { | |||||
if (event.getPriority() == Project.MSG_INFO | |||||
|| event.getPriority() == Project.MSG_WARN | |||||
|| event.getPriority() == Project.MSG_ERR) { | |||||
logBuffer.append(event.getMessage()); | logBuffer.append(event.getMessage()); | ||||
} | } | ||||
fullLogBuffer.append(event.getMessage()); | fullLogBuffer.append(event.getMessage()); | ||||
@@ -56,7 +56,7 @@ public class CaseTest { | |||||
try { | try { | ||||
buildRule.executeTarget("taskcase"); | buildRule.executeTarget("taskcase"); | ||||
fail("Build exception should have been thrown due to case sensitivity of name"); | fail("Build exception should have been thrown due to case sensitivity of name"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertContains("Task names should be case sensitive", "Problem: failed to create task or type ecHO", ex.getMessage()); | assertContains("Task names should be case sensitive", "Problem: failed to create task or type ecHO", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -34,6 +34,7 @@ public class DefaultLoggerTest { | |||||
return m.toString(); | return m.toString(); | ||||
} | } | ||||
@SuppressWarnings("serial") | |||||
@Test | @Test | ||||
public void testThrowableMessage() throws Exception { // #43398 | public void testThrowableMessage() throws Exception { // #43398 | ||||
BuildException be = new BuildException("oops", new Location("build.xml", 1, 0)); | BuildException be = new BuildException("oops", new Location("build.xml", 1, 0)); | ||||
@@ -21,8 +21,8 @@ package org.apache.tools.ant; | |||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import static org.junit.Assume.assumeTrue; | |||||
import static org.junit.Assume.assumeFalse; | import static org.junit.Assume.assumeFalse; | ||||
import static org.junit.Assume.assumeTrue; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
@@ -62,7 +62,7 @@ public class DirectoryScannerTest { | |||||
ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); | ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); | ||||
ds.setIncludes(new String[] {"alpha"}); | ds.setIncludes(new String[] {"alpha"}); | ||||
ds.scan(); | ds.scan(); | ||||
compareFiles(ds, new String[] {} ,new String[] {"alpha"}); | |||||
compareFiles(ds, new String[] {}, new String[] {"alpha"}); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -244,7 +244,7 @@ public class DirectoryScannerTest { | |||||
* Only supports test on Linux at the moment because Java has | * Only supports test on Linux at the moment because Java has | ||||
* no real notion of symlinks built in, so an os-specfic call | * no real notion of symlinks built in, so an os-specfic call | ||||
* to Runtime.exec() must be made to create a link to test against. | * to Runtime.exec() must be made to create a link to test against. | ||||
* @throws InterruptedException | |||||
* @throws InterruptedException if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testSetFollowLinks() throws IOException, InterruptedException { | public void testSetFollowLinks() throws IOException, InterruptedException { | ||||
@@ -276,13 +276,13 @@ public class DirectoryScannerTest { | |||||
boolean haveZipPackage = false; | boolean haveZipPackage = false; | ||||
boolean haveTaskdefsPackage = false; | boolean haveTaskdefsPackage = false; | ||||
String[] included = ds.getIncludedDirectories(); | |||||
for (int i=0; i<included.length; i++) { | |||||
if (included[i].equals("zip")) { | |||||
String[] includeds = ds.getIncludedDirectories(); | |||||
for (String included : includeds) { | |||||
if (included.equals("zip")) { | |||||
haveZipPackage = true; | haveZipPackage = true; | ||||
} else if (included[i].equals("ThisIsALink" | |||||
+ File.separator | |||||
+ "taskdefs")) { | |||||
} else if (included.equals("ThisIsALink" | |||||
+ File.separator | |||||
+ "taskdefs")) { | |||||
haveTaskdefsPackage = true; | haveTaskdefsPackage = true; | ||||
} | } | ||||
} | } | ||||
@@ -291,9 +291,7 @@ public class DirectoryScannerTest { | |||||
// bypass the excludes. | // bypass the excludes. | ||||
assertTrue("(1) zip package included", haveZipPackage); | assertTrue("(1) zip package included", haveZipPackage); | ||||
assertTrue("(1) taskdefs package included", | |||||
haveTaskdefsPackage); | |||||
assertTrue("(1) taskdefs package included", haveTaskdefsPackage); | |||||
ds = new DirectoryScanner(); | ds = new DirectoryScanner(); | ||||
ds.setFollowSymlinks(false); | ds.setFollowSymlinks(false); | ||||
@@ -304,19 +302,18 @@ public class DirectoryScannerTest { | |||||
haveZipPackage = false; | haveZipPackage = false; | ||||
haveTaskdefsPackage = false; | haveTaskdefsPackage = false; | ||||
included = ds.getIncludedDirectories(); | |||||
for (int i=0; i<included.length; i++) { | |||||
if (included[i].equals("zip")) { | |||||
includeds = ds.getIncludedDirectories(); | |||||
for (String included : includeds) { | |||||
if (included.equals("zip")) { | |||||
haveZipPackage = true; | haveZipPackage = true; | ||||
} else if (included[i].equals("ThisIsALink" | |||||
+ File.separator | |||||
+ "taskdefs")) { | |||||
} else if (included.equals("ThisIsALink" | |||||
+ File.separator | |||||
+ "taskdefs")) { | |||||
haveTaskdefsPackage = true; | haveTaskdefsPackage = true; | ||||
} | } | ||||
} | } | ||||
assertTrue("(2) zip package included", haveZipPackage); | assertTrue("(2) zip package included", haveZipPackage); | ||||
assertTrue("(2) taskdefs package not included", | |||||
!haveTaskdefsPackage); | |||||
assertFalse("(2) taskdefs package not included", haveTaskdefsPackage); | |||||
} finally { | } finally { | ||||
if (!linkFile.delete()) { | if (!linkFile.delete()) { | ||||
@@ -491,7 +488,7 @@ public class DirectoryScannerTest { | |||||
buildRule.getProject().executeTarget("extended-setup"); | buildRule.getProject().executeTarget("extended-setup"); | ||||
DirectoryScanner ds = new DirectoryScanner(); | DirectoryScanner ds = new DirectoryScanner(); | ||||
String tmpdir = buildRule.getProject().getProperty("output").replace( | String tmpdir = buildRule.getProject().getProperty("output").replace( | ||||
File.separatorChar, '/') ; | |||||
File.separatorChar, '/'); | |||||
ds.setIncludes(new String[] {tmpdir + "/alpha/beta/**/*", | ds.setIncludes(new String[] {tmpdir + "/alpha/beta/**/*", | ||||
tmpdir + "/delta/*"}); | tmpdir + "/delta/*"}); | ||||
ds.setExcludes(new String[] {"**/beta.xml"}); | ds.setExcludes(new String[] {"**/beta.xml"}); | ||||
@@ -516,28 +513,28 @@ public class DirectoryScannerTest { | |||||
private void compareFiles(DirectoryScanner ds, String[] expectedFiles, | private void compareFiles(DirectoryScanner ds, String[] expectedFiles, | ||||
String[] expectedDirectories) { | String[] expectedDirectories) { | ||||
String includedFiles[] = ds.getIncludedFiles(); | |||||
String includedDirectories[] = ds.getIncludedDirectories(); | |||||
String[] includedFiles = ds.getIncludedFiles(); | |||||
String[] includedDirectories = ds.getIncludedDirectories(); | |||||
assertEquals("file present: ", expectedFiles.length, | assertEquals("file present: ", expectedFiles.length, | ||||
includedFiles.length); | includedFiles.length); | ||||
assertEquals("directories present: ", expectedDirectories.length, | assertEquals("directories present: ", expectedDirectories.length, | ||||
includedDirectories.length); | includedDirectories.length); | ||||
TreeSet<String> files = new TreeSet<String>(); | TreeSet<String> files = new TreeSet<String>(); | ||||
for (int counter = 0; counter < includedFiles.length; counter++) { | |||||
files.add(includedFiles[counter].replace(File.separatorChar, '/')); | |||||
for (String includedFile : includedFiles) { | |||||
files.add(includedFile.replace(File.separatorChar, '/')); | |||||
} | } | ||||
TreeSet<String> directories = new TreeSet<String>(); | TreeSet<String> directories = new TreeSet<String>(); | ||||
for (int counter = 0; counter < includedDirectories.length; counter++) { | |||||
directories.add(includedDirectories[counter] | |||||
.replace(File.separatorChar, '/')); | |||||
for (String includedDirectory : includedDirectories) { | |||||
directories.add(includedDirectory | |||||
.replace(File.separatorChar, '/')); | |||||
} | } | ||||
String currentfile; | String currentfile; | ||||
Iterator<String> i = files.iterator(); | Iterator<String> i = files.iterator(); | ||||
int counter = 0; | int counter = 0; | ||||
while (i.hasNext()) { | while (i.hasNext()) { | ||||
currentfile = (String) i.next(); | |||||
currentfile = i.next(); | |||||
assertEquals(expectedFiles[counter], currentfile); | assertEquals(expectedFiles[counter], currentfile); | ||||
counter++; | counter++; | ||||
} | } | ||||
@@ -545,7 +542,7 @@ public class DirectoryScannerTest { | |||||
Iterator<String> dirit = directories.iterator(); | Iterator<String> dirit = directories.iterator(); | ||||
counter = 0; | counter = 0; | ||||
while (dirit.hasNext()) { | while (dirit.hasNext()) { | ||||
currentdirectory = (String) dirit.next(); | |||||
currentdirectory = dirit.next(); | |||||
assertEquals(expectedDirectories[counter], currentdirectory); | assertEquals(expectedDirectories[counter], currentdirectory); | ||||
counter++; | counter++; | ||||
} | } | ||||
@@ -53,12 +53,24 @@ public class ExecutorTest implements BuildListener { | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
targetCount++; | targetCount++; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event) {} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
@@ -50,7 +50,7 @@ public class ExtendedTaskdefTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testRun"); | buildRule.executeTarget("testRun"); | ||||
fail("BuildException should have been thrown"); | fail("BuildException should have been thrown"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage()); | assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -60,7 +60,7 @@ public class ExtendedTaskdefTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testRun2"); | buildRule.executeTarget("testRun2"); | ||||
fail("BuildException should have been thrown"); | fail("BuildException should have been thrown"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage()); | assertContains("exception thrown by the subclass", "executing the Foo task", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -58,7 +58,6 @@ public class FileUtilities { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Modified the timestamp on a file so it's <tt>seconds</tt> earlier than it was before. Where <tt>file</tt> | * Modified the timestamp on a file so it's <tt>seconds</tt> earlier than it was before. Where <tt>file</tt> | ||||
* is a directory, this function recurses into all child files (and directories) and reduces their modified | * is a directory, this function recurses into all child files (and directories) and reduces their modified | ||||
@@ -66,7 +65,7 @@ public class FileUtilities { | |||||
* @param file the file to change, or the directory to change then recurse into | * @param file the file to change, or the directory to change then recurse into | ||||
* @param seconds how many seconds to roll the timestamp back by | * @param seconds how many seconds to roll the timestamp back by | ||||
*/ | */ | ||||
public static void rollbackTimetamps(File file, long seconds) { | |||||
public static void rollbackTimestamps(File file, long seconds) { | |||||
if (null == file || !file.exists()) { | if (null == file || !file.exists()) { | ||||
return; | return; | ||||
} | } | ||||
@@ -80,7 +79,7 @@ public class FileUtilities { | |||||
return; | return; | ||||
} | } | ||||
for (File child : children) { | for (File child : children) { | ||||
rollbackTimetamps(child, seconds); | |||||
rollbackTimestamps(child, seconds); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -19,8 +19,8 @@ | |||||
package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
import java.io.File; | import java.io.File; | ||||
import java.lang.reflect.Method; | |||||
import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
import java.lang.reflect.Method; | |||||
import java.nio.file.Path; | import java.nio.file.Path; | ||||
import java.nio.file.Paths; | import java.nio.file.Paths; | ||||
import java.util.Enumeration; | import java.util.Enumeration; | ||||
@@ -30,6 +30,7 @@ import java.util.Iterator; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Locale; | import java.util.Locale; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.apache.tools.ant.taskdefs.condition.Os; | import org.apache.tools.ant.taskdefs.condition.Os; | ||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.ComparisonFailure; | import org.junit.ComparisonFailure; | ||||
@@ -98,7 +99,8 @@ public class IntrospectionHelperTest { | |||||
ih = IntrospectionHelper.getHelper(String.class); | ih = IntrospectionHelper.getHelper(String.class); | ||||
try { | try { | ||||
m = ih.getAddTextMethod(); | m = ih.getAddTextMethod(); | ||||
} catch (BuildException e) {} | |||||
} catch (BuildException e) { | |||||
} | |||||
} | } | ||||
@Test | @Test | ||||
@@ -221,7 +223,7 @@ public class IntrospectionHelperTest { | |||||
Class expect = (Class) elemMap.get(name); | Class expect = (Class) elemMap.get(name); | ||||
assertNotNull("Support for "+name+" in IntrospectioNHelperTest?", | assertNotNull("Support for "+name+" in IntrospectioNHelperTest?", | ||||
expect); | expect); | ||||
assertEquals("Return type of "+name, expect, ih.getElementType(name)); | |||||
assertEquals("Return type of " + name, expect, ih.getElementType(name)); | |||||
elemMap.remove(name); | elemMap.remove(name); | ||||
} | } | ||||
assertTrue("Found all", elemMap.isEmpty()); | assertTrue("Found all", elemMap.isEmpty()); | ||||
@@ -246,7 +248,8 @@ public class IntrospectionHelperTest { | |||||
try { | try { | ||||
actualMap.clear(); | actualMap.clear(); | ||||
//TODO we should be asserting a value somewhere in here | //TODO we should be asserting a value somewhere in here | ||||
} catch (UnsupportedOperationException e) {} | |||||
} catch (UnsupportedOperationException e) { | |||||
} | |||||
} | } | ||||
@Test | @Test | ||||
@@ -276,7 +279,8 @@ public class IntrospectionHelperTest { | |||||
return null; | return null; | ||||
} | } | ||||
public void createThree() {} | |||||
public void createThree() { | |||||
} | |||||
public Object[] createFour() { | public Object[] createFour() { | ||||
return null; | return null; | ||||
@@ -294,19 +298,24 @@ public class IntrospectionHelperTest { | |||||
throw new NullPointerException(); | throw new NullPointerException(); | ||||
} | } | ||||
public void addSeven(String s, String s2) {} | |||||
public void addSeven(String s, String s2) { | |||||
} | |||||
public void addEight() {} | |||||
public void addEight() { | |||||
} | |||||
public String addNine(String s) { | public String addNine(String s) { | ||||
return null; | return null; | ||||
} | } | ||||
public void addTen(String[] s) {} | |||||
public void addTen(String[] s) { | |||||
} | |||||
public void addEleven(int i) {} | |||||
public void addEleven(int i) { | |||||
} | |||||
public void addTwelve(Class c) {} | |||||
public void addTwelve(Class c) { | |||||
} | |||||
public void addThirteen(StringBuffer sb) { | public void addThirteen(StringBuffer sb) { | ||||
sb.append("test"); | sb.append("test"); | ||||
@@ -378,7 +387,7 @@ public class IntrospectionHelperTest { | |||||
ih.setAttribute(p, this, "ten", "2"); | ih.setAttribute(p, this, "ten", "2"); | ||||
try { | try { | ||||
ih.setAttribute(p, this, "ten", "3"); | ih.setAttribute(p, this, "ten", "3"); | ||||
fail(projectBasedir+"2 shouldn't be equals to "+projectBasedir+"3"); | |||||
fail(projectBasedir + "2 shouldn't be equals to " + projectBasedir + "3"); | |||||
} catch (BuildException be) { | } catch (BuildException be) { | ||||
assertTrue(be.getCause() instanceof AssertionError); | assertTrue(be.getCause() instanceof AssertionError); | ||||
} | } | ||||
@@ -518,7 +527,8 @@ public class IntrospectionHelperTest { | |||||
try { | try { | ||||
actualMap.clear(); | actualMap.clear(); | ||||
//TODO we should be asserting a value somewhere in here | //TODO we should be asserting a value somewhere in here | ||||
} catch (UnsupportedOperationException e) {} | |||||
} catch (UnsupportedOperationException e) { | |||||
} | |||||
} | } | ||||
@Test | @Test | ||||
@@ -570,13 +580,17 @@ public class IntrospectionHelperTest { | |||||
return 0; | return 0; | ||||
} | } | ||||
public void setThree() {} | |||||
public void setThree() { | |||||
} | |||||
public void setFour(String s1, String s2) {} | |||||
public void setFour(String s1, String s2) { | |||||
} | |||||
public void setFive(String[] s) {} | |||||
public void setFive(String[] s) { | |||||
} | |||||
public void setSix(Project p) {} | |||||
public void setSix(Project p) { | |||||
} | |||||
public void setSeven(String s) { | public void setSeven(String s) { | ||||
assertEquals("2", s); | assertEquals("2", s); | ||||
@@ -593,11 +607,11 @@ public class IntrospectionHelperTest { | |||||
public void setTen(File f) { | public void setTen(File f) { | ||||
String path = f.getAbsolutePath(); | String path = f.getAbsolutePath(); | ||||
if (Os.isFamily("unix") || Os.isFamily("openvms")) { | if (Os.isFamily("unix") || Os.isFamily("openvms")) { | ||||
assertEquals(projectBasedir+"2", path); | |||||
assertEquals(projectBasedir + "2", path); | |||||
} else if (Os.isFamily("netware")) { | } else if (Os.isFamily("netware")) { | ||||
assertEquals(projectBasedir+"2", path.toLowerCase(Locale.US)); | |||||
assertEquals(projectBasedir + "2", path.toLowerCase(Locale.US)); | |||||
} else { | } else { | ||||
assertEquals(":"+projectBasedir+"2", | |||||
assertEquals(":" + projectBasedir + "2", | |||||
path.toLowerCase(Locale.US).substring(1)); | path.toLowerCase(Locale.US).substring(1)); | ||||
} | } | ||||
} | } | ||||
@@ -642,11 +656,11 @@ public class IntrospectionHelperTest { | |||||
public void setTwenty(Path p) { | public void setTwenty(Path p) { | ||||
String path = p.toAbsolutePath().toString(); | String path = p.toAbsolutePath().toString(); | ||||
if (Os.isFamily("unix") || Os.isFamily("openvms")) { | if (Os.isFamily("unix") || Os.isFamily("openvms")) { | ||||
assertEquals(projectBasedir+"20", path); | |||||
assertEquals(projectBasedir + "20", path); | |||||
} else if (Os.isFamily("netware")) { | } else if (Os.isFamily("netware")) { | ||||
assertEquals(projectBasedir+"20", path.toLowerCase(Locale.US)); | |||||
assertEquals(projectBasedir + "20", path.toLowerCase(Locale.US)); | |||||
} else { | } else { | ||||
assertEquals(":"+projectBasedir+"20", | |||||
assertEquals(":" + projectBasedir + "20", | |||||
path.toLowerCase(Locale.US).substring(1)); | path.toLowerCase(Locale.US).substring(1)); | ||||
} | } | ||||
} | } | ||||
@@ -32,17 +32,29 @@ public class MockBuildListener implements BuildListener { | |||||
this.project = project; | this.project = project; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetStarted(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event) {} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(final BuildEvent actual) { | public void messageLogged(final BuildEvent actual) { | ||||
if(actual.getPriority()==Project.MSG_DEBUG) | |||||
if (actual.getPriority() == Project.MSG_DEBUG) { | |||||
return; | return; | ||||
assertTrue("unexpected messageLogged: "+actual.getMessage(), !buffer.isEmpty()); | |||||
} | |||||
assertTrue("unexpected messageLogged: "+ actual.getMessage(), !buffer.isEmpty()); | |||||
assertEquals("unexpected project ", project, actual.getProject()); | assertEquals("unexpected project ", project, actual.getProject()); | ||||
BuildEvent expected = (BuildEvent) buffer.elementAt(0); | BuildEvent expected = (BuildEvent) buffer.elementAt(0); | ||||
@@ -78,7 +78,7 @@ public class ProjectHelperRepositoryTest { | |||||
public void testNoDefaultContructor() throws Exception { | public void testNoDefaultContructor() throws Exception { | ||||
class IncrrectHelper extends ProjectHelper { | class IncrrectHelper extends ProjectHelper { | ||||
// the default constructor is not visible to ant here | |||||
// the default constructor is not visible to ant here | |||||
} | } | ||||
ProjectHelperRepository repo = ProjectHelperRepository.getInstance(); | ProjectHelperRepository repo = ProjectHelperRepository.getInstance(); | ||||
@@ -89,7 +89,7 @@ public class ProjectTest { | |||||
*/ | */ | ||||
String driveSpec = "C:"; | String driveSpec = "C:"; | ||||
String driveSpecLower = "c:"; | String driveSpecLower = "c:"; | ||||
assertEqualsIgnoreDriveCase(driveSpecLower + "\\", | assertEqualsIgnoreDriveCase(driveSpecLower + "\\", | ||||
p.resolveFile(driveSpec + "/", null).getPath()); | p.resolveFile(driveSpec + "/", null).getPath()); | ||||
assertEqualsIgnoreDriveCase(driveSpecLower + "\\", | assertEqualsIgnoreDriveCase(driveSpecLower + "\\", | ||||
@@ -168,8 +168,8 @@ public class ProjectTest { | |||||
private void assertEqualsIgnoreDriveCase(String s1, String s2) { | private void assertEqualsIgnoreDriveCase(String s1, String s2) { | ||||
if ((Os.isFamily("dos") || Os.isFamily("netware")) | if ((Os.isFamily("dos") || Os.isFamily("netware")) | ||||
&& s1.length() >= 1 && s2.length() >= 1) { | && s1.length() >= 1 && s2.length() >= 1) { | ||||
StringBuffer sb1 = new StringBuffer(s1); | |||||
StringBuffer sb2 = new StringBuffer(s2); | |||||
StringBuilder sb1 = new StringBuilder(s1); | |||||
StringBuilder sb2 = new StringBuilder(s2); | |||||
sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); | sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); | ||||
sb2.setCharAt(0, Character.toUpperCase(s2.charAt(0))); | sb2.setCharAt(0, Character.toUpperCase(s2.charAt(0))); | ||||
assertEquals(sb1.toString(), sb2.toString()); | assertEquals(sb1.toString(), sb2.toString()); | ||||
@@ -184,9 +184,9 @@ public class ProjectTest { | |||||
try { | try { | ||||
mbl.addBuildEvent(message, Project.MSG_ERR); | mbl.addBuildEvent(message, Project.MSG_ERR); | ||||
p.addTaskDefinition(dummyName, taskClass); | p.addTaskDefinition(dummyName, taskClass); | ||||
fail("expected BuildException(\""+message+"\", Project.MSG_ERR) when adding task " + taskClass); | |||||
} | |||||
catch(BuildException e) { | |||||
fail(String.format("expected BuildException(\"%s\", Project.MSG_ERR) when adding task %s", | |||||
message, taskClass)); | |||||
} catch (BuildException e) { | |||||
assertEquals(message, e.getMessage()); | assertEquals(message, e.getMessage()); | ||||
mbl.assertEmpty(); | mbl.assertEmpty(); | ||||
assertTrue(!p.getTaskDefinitions().containsKey(dummyName)); | assertTrue(!p.getTaskDefinitions().containsKey(dummyName)); | ||||
@@ -203,23 +203,27 @@ public class ProjectTest { | |||||
assertEquals(DummyTaskOkNonTask.class, p.getTaskDefinitions().get("OkNonTask")); | assertEquals(DummyTaskOkNonTask.class, p.getTaskDefinitions().get("OkNonTask")); | ||||
mbl.assertEmpty(); | mbl.assertEmpty(); | ||||
assertTaskDefFails(DummyTaskPrivate.class, DummyTaskPrivate.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskPrivate.class, | |||||
DummyTaskPrivate.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskProtected.class, | assertTaskDefFails(DummyTaskProtected.class, | ||||
DummyTaskProtected.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskPackage.class, DummyTaskPackage.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskAbstract.class, DummyTaskAbstract.class + " is abstract"); | |||||
assertTaskDefFails(DummyTaskInterface.class, DummyTaskInterface.class + " is abstract"); | |||||
assertTaskDefFails(DummyTaskWithoutDefaultConstructor.class, "No public no-arg constructor in " + DummyTaskWithoutDefaultConstructor.class); | |||||
assertTaskDefFails(DummyTaskWithoutPublicConstructor.class, "No public no-arg constructor in " + DummyTaskWithoutPublicConstructor.class); | |||||
assertTaskDefFails(DummyTaskWithoutExecute.class, "No public execute() in " + DummyTaskWithoutExecute.class); | |||||
assertTaskDefFails(DummyTaskWithNonPublicExecute.class, "No public execute() in " + DummyTaskWithNonPublicExecute.class); | |||||
mbl.addBuildEvent("return type of execute() should be void but was \"int\" in " + DummyTaskWithNonVoidExecute.class, Project.MSG_WARN); | |||||
DummyTaskProtected.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskPackage.class, | |||||
DummyTaskPackage.class + " is not public"); | |||||
assertTaskDefFails(DummyTaskAbstract.class, | |||||
DummyTaskAbstract.class + " is abstract"); | |||||
assertTaskDefFails(DummyTaskInterface.class, | |||||
DummyTaskInterface.class + " is abstract"); | |||||
assertTaskDefFails(DummyTaskWithoutDefaultConstructor.class, | |||||
"No public no-arg constructor in " + DummyTaskWithoutDefaultConstructor.class); | |||||
assertTaskDefFails(DummyTaskWithoutPublicConstructor.class, | |||||
"No public no-arg constructor in " + DummyTaskWithoutPublicConstructor.class); | |||||
assertTaskDefFails(DummyTaskWithoutExecute.class, | |||||
"No public execute() in " + DummyTaskWithoutExecute.class); | |||||
assertTaskDefFails(DummyTaskWithNonPublicExecute.class, | |||||
"No public execute() in " + DummyTaskWithNonPublicExecute.class); | |||||
mbl.addBuildEvent("return type of execute() should be void but was \"int\" in " | |||||
+ DummyTaskWithNonVoidExecute.class, Project.MSG_WARN); | |||||
p.addTaskDefinition("NonVoidExecute", DummyTaskWithNonVoidExecute.class); | p.addTaskDefinition("NonVoidExecute", DummyTaskWithNonVoidExecute.class); | ||||
mbl.assertEmpty(); | mbl.assertEmpty(); | ||||
assertEquals(DummyTaskWithNonVoidExecute.class, p.getTaskDefinitions().get("NonVoidExecute")); | assertEquals(DummyTaskWithNonVoidExecute.class, p.getTaskDefinitions().get("NonVoidExecute")); | ||||
@@ -271,12 +275,18 @@ public class ProjectTest { | |||||
throws InterruptedException { | throws InterruptedException { | ||||
final String FOO = "foo", BAR = "bar"; | final String FOO = "foo", BAR = "bar"; | ||||
p.addBuildListener(new BuildListener() { | p.addBuildListener(new BuildListener() { | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetStarted(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event) {} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(final BuildEvent actual) { | public void messageLogged(final BuildEvent actual) { | ||||
assertEquals(FOO, actual.getMessage()); | assertEquals(FOO, actual.getMessage()); | ||||
// each of the following lines would cause an | // each of the following lines would cause an | ||||
@@ -309,19 +319,25 @@ public class ProjectTest { | |||||
} | } | ||||
private class DummyTaskPrivate extends Task { | private class DummyTaskPrivate extends Task { | ||||
public DummyTaskPrivate() {} | |||||
public void execute() {} | |||||
@SuppressWarnings("unused") | |||||
public DummyTaskPrivate() { | |||||
} | |||||
public void execute() { | |||||
} | |||||
} | } | ||||
protected class DummyTaskProtected extends Task { | protected class DummyTaskProtected extends Task { | ||||
public DummyTaskProtected() {} | |||||
public void execute() {} | |||||
public DummyTaskProtected() { | |||||
} | |||||
public void execute() { | |||||
} | |||||
} | } | ||||
class DummyTaskPackage extends Task { | class DummyTaskPackage extends Task { | ||||
public DummyTaskPackage() {} | |||||
public void execute() {} | |||||
public DummyTaskPackage() { | |||||
} | |||||
public void execute() { | |||||
} | |||||
} | } | ||||
} | |||||
} |
@@ -28,7 +28,7 @@ public class TaskContainerTest { | |||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
buildRule.configureProject("src/etc/testcases/core/taskcontainer.xml"); | buildRule.configureProject("src/etc/testcases/core/taskcontainer.xml"); | ||||
@@ -57,17 +57,22 @@ public class UnknownElementTest { | |||||
@Ignore("Previously disabled through naming convention") | @Ignore("Previously disabled through naming convention") | ||||
public void XtestTaskFinishedEvent() { | public void XtestTaskFinishedEvent() { | ||||
buildRule.getProject().addBuildListener(new BuildListener() { | buildRule.getProject().addBuildListener(new BuildListener() { | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetStarted(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | public void taskStarted(BuildEvent event) { | ||||
assertTaskProperties(event.getTask()); | assertTaskProperties(event.getTask()); | ||||
} | } | ||||
public void taskFinished(BuildEvent event) { | public void taskFinished(BuildEvent event) { | ||||
assertTaskProperties(event.getTask()); | assertTaskProperties(event.getTask()); | ||||
} | } | ||||
public void messageLogged(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
private void assertTaskProperties(Task ue) { | private void assertTaskProperties(Task ue) { | ||||
assertNotNull(ue); | assertNotNull(ue); | ||||
assertTrue(ue instanceof UnknownElement); | assertTrue(ue instanceof UnknownElement); | ||||
@@ -111,5 +116,3 @@ public class UnknownElementTest { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -43,32 +43,28 @@ public class ConcatFilterTest { | |||||
+ "Line 1" + lSep | + "Line 1" + lSep | ||||
+ "Line 2" + lSep | + "Line 2" + lSep | ||||
+ "Line 3" + lSep | + "Line 3" + lSep | ||||
+ "Line 4" + lSep | |||||
; | |||||
+ "Line 4" + lSep; | |||||
private static final String FILE_PREPEND = | private static final String FILE_PREPEND = | ||||
"Line 1" + lSep | "Line 1" + lSep | ||||
+ "Line 2" + lSep | + "Line 2" + lSep | ||||
+ "Line 3" + lSep | + "Line 3" + lSep | ||||
+ "Line 4" + lSep | + "Line 4" + lSep | ||||
+ "Line 5" + lSep | |||||
; | |||||
+ "Line 5" + lSep; | |||||
private static final String FILE_APPEND_WITH = | private static final String FILE_APPEND_WITH = | ||||
"Line 57" + lSep | "Line 57" + lSep | ||||
+ "Line 58" + lSep | + "Line 58" + lSep | ||||
+ "Line 59" + lSep | + "Line 59" + lSep | ||||
+ "Line 60" + lSep | + "Line 60" + lSep | ||||
+ "this-should-be-the-last-line" + lSep | |||||
; | |||||
+ "this-should-be-the-last-line" + lSep; | |||||
private static final String FILE_APPEND = | private static final String FILE_APPEND = | ||||
"Line 56" + lSep | "Line 56" + lSep | ||||
+ "Line 57" + lSep | + "Line 57" + lSep | ||||
+ "Line 58" + lSep | + "Line 58" + lSep | ||||
+ "Line 59" + lSep | + "Line 59" + lSep | ||||
+ "Line 60" + lSep | |||||
; | |||||
+ "Line 60" + lSep; | |||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@@ -49,8 +49,6 @@ public class DynamicFilterTest { | |||||
assertContains("hellO wOrld", content); | assertContains("hellO wOrld", content); | ||||
} | } | ||||
public static class CustomFilter implements ChainableReader { | public static class CustomFilter implements ChainableReader { | ||||
char replace = 'x'; | char replace = 'x'; | ||||
char with = 'y'; | char with = 'y'; | ||||
@@ -65,14 +63,13 @@ public class DynamicFilterTest { | |||||
public Reader chain(final Reader rdr) { | public Reader chain(final Reader rdr) { | ||||
return new BaseFilterReader(rdr) { | return new BaseFilterReader(rdr) { | ||||
public int read() | |||||
throws IOException | |||||
{ | |||||
public int read() throws IOException { | |||||
int c = in.read(); | int c = in.read(); | ||||
if (c == replace) | |||||
if (c == replace) { | |||||
return with; | return with; | ||||
else | |||||
} else { | |||||
return c; | return c; | ||||
} | |||||
} | } | ||||
}; | }; | ||||
} | } | ||||
@@ -38,7 +38,7 @@ public class HeadTailTest { | |||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
buildRule.configureProject("src/etc/testcases/filters/head-tail.xml"); | buildRule.configureProject("src/etc/testcases/filters/head-tail.xml"); | ||||
@@ -32,10 +32,9 @@ import static org.junit.Assert.assertEquals; | |||||
public class LineContainsTest { | public class LineContainsTest { | ||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
buildRule.configureProject("src/etc/testcases/filters/build.xml"); | buildRule.configureProject("src/etc/testcases/filters/build.xml"); | ||||
@@ -251,9 +251,7 @@ public class TokenFilterTest { | |||||
// Helper methods | // Helper methods | ||||
// ----------------------------------------------------- | // ----------------------------------------------------- | ||||
private String getFileString(String filename) | |||||
throws IOException | |||||
{ | |||||
private String getFileString(String filename) throws IOException { | |||||
Reader r = null; | Reader r = null; | ||||
try { | try { | ||||
r = new FileReader(FILE_UTILS.resolveFile(buildRule.getProject().getBaseDir(),filename)); | r = new FileReader(FILE_UTILS.resolveFile(buildRule.getProject().getBaseDir(),filename)); | ||||
@@ -265,9 +263,7 @@ public class TokenFilterTest { | |||||
} | } | ||||
public static class Capitalize | |||||
implements TokenFilter.Filter | |||||
{ | |||||
public static class Capitalize implements TokenFilter.Filter { | |||||
public String filter(String token) { | public String filter(String token) { | ||||
if (token.length() == 0) | if (token.length() == 0) | ||||
return token; | return token; | ||||
@@ -33,7 +33,8 @@ public class LocatorTest { | |||||
private boolean windows; | private boolean windows; | ||||
private boolean unix; | private boolean unix; | ||||
private static final String LAUNCHER_JAR = "//morzine/slo/Java/Apache/ant/lib/ant-launcher.jar"; | private static final String LAUNCHER_JAR = "//morzine/slo/Java/Apache/ant/lib/ant-launcher.jar"; | ||||
private static final String SHARED_JAR_URI = "jar:file:"+ LAUNCHER_JAR +"!/org/apache/tools/ant/launch/Launcher.class"; | |||||
private static final String SHARED_JAR_URI = "jar:file:" + LAUNCHER_JAR + | |||||
"!/org/apache/tools/ant/launch/Launcher.class"; | |||||
@Before | @Before | ||||
@@ -84,8 +85,8 @@ public class LocatorTest { | |||||
/** | /** | ||||
* this isnt really a valid URI, except maybe in IE | |||||
* @throws Exception | |||||
* this isn't really a valid URI, except maybe in IE | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
public void testNetworkURI() throws Exception { | public void testNetworkURI() throws Exception { | ||||
resolveTo("file:\\\\PC03\\jclasses\\lib\\ant-1.7.0.jar", "" | resolveTo("file:\\\\PC03\\jclasses\\lib\\ant-1.7.0.jar", "" | ||||
@@ -126,7 +127,7 @@ public class LocatorTest { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testAntOnRemoteShare() throws Throwable { | public void testAntOnRemoteShare() throws Throwable { | ||||
String resolved=Locator.fromJarURI(SHARED_JAR_URI); | |||||
String resolved = Locator.fromJarURI(SHARED_JAR_URI); | |||||
assertResolved(SHARED_JAR_URI, LAUNCHER_JAR, resolved, unix); | assertResolved(SHARED_JAR_URI, LAUNCHER_JAR, resolved, unix); | ||||
assertResolved(SHARED_JAR_URI, LAUNCHER_JAR.replace('/', '\\'), | assertResolved(SHARED_JAR_URI, LAUNCHER_JAR.replace('/', '\\'), | ||||
resolved, windows); | resolved, windows); | ||||
@@ -67,4 +67,4 @@ public class AntLikeTasksAtTopLevelTest { | |||||
} | } | ||||
} | } | ||||
}// AntLikeTasksAtTopLevelTest | |||||
} |
@@ -415,12 +415,23 @@ public class AntTest { | |||||
expectedBasedirs = dirs; | expectedBasedirs = dirs; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event){} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
if (event.getTarget().getName().equals("")) { | if (event.getTarget().getName().equals("")) { | ||||
@@ -455,12 +466,23 @@ public class AntTest { | |||||
this.value = value; | this.value = value; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event){} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
if (event.getTarget().getName().equals("")) { | if (event.getTarget().getName().equals("")) { | ||||
@@ -488,7 +510,7 @@ public class AntTest { | |||||
String[] l1 = expect.list(); | String[] l1 = expect.list(); | ||||
String[] l2 = received.list(); | String[] l2 = received.list(); | ||||
if (l1.length == l2.length) { | if (l1.length == l2.length) { | ||||
for (int i=0; i<l1.length; i++) { | |||||
for (int i = 0; i < l1.length; i++) { | |||||
if (!l1[i].equals(l2[i])) { | if (!l1[i].equals(l2[i])) { | ||||
assertTrue(msg, !shouldBeEqual); | assertTrue(msg, !shouldBeEqual); | ||||
} | } | ||||
@@ -570,12 +592,23 @@ public class AntTest { | |||||
this.expectedValues = values; | this.expectedValues = values; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event){} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
if (event.getTarget().getName().equals("")) { | if (event.getTarget().getName().equals("")) { | ||||
@@ -19,8 +19,8 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.apache.tools.ant.Task; | |||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.Task; | |||||
import org.junit.Assume; | import org.junit.Assume; | ||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Rule; | import org.junit.Rule; | ||||
@@ -42,11 +42,11 @@ public class AntlibTest { | |||||
/** | /** | ||||
* only do the antlib tests if we are in the same JVM as ant. | * only do the antlib tests if we are in the same JVM as ant. | ||||
* @return | |||||
* @return boolean | |||||
*/ | */ | ||||
private boolean isSharedJVM() { | private boolean isSharedJVM() { | ||||
String property = System.getProperty("tests.and.ant.share.classloader"); | String property = System.getProperty("tests.and.ant.share.classloader"); | ||||
return property!=null && Project.toBoolean(property); | |||||
return property != null && Project.toBoolean(property); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -19,6 +19,8 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.apache.tools.ant.FileUtilities; | import org.apache.tools.ant.FileUtilities; | ||||
import org.junit.Before; | import org.junit.Before; | ||||
@@ -43,16 +45,16 @@ public class BUnzip2Test { | |||||
} | } | ||||
@Test | @Test | ||||
public void testRealTest() throws java.io.IOException { | |||||
public void testRealTest() throws IOException { | |||||
testRealTest("realTest"); | testRealTest("realTest"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testRealTestWithResource() throws java.io.IOException { | |||||
public void testRealTestWithResource() throws IOException { | |||||
testRealTest("realTestWithResource"); | testRealTest("realTestWithResource"); | ||||
} | } | ||||
private void testRealTest(String target) throws java.io.IOException { | |||||
private void testRealTest(String target) throws IOException { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
assertEquals("File content mismatch after bunzip2", | assertEquals("File content mismatch after bunzip2", | ||||
FileUtilities.getFileContents(new File(outputDir, "asf-logo-huge-from-gzip.tar")), | FileUtilities.getFileContents(new File(outputDir, "asf-logo-huge-from-gzip.tar")), | ||||
@@ -60,7 +62,7 @@ public class BUnzip2Test { | |||||
} | } | ||||
@Test | @Test | ||||
public void testDocumentationClaimsOnCopy() throws java.io.IOException { | |||||
public void testDocumentationClaimsOnCopy() throws IOException { | |||||
testRealTest("testDocumentationClaimsOnCopy"); | testRealTest("testDocumentationClaimsOnCopy"); | ||||
} | } | ||||
} | } |
@@ -101,12 +101,12 @@ public class BZip2Test { | |||||
} | } | ||||
@Test | @Test | ||||
public void testResource(){ | |||||
public void testResource() { | |||||
buildRule.executeTarget("realTestWithResource"); | buildRule.executeTarget("realTestWithResource"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testDateCheck(){ | |||||
public void testDateCheck() { | |||||
buildRule.executeTarget("testDateCheck"); | buildRule.executeTarget("testDateCheck"); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue( | assertTrue( | ||||
@@ -18,7 +18,7 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.*; | |||||
import java.io.File; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
@@ -56,20 +56,20 @@ public class CVSPassTest { | |||||
@Test | @Test | ||||
public void testNoCVSRoot() { | public void testNoCVSRoot() { | ||||
try{ | |||||
try { | |||||
buildRule.executeTarget("test1"); | buildRule.executeTarget("test1"); | ||||
fail("BuildException not thrown"); | fail("BuildException not thrown"); | ||||
}catch(BuildException e){ | |||||
} catch (BuildException e) { | |||||
assertEquals("cvsroot is required", e.getMessage()); | assertEquals("cvsroot is required", e.getMessage()); | ||||
} | } | ||||
} | } | ||||
@Test | @Test | ||||
public void testNoPassword() { | public void testNoPassword() { | ||||
try{ | |||||
try { | |||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
fail("BuildException not thrown"); | fail("BuildException not thrown"); | ||||
}catch(BuildException e){ | |||||
} catch (BuildException e) { | |||||
assertEquals("password is required", e.getMessage()); | assertEquals("password is required", e.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -84,10 +84,9 @@ public class CVSPassTest { | |||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | ||||
assertTrue( "Passfile "+f+" not created", f.exists()); | |||||
assertEquals(JAKARTA_URL+EOL, FileUtilities.getFileContents(f)); | |||||
assertTrue("Passfile " + f + " not created", f.exists()); | |||||
assertEquals(JAKARTA_URL + EOL, FileUtilities.getFileContents(f)); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -95,11 +94,9 @@ public class CVSPassTest { | |||||
buildRule.executeTarget("test4"); | buildRule.executeTarget("test4"); | ||||
File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | ||||
assertTrue( "Passfile "+f+" not created", f.exists()); | |||||
assertTrue("Passfile " + f + " not created", f.exists()); | |||||
assertEquals( | |||||
JAKARTA_URL+ EOL+ | |||||
TIGRIS_URL+ EOL, | |||||
assertEquals(JAKARTA_URL + EOL+ TIGRIS_URL + EOL, | |||||
FileUtilities.getFileContents(f)); | FileUtilities.getFileContents(f)); | ||||
} | } | ||||
@@ -108,12 +105,9 @@ public class CVSPassTest { | |||||
buildRule.executeTarget("test5"); | buildRule.executeTarget("test5"); | ||||
File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | File f = new File(buildRule.getProject().getBaseDir(), "testpassfile.tmp"); | ||||
assertTrue( "Passfile "+f+" not created", f.exists()); | |||||
assertTrue("Passfile " + f + " not created", f.exists()); | |||||
assertEquals( | |||||
JAKARTA_URL+ EOL+ | |||||
XML_URL+ EOL+ | |||||
TIGRIS_URL+ EOL, | |||||
assertEquals(JAKARTA_URL + EOL + XML_URL + EOL+ TIGRIS_URL + EOL, | |||||
FileUtilities.getFileContents(f)); | FileUtilities.getFileContents(f)); | ||||
} | } | ||||
} | } |
@@ -18,14 +18,14 @@ | |||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.junit.After; | import org.junit.After; | ||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Rule; | import org.junit.Rule; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.io.IOException; | |||||
public class ChecksumTest { | public class ChecksumTest { | ||||
@Rule | @Rule | ||||
@@ -96,7 +96,7 @@ public class ConcatTest { | |||||
try { | try { | ||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
fail("BuildException should have been thrown - Invalid destination file"); | fail("BuildException should have been thrown - Invalid destination file"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
//TODO assert value | //TODO assert value | ||||
} | } | ||||
} | } | ||||
@@ -192,7 +192,7 @@ public class ConcatTest { | |||||
File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2); | File file2 = new File(buildRule.getProject().getBaseDir(), tempFile2); | ||||
final long newSize = file2.length(); | final long newSize = file2.length(); | ||||
assertEquals(origSize*2, newSize); | |||||
assertEquals(origSize * 2, newSize); | |||||
} | } | ||||
@@ -267,9 +267,7 @@ public class ConcatTest { | |||||
* Check if fixlastline works | * Check if fixlastline works | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testfixlastline() | |||||
throws IOException | |||||
{ | |||||
public void testfixlastline() throws IOException { | |||||
buildRule.executeTarget("testfixlastline"); | buildRule.executeTarget("testfixlastline"); | ||||
assertContains("end of line" + System.getProperty("line.separator") + "This has", | assertContains("end of line" + System.getProperty("line.separator") + "This has", | ||||
FileUtilities.getFileContents(buildRule.getProject(), "concat.line4")); | FileUtilities.getFileContents(buildRule.getProject(), "concat.line4")); | ||||
@@ -279,14 +277,11 @@ public class ConcatTest { | |||||
* Check if fixlastline works with eol | * Check if fixlastline works with eol | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testfixlastlineeol() | |||||
throws IOException | |||||
{ | |||||
public void testfixlastlineeol() throws IOException { | |||||
buildRule.executeTarget("testfixlastlineeol"); | buildRule.executeTarget("testfixlastlineeol"); | ||||
assertContains("end of line\rThis has", FileUtilities.getFileContents(buildRule.getProject(), "concat.linecr")); | assertContains("end of line\rThis has", FileUtilities.getFileContents(buildRule.getProject(), "concat.linecr")); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTranscoding() throws IOException { | public void testTranscoding() throws IOException { | ||||
buildRule.executeTarget("testTranscoding"); | buildRule.executeTarget("testTranscoding"); | ||||
@@ -299,10 +294,9 @@ public class ConcatTest { | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// Helper methods - should be in a utility class | // Helper methods - should be in a utility class | ||||
// ----------------------------------------------------- | // ----------------------------------------------------- | ||||
private void expectFileContainsx( | |||||
String target, String filename, String contains) | |||||
throws IOException | |||||
{ | |||||
@SuppressWarnings("unused") | |||||
private void expectFileContainsx(String target, String filename, String contains) | |||||
throws IOException { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
String content = FileUtilities.getFileContents(buildRule.getProject(), filename); | String content = FileUtilities.getFileContents(buildRule.getProject(), filename); | ||||
assertTrue( | assertTrue( | ||||
@@ -311,5 +305,4 @@ public class ConcatTest { | |||||
" but got " + content, content.indexOf(contains) > -1); | " but got " + content, content.indexOf(contains) > -1); | ||||
} | } | ||||
} | } |
@@ -72,7 +72,7 @@ public class ConditionTest { | |||||
try { | try { | ||||
buildRule.executeTarget("condition-empty"); | buildRule.executeTarget("condition-empty"); | ||||
fail("BuildException should have been thrown - no conditions"); | fail("BuildException should have been thrown - no conditions"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("You must nest a condition into <condition>", ex.getMessage()); | assertEquals("You must nest a condition into <condition>", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -255,7 +255,7 @@ public class ConditionTest { | |||||
try { | try { | ||||
buildRule.executeTarget("contains-incomplete1"); | buildRule.executeTarget("contains-incomplete1"); | ||||
fail("BuildException should have been thrown - Missing contains attribute"); | fail("BuildException should have been thrown - Missing contains attribute"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("both string and substring are required in contains", ex.getMessage()); | assertEquals("both string and substring are required in contains", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -265,7 +265,7 @@ public class ConditionTest { | |||||
try { | try { | ||||
buildRule.executeTarget("contains-incomplete2"); | buildRule.executeTarget("contains-incomplete2"); | ||||
fail("BuildException should have been thrown - Missing contains attribute"); | fail("BuildException should have been thrown - Missing contains attribute"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("both string and substring are required in contains", ex.getMessage()); | assertEquals("both string and substring are required in contains", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -293,7 +293,7 @@ public class ConditionTest { | |||||
try { | try { | ||||
buildRule.executeTarget("istrue-incomplete"); | buildRule.executeTarget("istrue-incomplete"); | ||||
fail("BuildException should have been thrown - Missing attribute"); | fail("BuildException should have been thrown - Missing attribute"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("Nothing to test for truth", ex.getMessage()); | assertEquals("Nothing to test for truth", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -322,7 +322,7 @@ public class ConditionTest { | |||||
try { | try { | ||||
buildRule.executeTarget("isfalse-incomplete"); | buildRule.executeTarget("isfalse-incomplete"); | ||||
fail("BuildException should have been thrown - Missing attribute"); | fail("BuildException should have been thrown - Missing attribute"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("Nothing to test for falsehood", ex.getMessage()); | assertEquals("Nothing to test for falsehood", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -60,7 +60,7 @@ public class CopyTest { | |||||
public void test1() { | public void test1() { | ||||
buildRule.executeTarget("test1"); | buildRule.executeTarget("test1"); | ||||
File f = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp"); | File f = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp"); | ||||
if ( !f.exists()) { | |||||
if (!f.exists()) { | |||||
fail("Copy failed"); | fail("Copy failed"); | ||||
} | } | ||||
} | } | ||||
@@ -69,7 +69,7 @@ public class CopyTest { | |||||
public void test2() { | public void test2() { | ||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
File f = new File(buildRule.getProject().getProperty("output"), "copytest1dir/copy.xml"); | File f = new File(buildRule.getProject().getProperty("output"), "copytest1dir/copy.xml"); | ||||
if ( !f.exists()) { | |||||
if (!f.exists()) { | |||||
fail("Copy failed"); | fail("Copy failed"); | ||||
} | } | ||||
} | } | ||||
@@ -79,7 +79,7 @@ public class CopyTest { | |||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp"); | File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp"); | ||||
//rollback file timestamp instead of delaying test | //rollback file timestamp instead of delaying test | ||||
FileUtilities.rollbackTimetamps(file3, 3); | |||||
FileUtilities.rollbackTimestamps(file3, 3); | |||||
buildRule.executeTarget("test3Part2"); | buildRule.executeTarget("test3Part2"); | ||||
assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
@@ -91,19 +91,19 @@ public class CopyTest { | |||||
assertTrue(file3c.exists()); | assertTrue(file3c.exists()); | ||||
//file length checks rely on touch generating a zero byte file | //file length checks rely on touch generating a zero byte file | ||||
if(file3.length()==0) { | |||||
if (file3.length()==0) { | |||||
fail("could not overwrite an existing, older file"); | fail("could not overwrite an existing, older file"); | ||||
} | } | ||||
if(file3c.length()!=0) { | |||||
if (file3c.length()!=0) { | |||||
fail("could not force overwrite an existing, newer file"); | fail("could not force overwrite an existing, newer file"); | ||||
} | } | ||||
if(file3b.length()==0) { | |||||
if (file3b.length()==0) { | |||||
fail("unexpectedly overwrote an existing, newer file"); | fail("unexpectedly overwrote an existing, newer file"); | ||||
} | } | ||||
//file time checks for java1.2+ | //file time checks for java1.2+ | ||||
assertTrue(file3a.lastModified()==file3.lastModified()); | |||||
assertTrue(file3c.lastModified()<file3a.lastModified()); | |||||
assertTrue(file3a.lastModified() == file3.lastModified()); | |||||
assertTrue(file3c.lastModified() < file3a.lastModified()); | |||||
} | } | ||||
@@ -197,9 +197,9 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testFileResourcePlain() { | public void testFileResourcePlain() { | ||||
buildRule.executeTarget("testFileResourcePlain"); | buildRule.executeTarget("testFileResourcePlain"); | ||||
File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt"); | |||||
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt"); | |||||
assertTrue(file1.exists()); | assertTrue(file1.exists()); | ||||
assertTrue(file2.exists()); | assertTrue(file2.exists()); | ||||
assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
@@ -209,9 +209,9 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testFileResourceWithMapper() { | public void testFileResourceWithMapper() { | ||||
buildRule.executeTarget("testFileResourceWithMapper"); | buildRule.executeTarget("testFileResourceWithMapper"); | ||||
File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt.bak"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt.bak"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt.bak"); | |||||
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt.bak"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt.bak"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt.bak"); | |||||
assertTrue(file1.exists()); | assertTrue(file1.exists()); | ||||
assertTrue(file2.exists()); | assertTrue(file2.exists()); | ||||
assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
@@ -220,7 +220,7 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testFileResourceWithFilter() { | public void testFileResourceWithFilter() { | ||||
buildRule.executeTarget("testFileResourceWithFilter"); | buildRule.executeTarget("testFileResourceWithFilter"); | ||||
File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/fileNR.txt"); | |||||
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/fileNR.txt"); | |||||
assertTrue(file1.exists()); | assertTrue(file1.exists()); | ||||
try { | try { | ||||
String file1Content = FileUtils.readFully(new FileReader(file1)); | String file1Content = FileUtils.readFully(new FileReader(file1)); | ||||
@@ -233,9 +233,9 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testPathAsResource() { | public void testPathAsResource() { | ||||
buildRule.executeTarget("testPathAsResource"); | buildRule.executeTarget("testPathAsResource"); | ||||
File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt"); | |||||
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt"); | |||||
assertTrue(file1.exists()); | assertTrue(file1.exists()); | ||||
assertTrue(file2.exists()); | assertTrue(file2.exists()); | ||||
assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
@@ -244,9 +244,9 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testZipfileset() { | public void testZipfileset() { | ||||
buildRule.executeTarget("testZipfileset"); | buildRule.executeTarget("testZipfileset"); | ||||
File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir")+"/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir")+"/file3.txt"); | |||||
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt"); | |||||
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt"); | |||||
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt"); | |||||
assertTrue(file1.exists()); | assertTrue(file1.exists()); | ||||
assertTrue(file2.exists()); | assertTrue(file2.exists()); | ||||
assertTrue(file3.exists()); | assertTrue(file3.exists()); | ||||
@@ -285,7 +285,7 @@ public class CopyTest { | |||||
* Tests that the {@code copy} task doesn't corrupt the source file, if the target of the copy operation is a symlink | * Tests that the {@code copy} task doesn't corrupt the source file, if the target of the copy operation is a symlink | ||||
* to the source file being copied | * to the source file being copied | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
* @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=60644">issue 60644</a> | * @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=60644">issue 60644</a> | ||||
*/ | */ | ||||
@Test | @Test | ||||
@@ -79,7 +79,7 @@ public class CopydirTest { | |||||
@Test | @Test | ||||
public void test5() { | public void test5() { | ||||
buildRule.executeTarget("test5"); | buildRule.executeTarget("test5"); | ||||
java.io.File f = new java.io.File(new File(buildRule.getProject().getProperty("output")), "taskdefs.tmp"); | |||||
File f = new File(new File(buildRule.getProject().getProperty("output")), "taskdefs.tmp"); | |||||
if (!f.exists() || !f.isDirectory()) { | if (!f.exists() || !f.isDirectory()) { | ||||
fail("Copy failed"); | fail("Copy failed"); | ||||
@@ -157,13 +157,13 @@ public class DefaultExcludesTest { | |||||
private void assertArrayContentsEquals(String message, String[] expected, String[] actual) { | private void assertArrayContentsEquals(String message, String[] expected, String[] actual) { | ||||
// check that both arrays have the same size | // check that both arrays have the same size | ||||
assertEquals(message + " : string array length match", expected.length, actual.length); | assertEquals(message + " : string array length match", expected.length, actual.length); | ||||
for (int counter=0; counter < expected.length; counter++) { | |||||
for (String element : expected) { | |||||
boolean found = false; | boolean found = false; | ||||
for (int i = 0; !found && i < actual.length; i++) { | for (int i = 0; !found && i < actual.length; i++) { | ||||
found |= expected[counter].equals(actual[i]); | |||||
found |= element.equals(actual[i]); | |||||
} | } | ||||
assertTrue(message + " : didn't find element " | assertTrue(message + " : didn't find element " | ||||
+ expected[counter] + " in array match", found); | |||||
+ element + " in array match", found); | |||||
} | } | ||||
} | } | ||||
@@ -46,7 +46,7 @@ public class DirnameTest { | |||||
try { | try { | ||||
buildRule.executeTarget("test1"); | buildRule.executeTarget("test1"); | ||||
fail("Build exception should have been thrown as property attribute is required"); | fail("Build exception should have been thrown as property attribute is required"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("property attribute required", ex.getMessage()); | assertEquals("property attribute required", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -56,7 +56,7 @@ public class DirnameTest { | |||||
try { | try { | ||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
fail("Build exception should have been thrown as file attribute is required"); | fail("Build exception should have been thrown as file attribute is required"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("file attribute required", ex.getMessage()); | assertEquals("file attribute required", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -66,7 +66,7 @@ public class DirnameTest { | |||||
try { | try { | ||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
fail("Build exception should have been thrown as property attribute is required"); | fail("Build exception should have been thrown as property attribute is required"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals("property attribute required", ex.getMessage()); | assertEquals("property attribute required", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -50,7 +50,7 @@ public class EchoTest { | |||||
echo.setProject(p); | echo.setProject(p); | ||||
echo.setTaskName("testLogBlankEcho"); | echo.setTaskName("testLogBlankEcho"); | ||||
echo.execute(); | echo.execute(); | ||||
assertEquals("[testLogBlankEcho] ", logger.lastLoggedMessage ); | |||||
assertEquals("[testLogBlankEcho] ", logger.lastLoggedMessage); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -67,15 +67,14 @@ public class EchoTest { | |||||
echo.setFile(removeThis); | echo.setFile(removeThis); | ||||
echo.setEncoding("UTF-8"); | echo.setEncoding("UTF-8"); | ||||
echo.execute(); | echo.execute(); | ||||
String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8" )); | |||||
String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8")); | |||||
assertEquals(x,"\u00e4\u00a9"); | assertEquals(x,"\u00e4\u00a9"); | ||||
} | } | ||||
@After | @After | ||||
public void tearDown() { | public void tearDown() { | ||||
if (removeThis != null && removeThis.exists()) { | if (removeThis != null && removeThis.exists()) { | ||||
if (!removeThis.delete()) | |||||
{ | |||||
if (!removeThis.delete()) { | |||||
removeThis.deleteOnExit(); | removeThis.deleteOnExit(); | ||||
} | } | ||||
} | } | ||||
@@ -37,15 +37,15 @@ public class ExecuteJavaTest { | |||||
private final static int TIME_OUT = 5000; | private final static int TIME_OUT = 5000; | ||||
private final static int CLOCK_ERROR=200; | |||||
private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; | |||||
private final static int CLOCK_ERROR = 200; | |||||
private final static int TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; | |||||
private ExecuteJava ej; | private ExecuteJava ej; | ||||
private Project project; | private Project project; | ||||
private Path cp; | private Path cp; | ||||
@Before | @Before | ||||
public void setUp(){ | |||||
public void setUp() { | |||||
ej = new ExecuteJava(); | ej = new ExecuteJava(); | ||||
ej.setTimeout((long)TIME_OUT); | ej.setTimeout((long)TIME_OUT); | ||||
project = new Project(); | project = new Project(); | ||||
@@ -64,7 +64,7 @@ public class ExecuteJavaTest { | |||||
@Test | @Test | ||||
public void testNoTimeOut() throws Exception { | public void testNoTimeOut() throws Exception { | ||||
Commandline cmd = getCommandline(TIME_OUT/2); | |||||
Commandline cmd = getCommandline(TIME_OUT / 2); | |||||
ej.setJavaCommand(cmd); | ej.setJavaCommand(cmd); | ||||
ej.execute(project); | ej.execute(project); | ||||
assertTrue("process should not have been killed", !ej.killedProcess()); | assertTrue("process should not have been killed", !ej.killedProcess()); | ||||
@@ -73,24 +73,24 @@ public class ExecuteJavaTest { | |||||
// test that the watchdog ends the process | // test that the watchdog ends the process | ||||
@Test | @Test | ||||
public void testTimeOut() throws Exception { | public void testTimeOut() throws Exception { | ||||
Commandline cmd = getCommandline(TIME_OUT*2); | |||||
Commandline cmd = getCommandline(TIME_OUT * 2); | |||||
ej.setJavaCommand(cmd); | ej.setJavaCommand(cmd); | ||||
long now = System.currentTimeMillis(); | long now = System.currentTimeMillis(); | ||||
ej.execute(project); | ej.execute(project); | ||||
long elapsed = System.currentTimeMillis() - now; | long elapsed = System.currentTimeMillis() - now; | ||||
assertTrue("process should have been killed", ej.killedProcess()); | assertTrue("process should have been killed", ej.killedProcess()); | ||||
assertTrue("elapse time of "+elapsed | |||||
+" ms is less than timeout value of "+TIME_OUT_TEST+" ms", | |||||
assertTrue("elapse time of " + elapsed | |||||
+ " ms is less than timeout value of " + TIME_OUT_TEST + " ms", | |||||
elapsed >= TIME_OUT_TEST); | elapsed >= TIME_OUT_TEST); | ||||
assertTrue("elapse time of "+elapsed | |||||
+" ms is greater than run value of "+(TIME_OUT*2)+" ms", | |||||
elapsed < TIME_OUT*2); | |||||
assertTrue("elapse time of " + elapsed | |||||
+ " ms is greater than run value of " + (TIME_OUT * 2) + " ms", | |||||
elapsed < TIME_OUT * 2); | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoTimeOutForked() throws Exception { | public void testNoTimeOutForked() throws Exception { | ||||
Commandline cmd = getCommandline(TIME_OUT/2); | |||||
Commandline cmd = getCommandline(TIME_OUT / 2); | |||||
ej.setJavaCommand(cmd); | ej.setJavaCommand(cmd); | ||||
ej.fork(cp); | ej.fork(cp); | ||||
assertTrue("process should not have been killed", !ej.killedProcess()); | assertTrue("process should not have been killed", !ej.killedProcess()); | ||||
@@ -99,26 +99,26 @@ public class ExecuteJavaTest { | |||||
// test that the watchdog ends the process | // test that the watchdog ends the process | ||||
@Test | @Test | ||||
public void testTimeOutForked() throws Exception { | public void testTimeOutForked() throws Exception { | ||||
Commandline cmd = getCommandline(TIME_OUT*2); | |||||
Commandline cmd = getCommandline(TIME_OUT * 2); | |||||
ej.setJavaCommand(cmd); | ej.setJavaCommand(cmd); | ||||
long now = System.currentTimeMillis(); | long now = System.currentTimeMillis(); | ||||
ej.fork(cp); | ej.fork(cp); | ||||
long elapsed = System.currentTimeMillis() - now; | long elapsed = System.currentTimeMillis() - now; | ||||
assertTrue("process should have been killed", ej.killedProcess()); | assertTrue("process should have been killed", ej.killedProcess()); | ||||
assertTrue("elapse time of "+elapsed | |||||
+" ms is less than timeout value of "+TIME_OUT_TEST+" ms", | |||||
assertTrue("elapse time of " + elapsed | |||||
+ " ms is less than timeout value of " + TIME_OUT_TEST + " ms", | |||||
elapsed >= TIME_OUT_TEST); | elapsed >= TIME_OUT_TEST); | ||||
assertTrue("elapse time of "+elapsed | |||||
+" ms is greater than run value of "+(TIME_OUT*2)+" ms", | |||||
elapsed < TIME_OUT*2); | |||||
assertTrue("elapse time of " + elapsed | |||||
+ " ms is greater than run value of " + (TIME_OUT * 2) + " ms", | |||||
elapsed < TIME_OUT * 2); | |||||
} | } | ||||
/** | /** | ||||
* Dangerous method to obtain the classpath for the test. This is | * Dangerous method to obtain the classpath for the test. This is | ||||
* severely tighted to the build.xml properties. | * severely tighted to the build.xml properties. | ||||
*/ | */ | ||||
private static String getTestClassPath(){ | |||||
private static String getTestClassPath() { | |||||
String classpath = System.getProperty("build.tests"); | String classpath = System.getProperty("build.tests"); | ||||
if (classpath == null) { | if (classpath == null) { | ||||
System.err.println("WARNING: 'build.tests' property is not available !"); | System.err.println("WARNING: 'build.tests' property is not available !"); | ||||
@@ -40,13 +40,13 @@ public class ExecuteWatchdogTest { | |||||
private final static String TEST_CLASSPATH = getTestClassPath(); | private final static String TEST_CLASSPATH = getTestClassPath(); | ||||
private final static int CLOCK_ERROR=200; | |||||
private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; | |||||
private final static int CLOCK_ERROR = 200; | |||||
private final static long TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; | |||||
private ExecuteWatchdog watchdog; | private ExecuteWatchdog watchdog; | ||||
@Before | @Before | ||||
public void setUp(){ | |||||
public void setUp() { | |||||
watchdog = new ExecuteWatchdog(TIME_OUT); | watchdog = new ExecuteWatchdog(TIME_OUT); | ||||
} | } | ||||
@@ -54,7 +54,7 @@ public class ExecuteWatchdogTest { | |||||
* Dangerous method to obtain the classpath for the test. This is | * Dangerous method to obtain the classpath for the test. This is | ||||
* severely tied to the build.xml properties. | * severely tied to the build.xml properties. | ||||
*/ | */ | ||||
private static String getTestClassPath(){ | |||||
private static String getTestClassPath() { | |||||
String classpath = System.getProperty("build.tests"); | String classpath = System.getProperty("build.tests"); | ||||
if (classpath == null) { | if (classpath == null) { | ||||
System.err.println("WARNING: 'build.tests' property is not available !"); | System.err.println("WARNING: 'build.tests' property is not available !"); | ||||
@@ -74,10 +74,10 @@ public class ExecuteWatchdogTest { | |||||
} | } | ||||
private String getErrorOutput(Process p) throws Exception { | private String getErrorOutput(Process p) throws Exception { | ||||
BufferedReader err = new BufferedReader( new InputStreamReader(p.getErrorStream()) ); | |||||
StringBuffer buf = new StringBuffer(); | |||||
BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); | |||||
StringBuilder buf = new StringBuilder(); | |||||
String line; | String line; | ||||
while ( (line = err.readLine()) != null){ | |||||
while ((line = err.readLine()) != null) { | |||||
buf.append(line); | buf.append(line); | ||||
} | } | ||||
return buf.toString(); | return buf.toString(); | ||||
@@ -85,9 +85,9 @@ public class ExecuteWatchdogTest { | |||||
private int waitForEnd(Process p) throws Exception { | private int waitForEnd(Process p) throws Exception { | ||||
int retcode = p.waitFor(); | int retcode = p.waitFor(); | ||||
if (retcode != 0){ | |||||
if (retcode != 0) { | |||||
String err = getErrorOutput(p); | String err = getErrorOutput(p); | ||||
if (err.length() > 0){ | |||||
if (err.length() > 0) { | |||||
System.err.println("ERROR:"); | System.err.println("ERROR:"); | ||||
System.err.println(err); | System.err.println(err); | ||||
} | } | ||||
@@ -97,25 +97,28 @@ public class ExecuteWatchdogTest { | |||||
@Test | @Test | ||||
public void testNoTimeOut() throws Exception { | public void testNoTimeOut() throws Exception { | ||||
Process process = getProcess(TIME_OUT/2); | |||||
Process process = getProcess(TIME_OUT / 2); | |||||
watchdog.start(process); | watchdog.start(process); | ||||
int retCode = waitForEnd(process); | int retCode = waitForEnd(process); | ||||
assertTrue("process should not have been killed", !watchdog.killedProcess()); | |||||
assertFalse("process should not have been killed", watchdog.killedProcess()); | |||||
assertFalse(Execute.isFailure(retCode)); | assertFalse(Execute.isFailure(retCode)); | ||||
} | } | ||||
// test that the watchdog ends the process | // test that the watchdog ends the process | ||||
@Test | @Test | ||||
public void testTimeOut() throws Exception { | public void testTimeOut() throws Exception { | ||||
Process process = getProcess(TIME_OUT*2); | |||||
Process process = getProcess(TIME_OUT * 2); | |||||
long now = System.currentTimeMillis(); | long now = System.currentTimeMillis(); | ||||
watchdog.start(process); | watchdog.start(process); | ||||
int retCode = process.waitFor(); | |||||
@SuppressWarnings("unused") | |||||
int retCode = process.waitFor(); | |||||
long elapsed = System.currentTimeMillis() - now; | long elapsed = System.currentTimeMillis() - now; | ||||
assertTrue("process should have been killed", watchdog.killedProcess()); | assertTrue("process should have been killed", watchdog.killedProcess()); | ||||
// assertTrue("return code is invalid: " + retCode, retCode!=0); | |||||
assertTrue("elapse time of "+elapsed+" ms is less than timeout value of "+TIME_OUT_TEST+" ms", elapsed >= TIME_OUT_TEST); | |||||
assertTrue("elapse time of "+elapsed+" ms is greater than run value of "+(TIME_OUT*2)+" ms", elapsed < TIME_OUT*2); | |||||
// assertNotEquals("return code is invalid: " + retCode, retCode, 0); | |||||
assertTrue("elapse time of " + elapsed + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", | |||||
elapsed >= TIME_OUT_TEST); | |||||
assertTrue("elapse time of " + elapsed + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", | |||||
elapsed < TIME_OUT * 2); | |||||
} | } | ||||
// test a process that runs and failed | // test a process that runs and failed | ||||
@@ -130,7 +133,7 @@ public class ExecuteWatchdogTest { | |||||
@Test | @Test | ||||
public void testManualStop() throws Exception { | public void testManualStop() throws Exception { | ||||
final Process process = getProcess(TIME_OUT*2); | |||||
final Process process = getProcess(TIME_OUT * 2); | |||||
watchdog.start(process); | watchdog.start(process); | ||||
// I assume that starting this takes less than TIME_OUT/2 ms... | // I assume that starting this takes less than TIME_OUT/2 ms... | ||||
@@ -146,8 +149,8 @@ public class ExecuteWatchdogTest { | |||||
}; | }; | ||||
thread.start(); | thread.start(); | ||||
// wait for TIME_OUT/2, there should be about TIME_OUT/2 ms remaining before timeout | |||||
thread.join(TIME_OUT/2); | |||||
// wait for TIME_OUT / 2, there should be about TIME_OUT / 2 ms remaining before timeout | |||||
thread.join(TIME_OUT / 2); | |||||
// now stop the watchdog. | // now stop the watchdog. | ||||
watchdog.stop(); | watchdog.stop(); | ||||
@@ -43,7 +43,7 @@ public class FailTest { | |||||
public void test1() { | public void test1() { | ||||
try { | try { | ||||
buildRule.executeTarget("test1"); | buildRule.executeTarget("test1"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("No message", ex.getMessage()); | assertEquals("No message", ex.getMessage()); | ||||
} | } | ||||
@@ -53,7 +53,7 @@ public class FailTest { | |||||
public void test2() { | public void test2() { | ||||
try { | try { | ||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("test2", ex.getMessage()); | assertEquals("test2", ex.getMessage()); | ||||
} | } | ||||
@@ -63,7 +63,7 @@ public class FailTest { | |||||
public void testText() { | public void testText() { | ||||
try { | try { | ||||
buildRule.executeTarget("testText"); | buildRule.executeTarget("testText"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("testText", ex.getMessage()); | assertEquals("testText", ex.getMessage()); | ||||
} | } | ||||
@@ -75,7 +75,7 @@ public class FailTest { | |||||
buildRule.getProject().setProperty("foo", ""); | buildRule.getProject().setProperty("foo", ""); | ||||
try { | try { | ||||
buildRule.executeTarget("testIf"); | buildRule.executeTarget("testIf"); | ||||
fail("testIf must fail if foo has been set") ; | |||||
fail("testIf must fail if foo has been set"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
//TODO assert result | //TODO assert result | ||||
} | } | ||||
@@ -85,7 +85,7 @@ public class FailTest { | |||||
public void testUnless() { | public void testUnless() { | ||||
try { | try { | ||||
buildRule.executeTarget("testUnless"); | buildRule.executeTarget("testUnless"); | ||||
fail("testUnless must fail unless foo has been set") ; | |||||
fail("testUnless must fail unless foo has been set"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
//TODO assert rules | //TODO assert rules | ||||
} | } | ||||
@@ -106,7 +106,7 @@ public class FailTest { | |||||
buildRule.getProject().setProperty("if", ""); | buildRule.getProject().setProperty("if", ""); | ||||
try { | try { | ||||
buildRule.executeTarget("testIfAndUnless"); | buildRule.executeTarget("testIfAndUnless"); | ||||
fail("expect fail on defined(if)") ; | |||||
fail("expect fail on defined(if)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("if=if and unless=unless", ex.getMessage()); | assertEquals("if=if and unless=unless", ex.getMessage()); | ||||
} | } | ||||
@@ -129,7 +129,7 @@ public class FailTest { | |||||
public void testNested1() { | public void testNested1() { | ||||
try { | try { | ||||
buildRule.executeTarget("testNested1"); | buildRule.executeTarget("testNested1"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("condition satisfied", ex.getMessage()); | assertEquals("condition satisfied", ex.getMessage()); | ||||
} | } | ||||
@@ -144,7 +144,7 @@ public class FailTest { | |||||
public void testNested3() { | public void testNested3() { | ||||
try { | try { | ||||
buildRule.executeTarget("testNested3"); | buildRule.executeTarget("testNested3"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("testNested3", ex.getMessage()); | assertEquals("testNested3", ex.getMessage()); | ||||
} | } | ||||
@@ -156,13 +156,13 @@ public class FailTest { | |||||
+ "not permitted in conjunction with if/unless attributes"; | + "not permitted in conjunction with if/unless attributes"; | ||||
char[] c = {'a', 'b', 'c'}; | char[] c = {'a', 'b', 'c'}; | ||||
StringBuffer target = new StringBuffer("testNested4x"); | |||||
StringBuilder target = new StringBuilder("testNested4x"); | |||||
for (int i = 0; i < c.length; i++) { | for (int i = 0; i < c.length; i++) { | ||||
target.setCharAt(target.length() - 1, c[i]); | target.setCharAt(target.length() - 1, c[i]); | ||||
try { | try { | ||||
buildRule.executeTarget(target.toString()); | buildRule.executeTarget(target.toString()); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals(specificMessage, ex.getMessage()); | assertEquals(specificMessage, ex.getMessage()); | ||||
} | } | ||||
@@ -173,7 +173,7 @@ public class FailTest { | |||||
public void testNested5() { | public void testNested5() { | ||||
try { | try { | ||||
buildRule.executeTarget("testNested5"); | buildRule.executeTarget("testNested5"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("Only one nested condition is allowed.", ex.getMessage()); | assertEquals("Only one nested condition is allowed.", ex.getMessage()); | ||||
} | } | ||||
@@ -183,7 +183,7 @@ public class FailTest { | |||||
public void testNested6() { | public void testNested6() { | ||||
try { | try { | ||||
buildRule.executeTarget("testNested6"); | buildRule.executeTarget("testNested6"); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("testNested6\ntestNested6\ntestNested6", ex.getMessage()); | assertEquals("testNested6\ntestNested6\ntestNested6", ex.getMessage()); | ||||
} | } | ||||
@@ -194,13 +194,13 @@ public class FailTest { | |||||
String specificMessage = "A single nested condition is required."; | String specificMessage = "A single nested condition is required."; | ||||
char[] c = {'a', 'b'}; | char[] c = {'a', 'b'}; | ||||
StringBuffer target = new StringBuffer("testNested7x"); | |||||
StringBuilder target = new StringBuilder("testNested7x"); | |||||
for (int i = 0; i < c.length; i++) { | for (int i = 0; i < c.length; i++) { | ||||
target.setCharAt(target.length() - 1, c[i]); | target.setCharAt(target.length() - 1, c[i]); | ||||
try { | try { | ||||
buildRule.executeTarget(target.toString()); | buildRule.executeTarget(target.toString()); | ||||
fail("it is required to fail :-)") ; | |||||
fail("it is required to fail :-)"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals(specificMessage, ex.getMessage()); | assertEquals(specificMessage, ex.getMessage()); | ||||
} | } | ||||
@@ -126,19 +126,19 @@ public class FilterTest { | |||||
String line = null; | String line = null; | ||||
File f = new File(buildRule.getProject().getBaseDir(), filteredFile); | File f = new File(buildRule.getProject().getBaseDir(), filteredFile); | ||||
if (!f.exists()) { | if (!f.exists()) { | ||||
fail("filter test"+testNumber+" failed"); | |||||
fail("filter test" + testNumber + " failed"); | |||||
} else { | } else { | ||||
BufferedReader in = null; | BufferedReader in = null; | ||||
try { | try { | ||||
in = new BufferedReader(new FileReader(f)); | in = new BufferedReader(new FileReader(f)); | ||||
} catch (FileNotFoundException fnfe) { | } catch (FileNotFoundException fnfe) { | ||||
fail("filter test"+testNumber+" failed, filtered file: " + f.toString() + " not found"); | |||||
fail("filter test" + testNumber + " failed, filtered file: " + f.toString() + " not found"); | |||||
} | } | ||||
try { | try { | ||||
line = in.readLine(); | line = in.readLine(); | ||||
in.close(); | in.close(); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
fail("filter test"+testNumber+" failed. IOException while reading filtered file: " + ioe); | |||||
fail("filter test" + testNumber + " failed. IOException while reading filtered file: " + ioe); | |||||
} | } | ||||
} | } | ||||
f.delete(); | f.delete(); | ||||
@@ -234,7 +234,7 @@ public class FixCrLfTest { | |||||
public void assertEqualContent(File expect, File result) | public void assertEqualContent(File expect, File result) | ||||
throws AssertionFailedError, IOException { | throws AssertionFailedError, IOException { | ||||
if (!result.exists()) { | if (!result.exists()) { | ||||
fail("Expected file "+result+" doesn\'t exist"); | |||||
fail("Expected file " + result + " doesn\'t exist"); | |||||
} | } | ||||
InputStream inExpect = null; | InputStream inExpect = null; | ||||
@@ -17,6 +17,8 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.apache.tools.ant.FileUtilities; | import org.apache.tools.ant.FileUtilities; | ||||
@@ -64,28 +66,28 @@ public class GUnzipTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testRealTest() throws java.io.IOException { | |||||
public void testRealTest() throws IOException { | |||||
testRealTest("realTest"); | testRealTest("realTest"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testRealTestWithResource() throws java.io.IOException { | |||||
public void testRealTestWithResource() throws IOException { | |||||
testRealTest("realTestWithResource"); | testRealTest("realTestWithResource"); | ||||
} | } | ||||
private void testRealTest(String target) throws java.io.IOException { | |||||
private void testRealTest(String target) throws IOException { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | ||||
FileUtilities.getFileContents(buildRule.getProject().resolveFile("asf-logo.gif"))); | FileUtilities.getFileContents(buildRule.getProject().resolveFile("asf-logo.gif"))); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTestGzipTask() throws java.io.IOException { | |||||
public void testTestGzipTask() throws IOException { | |||||
testRealTest("testGzipTask"); | testRealTest("testGzipTask"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testDocumentationClaimsOnCopy() throws java.io.IOException { | |||||
public void testDocumentationClaimsOnCopy() throws IOException { | |||||
testRealTest("testDocumentationClaimsOnCopy"); | testRealTest("testDocumentationClaimsOnCopy"); | ||||
} | } | ||||
} | } |
@@ -82,7 +82,7 @@ public class GzipTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testGZip(){ | |||||
public void testGZip() { | |||||
buildRule.executeTarget("realTest"); | buildRule.executeTarget("realTest"); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue("Expecting message starting with 'Building:' but got '" | assertTrue("Expecting message starting with 'Building:' but got '" | ||||
@@ -92,12 +92,12 @@ public class GzipTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testResource(){ | |||||
public void testResource() { | |||||
buildRule.executeTarget("realTestWithResource"); | buildRule.executeTarget("realTestWithResource"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testDateCheck(){ | |||||
public void testDateCheck() { | |||||
buildRule.executeTarget("testDateCheck"); | buildRule.executeTarget("testDateCheck"); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue( | assertTrue( | ||||
@@ -106,7 +106,7 @@ public class GzipTest { | |||||
} | } | ||||
@After | @After | ||||
public void tearDown(){ | |||||
public void tearDown() { | |||||
buildRule.executeTarget("cleanup"); | buildRule.executeTarget("cleanup"); | ||||
} | } | ||||
@@ -90,8 +90,9 @@ public class ImportTest { | |||||
try { | try { | ||||
buildRule.executeTarget("do-import"); | buildRule.executeTarget("do-import"); | ||||
fail("Build exception should have been thrown as import only allowed in top level task"); | fail("Build exception should have been thrown as import only allowed in top level task"); | ||||
} catch(BuildException ex) { | |||||
assertContains( "not a top level task", "import only allowed as a top-level task", ex.getMessage()); | |||||
} catch (BuildException ex) { | |||||
assertContains("not a top level task", "import only allowed as a top-level task", | |||||
ex.getMessage()); | |||||
} | } | ||||
} | } | ||||
@@ -111,7 +112,8 @@ public class ImportTest { | |||||
"src/etc/testcases/taskdefs/import/same_target.xml"); | "src/etc/testcases/taskdefs/import/same_target.xml"); | ||||
fail("Expected build exception"); | fail("Expected build exception"); | ||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertContains("Message did not contain expected contents", "Duplicate target", ex.getMessage()); | |||||
assertContains("Message did not contain expected contents", "Duplicate target", | |||||
ex.getMessage()); | |||||
} | } | ||||
} | } | ||||
@@ -137,7 +137,7 @@ public class JarTest { | |||||
// move the modified date back a couple of seconds rather than delay the test on each run | // move the modified date back a couple of seconds rather than delay the test on each run | ||||
Assume.assumeTrue(jarFile.setLastModified(jarFile.lastModified() | Assume.assumeTrue(jarFile.setLastModified(jarFile.lastModified() | ||||
- (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); | |||||
- FileUtils.getFileUtils().getFileTimestampGranularity() * 3)); | |||||
long jarModifiedDate = jarFile.lastModified(); | long jarModifiedDate = jarFile.lastModified(); | ||||
buildRule.executeTarget(secondTarget); | buildRule.executeTarget(secondTarget); | ||||
@@ -169,13 +169,13 @@ public class JarTest { | |||||
private void testRecreate(String firstTarget, String secondTarget) { | private void testRecreate(String firstTarget, String secondTarget) { | ||||
//Move the modified date on all input back a couple of seconds rather then delay the test to achieve a similar effect | //Move the modified date on all input back a couple of seconds rather then delay the test to achieve a similar effect | ||||
FileUtilities.rollbackTimetamps(buildRule.getProject().getBaseDir(), 5); | |||||
FileUtilities.rollbackTimestamps(buildRule.getProject().getBaseDir(), 5); | |||||
buildRule.executeTarget(firstTarget); | buildRule.executeTarget(firstTarget); | ||||
File jarFile = new File(getOutputDir(), tempJar); | File jarFile = new File(getOutputDir(), tempJar); | ||||
//Move the modified date back a couple of seconds rather then delay the test to achieve a similar effect | //Move the modified date back a couple of seconds rather then delay the test to achieve a similar effect | ||||
FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); | |||||
FileUtilities.rollbackTimestamps(buildRule.getOutputDir(), 5); | |||||
long jarModifiedDate = jarFile.lastModified(); | long jarModifiedDate = jarFile.lastModified(); | ||||
buildRule.executeTarget(secondTarget); | buildRule.executeTarget(secondTarget); | ||||
@@ -334,7 +334,7 @@ public class JarTest { | |||||
public void testNoVersionInfoFail() { | public void testNoVersionInfoFail() { | ||||
try { | try { | ||||
buildRule.executeTarget("testNoVersionInfoFail"); | buildRule.executeTarget("testNoVersionInfoFail"); | ||||
fail("BuildException expected: Manifest Implemention information missing."); | |||||
fail("BuildException expected: Manifest Implementation information missing."); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertContains("No Implementation-Title set.", ex.getMessage()); | assertContains("No Implementation-Title set.", ex.getMessage()); | ||||
} | } | ||||
@@ -343,33 +343,33 @@ public class JarTest { | |||||
@Test | @Test | ||||
public void testNoVersionInfoIgnore() { | public void testNoVersionInfoIgnore() { | ||||
buildRule.executeTarget("testNoVersionInfoIgnore"); | buildRule.executeTarget("testNoVersionInfoIgnore"); | ||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Title set.") > -1 ); | |||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Version set.") > -1 ); | |||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Vendor set.") > -1 ); | |||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Title set.") > -1); | |||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Version set.") > -1); | |||||
assertTrue(buildRule.getFullLog().indexOf("No Implementation-Vendor set.") > -1); | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoVersionInfoWarn() { | public void testNoVersionInfoWarn() { | ||||
buildRule.executeTarget("testNoVersionInfoWarn"); | buildRule.executeTarget("testNoVersionInfoWarn"); | ||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); | |||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); | |||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); | |||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); | |||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); | |||||
assertTrue(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoVersionInfoNoStrict() { | public void testNoVersionInfoNoStrict() { | ||||
buildRule.executeTarget("testNoVersionInfoNoStrict"); | buildRule.executeTarget("testNoVersionInfoNoStrict"); | ||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); | |||||
} | } | ||||
@Test | @Test | ||||
public void testHasVersionInfo() { | public void testHasVersionInfo() { | ||||
buildRule.executeTarget("testHasVersionInfo"); | buildRule.executeTarget("testHasVersionInfo"); | ||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); | |||||
assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); | |||||
} | } | ||||
} | } |
@@ -78,14 +78,15 @@ public class JavaTest { | |||||
//final String propname="tests-classpath.value"; | //final String propname="tests-classpath.value"; | ||||
//String testClasspath=System.getProperty(propname); | //String testClasspath=System.getProperty(propname); | ||||
//System.out.println("Test cp="+testClasspath); | |||||
String runFatal=System.getProperty("junit.run.fatal.tests"); | |||||
if(runFatal!=null) | |||||
runFatalTests=true; | |||||
//System.out.println("Test cp=" + testClasspath); | |||||
String runFatal = System.getProperty("junit.run.fatal.tests"); | |||||
if (runFatal != null) { | |||||
runFatalTests = true; | |||||
} | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoJarNoClassname(){ | |||||
public void testNoJarNoClassname() { | |||||
try { | try { | ||||
buildRule.executeTarget("testNoJarNoClassname"); | buildRule.executeTarget("testNoJarNoClassname"); | ||||
fail("Build exception should have been thrown - parameter validation"); | fail("Build exception should have been thrown - parameter validation"); | ||||
@@ -173,20 +174,20 @@ public class JavaTest { | |||||
assertEquals("Command line should have 5 elements", 5, cmdLine.length); | assertEquals("Command line should have 5 elements", 5, cmdLine.length); | ||||
assertEquals("Last command line element should be java argument: " + arg, | assertEquals("Last command line element should be java argument: " + arg, | ||||
arg, | arg, | ||||
cmdLine[cmdLine.length-1]); | |||||
cmdLine[cmdLine.length - 1]); | |||||
assertEquals("The command line element at index 3 should be module name: " + moduleName, | assertEquals("The command line element at index 3 should be module name: " + moduleName, | ||||
moduleName, | moduleName, | ||||
cmdLine[cmdLine.length-2]); | |||||
cmdLine[cmdLine.length - 2]); | |||||
assertEquals("The command line element at index 2 should be -m", | assertEquals("The command line element at index 2 should be -m", | ||||
"-m", | "-m", | ||||
cmdLine[cmdLine.length-3]); | |||||
cmdLine[cmdLine.length - 3]); | |||||
} | } | ||||
@Test | @Test | ||||
public void testModuleAndClassnameCommandLine() { | public void testModuleAndClassnameCommandLine() { | ||||
final String moduleName = "TestModule"; //NOI18N | final String moduleName = "TestModule"; //NOI18N | ||||
final String className = "org.apache.Test"; //NOI18N | final String className = "org.apache.Test"; //NOI18N | ||||
final String moduleClassPair= String.format("%s/%s", moduleName, className); | |||||
final String moduleClassPair = String.format("%s/%s", moduleName, className); | |||||
final String arg = "appArg"; //NOI18N | final String arg = "appArg"; //NOI18N | ||||
final Java java = new Java(); | final Java java = new Java(); | ||||
java.setFork(true); | java.setFork(true); | ||||
@@ -199,13 +200,13 @@ public class JavaTest { | |||||
assertEquals("Command line should have 5 elements", 5, cmdLine.length); | assertEquals("Command line should have 5 elements", 5, cmdLine.length); | ||||
assertEquals("Last command line element should be java argument: " + arg, | assertEquals("Last command line element should be java argument: " + arg, | ||||
arg, | arg, | ||||
cmdLine[cmdLine.length-1]); | |||||
cmdLine[cmdLine.length - 1]); | |||||
assertEquals("The command line element at index 3 should be module class pair: " + moduleClassPair, | assertEquals("The command line element at index 3 should be module class pair: " + moduleClassPair, | ||||
moduleClassPair, | moduleClassPair, | ||||
cmdLine[cmdLine.length-2]); | |||||
cmdLine[cmdLine.length - 2]); | |||||
assertEquals("The command line element at index 2 should be -m", | assertEquals("The command line element at index 2 should be -m", | ||||
"-m", | "-m", | ||||
cmdLine[cmdLine.length-3]); | |||||
cmdLine[cmdLine.length - 3]); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -395,7 +396,7 @@ public class JavaTest { | |||||
// wait a little bit for the task to wait for input | // wait a little bit for the task to wait for input | ||||
Thread.sleep(100); | Thread.sleep(100); | ||||
// write some stuff in the input stream to be catched by the input task | |||||
// write some stuff in the input stream to be caught by the input task | |||||
out.write("foo\n".getBytes()); | out.write("foo\n".getBytes()); | ||||
out.flush(); | out.flush(); | ||||
try { | try { | ||||
@@ -459,21 +460,21 @@ public class JavaTest { | |||||
* argv[1] = string to print to System.err (optional) | * argv[1] = string to print to System.err (optional) | ||||
*/ | */ | ||||
public static void main(String[] argv) { | public static void main(String[] argv) { | ||||
int exitCode=0; | |||||
if(argv.length>0) { | |||||
int exitCode = 0; | |||||
if (argv.length > 0) { | |||||
try { | try { | ||||
exitCode=Integer.parseInt(argv[0]); | |||||
} catch(NumberFormatException nfe) { | |||||
exitCode=-1; | |||||
exitCode = Integer.parseInt(argv[0]); | |||||
} catch (NumberFormatException nfe) { | |||||
exitCode = -1; | |||||
} | } | ||||
} | } | ||||
if(argv.length>1) { | |||||
if (argv.length > 1) { | |||||
System.out.println(argv[1]); | System.out.println(argv[1]); | ||||
} | } | ||||
if(argv.length>2) { | |||||
if (argv.length > 2) { | |||||
System.err.println(argv[2]); | System.err.println(argv[2]); | ||||
} | } | ||||
if(exitCode!=0) { | |||||
if (exitCode != 0) { | |||||
System.exit(exitCode); | System.exit(exitCode); | ||||
} | } | ||||
} | } | ||||
@@ -503,8 +504,7 @@ public class JavaTest { | |||||
if (argv.length >= 1) { | if (argv.length >= 1) { | ||||
sleepTime = Integer.parseInt(argv[0]); | sleepTime = Integer.parseInt(argv[0]); | ||||
} | } | ||||
if (argv.length >= 2) | |||||
{ | |||||
if (argv.length >= 2) { | |||||
logFile = argv[1]; | logFile = argv[1]; | ||||
} | } | ||||
OutputStreamWriter out = null; | OutputStreamWriter out = null; | ||||
@@ -515,9 +515,13 @@ public class JavaTest { | |||||
FileOutputStream fos = new FileOutputStream(dest); | FileOutputStream fos = new FileOutputStream(dest); | ||||
out = new OutputStreamWriter(fos); | out = new OutputStreamWriter(fos); | ||||
out.write("bye bye\n"); | out.write("bye bye\n"); | ||||
} catch (Exception ex) {} | |||||
finally { | |||||
try {out.close();} catch (IOException ioe) {}} | |||||
} catch (Exception ex) { | |||||
} finally { | |||||
try { | |||||
out.close(); | |||||
} catch (IOException ioe) { | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -288,7 +288,7 @@ public class JavacTest { | |||||
final File tmp = new File(System.getProperty("java.io.tmpdir")); //NOI18N | final File tmp = new File(System.getProperty("java.io.tmpdir")); //NOI18N | ||||
final File destDir = new File(tmp, String.format("%stestMP%d", | final File destDir = new File(tmp, String.format("%stestMP%d", | ||||
getClass().getName(), | getClass().getName(), | ||||
System.currentTimeMillis()/1000)); | |||||
System.currentTimeMillis() / 1000)); | |||||
destDir.mkdirs(); | destDir.mkdirs(); | ||||
try { | try { | ||||
final Path p = new Path(project); | final Path p = new Path(project); | ||||
@@ -38,19 +38,16 @@ public class LoadFileTest { | |||||
@Rule | @Rule | ||||
public final BuildFileRule buildRule = new BuildFileRule(); | public final BuildFileRule buildRule = new BuildFileRule(); | ||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
buildRule.configureProject("src/etc/testcases/taskdefs/loadfile.xml"); | buildRule.configureProject("src/etc/testcases/taskdefs/loadfile.xml"); | ||||
} | } | ||||
@After | @After | ||||
public void tearDown() { | public void tearDown() { | ||||
buildRule.executeTarget("cleanup"); | buildRule.executeTarget("cleanup"); | ||||
} | } | ||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@@ -64,7 +61,6 @@ public class LoadFileTest { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@@ -78,7 +74,6 @@ public class LoadFileTest { | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@@ -96,32 +91,27 @@ public class LoadFileTest { | |||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testFailOnError() | |||||
throws BuildException { | |||||
public void testFailOnError() throws BuildException { | |||||
buildRule.executeTarget("testFailOnError"); | buildRule.executeTarget("testFailOnError"); | ||||
assertNull(buildRule.getProject().getProperty("testFailOnError")); | assertNull(buildRule.getProject().getProperty("testFailOnError")); | ||||
} | } | ||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testLoadAFile() | |||||
throws BuildException { | |||||
public void testLoadAFile() throws BuildException { | |||||
buildRule.executeTarget("testLoadAFile"); | buildRule.executeTarget("testLoadAFile"); | ||||
if(buildRule.getProject().getProperty("testLoadAFile").indexOf("eh?")<0) { | if(buildRule.getProject().getProperty("testLoadAFile").indexOf("eh?")<0) { | ||||
fail("property is not all in the file"); | fail("property is not all in the file"); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testLoadAFileEnc() | |||||
throws BuildException { | |||||
public void testLoadAFileEnc() throws BuildException { | |||||
buildRule.executeTarget("testLoadAFileEnc"); | buildRule.executeTarget("testLoadAFileEnc"); | ||||
assertNotNull("file load files", buildRule.getProject().getProperty("testLoadAFileEnc")); | assertNotNull("file load files", buildRule.getProject().getProperty("testLoadAFileEnc")); | ||||
} | } | ||||
@@ -130,8 +120,7 @@ public class LoadFileTest { | |||||
* A unit test for JUnit | * A unit test for JUnit | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testEvalProps() | |||||
throws BuildException { | |||||
public void testEvalProps() throws BuildException { | |||||
buildRule.executeTarget("testEvalProps"); | buildRule.executeTarget("testEvalProps"); | ||||
if(buildRule.getProject().getProperty("testEvalProps").indexOf("rain")<0) { | if(buildRule.getProject().getProperty("testEvalProps").indexOf("rain")<0) { | ||||
fail("property eval broken"); | fail("property eval broken"); | ||||
@@ -142,8 +131,7 @@ public class LoadFileTest { | |||||
* Test FilterChain and FilterReaders | * Test FilterChain and FilterReaders | ||||
*/ | */ | ||||
@Test | @Test | ||||
public void testFilterChain() | |||||
throws BuildException { | |||||
public void testFilterChain() throws BuildException { | |||||
buildRule.executeTarget("testFilterChain"); | buildRule.executeTarget("testFilterChain"); | ||||
if(buildRule.getProject().getProperty("testFilterChain").indexOf("World!")<0) { | if(buildRule.getProject().getProperty("testFilterChain").indexOf("World!")<0) { | ||||
fail("Filter Chain broken"); | fail("Filter Chain broken"); | ||||
@@ -154,8 +142,7 @@ public class LoadFileTest { | |||||
* Test StripJavaComments filterreader functionality. | * Test StripJavaComments filterreader functionality. | ||||
*/ | */ | ||||
@Test | @Test | ||||
public final void testStripJavaComments() | |||||
throws BuildException { | |||||
public final void testStripJavaComments() throws BuildException { | |||||
buildRule.executeTarget("testStripJavaComments"); | buildRule.executeTarget("testStripJavaComments"); | ||||
final String expected = buildRule.getProject().getProperty("expected"); | final String expected = buildRule.getProject().getProperty("expected"); | ||||
final String generated = buildRule.getProject().getProperty("testStripJavaComments"); | final String generated = buildRule.getProject().getProperty("testStripJavaComments"); | ||||
@@ -100,7 +100,7 @@ public class MakeUrlTest { | |||||
/** | /** | ||||
* test that we can round trip by opening a url that exists | * test that we can round trip by opening a url that exists | ||||
* | * | ||||
* @throws IOException | |||||
* @throws IOException if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testRoundTrip() throws IOException { | public void testRoundTrip() throws IOException { | ||||
@@ -142,8 +142,8 @@ public class MakeUrlTest { | |||||
/** | /** | ||||
* assert that a property ends with | * assert that a property ends with | ||||
* | * | ||||
* @param property | |||||
* @param ending | |||||
* @param property String | |||||
* @param ending String | |||||
*/ | */ | ||||
private void assertPropertyEndsWith(String property, String ending) { | private void assertPropertyEndsWith(String property, String ending) { | ||||
String result = getProperty(property); | String result = getProperty(property); | ||||
@@ -167,8 +167,8 @@ public class MakeUrlTest { | |||||
/** | /** | ||||
* get a property from the project | * get a property from the project | ||||
* | * | ||||
* @param property | |||||
* @return | |||||
* @param property String | |||||
* @return String | |||||
*/ | */ | ||||
protected String getProperty(String property) { | protected String getProperty(String property) { | ||||
return buildRule.getProject().getProperty(property); | return buildRule.getProject().getProperty(property); | ||||
@@ -17,7 +17,6 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import static org.apache.tools.ant.AntAssert.assertContains; | import static org.apache.tools.ant.AntAssert.assertContains; | ||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertNull; | import static org.junit.Assert.assertNull; | ||||
@@ -231,8 +230,8 @@ public class ManifestClassPathTest { | |||||
} else { | } else { | ||||
altDriveLetter = "C"; | altDriveLetter = "C"; | ||||
} | } | ||||
new java.io.File(altDriveLetter + ":/foo.txt").getCanonicalPath(); | |||||
} catch (java.io.IOException e) { | |||||
new File(altDriveLetter + ":/foo.txt").getCanonicalPath(); | |||||
} catch (IOException e) { | |||||
Assume.assumeNoException("Drive " + altDriveLetter + ": doesn't exist or is not ready", e); | Assume.assumeNoException("Drive " + altDriveLetter + ": doesn't exist or is not ready", e); | ||||
} | } | ||||
buildRule.getProject().setProperty("altDriveLetter", altDriveLetter); | buildRule.getProject().setProperty("altDriveLetter", altDriveLetter); | ||||
@@ -134,9 +134,8 @@ public class ManifestTest { | |||||
@Test | @Test | ||||
public void test5() { | public void test5() { | ||||
buildRule.executeTarget("test5"); | buildRule.executeTarget("test5"); | ||||
String output = buildRule.getLog(); | |||||
boolean hasWarning = output.indexOf("Manifest warning: \"Name\" attributes should not occur in the main section") != -1; | |||||
assertTrue("Expected warning about Name in main section", hasWarning); | |||||
assertTrue("Expected warning about Name in main section", buildRule.getLog() | |||||
.contains("Manifest warning: \"Name\" attributes should not occur in the main section")); | |||||
} | } | ||||
/** | /** | ||||
@@ -150,9 +149,8 @@ public class ManifestTest { | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertContains("Invalid Manifest", ex.getMessage()); | assertContains("Invalid Manifest", ex.getMessage()); | ||||
} | } | ||||
String output = buildRule.getLog(); | |||||
boolean hasWarning = output.indexOf("Manifest sections should start with a \"Name\" attribute") != -1; | |||||
assertTrue("Expected warning about section not starting with Name: attribute", hasWarning); | |||||
assertTrue("Expected warning about section not starting with Name: attribute", buildRule.getLog() | |||||
.contains("Manifest sections should start with a \"Name\" attribute")); | |||||
} | } | ||||
@@ -162,9 +160,8 @@ public class ManifestTest { | |||||
@Test | @Test | ||||
public void test7() { | public void test7() { | ||||
buildRule.executeTarget("test7"); | buildRule.executeTarget("test7"); | ||||
boolean hasWarning = buildRule.getLog().indexOf(Manifest.ERROR_FROM_FORBIDDEN) != -1; | |||||
assertTrue("Expected warning about From: attribute", hasWarning); | |||||
assertTrue("Expected warning about From: attribute", buildRule.getLog() | |||||
.contains(Manifest.ERROR_FROM_FORBIDDEN)); | |||||
} | } | ||||
/** | /** | ||||
@@ -245,7 +242,8 @@ public class ManifestTest { | |||||
buildRule.executeTarget("test13"); | buildRule.executeTarget("test13"); | ||||
fail("BuildException expected: Duplicate Attribute"); | fail("BuildException expected: Duplicate Attribute"); | ||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertContains("The attribute \"Test\" may not occur more than once in the same section", ex.getMessage()); | |||||
assertContains("The attribute \"Test\" may not occur more than once in the same section", | |||||
ex.getMessage()); | |||||
} | } | ||||
} | } | ||||
@@ -269,9 +267,9 @@ public class ManifestTest { | |||||
public void testLongLine() throws IOException, ManifestException { | public void testLongLine() throws IOException, ManifestException { | ||||
Project p = buildRule.getProject(); | Project p = buildRule.getProject(); | ||||
p.setUserProperty("test.longline", LONG_LINE); | p.setUserProperty("test.longline", LONG_LINE); | ||||
p.setUserProperty("test.long68name" , LONG_68_NAME); | |||||
p.setUserProperty("test.long70name" , LONG_70_NAME); | |||||
p.setUserProperty("test.notlongname" , NOT_LONG_NAME); | |||||
p.setUserProperty("test.long68name", LONG_68_NAME); | |||||
p.setUserProperty("test.long70name", LONG_70_NAME); | |||||
p.setUserProperty("test.notlongname", NOT_LONG_NAME); | |||||
p.setUserProperty("test.value", VALUE); | p.setUserProperty("test.value", VALUE); | ||||
buildRule.executeTarget("testLongLine"); | buildRule.executeTarget("testLongLine"); | ||||
@@ -17,6 +17,8 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.io.File; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.junit.Before; | import org.junit.Before; | ||||
@@ -60,7 +62,7 @@ public class MkdirTest { | |||||
@Test | @Test | ||||
public void test3() { | public void test3() { | ||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
java.io.File f = new java.io.File(buildRule.getProject().getProperty("output"), "testdir.tmp"); | |||||
File f = new File(buildRule.getProject().getProperty("output"), "testdir.tmp"); | |||||
if (!f.exists() || !f.isDirectory()) { | if (!f.exists() || !f.isDirectory()) { | ||||
fail("mkdir failed"); | fail("mkdir failed"); | ||||
} else { | } else { | ||||
@@ -68,12 +68,17 @@ public class MultiMapTest { | |||||
} | } | ||||
public static class TestMapper implements FileNameMapper { | public static class TestMapper implements FileNameMapper { | ||||
public TestMapper() {} | |||||
public void setFrom(String from) {} | |||||
public void setTo(String to) {} | |||||
public TestMapper() { | |||||
} | |||||
public void setFrom(String from) { | |||||
} | |||||
public void setTo(String to) { | |||||
} | |||||
public String[] mapFileName(final String source_file_name) { | public String[] mapFileName(final String source_file_name) { | ||||
return new String[] { | |||||
source_file_name, source_file_name+".copy2" }; | |||||
return new String[] {source_file_name, source_file_name + ".copy2"}; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -46,7 +46,7 @@ public class ParallelTest { | |||||
/** Standard property value for the fail test */ | /** Standard property value for the fail test */ | ||||
public final static String FAILURE_MESSAGE = "failure"; | public final static String FAILURE_MESSAGE = "failure"; | ||||
/** the build fiel associated with this test */ | |||||
/** the build file associated with this test */ | |||||
public final static String TEST_BUILD_FILE | public final static String TEST_BUILD_FILE | ||||
= "src/etc/testcases/taskdefs/parallel.xml"; | = "src/etc/testcases/taskdefs/parallel.xml"; | ||||
@@ -66,8 +66,7 @@ public class PropertyTest { | |||||
try { | try { | ||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
fail("Did not throw exception on circular exception"); | fail("Did not throw exception on circular exception"); | ||||
} | |||||
catch (BuildException e) { | |||||
} catch (BuildException e) { | |||||
assertTrue("Circular definition not detected - ", | assertTrue("Circular definition not detected - ", | ||||
e.getMessage().indexOf("was circularly defined") != -1); | e.getMessage().indexOf("was circularly defined") != -1); | ||||
} | } | ||||
@@ -101,8 +100,7 @@ public class PropertyTest { | |||||
try { | try { | ||||
buildRule.executeTarget("prefix.fail"); | buildRule.executeTarget("prefix.fail"); | ||||
fail("Did not throw exception on invalid use of prefix"); | fail("Did not throw exception on invalid use of prefix"); | ||||
} | |||||
catch (BuildException e) { | |||||
} catch (BuildException e) { | |||||
assertContains("Prefix allowed on non-resource/file load - ", | assertContains("Prefix allowed on non-resource/file load - ", | ||||
"Prefix is only valid", e.getMessage()); | "Prefix is only valid", e.getMessage()); | ||||
} | } | ||||
@@ -153,7 +153,7 @@ public class ReplaceTest { | |||||
public void assertEqualContent(File expect, File result) | public void assertEqualContent(File expect, File result) | ||||
throws AssertionFailedError, IOException { | throws AssertionFailedError, IOException { | ||||
if (!result.exists()) { | if (!result.exists()) { | ||||
fail("Expected file "+result+" doesn\'t exist"); | |||||
fail("Expected file " + result + " doesn\'t exist"); | |||||
} | } | ||||
InputStream inExpect = null; | InputStream inExpect = null; | ||||
@@ -282,7 +282,7 @@ public class RmicAdvancedTest { | |||||
public void NotestFailingAdapter() throws Exception { | public void NotestFailingAdapter() throws Exception { | ||||
try { | try { | ||||
buildRule.executeTarget("testFailingAdapter"); | buildRule.executeTarget("testFailingAdapter"); | ||||
fail("Expected failures to propogate"); | |||||
fail("Expected failures to propagate"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
AntAssert.assertContains(Rmic.ERROR_RMIC_FAILED, ex.getMessage()); | AntAssert.assertContains(Rmic.ERROR_RMIC_FAILED, ex.getMessage()); | ||||
} | } | ||||
@@ -291,7 +291,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version 1.1 stubs are good | * test that version 1.1 stubs are good | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersion11() throws Exception { | public void testVersion11() throws Exception { | ||||
@@ -300,7 +300,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version 1.1 stubs are good | * test that version 1.1 stubs are good | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersion11Dest() throws Exception { | public void testVersion11Dest() throws Exception { | ||||
@@ -310,7 +310,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version 1.2 stubs are good | * test that version 1.2 stubs are good | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersion12() throws Exception { | public void testVersion12() throws Exception { | ||||
@@ -320,7 +320,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version 1.2 stubs are good | * test that version 1.2 stubs are good | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersion12Dest() throws Exception { | public void testVersion12Dest() throws Exception { | ||||
@@ -330,7 +330,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version compat stubs are good | * test that version compat stubs are good | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersionCompat() throws Exception { | public void testVersionCompat() throws Exception { | ||||
@@ -340,7 +340,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that version compat stubs are good | * test that version compat stubs are good | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testVersionCompatDest() throws Exception { | public void testVersionCompatDest() throws Exception { | ||||
@@ -350,7 +350,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that passes -Xnew to sun's rmic running in a different VM. | * test that passes -Xnew to sun's rmic running in a different VM. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testXnewForked() throws Exception { | public void testXnewForked() throws Exception { | ||||
@@ -360,7 +360,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that passes -Xnew to sun's rmic running in a different VM. | * test that passes -Xnew to sun's rmic running in a different VM. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testXnewForkedDest() throws Exception { | public void testXnewForkedDest() throws Exception { | ||||
@@ -370,7 +370,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that runs the new xnew compiler adapter. | * test that runs the new xnew compiler adapter. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testXnewCompiler() throws Exception { | public void testXnewCompiler() throws Exception { | ||||
@@ -380,7 +380,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that runs the new xnew compiler adapter. | * test that runs the new xnew compiler adapter. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testXnewCompilerDest() throws Exception { | public void testXnewCompilerDest() throws Exception { | ||||
@@ -390,7 +390,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that verifies that IDL compiles. | * test that verifies that IDL compiles. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testIDL() throws Exception { | public void testIDL() throws Exception { | ||||
@@ -400,7 +400,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that verifies that IDL compiles. | * test that verifies that IDL compiles. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testIDLDest() throws Exception { | public void testIDLDest() throws Exception { | ||||
@@ -410,7 +410,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that verifies that IIOP compiles. | * test that verifies that IIOP compiles. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testIIOP() throws Exception { | public void testIIOP() throws Exception { | ||||
@@ -420,7 +420,7 @@ public class RmicAdvancedTest { | |||||
/** | /** | ||||
* test that verifies that IIOP compiles. | * test that verifies that IIOP compiles. | ||||
* | * | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testIIOPDest() throws Exception { | public void testIIOPDest() throws Exception { | ||||
@@ -88,7 +88,7 @@ public class RmicTest { | |||||
// check defaults | // check defaults | ||||
String compiler = rmic.getCompiler(); | String compiler = rmic.getCompiler(); | ||||
assertNotNull(compiler); | assertNotNull(compiler); | ||||
assertEquals("expected sun or kaffe, but found "+compiler,compiler,"default"); | |||||
assertEquals("expected sun or kaffe, but found " + compiler, compiler,"default"); | |||||
project.setNewProperty("build.rmic", "weblogic"); | project.setNewProperty("build.rmic", "weblogic"); | ||||
compiler = rmic.getCompiler(); | compiler = rmic.getCompiler(); | ||||
@@ -26,8 +26,8 @@ import java.io.File; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.util.logging.Logger; | import java.util.logging.Logger; | ||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.Project; | |||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Ignore; | import org.junit.Ignore; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
@@ -70,13 +70,13 @@ public class SQLExecTest { | |||||
// simple test to ensure that the caching does work... | // simple test to ensure that the caching does work... | ||||
@Test | @Test | ||||
public void testDriverCaching(){ | |||||
public void testDriverCaching() { | |||||
SQLExec sql = createTask(getProperties(NULL)); | SQLExec sql = createTask(getProperties(NULL)); | ||||
assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | ||||
try { | try { | ||||
sql.execute(); | sql.execute(); | ||||
fail("BuildException should have been thrown"); | fail("BuildException should have been thrown"); | ||||
} catch (BuildException e){ | |||||
} catch (BuildException e) { | |||||
assertContains("No suitable Driver", e.getMessage()); | assertContains("No suitable Driver", e.getMessage()); | ||||
} | } | ||||
assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); | ||||
@@ -104,13 +104,13 @@ public class SQLExecTest { | |||||
@Ignore | @Ignore | ||||
@Test | @Test | ||||
public void testOracle(){ | |||||
public void testOracle() { | |||||
doMultipleCalls(1000, ORACLE, true, false); | doMultipleCalls(1000, ORACLE, true, false); | ||||
} | } | ||||
@Ignore | @Ignore | ||||
@Test | @Test | ||||
public void testMySQL(){ | |||||
public void testMySQL() { | |||||
doMultipleCalls(1000, MYSQL, true, false); | doMultipleCalls(1000, MYSQL, true, false); | ||||
} | } | ||||
@@ -122,15 +122,15 @@ public class SQLExecTest { | |||||
* @param caching should caching be enabled ? | * @param caching should caching be enabled ? | ||||
* @param catchexception true to catch exception for each call, false if not. | * @param catchexception true to catch exception for each call, false if not. | ||||
*/ | */ | ||||
protected void doMultipleCalls(int calls, int database, boolean caching, boolean catchexception){ | |||||
protected void doMultipleCalls(int calls, int database, boolean caching, boolean catchexception) { | |||||
Properties props = getProperties(database); | Properties props = getProperties(database); | ||||
for (int i = 0; i < calls; i++){ | |||||
for (int i = 0; i < calls; i++) { | |||||
SQLExec sql = createTask(props); | SQLExec sql = createTask(props); | ||||
sql.setCaching(caching); | sql.setCaching(caching); | ||||
try { | try { | ||||
sql.execute(); | sql.execute(); | ||||
} catch (BuildException e){ | |||||
if (!catchexception){ | |||||
} catch (BuildException e) { | |||||
if (!catchexception) { | |||||
throw e; | throw e; | ||||
} | } | ||||
} | } | ||||
@@ -141,15 +141,15 @@ public class SQLExecTest { | |||||
* Create a task from a set of properties | * Create a task from a set of properties | ||||
* @see #getProperties(int) | * @see #getProperties(int) | ||||
*/ | */ | ||||
protected SQLExec createTask(Properties props){ | |||||
protected SQLExec createTask(Properties props) { | |||||
SQLExec sql = new SQLExec(); | SQLExec sql = new SQLExec(); | ||||
sql.setProject( new Project() ); | |||||
sql.setDriver( props.getProperty(DRIVER) ); | |||||
sql.setUserid( props.getProperty(USER) ); | |||||
sql.setPassword( props.getProperty(PASSWORD) ); | |||||
sql.setUrl( props.getProperty(URL) ); | |||||
sql.createClasspath().setLocation( new File(props.getProperty(PATH)) ); | |||||
sql.addText( props.getProperty(SQL) ); | |||||
sql.setProject(new Project()); | |||||
sql.setDriver(props.getProperty(DRIVER)); | |||||
sql.setUserid(props.getProperty(USER)); | |||||
sql.setPassword(props.getProperty(PASSWORD)); | |||||
sql.setUrl(props.getProperty(URL)); | |||||
sql.createClasspath().setLocation(new File(props.getProperty(PATH))); | |||||
sql.addText(props.getProperty(SQL)); | |||||
return sql; | return sql; | ||||
} | } | ||||
@@ -157,7 +157,7 @@ public class SQLExecTest { | |||||
* try to find the path from a resource (jar file or directory name) | * try to find the path from a resource (jar file or directory name) | ||||
* so that it can be used as a classpath to load the resource. | * so that it can be used as a classpath to load the resource. | ||||
*/ | */ | ||||
protected String findResourcePath(String resource){ | |||||
protected String findResourcePath(String resource) { | |||||
resource = resource.replace('.', '/') + ".class"; | resource = resource.replace('.', '/') + ".class"; | ||||
URL url = getClass().getClassLoader().getResource(resource); | URL url = getClass().getClassLoader().getResource(resource); | ||||
if (url == null) { | if (url == null) { | ||||
@@ -180,9 +180,9 @@ public class SQLExecTest { | |||||
* tweak this to make it run or add your own database. | * tweak this to make it run or add your own database. | ||||
* The driver lib should be dropped into the system classloader. | * The driver lib should be dropped into the system classloader. | ||||
*/ | */ | ||||
protected Properties getProperties(int database){ | |||||
protected Properties getProperties(int database) { | |||||
Properties props = null; | Properties props = null; | ||||
switch (database){ | |||||
switch (database) { | |||||
case ORACLE: | case ORACLE: | ||||
props = getProperties("oracle.jdbc.driver.OracleDriver", "test", "test", "jdbc:oracle:thin:@127.0.0.1:1521:orcl"); | props = getProperties("oracle.jdbc.driver.OracleDriver", "test", "test", "jdbc:oracle:thin:@127.0.0.1:1521:orcl"); | ||||
break; | break; | ||||
@@ -201,7 +201,7 @@ public class SQLExecTest { | |||||
} | } | ||||
/** helper method to build properties */ | /** helper method to build properties */ | ||||
protected Properties getProperties(String driver, String user, String pwd, String url){ | |||||
protected Properties getProperties(String driver, String user, String pwd, String url) { | |||||
Properties props = new Properties(); | Properties props = new Properties(); | ||||
props.put(DRIVER, driver); | props.put(DRIVER, driver); | ||||
props.put(USER, user); | props.put(USER, user); | ||||
@@ -33,8 +33,7 @@ public class SleepTest { | |||||
public final BuildFileRule buildRule = new BuildFileRule(); | public final BuildFileRule buildRule = new BuildFileRule(); | ||||
private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; | private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; | ||||
private final static int ERROR_RANGE=1000; | |||||
private final static int ERROR_RANGE = 1000; | |||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
@@ -43,34 +42,34 @@ public class SleepTest { | |||||
@Test | @Test | ||||
public void test1() { | public void test1() { | ||||
Timer timer=new Timer(); | |||||
Timer timer = new Timer(); | |||||
buildRule.executeTarget("test1"); | buildRule.executeTarget("test1"); | ||||
timer.stop(); | timer.stop(); | ||||
assertTrue(timer.time()>=0); | |||||
assertTrue(timer.time() >= 0); | |||||
} | } | ||||
@Test | @Test | ||||
public void test2() { | public void test2() { | ||||
Timer timer=new Timer(); | |||||
Timer timer = new Timer(); | |||||
buildRule.executeTarget("test2"); | buildRule.executeTarget("test2"); | ||||
timer.stop(); | timer.stop(); | ||||
assertTrue(timer.time()>=0); | |||||
assertTrue(timer.time() >= 0); | |||||
} | } | ||||
@Test | @Test | ||||
public void test3() { | public void test3() { | ||||
Timer timer=new Timer(); | |||||
Timer timer = new Timer(); | |||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
timer.stop(); | timer.stop(); | ||||
assertTrue(timer.time()>=(2000-ERROR_RANGE)); | |||||
assertTrue(timer.time() >= (2000 - ERROR_RANGE)); | |||||
} | } | ||||
@Test | @Test | ||||
public void test4() { | public void test4() { | ||||
Timer timer=new Timer(); | |||||
Timer timer = new Timer(); | |||||
buildRule.executeTarget("test3"); | buildRule.executeTarget("test3"); | ||||
timer.stop(); | timer.stop(); | ||||
assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000); | |||||
assertTrue(timer.time() >= (2000 - ERROR_RANGE) && timer.time() < 60000); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -85,10 +84,10 @@ public class SleepTest { | |||||
@Test | @Test | ||||
public void test6() { | public void test6() { | ||||
Timer timer=new Timer(); | |||||
Timer timer = new Timer(); | |||||
buildRule.executeTarget("test6"); | buildRule.executeTarget("test6"); | ||||
timer.stop(); | timer.stop(); | ||||
assertTrue(timer.time()<2000); | |||||
assertTrue(timer.time() < 2000); | |||||
} | } | ||||
@@ -96,23 +95,23 @@ public class SleepTest { | |||||
* inner timer class | * inner timer class | ||||
*/ | */ | ||||
private static class Timer { | private static class Timer { | ||||
long start=0; | |||||
long stop=0; | |||||
long start = 0; | |||||
long stop = 0; | |||||
public Timer() { | public Timer() { | ||||
start(); | start(); | ||||
} | } | ||||
public void start() { | public void start() { | ||||
start=System.currentTimeMillis(); | |||||
start = System.currentTimeMillis(); | |||||
} | } | ||||
public void stop() { | public void stop() { | ||||
stop=System.currentTimeMillis(); | |||||
stop = System.currentTimeMillis(); | |||||
} | } | ||||
public long time() { | public long time() { | ||||
return stop-start; | |||||
return stop - start; | |||||
} | } | ||||
} | } | ||||
@@ -64,7 +64,7 @@ public class StyleTest { | |||||
public void testTransferParameterSet() throws Exception { | public void testTransferParameterSet() throws Exception { | ||||
expectFileContains("testTransferParameterSet", // target | expectFileContains("testTransferParameterSet", // target | ||||
buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", // file | buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", // file | ||||
"set='myvalue'"); // exptected string | |||||
"set='myvalue'"); // expected string | |||||
} | } | ||||
@Test | @Test | ||||
@@ -207,8 +207,7 @@ public class StyleTest { | |||||
private void expectFileContains( | private void expectFileContains( | ||||
String target, String filename, String contains) | String target, String filename, String contains) | ||||
throws IOException | |||||
{ | |||||
throws IOException { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
assertFileContains(filename, contains); | assertFileContains(filename, contains); | ||||
} | } | ||||
@@ -130,12 +130,23 @@ public class SubAntTest { | |||||
expectedBasedirs = dirs; | expectedBasedirs = dirs; | ||||
} | } | ||||
public void buildStarted(BuildEvent event) {} | |||||
public void buildFinished(BuildEvent event) {} | |||||
public void targetFinished(BuildEvent event){} | |||||
public void taskStarted(BuildEvent event) {} | |||||
public void taskFinished(BuildEvent event) {} | |||||
public void messageLogged(BuildEvent event) {} | |||||
public void buildStarted(BuildEvent event) { | |||||
} | |||||
public void buildFinished(BuildEvent event) { | |||||
} | |||||
public void targetFinished(BuildEvent event) { | |||||
} | |||||
public void taskStarted(BuildEvent event) { | |||||
} | |||||
public void taskFinished(BuildEvent event) { | |||||
} | |||||
public void messageLogged(BuildEvent event) { | |||||
} | |||||
public void targetStarted(BuildEvent event) { | public void targetStarted(BuildEvent event) { | ||||
if (event.getTarget().getName().equals("")) { | if (event.getTarget().getName().equals("")) { | ||||
@@ -17,13 +17,13 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
import java.text.SimpleDateFormat; | |||||
import java.util.Calendar; | import java.util.Calendar; | ||||
import java.util.TimeZone; | |||||
import java.util.Date; | import java.util.Date; | ||||
import java.text.SimpleDateFormat; | |||||
import java.util.TimeZone; | |||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Location; | import org.apache.tools.ant.Location; | ||||
import org.apache.tools.ant.Project; | |||||
import org.junit.Before; | import org.junit.Before; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
@@ -59,7 +59,7 @@ public class TStampTest { | |||||
String today = project.getProperty("today"); | String today = project.getProperty("today"); | ||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); | ||||
sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); | |||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); | |||||
String expected = sdf.format(date); | String expected = sdf.format(date); | ||||
assertEquals(expected, today); | assertEquals(expected, today); | ||||
@@ -68,7 +68,7 @@ public class TStampTest { | |||||
/** | /** | ||||
* verifies that custom props have priority over the | * verifies that custom props have priority over the | ||||
* originals | * originals | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testWriteOrder() throws Exception { | public void testWriteOrder() throws Exception { | ||||
@@ -81,7 +81,7 @@ public class TStampTest { | |||||
String today = project.getProperty("TODAY"); | String today = project.getProperty("TODAY"); | ||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); | ||||
sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); | |||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); | |||||
String expected = sdf.format(date); | String expected = sdf.format(date); | ||||
assertEquals(expected, today); | assertEquals(expected, today); | ||||
@@ -91,13 +91,13 @@ public class TStampTest { | |||||
/** | /** | ||||
* verifies that custom props have priority over the | * verifies that custom props have priority over the | ||||
* originals | * originals | ||||
* @throws Exception | |||||
* @throws Exception if something goes wrong | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testPrefix() throws Exception { | public void testPrefix() throws Exception { | ||||
tstamp.setPrefix("prefix"); | tstamp.setPrefix("prefix"); | ||||
tstamp.execute(); | tstamp.execute(); | ||||
String prop= project.getProperty("prefix.DSTAMP"); | |||||
String prop = project.getProperty("prefix.DSTAMP"); | |||||
assertNotNull(prop); | assertNotNull(prop); | ||||
} | } | ||||
@@ -110,7 +110,7 @@ public class TStampTest { | |||||
tstamp.setPrefix("prefix"); | tstamp.setPrefix("prefix"); | ||||
tstamp.execute(); | tstamp.execute(); | ||||
String prop= project.getProperty("prefix.format"); | |||||
String prop = project.getProperty("prefix.format"); | |||||
assertNotNull(prop); | assertNotNull(prop); | ||||
} | } | ||||
@@ -165,7 +165,7 @@ public class TarTest { | |||||
File f1 | File f1 | ||||
= new File(buildRule.getProject().getProperty("output"), "untar/test8.xml"); | = new File(buildRule.getProject().getProperty("output"), "untar/test8.xml"); | ||||
if (! f1.exists()) { | if (! f1.exists()) { | ||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); | |||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); | |||||
} | } | ||||
} | } | ||||
@@ -185,7 +185,7 @@ public class TarTest { | |||||
File f1 | File f1 | ||||
= new File(buildRule.getProject().getProperty("output"), "untar/test10.xml"); | = new File(buildRule.getProject().getProperty("output"), "untar/test10.xml"); | ||||
if (! f1.exists()) { | if (! f1.exists()) { | ||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); | |||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); | |||||
} | } | ||||
} | } | ||||
@@ -195,7 +195,7 @@ public class TarTest { | |||||
File f1 | File f1 | ||||
= new File(buildRule.getProject().getProperty("output"), "untar/test11.xml"); | = new File(buildRule.getProject().getProperty("output"), "untar/test11.xml"); | ||||
if (! f1.exists()) { | if (! f1.exists()) { | ||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); | |||||
fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); | |||||
} | } | ||||
} | } | ||||
@@ -24,23 +24,17 @@ import org.junit.internal.AssumptionViolatedException; | |||||
* Interactive Testcase for Processdestroyer. | * Interactive Testcase for Processdestroyer. | ||||
* | * | ||||
*/ | */ | ||||
public class TestProcess | |||||
implements Runnable | |||||
{ | |||||
public class TestProcess implements Runnable { | |||||
private boolean run = true; | private boolean run = true; | ||||
private boolean done = false; | private boolean done = false; | ||||
public void shutdown() | |||||
{ | |||||
if (!done) | |||||
{ | |||||
public void shutdown() { | |||||
if (!done) { | |||||
System.out.println("shutting down TestProcess"); | System.out.println("shutting down TestProcess"); | ||||
run = false; | run = false; | ||||
synchronized(this) | |||||
{ | |||||
while (!done) | |||||
{ | |||||
synchronized (this) { | |||||
while (!done) { | |||||
try { | try { | ||||
wait(); | wait(); | ||||
} catch (InterruptedException ie) { | } catch (InterruptedException ie) { | ||||
@@ -53,10 +47,8 @@ public class TestProcess | |||||
} | } | ||||
} | } | ||||
public void run() | |||||
{ | |||||
for (int i = 0; i < 5 && run; i++) | |||||
{ | |||||
public void run() { | |||||
for (int i = 0; i < 5 && run; i++) { | |||||
System.out.println(Thread.currentThread().getName()); | System.out.println(Thread.currentThread().getName()); | ||||
try { | try { | ||||
@@ -66,29 +58,23 @@ public class TestProcess | |||||
} | } | ||||
} | } | ||||
synchronized(this) | |||||
{ | |||||
synchronized (this) { | |||||
done = true; | done = true; | ||||
notifyAll(); | notifyAll(); | ||||
} | } | ||||
} | } | ||||
public Thread getShutdownHook() | |||||
{ | |||||
public Thread getShutdownHook() { | |||||
return new TestProcessShutdownHook(); | return new TestProcessShutdownHook(); | ||||
} | } | ||||
private class TestProcessShutdownHook | |||||
extends Thread | |||||
{ | |||||
public void run() | |||||
{ | |||||
private class TestProcessShutdownHook extends Thread { | |||||
public void run() { | |||||
shutdown(); | shutdown(); | ||||
} | } | ||||
} | } | ||||
public static void main(String[] args) | |||||
{ | |||||
public static void main(String[] args) { | |||||
TestProcess tp = new TestProcess(); | TestProcess tp = new TestProcess(); | ||||
new Thread(tp, "TestProcess thread").start(); | new Thread(tp, "TestProcess thread").start(); | ||||
Runtime.getRuntime().addShutdownHook(tp.getShutdownHook()); | Runtime.getRuntime().addShutdownHook(tp.getShutdownHook()); | ||||
@@ -56,7 +56,7 @@ public class TouchTest { | |||||
public long getTargetTime() { | public long getTargetTime() { | ||||
File file = new File(System.getProperty("root"), TOUCH_FILE); | File file = new File(System.getProperty("root"), TOUCH_FILE); | ||||
if(!file.exists()) { | |||||
if (!file.exists()) { | |||||
throw new BuildException("failed to touch file " + file); | throw new BuildException("failed to touch file " + file); | ||||
} | } | ||||
return file.lastModified(); | return file.lastModified(); | ||||
@@ -94,7 +94,7 @@ public class TouchTest { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testNow() { | public void testNow() { | ||||
long now=System.currentTimeMillis(); | |||||
long now = System.currentTimeMillis(); | |||||
buildRule.executeTarget("testNow"); | buildRule.executeTarget("testNow"); | ||||
long time = getTargetTime(); | long time = getTargetTime(); | ||||
assertTimesNearlyMatch(time,now,5000); | assertTimesNearlyMatch(time,now,5000); | ||||
@@ -179,8 +179,8 @@ public class TouchTest { | |||||
/** | /** | ||||
* run a target to touch the test file; verify the timestamp is as expected | * run a target to touch the test file; verify the timestamp is as expected | ||||
* @param targetName | |||||
* @param timestamp | |||||
* @param targetName String | |||||
* @param timestamp long | |||||
*/ | */ | ||||
private void touchFile(String targetName, long timestamp) { | private void touchFile(String targetName, long timestamp) { | ||||
buildRule.executeTarget(targetName); | buildRule.executeTarget(targetName); | ||||
@@ -190,8 +190,8 @@ public class TouchTest { | |||||
/** | /** | ||||
* assert that two times are within the current FS granularity; | * assert that two times are within the current FS granularity; | ||||
* @param timestamp | |||||
* @param time | |||||
* @param timestamp long | |||||
* @param time long | |||||
*/ | */ | ||||
public void assertTimesNearlyMatch(long timestamp,long time) { | public void assertTimesNearlyMatch(long timestamp,long time) { | ||||
long granularity= FILE_UTILS.getFileTimestampGranularity(); | long granularity= FILE_UTILS.getFileTimestampGranularity(); | ||||
@@ -200,9 +200,9 @@ public class TouchTest { | |||||
/** | /** | ||||
* assert that two times are within a specified range | * assert that two times are within a specified range | ||||
* @param timestamp | |||||
* @param time | |||||
* @param range | |||||
* @param timestamp long | |||||
* @param time long | |||||
* @param range long | |||||
*/ | */ | ||||
private void assertTimesNearlyMatch(long timestamp, long time, long range) { | private void assertTimesNearlyMatch(long timestamp, long time, long range) { | ||||
assertTrue("Time " + timestamp + " is not within " + range + " ms of " | assertTrue("Time " + timestamp + " is not within " + range + " ms of " | ||||
@@ -20,8 +20,8 @@ package org.apache.tools.ant.taskdefs; | |||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import org.apache.tools.ant.BuildFileRule; | |||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.BuildFileRule; | |||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.TypeAdapter; | import org.apache.tools.ant.TypeAdapter; | ||||
@@ -116,8 +116,7 @@ public class TypeAdapterTest { | |||||
} | } | ||||
public static class RunnableAdapter | public static class RunnableAdapter | ||||
extends Task implements TypeAdapter | |||||
{ | |||||
extends Task implements TypeAdapter { | |||||
private String execMethodName = "run"; | private String execMethodName = "run"; | ||||
private Object proxy; | private Object proxy; | ||||
@@ -128,14 +127,12 @@ public class TypeAdapterTest { | |||||
String message = | String message = | ||||
"return type of " + execMethodName + "() should be " | "return type of " + execMethodName + "() should be " | ||||
+ "void but was \"" + execMethod.getReturnType() + | + "void but was \"" + execMethod.getReturnType() + | ||||
"\" in " | |||||
+ proxyClass; | |||||
"\" in " + proxyClass; | |||||
log(message, Project.MSG_WARN); | log(message, Project.MSG_WARN); | ||||
} | } | ||||
return execMethod; | return execMethod; | ||||
} catch (NoSuchMethodException e) { | } catch (NoSuchMethodException e) { | ||||
String message = "No public "+ execMethodName + | |||||
"() method in " | |||||
String message = "No public " + execMethodName + "() method in " | |||||
+ proxyClass; | + proxyClass; | ||||
log(message, Project.MSG_ERR); | log(message, Project.MSG_ERR); | ||||
throw new BuildException(message); | throw new BuildException(message); | ||||
@@ -113,7 +113,7 @@ public class TypedefTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoResourceOnErrorFailAll(){ | |||||
public void testNoResourceOnErrorFailAll() { | |||||
try { | try { | ||||
buildRule.executeTarget("noresourcefailall"); | buildRule.executeTarget("noresourcefailall"); | ||||
fail("BuildException expected: the requested resource does not exist"); | fail("BuildException expected: the requested resource does not exist"); | ||||
@@ -123,13 +123,13 @@ public class TypedefTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testNoResourceOnErrorFail(){ | |||||
public void testNoResourceOnErrorFail() { | |||||
buildRule.executeTarget("noresourcefail"); | buildRule.executeTarget("noresourcefail"); | ||||
assertContains("Could not load definitions from resource ", buildRule.getLog()); | assertContains("Could not load definitions from resource ", buildRule.getLog()); | ||||
} | } | ||||
@Test | @Test | ||||
public void testNoResourceOnErrorNotFail(){ | |||||
public void testNoResourceOnErrorNotFail() { | |||||
buildRule.executeTarget("noresourcenotfail"); | buildRule.executeTarget("noresourcenotfail"); | ||||
assertContains("Could not load definitions from resource ", buildRule.getLog()); | assertContains("Could not load definitions from resource ", buildRule.getLog()); | ||||
} | } | ||||
@@ -25,6 +25,7 @@ import org.junit.Rule; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | |||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
@@ -43,32 +44,32 @@ public class UntarTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testRealTest() throws java.io.IOException { | |||||
public void testRealTest() throws IOException { | |||||
testLogoExtraction("realTest"); | testLogoExtraction("realTest"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testRealGzipTest() throws java.io.IOException { | |||||
public void testRealGzipTest() throws IOException { | |||||
testLogoExtraction("realGzipTest"); | testLogoExtraction("realGzipTest"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testRealBzip2Test() throws java.io.IOException { | |||||
public void testRealBzip2Test() throws IOException { | |||||
testLogoExtraction("realBzip2Test"); | testLogoExtraction("realBzip2Test"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTestTarTask() throws java.io.IOException { | |||||
public void testTestTarTask() throws IOException { | |||||
testLogoExtraction("testTarTask"); | testLogoExtraction("testTarTask"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTestGzipTarTask() throws java.io.IOException { | |||||
public void testTestGzipTarTask() throws IOException { | |||||
testLogoExtraction("testGzipTarTask"); | testLogoExtraction("testGzipTarTask"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTestBzip2TarTask() throws java.io.IOException { | |||||
public void testTestBzip2TarTask() throws IOException { | |||||
testLogoExtraction("testBzip2TarTask"); | testLogoExtraction("testBzip2TarTask"); | ||||
} | } | ||||
@@ -91,11 +92,11 @@ public class UntarTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testResourceCollection() throws java.io.IOException { | |||||
public void testResourceCollection() throws IOException { | |||||
testLogoExtraction("resourceCollection"); | testLogoExtraction("resourceCollection"); | ||||
} | } | ||||
private void testLogoExtraction(String target) throws java.io.IOException { | |||||
private void testLogoExtraction(String target) throws IOException { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | ||||
FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "untar/asf-logo.gif"))); | FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "untar/asf-logo.gif"))); | ||||
@@ -74,14 +74,14 @@ public class UnzipTest { | |||||
@Test | @Test | ||||
public void testRealTest() throws java.io.IOException { | |||||
public void testRealTest() throws IOException { | |||||
buildRule.executeTarget("realTest"); | buildRule.executeTarget("realTest"); | ||||
assertLogoUncorrupted(); | assertLogoUncorrupted(); | ||||
} | } | ||||
/** | /** | ||||
* test that the logo gif file has not been corrupted | * test that the logo gif file has not been corrupted | ||||
* @throws IOException | |||||
* @throws IOException if something goes wrong | |||||
*/ | */ | ||||
private void assertLogoUncorrupted() throws IOException { | private void assertLogoUncorrupted() throws IOException { | ||||
assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), | ||||
@@ -90,13 +90,13 @@ public class UnzipTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testTestZipTask() throws java.io.IOException { | |||||
public void testTestZipTask() throws IOException { | |||||
buildRule.executeTarget("testZipTask"); | buildRule.executeTarget("testZipTask"); | ||||
assertLogoUncorrupted(); | assertLogoUncorrupted(); | ||||
} | } | ||||
@Test | @Test | ||||
public void testTestUncompressedZipTask() throws java.io.IOException { | |||||
public void testTestUncompressedZipTask() throws IOException { | |||||
buildRule.executeTarget("testUncompressedZipTask"); | buildRule.executeTarget("testUncompressedZipTask"); | ||||
assertLogoUncorrupted(); | assertLogoUncorrupted(); | ||||
} | } | ||||
@@ -204,7 +204,7 @@ public class UnzipTest { | |||||
} | } | ||||
/** | /** | ||||
* assert that a file doesnt exist, relative to the project | |||||
* assert that a file doesn't exist, relative to the project | |||||
* | * | ||||
* @param message message if there is no mpatch | * @param message message if there is no mpatch | ||||
* @param filename filename to resolve against the project | * @param filename filename to resolve against the project | ||||
@@ -43,7 +43,7 @@ public class UpToDateTest { | |||||
File srcDir = buildRule.getProject().resolveFile("source"); | File srcDir = buildRule.getProject().resolveFile("source"); | ||||
assumeTrue("Could not change modification timestamp of source directory", | assumeTrue("Could not change modification timestamp of source directory", | ||||
srcDir.setLastModified(srcDir.lastModified() | srcDir.setLastModified(srcDir.lastModified() | ||||
- (3 * FileUtils.getFileUtils().getFileTimestampGranularity()))); | |||||
- 3 * FileUtils.getFileUtils().getFileTimestampGranularity())); | |||||
} | } | ||||
@After | @After | ||||
@@ -79,7 +79,7 @@ public class XmlPropertyTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testNone () throws IOException { | |||||
public void testNone() throws IOException { | |||||
doTest("testNone", false, false, false, false, false); | doTest("testNone", false, false, false, false, false); | ||||
} | } | ||||
@@ -89,47 +89,47 @@ public class XmlPropertyTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testCollapse () throws IOException { | |||||
public void testCollapse() throws IOException { | |||||
doTest("testCollapse", false, true, false, false, false); | doTest("testCollapse", false, true, false, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testSemantic () throws IOException { | |||||
public void testSemantic() throws IOException { | |||||
doTest("testSemantic", false, false, true, false, false); | doTest("testSemantic", false, false, true, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testKeeprootCollapse () throws IOException { | |||||
public void testKeeprootCollapse() throws IOException { | |||||
doTest("testKeeprootCollapse", true, true, false, false, false); | doTest("testKeeprootCollapse", true, true, false, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testKeeprootSemantic () throws IOException { | |||||
public void testKeeprootSemantic() throws IOException { | |||||
doTest("testKeeprootSemantic", true, false, true, false, false); | doTest("testKeeprootSemantic", true, false, true, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testCollapseSemantic () throws IOException { | |||||
public void testCollapseSemantic() throws IOException { | |||||
doTest("testCollapseSemantic", false, true, true, false, false); | doTest("testCollapseSemantic", false, true, true, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testKeeprootCollapseSemantic () throws IOException { | |||||
public void testKeeprootCollapseSemantic() throws IOException { | |||||
doTest("testKeeprootCollapseSemantic", true, true, true, false, false); | doTest("testKeeprootCollapseSemantic", true, true, true, false, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testInclude () throws IOException { | |||||
public void testInclude() throws IOException { | |||||
doTest("testInclude", false, false, false, true, false); | doTest("testInclude", false, false, false, true, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testSemanticInclude () throws IOException { | |||||
public void testSemanticInclude() throws IOException { | |||||
doTest("testSemanticInclude", false, false, true, true, false); | doTest("testSemanticInclude", false, false, true, true, false); | ||||
} | } | ||||
@Test | @Test | ||||
public void testSemanticLocal () throws IOException { | |||||
public void testSemanticLocal() throws IOException { | |||||
doTest("testSemanticInclude", false, false, true, false, true); | doTest("testSemanticInclude", false, false, true, false, true); | ||||
} | } | ||||
@@ -152,7 +152,7 @@ public class XmlPropertyTest { | |||||
// What's the working directory? If local, then its the | // What's the working directory? If local, then its the | ||||
// folder of the input file. Otherwise, its the "current" dir.. | // folder of the input file. Otherwise, its the "current" dir.. | ||||
File workingDir; | File workingDir; | ||||
if ( localRoot ) { | |||||
if (localRoot) { | |||||
workingDir = inputFile.getParentFile(); | workingDir = inputFile.getParentFile(); | ||||
} else { | } else { | ||||
workingDir = FILE_UTILS.resolveFile(new File("."), "."); | workingDir = FILE_UTILS.resolveFile(new File("."), "."); | ||||
@@ -206,13 +206,13 @@ public class XmlPropertyTest { | |||||
* 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, | |||||
private static void ensureProperties(String msg, File inputFile, | |||||
File workingDir, Project p, | File workingDir, Project p, | ||||
Properties properties) { | Properties properties) { | ||||
Hashtable xmlproperties = p.getProperties(); | Hashtable xmlproperties = p.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(); | |||||
while(propertyKeyEnum.hasMoreElements()){ | |||||
Enumeration<?> propertyKeyEnum = properties.propertyNames(); | |||||
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; | ||||
@@ -227,10 +227,9 @@ public class XmlPropertyTest { | |||||
// that the object was created with the given id. | // that the object was created with the given id. | ||||
// We don't have an adequate way of testing the actual | // We don't have an adequate way of testing the actual | ||||
// *value* of the Path object, though... | // *value* of the Path object, though... | ||||
String id = currentKey; | |||||
Object obj = p.getReferences().get(id); | |||||
Object obj = p.getReferences().get(currentKey); | |||||
if ( obj == null ) { | |||||
if (obj == null) { | |||||
fail(assertMsg + " Object ID does not exist."); | fail(assertMsg + " Object ID does not exist."); | ||||
} | } | ||||
@@ -286,13 +285,10 @@ public class XmlPropertyTest { | |||||
String currentKey = referenceKeyEnum.nextElement().toString(); | String currentKey = referenceKeyEnum.nextElement().toString(); | ||||
Object currentValue = references.get(currentKey); | Object currentValue = references.get(currentKey); | ||||
if (currentValue instanceof Path) { | |||||
} else if (currentValue instanceof String) { | |||||
} else { | |||||
if( ! currentKey.startsWith("ant.") ) { | |||||
fail(msg + "-" + inputFile.getName() + " Key=" | |||||
+ currentKey + " is not a recognized type."); | |||||
} | |||||
if (!(currentValue instanceof Path) && !(currentValue instanceof String) | |||||
&& !currentKey.startsWith("ant.")) { | |||||
fail(msg + "-" + inputFile.getName() + " Key=" | |||||
+ currentKey + " is not a recognized type."); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -301,7 +297,7 @@ public class XmlPropertyTest { | |||||
* 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, | |||||
private static File getGoldfile(File input, boolean keepRoot, | |||||
boolean collapse, boolean semantic, | boolean collapse, boolean semantic, | ||||
boolean include, boolean localRoot) { | boolean include, boolean localRoot) { | ||||
// Substitute .xml with .properties | // Substitute .xml with .properties | ||||
@@ -358,14 +354,13 @@ public class XmlPropertyTest { | |||||
return true; | return true; | ||||
} else { | } else { | ||||
return (file.getPath().indexOf("taskdefs") > 0 && | return (file.getPath().indexOf("taskdefs") > 0 && | ||||
file.getPath().toLowerCase().endsWith(".xml") ); | |||||
file.getPath().toLowerCase().endsWith(".xml")); | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
File[] files = startingDir.listFiles(filter); | File[] files = startingDir.listFiles(filter); | ||||
for (int i=0;i<files.length;i++) { | |||||
File f = files[i]; | |||||
for (File f : files) { | |||||
if (!f.isDirectory()) { | if (!f.isDirectory()) { | ||||
collect.addElement(f); | collect.addElement(f); | ||||
} else { | } else { | ||||
@@ -20,13 +20,12 @@ package org.apache.tools.ant.taskdefs; | |||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.InputStream; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | |||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.tools.ant.types.Resource; | import org.apache.tools.ant.types.Resource; | ||||
import org.apache.tools.ant.types.ResourceCollection; | import org.apache.tools.ant.types.ResourceCollection; | ||||
import org.apache.tools.ant.types.resources.ZipResource; | import org.apache.tools.ant.types.resources.ZipResource; | ||||
import org.apache.tools.zip.JarMarker; | import org.apache.tools.zip.JarMarker; | ||||
@@ -82,8 +81,12 @@ public class ZipExtraFieldTest { | |||||
} | } | ||||
}; | }; | ||||
testInstance.add(new ResourceCollection() { | testInstance.add(new ResourceCollection() { | ||||
public boolean isFilesystemOnly() { return false; } | |||||
public int size() { return 1; } | |||||
public boolean isFilesystemOnly() { | |||||
return false; | |||||
} | |||||
public int size() { | |||||
return 1; | |||||
} | |||||
public Iterator<Resource> iterator() { | public Iterator<Resource> iterator() { | ||||
return Collections.<Resource>singleton(r).iterator(); | return Collections.<Resource>singleton(r).iterator(); | ||||
} | } | ||||
@@ -101,7 +101,7 @@ public class ZipTest { | |||||
@After | @After | ||||
public void tearDown() { | public void tearDown() { | ||||
try { | try { | ||||
if ( zfPrefixAddsDir != null) { | |||||
if (zfPrefixAddsDir != null) { | |||||
zfPrefixAddsDir.close(); | zfPrefixAddsDir.close(); | ||||
} | } | ||||
@@ -189,21 +189,25 @@ public class ZipTest { | |||||
public void testEmptySkip() { | public void testEmptySkip() { | ||||
buildRule.executeTarget("testEmptySkip"); | buildRule.executeTarget("testEmptySkip"); | ||||
} | } | ||||
// Bugzilla Report 30365 | // Bugzilla Report 30365 | ||||
@Test | @Test | ||||
public void testZipEmptyDir() { | public void testZipEmptyDir() { | ||||
buildRule.executeTarget("zipEmptyDir"); | buildRule.executeTarget("zipEmptyDir"); | ||||
} | } | ||||
// Bugzilla Report 40258 | // Bugzilla Report 40258 | ||||
@Test | @Test | ||||
public void testZipEmptyDirFilesOnly() { | public void testZipEmptyDirFilesOnly() { | ||||
buildRule.executeTarget("zipEmptyDirFilesOnly"); | buildRule.executeTarget("zipEmptyDirFilesOnly"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testZipEmptyCreate() { | public void testZipEmptyCreate() { | ||||
buildRule.executeTarget("zipEmptyCreate"); | buildRule.executeTarget("zipEmptyCreate"); | ||||
assertContains("Note: creating empty", buildRule.getLog()); | assertContains("Note: creating empty", buildRule.getLog()); | ||||
} | } | ||||
// Bugzilla Report 25513 | // Bugzilla Report 25513 | ||||
@Test | @Test | ||||
public void testCompressionLevel() { | public void testCompressionLevel() { | ||||
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertEquals; | |||||
public class DefaultCompilerAdapterTest { | public class DefaultCompilerAdapterTest { | ||||
private static class LogCapturingJavac extends Javac { | private static class LogCapturingJavac extends Javac { | ||||
private StringBuffer sb = new StringBuffer(); | |||||
private StringBuilder sb = new StringBuilder(); | |||||
public void log(String msg, int msgLevel) { | public void log(String msg, int msgLevel) { | ||||
sb.append(msg); | sb.append(msg); | ||||
} | } | ||||
@@ -58,7 +58,9 @@ public class DefaultCompilerAdapterTest { | |||||
return cmd; | return cmd; | ||||
} | } | ||||
public boolean execute() { return false; } | |||||
public boolean execute() { | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* public to avoid classloader issues. | * public to avoid classloader issues. | ||||
@@ -70,7 +72,9 @@ public class DefaultCompilerAdapterTest { | |||||
private static class SourceTargetHelperNoOverride extends DefaultCompilerAdapter { | private static class SourceTargetHelperNoOverride extends DefaultCompilerAdapter { | ||||
public boolean execute() { return false; } | |||||
public boolean execute() { | |||||
return false; | |||||
} | |||||
/** | /** | ||||
* public to avoid classloader issues. | * public to avoid classloader issues. | ||||
@@ -357,6 +361,7 @@ public class DefaultCompilerAdapterTest { | |||||
src.mkdir(); | src.mkdir(); | ||||
final File java1 = createFile(src,"main/m1/lin/classes/org/apache/ant/tests/J1.java"); | final File java1 = createFile(src,"main/m1/lin/classes/org/apache/ant/tests/J1.java"); | ||||
final File java2 = createFile(src,"main/m3/sol/classes/org/apache/ant/tests/J2.java"); | final File java2 = createFile(src,"main/m3/sol/classes/org/apache/ant/tests/J2.java"); | ||||
@SuppressWarnings("unused") | |||||
final File java3 = createFile(src,"main/m3/sol/classes/org/apache/ant/invisible/J3.java"); | final File java3 = createFile(src,"main/m3/sol/classes/org/apache/ant/invisible/J3.java"); | ||||
final File build = new File(workDir, "build"); | final File build = new File(workDir, "build"); | ||||
build.mkdirs(); | build.mkdirs(); | ||||
@@ -501,7 +506,7 @@ public class DefaultCompilerAdapterTest { | |||||
final File destDir = new File(tmp, String.format("%s%s%d", | final File destDir = new File(tmp, String.format("%s%s%d", | ||||
getClass().getName(), | getClass().getName(), | ||||
testName, | testName, | ||||
System.currentTimeMillis()/1000)); | |||||
System.currentTimeMillis() / 1000)); | |||||
destDir.mkdirs(); | destDir.mkdirs(); | ||||
return destDir; | return destDir; | ||||
} | } | ||||
@@ -68,7 +68,7 @@ public class IsReachableTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testBoth"); | buildRule.executeTarget("testBoth"); | ||||
fail("Build exception expected: error on two targets"); | fail("Build exception expected: error on two targets"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals(IsReachable.ERROR_BOTH_TARGETS, ex.getMessage()); | assertEquals(IsReachable.ERROR_BOTH_TARGETS, ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -78,7 +78,7 @@ public class IsReachableTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testNoTargets"); | buildRule.executeTarget("testNoTargets"); | ||||
fail("Build exception expected: no params"); | fail("Build exception expected: no params"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals(IsReachable.ERROR_NO_HOSTNAME, ex.getMessage()); | assertEquals(IsReachable.ERROR_NO_HOSTNAME, ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -88,7 +88,7 @@ public class IsReachableTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testBadTimeout"); | buildRule.executeTarget("testBadTimeout"); | ||||
fail("Build exception expected: error on -ve timeout"); | fail("Build exception expected: error on -ve timeout"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals(IsReachable.ERROR_BAD_TIMEOUT, ex.getMessage()); | assertEquals(IsReachable.ERROR_BAD_TIMEOUT, ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -99,7 +99,7 @@ public class IsReachableTest { | |||||
try { | try { | ||||
buildRule.executeTarget("testFile"); | buildRule.executeTarget("testFile"); | ||||
fail("Build exception expected: error on file URL"); | fail("Build exception expected: error on file URL"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertEquals(IsReachable.ERROR_NO_HOST_IN_URL, ex.getMessage()); | assertEquals(IsReachable.ERROR_NO_HOST_IN_URL, ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -20,9 +20,9 @@ package org.apache.tools.ant.taskdefs.cvslib; | |||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.util.Calendar; | import java.util.Calendar; | ||||
import java.util.Date; | |||||
import java.util.Locale; | import java.util.Locale; | ||||
import java.util.TimeZone; | import java.util.TimeZone; | ||||
import java.util.Date; | |||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
@@ -17,21 +17,21 @@ | |||||
*/ | */ | ||||
package org.apache.tools.ant.taskdefs.cvslib; | package org.apache.tools.ant.taskdefs.cvslib; | ||||
import java.util.Date; | |||||
import java.io.PrintWriter; | |||||
import java.io.OutputStreamWriter; | |||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStreamWriter; | |||||
import java.io.PrintWriter; | |||||
import java.util.Date; | |||||
import org.apache.tools.ant.util.JAXPUtils; | import org.apache.tools.ant.util.JAXPUtils; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.xml.sax.XMLReader; | |||||
import org.xml.sax.InputSource; | |||||
import org.xml.sax.Attributes; | |||||
import org.xml.sax.ContentHandler; | import org.xml.sax.ContentHandler; | ||||
import org.xml.sax.SAXException; | |||||
import org.xml.sax.InputSource; | |||||
import org.xml.sax.Locator; | import org.xml.sax.Locator; | ||||
import org.xml.sax.Attributes; | |||||
import org.xml.sax.SAXException; | |||||
import org.xml.sax.XMLReader; | |||||
/** | /** | ||||
* Test for the cvslib ChangeLogWriter | * Test for the cvslib ChangeLogWriter | ||||
@@ -65,11 +65,12 @@ public class ChangeLogWriterTest { | |||||
public void startDocument() throws SAXException { | public void startDocument() throws SAXException { | ||||
} | } | ||||
public void characters(char ch[], int start, int length) throws SAXException { | |||||
public void characters(char[] ch, int start, int length) throws SAXException { | |||||
@SuppressWarnings("unused") | |||||
String debug = new String(ch, start, length); | String debug = new String(ch, start, length); | ||||
} | } | ||||
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { | |||||
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { | |||||
} | } | ||||
public void endPrefixMapping(String prefix) throws SAXException { | public void endPrefixMapping(String prefix) throws SAXException { | ||||
@@ -24,14 +24,14 @@ public class A { | |||||
System.out.println(a); | System.out.println(a); | ||||
} | } | ||||
static A a=new A(); | |||||
static A a = new A(); | |||||
static { | static { | ||||
System.out.println("A CLASS INITIALIZATION"); | System.out.println("A CLASS INITIALIZATION"); | ||||
} | } | ||||
protected static void setA(A oa) { | protected static void setA(A oa) { | ||||
a=oa; | |||||
a = oa; | |||||
} | } | ||||
public String toString() { | public String toString() { | ||||
@@ -30,83 +30,83 @@ public class EmailAddressTest { | |||||
@Test | @Test | ||||
public void test1() { | public void test1() { | ||||
expectNameAddress( new EmailAddress("address (name)") ); | |||||
expectNameAddress(new EmailAddress("address (name)")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test2() { | public void test2() { | ||||
expectNameAddress( new EmailAddress("(name) address") ); | |||||
expectNameAddress(new EmailAddress("(name) address")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test3() { | public void test3() { | ||||
expectNameAddress( new EmailAddress("name <address>") ); | |||||
expectNameAddress(new EmailAddress("name <address>")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test4() { | public void test4() { | ||||
expectNameAddress( new EmailAddress("<address> name") ); | |||||
expectNameAddress(new EmailAddress("<address> name")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test5() { | public void test5() { | ||||
expectNameAddress( new EmailAddress("<address> (name)") ); | |||||
expectNameAddress(new EmailAddress("<address> (name)")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test6() { | public void test6() { | ||||
expectNameAddress( new EmailAddress("(name) <address>") ); | |||||
expectNameAddress(new EmailAddress("(name) <address>")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test7() { | public void test7() { | ||||
expectNameAddress2( new EmailAddress("address (<name>)") ); | |||||
expectNameAddress2(new EmailAddress("address (<name>)")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test8() { | public void test8() { | ||||
expectNameAddress2( new EmailAddress("(<name>) address") ); | |||||
expectNameAddress2(new EmailAddress("(<name>) address")); | |||||
} | } | ||||
@Test | @Test | ||||
public void test9() { | public void test9() { | ||||
expectNameAddress3( new EmailAddress("address") ); | |||||
expectNameAddress3(new EmailAddress("address")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testA() { | public void testA() { | ||||
expectNameAddress3( new EmailAddress("<address>") ); | |||||
expectNameAddress3(new EmailAddress("<address>")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testB() { | public void testB() { | ||||
expectNameAddress3( new EmailAddress(" <address> ") ); | |||||
expectNameAddress3(new EmailAddress(" <address> ")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testC() { | public void testC() { | ||||
expectNameAddress3( new EmailAddress("< address >") ); | |||||
expectNameAddress3(new EmailAddress("< address >")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testD() { | public void testD() { | ||||
expectNameAddress3( new EmailAddress(" < address > ") ); | |||||
expectNameAddress3(new EmailAddress(" < address > ")); | |||||
} | } | ||||
private void expectNameAddress(EmailAddress e) { | private void expectNameAddress(EmailAddress e) { | ||||
assertEquals( "name", e.getName() ); | |||||
assertEquals( "address", e.getAddress() ); | |||||
assertEquals("name", e.getName()); | |||||
assertEquals("address", e.getAddress()); | |||||
} | } | ||||
// where the name contains <> | // where the name contains <> | ||||
private void expectNameAddress2(EmailAddress e) { | private void expectNameAddress2(EmailAddress e) { | ||||
assertEquals( "<name>", e.getName() ); | |||||
assertEquals( "address", e.getAddress() ); | |||||
assertEquals("<name>", e.getName()); | |||||
assertEquals("address", e.getAddress()); | |||||
} | } | ||||
// where only an address is supplied | // where only an address is supplied | ||||
private void expectNameAddress3(EmailAddress e) { | private void expectNameAddress3(EmailAddress e) { | ||||
assertNull("Expected null, found <" + e.getName() + ">", e.getName()); | assertNull("Expected null, found <" + e.getName() + ">", e.getName()); | ||||
assertEquals( "address", e.getAddress() ); | |||||
assertEquals("address", e.getAddress()); | |||||
} | } | ||||
} | } |
@@ -188,7 +188,7 @@ public class ANTLRTest { | |||||
buildRule.executeTarget("test9"); | buildRule.executeTarget("test9"); | ||||
assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | ||||
FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); | |||||
FileUtilities.rollbackTimestamps(buildRule.getOutputDir(), 5); | |||||
buildRule.executeTarget("normalRecompile"); | buildRule.executeTarget("normalRecompile"); | ||||
assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | ||||
@@ -200,7 +200,7 @@ public class ANTLRTest { | |||||
buildRule.executeTarget("test9"); | buildRule.executeTarget("test9"); | ||||
assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | ||||
FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); | |||||
FileUtilities.rollbackTimestamps(buildRule.getOutputDir(), 5); | |||||
buildRule.executeTarget("supergrammarChangeRecompile"); | buildRule.executeTarget("supergrammarChangeRecompile"); | ||||
assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | assertNotContains("Skipped grammar file.", buildRule.getFullLog()); | ||||
@@ -34,7 +34,7 @@ import org.junit.Test; | |||||
import org.w3c.dom.Document; | import org.w3c.dom.Document; | ||||
/** | /** | ||||
* Abtract testcase for XSLTLiaison. | |||||
* Abstract testcase for XSLTLiaison. | |||||
* Override createLiaison for each XSLTLiaison. | * Override createLiaison for each XSLTLiaison. | ||||
* | * | ||||
* <a href="sbailliez@apache.org">Stephane Bailliez</a> | * <a href="sbailliez@apache.org">Stephane Bailliez</a> | ||||
@@ -51,12 +51,12 @@ public abstract class AbstractXSLTLiaisonTest { | |||||
} | } | ||||
// to override | // to override | ||||
protected abstract XSLTLiaison createLiaison() throws Exception ; | |||||
protected abstract XSLTLiaison createLiaison() throws Exception; | |||||
/** load the file from the caller classloader that loaded this class */ | /** load the file from the caller classloader that loaded this class */ | ||||
protected File getFile(String name) throws FileNotFoundException { | protected File getFile(String name) throws FileNotFoundException { | ||||
URL url = getClass().getResource(name); | URL url = getClass().getResource(name); | ||||
if (url == null){ | |||||
if (url == null) { | |||||
throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); | ||||
} | } | ||||
return new File(FILE_UTILS.fromURI(url.toExternalForm())); | return new File(FILE_UTILS.fromURI(url.toExternalForm())); | ||||
@@ -50,7 +50,7 @@ import org.junit.Test; | |||||
*/ | */ | ||||
public class EchoPropertiesTest { | public class EchoPropertiesTest { | ||||
private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; | |||||
private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; | |||||
private static final String GOOD_OUTFILE = "test.properties"; | private static final String GOOD_OUTFILE = "test.properties"; | ||||
private static final String GOOD_OUTFILE_XML = "test.xml"; | private static final String GOOD_OUTFILE_XML = "test.xml"; | ||||
private static final String PREFIX_OUTFILE = "test-prefix.properties"; | private static final String PREFIX_OUTFILE = "test-prefix.properties"; | ||||
@@ -59,20 +59,17 @@ public class EchoPropertiesTest { | |||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@Before | @Before | ||||
public void setUp() { | public void setUp() { | ||||
buildRule.configureProject(TASKDEFS_DIR + "echoproperties.xml"); | buildRule.configureProject(TASKDEFS_DIR + "echoproperties.xml"); | ||||
buildRule.getProject().setProperty("test.property", TEST_VALUE); | buildRule.getProject().setProperty("test.property", TEST_VALUE); | ||||
} | } | ||||
@After | @After | ||||
public void tearDown() { | public void tearDown() { | ||||
buildRule.executeTarget("cleanup"); | buildRule.executeTarget("cleanup"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToLog() { | public void testEchoToLog() { | ||||
buildRule.executeTarget("testEchoToLog"); | buildRule.executeTarget("testEchoToLog"); | ||||
@@ -82,17 +79,15 @@ public class EchoPropertiesTest { | |||||
@Test | @Test | ||||
public void testEchoWithEmptyPrefixToLog() { | public void testEchoWithEmptyPrefixToLog() { | ||||
buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); | buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); | ||||
assertContains("test.property="+TEST_VALUE, buildRule.getLog()); | |||||
assertContains("test.property=" + TEST_VALUE, buildRule.getLog()); | |||||
} | } | ||||
@Test | @Test | ||||
public void testReadBadFile() { | public void testReadBadFile() { | ||||
try { | try { | ||||
buildRule.executeTarget("testReadBadFile"); | buildRule.executeTarget("testReadBadFile"); | ||||
fail("BuildException should have been thrown on bad file"); | fail("BuildException should have been thrown on bad file"); | ||||
} | |||||
catch(BuildException ex) { | |||||
} catch(BuildException ex) { | |||||
assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage()); | assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -103,32 +98,28 @@ public class EchoPropertiesTest { | |||||
assertContains("srcfile is a directory!", buildRule.getLog()); | assertContains("srcfile is a directory!", buildRule.getLog()); | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToBadFile() { | public void testEchoToBadFile() { | ||||
try { | try { | ||||
buildRule.executeTarget("testEchoToBadFile"); | buildRule.executeTarget("testEchoToBadFile"); | ||||
fail("BuildException should have been thrown on destination file being a directory"); | fail("BuildException should have been thrown on destination file being a directory"); | ||||
} catch(BuildException ex) { | |||||
} catch (BuildException ex) { | |||||
assertContains("destfile is a directory", "destfile is a directory!", ex.getMessage()); | assertContains("destfile is a directory", "destfile is a directory!", ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToBadFileNoFail() { | public void testEchoToBadFileNoFail() { | ||||
buildRule.executeTarget("testEchoToBadFileNoFail"); | buildRule.executeTarget("testEchoToBadFileNoFail"); | ||||
assertContains("destfile is a directory!", buildRule.getLog()); | assertContains("destfile is a directory!", buildRule.getLog()); | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToGoodFile() throws Exception { | public void testEchoToGoodFile() throws Exception { | ||||
buildRule.executeTarget("testEchoToGoodFile"); | buildRule.executeTarget("testEchoToGoodFile"); | ||||
assertGoodFile(); | assertGoodFile(); | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToGoodFileXml() throws Exception { | public void testEchoToGoodFileXml() throws Exception { | ||||
buildRule.executeTarget("testEchoToGoodFileXml"); | buildRule.executeTarget("testEchoToGoodFileXml"); | ||||
@@ -149,21 +140,21 @@ public class EchoPropertiesTest { | |||||
} finally { | } finally { | ||||
try { | try { | ||||
fr.close(); | fr.close(); | ||||
} catch(IOException e) {} | |||||
} catch (IOException e) { | |||||
} | |||||
try { | try { | ||||
br.close(); | br.close(); | ||||
} catch(IOException e) {} | |||||
} catch (IOException e) { | |||||
} | |||||
} | } | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToGoodFileFail() throws Exception { | public void testEchoToGoodFileFail() throws Exception { | ||||
buildRule.executeTarget("testEchoToGoodFileFail"); | buildRule.executeTarget("testEchoToGoodFileFail"); | ||||
assertGoodFile(); | assertGoodFile(); | ||||
} | } | ||||
@Test | @Test | ||||
public void testEchoToGoodFileNoFail() throws Exception { | public void testEchoToGoodFileNoFail() throws Exception { | ||||
buildRule.executeTarget("testEchoToGoodFileNoFail"); | buildRule.executeTarget("testEchoToGoodFileNoFail"); | ||||
@@ -194,23 +185,26 @@ public class EchoPropertiesTest { | |||||
public void testWithPrefixAndRegex() throws Exception { | public void testWithPrefixAndRegex() throws Exception { | ||||
try { | try { | ||||
buildRule.executeTarget("testWithPrefixAndRegex"); | buildRule.executeTarget("testWithPrefixAndRegex"); | ||||
fail("BuildException should have been thrown on Prefix and RegEx beng set"); | |||||
fail("BuildException should have been thrown on Prefix and RegEx being set"); | |||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
assertEquals("The target must fail with prefix and regex attributes set", "Please specify either prefix or regex, but not both", ex.getMessage()); | |||||
assertEquals("The target must fail with prefix and regex attributes set", | |||||
"Please specify either prefix or regex, but not both", ex.getMessage()); | |||||
} | } | ||||
} | } | ||||
@Test | @Test | ||||
public void testWithEmptyPrefixAndRegex() throws Exception { | public void testWithEmptyPrefixAndRegex() throws Exception { | ||||
buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); | buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); | ||||
assertContains("test.property="+TEST_VALUE, buildRule.getLog()); | |||||
assertContains("test.property=" + TEST_VALUE, buildRule.getLog()); | |||||
} | } | ||||
@Test | @Test | ||||
public void testWithRegex() throws Exception { | public void testWithRegex() throws Exception { | ||||
assumeTrue("Test skipped because no regexp matcher is present.", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); | |||||
assumeTrue("Test skipped because no regexp matcher is present.", | |||||
RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); | |||||
buildRule.executeTarget("testWithRegex"); | buildRule.executeTarget("testWithRegex"); | ||||
// the following line has been changed from checking ant.home to ant.version so the test will still work when run outside of an ant script | |||||
// the following line has been changed from checking ant.home to ant.version | |||||
// so the test will still work when run outside of an Ant script | |||||
assertContains("ant.version=", buildRule.getFullLog()); | assertContains("ant.version=", buildRule.getFullLog()); | ||||
} | } | ||||
@@ -226,14 +220,17 @@ public class EchoPropertiesTest { | |||||
protected Properties loadPropFile(String relativeFilename) | protected Properties loadPropFile(String relativeFilename) | ||||
throws IOException { | throws IOException { | ||||
File f = createRelativeFile(relativeFilename); | File f = createRelativeFile(relativeFilename); | ||||
Properties props=new Properties(); | |||||
InputStream in=null; | |||||
Properties props = new Properties(); | |||||
InputStream in = null; | |||||
try { | try { | ||||
in=new BufferedInputStream(new FileInputStream(f)); | |||||
in = new BufferedInputStream(new FileInputStream(f)); | |||||
props.load(in); | props.load(in); | ||||
} finally { | } finally { | ||||
if(in!=null) { | |||||
try { in.close(); } catch(IOException e) {} | |||||
if (in != null) { | |||||
try { | |||||
in.close(); | |||||
} catch (IOException e) { | |||||
} | |||||
} | } | ||||
} | } | ||||
return props; | return props; | ||||
@@ -241,20 +238,18 @@ public class EchoPropertiesTest { | |||||
protected void assertGoodFile() throws Exception { | protected void assertGoodFile() throws Exception { | ||||
File f = createRelativeFile(GOOD_OUTFILE); | File f = createRelativeFile(GOOD_OUTFILE); | ||||
assertTrue("Did not create "+f.getAbsolutePath(), | |||||
assertTrue("Did not create " + f.getAbsolutePath(), | |||||
f.exists()); | f.exists()); | ||||
Properties props=loadPropFile(GOOD_OUTFILE); | |||||
Properties props = loadPropFile(GOOD_OUTFILE); | |||||
props.list(System.out); | props.list(System.out); | ||||
assertEquals("test property not found ", | assertEquals("test property not found ", | ||||
TEST_VALUE, props.getProperty("test.property")); | TEST_VALUE, props.getProperty("test.property")); | ||||
} | } | ||||
protected String toAbsolute(String filename) { | protected String toAbsolute(String filename) { | ||||
return createRelativeFile(filename).getAbsolutePath(); | return createRelativeFile(filename).getAbsolutePath(); | ||||
} | } | ||||
protected File createRelativeFile(String filename) { | protected File createRelativeFile(String filename) { | ||||
if (filename.equals(".")) { | if (filename.equals(".")) { | ||||
return buildRule.getProject().getBaseDir(); | return buildRule.getProject().getBaseDir(); | ||||
@@ -37,15 +37,15 @@ import static org.junit.Assert.fail; | |||||
/** | /** | ||||
* Tests the Jspc task. | * Tests the Jspc task. | ||||
* | |||||
* <p> | |||||
* created 07 March 2002 | * created 07 March 2002 | ||||
* </p> | |||||
* @since Ant 1.5 | * @since Ant 1.5 | ||||
*/ | */ | ||||
public class JspcTest { | public class JspcTest { | ||||
private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; | private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; | ||||
@Rule | @Rule | ||||
public BuildFileRule buildRule = new BuildFileRule(); | public BuildFileRule buildRule = new BuildFileRule(); | ||||
@@ -54,26 +54,21 @@ public class JspcTest { | |||||
buildRule.configureProject(TASKDEFS_DIR + "jspc.xml"); | buildRule.configureProject(TASKDEFS_DIR + "jspc.xml"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testSimple() { | public void testSimple() { | ||||
executeJspCompile("testSimple", "simple_jsp.java"); | executeJspCompile("testSimple", "simple_jsp.java"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testUriroot() throws Exception { | public void testUriroot() throws Exception { | ||||
executeJspCompile("testUriroot", "uriroot_jsp.java"); | executeJspCompile("testUriroot", "uriroot_jsp.java"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testXml() throws Exception { | public void testXml() throws Exception { | ||||
executeJspCompile("testXml", "xml_jsp.java"); | executeJspCompile("testXml", "xml_jsp.java"); | ||||
} | } | ||||
/** | /** | ||||
* try a keyword in a file | * try a keyword in a file | ||||
*/ | */ | ||||
@@ -82,7 +77,6 @@ public class JspcTest { | |||||
executeJspCompile("testKeyword", "default_jsp.java"); | executeJspCompile("testKeyword", "default_jsp.java"); | ||||
} | } | ||||
/** | /** | ||||
* what happens to 1nvalid-classname | * what happens to 1nvalid-classname | ||||
*/ | */ | ||||
@@ -92,7 +86,6 @@ public class JspcTest { | |||||
"_1nvalid_0002dclassname_jsp.java"); | "_1nvalid_0002dclassname_jsp.java"); | ||||
} | } | ||||
@Test | @Test | ||||
public void testNoTld() throws Exception { | public void testNoTld() throws Exception { | ||||
try { | try { | ||||
@@ -103,7 +96,6 @@ public class JspcTest { | |||||
} | } | ||||
} | } | ||||
@Test | @Test | ||||
public void testNotAJspFile() throws Exception { | public void testNotAJspFile() throws Exception { | ||||
buildRule.executeTarget("testNotAJspFile"); | buildRule.executeTarget("testNotAJspFile"); | ||||
@@ -130,7 +122,6 @@ public class JspcTest { | |||||
assertJavaFileCreated(javafile); | assertJavaFileCreated(javafile); | ||||
} | } | ||||
/** | /** | ||||
* verify that a named file was created | * verify that a named file was created | ||||
* | * | ||||
@@ -157,11 +148,11 @@ public class JspcTest { | |||||
*/ | */ | ||||
@Test | @Test | ||||
public void testJasperNameManglerSelection() { | public void testJasperNameManglerSelection() { | ||||
JspCompilerAdapter adapter= | |||||
JspCompilerAdapter adapter = | |||||
JspCompilerAdapterFactory.getCompiler("jasper", null,null); | JspCompilerAdapterFactory.getCompiler("jasper", null,null); | ||||
JspMangler mangler=adapter.createMangler(); | |||||
JspMangler mangler = adapter.createMangler(); | |||||
assertTrue(mangler instanceof JspNameMangler); | assertTrue(mangler instanceof JspNameMangler); | ||||
adapter= JspCompilerAdapterFactory.getCompiler("jasper41", null, null); | |||||
adapter = JspCompilerAdapterFactory.getCompiler("jasper41", null, null); | |||||
mangler = adapter.createMangler(); | mangler = adapter.createMangler(); | ||||
assertTrue(mangler instanceof Jasper41Mangler); | assertTrue(mangler instanceof Jasper41Mangler); | ||||
} | } | ||||
@@ -184,16 +175,15 @@ public class JspcTest { | |||||
/** | /** | ||||
* assert our mapping rules | * assert our mapping rules | ||||
* @param mangler | |||||
* @param filename | |||||
* @param classname | |||||
* @param mangler JspMangler | |||||
* @param filename String | |||||
* @param classname String | |||||
*/ | */ | ||||
protected void assertMapped(JspMangler mangler, String filename, String classname) { | protected void assertMapped(JspMangler mangler, String filename, String classname) { | ||||
String mappedname = mangler.mapJspToJavaName(new File(filename)); | String mappedname = mangler.mapJspToJavaName(new File(filename)); | ||||
assertTrue(filename+" should have mapped to "+classname | |||||
+" but instead mapped to "+mappedname, | |||||
assertTrue(filename + " should have mapped to " + classname | |||||
+ " but instead mapped to " + mappedname, | |||||
classname.equals(mappedname)); | classname.equals(mappedname)); | ||||
} | } | ||||
} | } |
@@ -19,6 +19,7 @@ | |||||
package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | |||||
import org.apache.tools.ant.BuildFileRule; | import org.apache.tools.ant.BuildFileRule; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
@@ -48,7 +49,7 @@ public class Native2AsciiTest { | |||||
} | } | ||||
@Test | @Test | ||||
public void testIso8859_1() throws java.io.IOException { | |||||
public void testIso8859_1() throws IOException { | |||||
buildRule.executeTarget("testIso8859-1"); | buildRule.executeTarget("testIso8859-1"); | ||||
File in = buildRule.getProject().resolveFile("expected/iso8859-1.test"); | File in = buildRule.getProject().resolveFile("expected/iso8859-1.test"); | ||||
File out = new File(buildRule.getProject().getProperty("output"), "iso8859-1.test"); | File out = new File(buildRule.getProject().getProperty("output"), "iso8859-1.test"); | ||||
@@ -62,7 +62,7 @@ public class PropertyFileTest { | |||||
@Test | @Test | ||||
public void testNonExistingFile() { | public void testNonExistingFile() { | ||||
PropertyFile props = new PropertyFile(); | PropertyFile props = new PropertyFile(); | ||||
props.setProject( buildRule.getProject() ); | |||||
props.setProject(buildRule.getProject()); | |||||
File file = new File("this-file-does-not-exist.properties"); | File file = new File("this-file-does-not-exist.properties"); | ||||
props.setFile(file); | props.setFile(file); | ||||
assertFalse("Properties file exists before test.", file.exists()); | assertFalse("Properties file exists before test.", file.exists()); | ||||
@@ -199,6 +199,7 @@ public class PropertyFileTest { | |||||
fos.close(); | fos.close(); | ||||
} | } | ||||
@SuppressWarnings("unused") | |||||
private static final String | private static final String | ||||
projectFilePath = "src/etc/testcases/taskdefs/optional/propertyfile.xml", | projectFilePath = "src/etc/testcases/taskdefs/optional/propertyfile.xml", | ||||
@@ -24,10 +24,10 @@ import org.junit.Before; | |||||
import org.junit.Rule; | import org.junit.Rule; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import java.util.Properties; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Properties; | |||||
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
@@ -126,7 +126,7 @@ public class ReplaceRegExpTest { | |||||
- (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); | - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); | ||||
long ts1 = testFile.lastModified(); | long ts1 = testFile.lastModified(); | ||||
buildRule.executeTarget("testPreserve"); | buildRule.executeTarget("testPreserve"); | ||||
assertEquals(ts1 , testFile.lastModified()); | |||||
assertEquals(ts1, testFile.lastModified()); | |||||
} | } | ||||
} | } |