http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java index 95d4f3d..695d45c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java @@ -39,71 +39,71 @@ import org.junit.Test; * Tests <bm:manifestclasspath>. */ public class ManifestClassPathTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - @Before + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before public void setUp() { buildRule.configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml"); } - @Test + @Test public void testBadDirectory() { - try { - buildRule.executeTarget("test-bad-directory"); - fail("Build exception should have been thrown on bad directory"); - } catch (BuildException ex) { - assertContains("Jar's directory not found:", ex.getMessage()); - } + try { + buildRule.executeTarget("test-bad-directory"); + fail("Build exception should have been thrown on bad directory"); + } catch (BuildException ex) { + assertContains("Jar's directory not found:", ex.getMessage()); + } assertNull(buildRule.getProject().getProperty("jar.classpath")); } - @Test + @Test public void testBadNoProperty() { try { - buildRule.executeTarget("test-bad-no-property"); - fail("Build exception should have been thrown on no property"); - } catch (BuildException ex) { - assertContains("Missing 'property' attribute!", ex.getMessage()); - } + buildRule.executeTarget("test-bad-no-property"); + fail("Build exception should have been thrown on no property"); + } catch (BuildException ex) { + assertContains("Missing 'property' attribute!", ex.getMessage()); + } assertNull(buildRule.getProject().getProperty("jar.classpath")); } - @Test + @Test public void testBadPropertyExists() { try { - buildRule.executeTarget("test-bad-property-exists"); - fail("Build exception should have been thrown on bad property"); - } catch (BuildException ex) { - assertContains("Property 'jar.classpath' already set!", ex.getMessage()); - } + buildRule.executeTarget("test-bad-property-exists"); + fail("Build exception should have been thrown on bad property"); + } catch (BuildException ex) { + assertContains("Property 'jar.classpath' already set!", ex.getMessage()); + } assertEquals(buildRule.getProject().getProperty("jar.classpath"), "exists"); } - @Test + @Test public void testBadNoJarfile() { - try { - buildRule.executeTarget("test-bad-no-jarfile"); - fail("Build exception should have been thrown on bad jar file"); - } catch (BuildException ex) { - assertContains("Missing 'jarfile' attribute!", ex.getMessage()); - } + try { + buildRule.executeTarget("test-bad-no-jarfile"); + fail("Build exception should have been thrown on bad jar file"); + } catch (BuildException ex) { + assertContains("Missing 'jarfile' attribute!", ex.getMessage()); + } assertNull(buildRule.getProject().getProperty("jar.classpath")); } - @Test + @Test public void testBadNoClassPath() { - try { - buildRule.executeTarget("test-bad-no-classpath"); - fail("Build exception should have been thrown on no classpath"); - } catch (BuildException ex) { - assertContains("Missing nested <classpath>!", ex.getMessage()); - } + try { + buildRule.executeTarget("test-bad-no-classpath"); + fail("Build exception should have been thrown on no classpath"); + } catch (BuildException ex) { + assertContains("Missing nested <classpath>!", ex.getMessage()); + } assertNull(buildRule.getProject().getProperty("jar.classpath")); } - @Test + @Test public void testParentLevel1() { buildRule.executeTarget("test-parent-level1"); @@ -118,7 +118,7 @@ public class ManifestClassPathTest { "../resources/dsp-void/"); } - @Test + @Test public void testParentLevel2() { buildRule.executeTarget("test-parent-level2"); @@ -133,21 +133,21 @@ public class ManifestClassPathTest { "../../resources/dsp-void/"); } - @Test + @Test public void testParentLevel2TooDeep() { - try { - buildRule.executeTarget("test-parent-level2-too-deep"); - fail("Build exception should have been thrown on no suitable path"); - } catch (BuildException ex) { - assertContains("No suitable relative path from ", ex.getMessage()); - } + try { + buildRule.executeTarget("test-parent-level2-too-deep"); + fail("Build exception should have been thrown on no suitable path"); + } catch (BuildException ex) { + assertContains("No suitable relative path from ", ex.getMessage()); + } assertNull(buildRule.getProject().getProperty("jar.classpath")); } @Test public void testPseudoTahoeRefid() { Assume.assumeTrue("No regexp matcher is present", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); - + buildRule.executeTarget("test-pseudo-tahoe-refid"); assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + "classes/dsp-pres/ " + @@ -159,9 +159,9 @@ public class ManifestClassPathTest { @Test public void testPseudoTahoeNested() { - Assume.assumeTrue("No regexp matcher is present", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); - - buildRule.executeTarget("test-pseudo-tahoe-nested"); + Assume.assumeTrue("No regexp matcher is present", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); + + buildRule.executeTarget("test-pseudo-tahoe-nested"); assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + "classes/dsp-pres/ " + "classes/dsp-void/ " + @@ -186,7 +186,7 @@ public class ManifestClassPathTest { "../../resources/dsp-pres/ " + "../../resources/dsp-void/"); } - + @Test public void testInternationalGerman() { buildRule.executeTarget("international-german"); @@ -194,10 +194,10 @@ public class ManifestClassPathTest { assertContains("beta alpha", buildRule.getLog()); } - + @Test public void testInternationalHebrew() { - Assume.assumeFalse("Test with hebrew path not attempted under Windows", Os.isFamily("windows")); + Assume.assumeFalse("Test with hebrew path not attempted under Windows", Os.isFamily("windows")); buildRule.executeTarget("international-hebrew"); buildRule.executeTarget("run-two-jars"); assertContains("beta alpha", buildRule.getLog()); @@ -212,7 +212,7 @@ public class ManifestClassPathTest { @Test public void testDifferentWindowsDrive() { - Assume.assumeTrue("Test with drive letters only run on windows", Os.isFamily("windows")); + Assume.assumeTrue("Test with drive letters only run on windows", Os.isFamily("windows")); // the lines below try to find a drive name different than the one containing the temp dir // if the temp dir is C will try to use D // if the temp dir is on D or other will try to use C @@ -233,17 +233,17 @@ public class ManifestClassPathTest { } new java.io.File(altDriveLetter + ":/foo.txt").getCanonicalPath(); } catch (java.io.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); - + try { - buildRule.executeTarget("testDifferentDrive"); - fail("Build exception should have been thrown on no alternative drive"); - } catch (BuildException ex) { - assertContains("No suitable relative path from ", ex.getMessage()); - } - + buildRule.executeTarget("testDifferentDrive"); + fail("Build exception should have been thrown on no alternative drive"); + } catch (BuildException ex) { + assertContains("No suitable relative path from ", ex.getMessage()); + } + assertNull(buildRule.getProject().getProperty("cp")); } -} // END class ManifestClassPathTest +}
http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java index d8f1bfc..637face 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java @@ -40,21 +40,21 @@ public class MkdirTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument missing"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument missing"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: directory already exists as a file"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: directory already exists as a file"); + } catch (BuildException ex) { + //TODO assert value + } } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java index 98d9fa5..635c2d5 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java @@ -63,21 +63,21 @@ public class NiceTest { @Test public void testTooSlow() { try { - buildRule.executeTarget("too_slow"); - fail("BuildException expected: out of range"); - } catch (BuildException ex) { - assertContains("out of the range 1-10", ex.getMessage()); - } + buildRule.executeTarget("too_slow"); + fail("BuildException expected: out of range"); + } catch (BuildException ex) { + assertContains("out of the range 1-10", ex.getMessage()); + } } @Test public void testTooFast() { try { - buildRule.executeTarget("too_fast"); - fail("BuildException expected: out of range"); - } catch (BuildException ex) { - assertContains("out of the range 1-10", ex.getMessage()); - } + buildRule.executeTarget("too_fast"); + fail("BuildException expected: out of range"); + } catch (BuildException ex) { + assertContains("out of the range 1-10", ex.getMessage()); + } } } http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java index 8c7c1f3..65b66a4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java @@ -33,10 +33,10 @@ import static org.junit.Assert.fail; /** */ public class PreSetDefTest { - + @Rule public final BuildFileRule buildRule = new BuildFileRule(); - + @Before public void setUp() { buildRule.configureProject("src/etc/testcases/taskdefs/presetdef.xml"); @@ -45,55 +45,55 @@ public class PreSetDefTest { @Test public void testSimple() { buildRule.executeTarget("simple"); - assertEquals("Hello world", buildRule.getLog()); + assertEquals("Hello world", buildRule.getLog()); } @Test public void testText() { buildRule.executeTarget("text"); - assertEquals("Inner Text", buildRule.getLog()); + assertEquals("Inner Text", buildRule.getLog()); } @Test public void testUri() { buildRule.executeTarget("uri"); - assertEquals("Hello world", buildRule.getLog()); + assertEquals("Hello world", buildRule.getLog()); } @Test public void testDefaultTest() { buildRule.executeTarget("defaulttest"); - assertEquals("attribute is false", buildRule.getLog()); + assertEquals("attribute is false", buildRule.getLog()); } @Test public void testDoubleDefault() { buildRule.executeTarget("doubledefault"); - assertEquals("attribute is falseattribute is true", buildRule.getLog()); + assertEquals("attribute is falseattribute is true", buildRule.getLog()); } @Test public void testTextOptional() { buildRule.executeTarget("text.optional"); - assertEquals("MyTextoverride text", buildRule.getLog()); + assertEquals("MyTextoverride text", buildRule.getLog()); } @Test public void testElementOrder() { buildRule.executeTarget("element.order"); - assertEquals("Line 1Line 2", buildRule.getLog()); + assertEquals("Line 1Line 2", buildRule.getLog()); } @Test public void testElementOrder2() { buildRule.executeTarget("element.order2"); - assertEquals("Line 1Line 2Line 3", buildRule.getLog()); + assertEquals("Line 1Line 2Line 3", buildRule.getLog()); } @Test public void testAntTypeTest() { buildRule.executeTarget("antTypeTest"); - assertEquals("", buildRule.getLog()); + assertEquals("", buildRule.getLog()); } @Test @@ -115,13 +115,13 @@ public class PreSetDefTest { assertContains("javac doesn't support the", ex.getMessage()); } } - + @Test public void testPresetdefWithNestedElementTwice() { // #38056 buildRule.executeTarget("presetdef-with-nested-element-twice"); buildRule.executeTarget("presetdef-with-nested-element-twice"); } - + /** * A test class to check default properties */ @@ -151,4 +151,3 @@ public class PreSetDefTest { } } } - http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index 52b762d..17e7114 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -34,9 +34,9 @@ import org.junit.Test; /** */ public class PropertyTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); /** Utilities used for file operations */ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); @@ -50,14 +50,14 @@ public class PropertyTest { @Test public void test1() { // should get no output at all - buildRule.executeTarget("test1"); - assertEquals("System output should have been empty", "", buildRule.getOutput()); - assertEquals("System error should have been empty", "", buildRule.getError()); + buildRule.executeTarget("test1"); + assertEquals("System output should have been empty", "", buildRule.getOutput()); + assertEquals("System error should have been empty", "", buildRule.getError()); } @Test public void test2() { - buildRule.executeTarget("test2"); + buildRule.executeTarget("test2"); assertContains("testprop1=aa, testprop3=xxyy, testprop4=aazz", buildRule.getLog()); } @@ -71,21 +71,21 @@ public class PropertyTest { assertTrue("Circular definition not detected - ", e.getMessage().indexOf("was circularly defined") != -1); } - + } @Test public void test4() { - buildRule.executeTarget("test4"); - assertContains("http.url is http://localhost:999", buildRule.getLog()); + buildRule.executeTarget("test4"); + assertContains("http.url is http://localhost:999", buildRule.getLog()); } @Test public void test5() { String baseDir = buildRule.getProject().getProperty("basedir"); - String uri = FILE_UTILS.toURI(baseDir + "/property3.properties"); + String uri = FILE_UTILS.toURI(baseDir + "/property3.properties"); buildRule.getProject().setNewProperty("test5.url", uri); - + buildRule.executeTarget("test5"); assertContains("http.url is http://localhost:999", buildRule.getLog()); } @@ -103,7 +103,7 @@ public class PropertyTest { fail("Did not throw exception on invalid use of prefix"); } 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()); } } @@ -121,21 +121,21 @@ public class PropertyTest { @Test public void testThisIsNotACircularReference() { - buildRule.executeTarget("thisIsNotACircularReference"); + buildRule.executeTarget("thisIsNotACircularReference"); assertContains("b is A/A/A", buildRule.getLog()); } - + @Test public void testXmlProperty() { try { Class.forName("java.lang.Iterable"); } catch (ClassNotFoundException e) { - Assume.assumeNoException("XML Loading only on Java 5+", e); + Assume.assumeNoException("XML Loading only on Java 5+", e); } buildRule.executeTarget("testXmlProperty"); assertEquals("ONE", buildRule.getProject().getProperty("xml.one")); assertEquals("TWO", buildRule.getProject().getProperty("xml.two")); - + } } http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java index 387c54d..cd485d0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java @@ -41,7 +41,7 @@ import static org.junit.Assume.assumeTrue; /** */ public class ReplaceTest { - + @Rule public final BuildFileRule buildRule = new BuildFileRule(); @@ -54,41 +54,41 @@ public class ReplaceTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test3() { try { - buildRule.executeTarget("test3"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test3"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test4() { try { - buildRule.executeTarget("test4"); - fail("BuildException expected: empty token not allowed"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test4"); + fail("BuildException expected: empty token not allowed"); + } catch (BuildException ex) { + //TODO assert value + } } @Test @@ -99,21 +99,21 @@ public class ReplaceTest { @Test public void test6() { try { - buildRule.executeTarget("test6"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test6"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test7() { try { - buildRule.executeTarget("test7"); - fail("BuildException expected: empty token not allowed"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test7"); + fail("BuildException expected: empty token not allowed"); + } catch (BuildException ex) { + //TODO assert value + } } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java index d1487df..f34c26c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java @@ -33,9 +33,9 @@ public class SleepTest { public final BuildFileRule buildRule = new BuildFileRule(); 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 public void setUp() { buildRule.configureProject(TASKDEFS_DIR + "sleep.xml"); @@ -117,4 +117,3 @@ public class SleepTest { } } - http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java index ed7403c..71921cb 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java @@ -103,7 +103,7 @@ public class TStampTest { @Test public void testFormatPrefix() throws Exception { - Tstamp.CustomFormat format = tstamp.createFormat(); + Tstamp.CustomFormat format = tstamp.createFormat(); format.setProperty("format"); format.setPattern("HH:mm:ss z"); format.setTimezone("GMT"); http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java index c5ba120..3d77ba1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java @@ -45,41 +45,41 @@ public class TarTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test3() { try { - buildRule.executeTarget("test3"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test3"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test4() { try { - buildRule.executeTarget("test4"); - fail("BuildException expected: tar cannot include itself"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test4"); + fail("BuildException expected: tar cannot include itself"); + } catch (BuildException ex) { + //TODO assert value + } } @Test @@ -96,11 +96,11 @@ public class TarTest { @Test public void test6() { try { - buildRule.executeTarget("test6"); - fail("BuildException expected: Invalid value specified for longfile attribute."); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test6"); + fail("BuildException expected: Invalid value specified for longfile attribute."); + } catch (BuildException ex) { + //TODO assert value + } } @Test @@ -172,11 +172,11 @@ public class TarTest { @Test public void test9() { try { - buildRule.executeTarget("test9"); - fail("BuildException expected: Invalid value specified for compression attribute."); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test9"); + fail("BuildException expected: Invalid value specified for compression attribute."); + } catch (BuildException ex) { + //TODO assert value + } } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java index eaa8a66..7f28de0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java @@ -44,41 +44,41 @@ public class TaskdefTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test3() { try { - buildRule.executeTarget("test3"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test3"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test4() { try { - buildRule.executeTarget("test4"); - fail("BuildException expected: classname specified doesn't exist"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test4"); + fail("BuildException expected: classname specified doesn't exist"); + } catch (BuildException ex) { + //TODO assert value + } } @Test @@ -99,19 +99,19 @@ public class TaskdefTest { @Test public void test6() { buildRule.executeTarget("test6"); - assertEquals("simpletask: worked", buildRule.getLog()); + assertEquals("simpletask: worked", buildRule.getLog()); } @Test public void test7() { buildRule.executeTarget("test7"); - assertEquals("worked", buildRule.getLog()); + assertEquals("worked", buildRule.getLog()); } @Test public void testGlobal() { buildRule.executeTarget("testGlobal"); - assertEquals("worked", buildRule.getLog()); + assertEquals("worked", buildRule.getLog()); } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java index 3488f39..14c1c56 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java @@ -50,13 +50,13 @@ public class TypeAdapterTest { @Test public void testTaskAdapter() { buildRule.executeTarget("taskadapter"); - assertContains("MyExec called", buildRule.getLog()); + assertContains("MyExec called", buildRule.getLog()); } @Test public void testRunAdapter() { buildRule.executeTarget("runadapter"); - assertContains("MyRunnable called", buildRule.getLog()); + assertContains("MyRunnable called", buildRule.getLog()); } @Test @@ -72,19 +72,19 @@ public class TypeAdapterTest { @Test public void testDelay() { buildRule.executeTarget("delay"); - assertContains("MyTask called", buildRule.getLog()); + assertContains("MyTask called", buildRule.getLog()); } @Test public void testOnErrorReport() { buildRule.executeTarget("onerror.report"); - assertContains("MyTaskNotPresent cannot be found", buildRule.getLog()); + assertContains("MyTaskNotPresent cannot be found", buildRule.getLog()); } @Test public void testOnErrorIgnore() { buildRule.executeTarget("onerror.ignore"); - assertEquals("", buildRule.getLog()); + assertEquals("", buildRule.getLog()); } public static class MyTask extends Task { http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java index bfc11dd..242f7c6 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java @@ -32,7 +32,7 @@ import static org.junit.Assert.fail; /** */ public class TypedefTest { - + @Rule public final BuildFileRule buildRule = new BuildFileRule(); @@ -45,41 +45,41 @@ public class TypedefTest { @Test public void testEmpty() { try { - buildRule.executeTarget("empty"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("empty"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void testNoName() { try { - buildRule.executeTarget("noName"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("noName"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void testNoClassname() { try { - buildRule.executeTarget("noClassname"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("noClassname"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void testClassNotFound() { try { - buildRule.executeTarget("classNotFound"); - fail("BuildException expected: classname specified doesn't exist"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("classNotFound"); + fail("BuildException expected: classname specified doesn't exist"); + } catch (BuildException ex) { + //TODO assert value + } } @Test @@ -109,28 +109,28 @@ public class TypedefTest { @Test public void testDoubleNotPresent() { buildRule.executeTarget("double-notpresent"); - assertContains("hi", buildRule.getLog()); + assertContains("hi", buildRule.getLog()); } - + @Test public void testNoResourceOnErrorFailAll(){ - try { - buildRule.executeTarget("noresourcefailall"); - fail("BuildException expected: the requested resource does not exist"); - } catch (BuildException ex) { - assertContains("Could not load definitions from resource ", ex.getMessage()); - } + try { + buildRule.executeTarget("noresourcefailall"); + fail("BuildException expected: the requested resource does not exist"); + } catch (BuildException ex) { + assertContains("Could not load definitions from resource ", ex.getMessage()); + } } - + @Test public void testNoResourceOnErrorFail(){ - buildRule.executeTarget("noresourcefail"); - assertContains("Could not load definitions from resource ", buildRule.getLog()); + buildRule.executeTarget("noresourcefail"); + assertContains("Could not load definitions from resource ", buildRule.getLog()); } - + @Test public void testNoResourceOnErrorNotFail(){ - buildRule.executeTarget("noresourcenotfail"); - assertContains("Could not load definitions from resource ", buildRule.getLog()); + buildRule.executeTarget("noresourcenotfail"); + assertContains("Could not load definitions from resource ", buildRule.getLog()); } } http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java index ad99620..1997561 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java @@ -45,31 +45,31 @@ public class UnzipTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test3() { try { - buildRule.executeTarget("test3"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test3"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @@ -227,11 +227,11 @@ public class UnzipTest { @Test public void testTwoMappers() { try { - buildRule.executeTarget("testTwoMappers"); - fail("BuildException expected: " + Expand.ERROR_MULTIPLE_MAPPERS); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("testTwoMappers"); + fail("BuildException expected: " + Expand.ERROR_MULTIPLE_MAPPERS); + } catch (BuildException ex) { + //TODO assert value + } } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java index b9677c4..4428b93 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java @@ -54,24 +54,24 @@ public class UpToDateTest { @Test public void testFilesetUpToDate() { buildRule.executeTarget("testFilesetUpToDate"); - assertEquals("true", buildRule.getProject().getProperty("foo")); + assertEquals("true", buildRule.getProject().getProperty("foo")); } @Test public void testFilesetOutOfDate() { buildRule.executeTarget("testFilesetOutOfDate"); - assertNull(buildRule.getProject().getProperty("foo")); + assertNull(buildRule.getProject().getProperty("foo")); } @Test public void testRCUpToDate() { buildRule.executeTarget("testRCUpToDate"); - assertEquals("true", buildRule.getProject().getProperty("foo")); + assertEquals("true", buildRule.getProject().getProperty("foo")); } @Test public void testRCOutOfDate() { buildRule.executeTarget("testRCOutOfDate"); - assertNull(buildRule.getProject().getProperty("foo")); + assertNull(buildRule.getProject().getProperty("foo")); } } http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java index 590a4db..379fc02 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java @@ -42,19 +42,19 @@ public class XmlnsTest { @Test public void testXmlns() { buildRule.executeTarget("xmlns"); - assertEquals("MyTask called", buildRule.getLog()); + assertEquals("MyTask called", buildRule.getLog()); } @Test public void testXmlnsFile() { buildRule.executeTarget("xmlns.file"); - assertEquals("MyTask called", buildRule.getLog()); + assertEquals("MyTask called", buildRule.getLog()); } @Test public void testCore() { buildRule.executeTarget("core"); - assertEquals("MyTask called", buildRule.getLog()); + assertEquals("MyTask called", buildRule.getLog()); } @Test @@ -70,13 +70,13 @@ public class XmlnsTest { @Test public void testOther() { buildRule.executeTarget("other"); - assertEquals("a message", buildRule.getLog()); + assertEquals("a message", buildRule.getLog()); } @Test public void testNsAttributes() { buildRule.executeTarget("ns.attributes"); - assertEquals("hello world", buildRule.getLog()); + assertEquals("hello world", buildRule.getLog()); } public static class MyTask extends Task { @@ -86,4 +86,3 @@ public class XmlnsTest { } } - http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java index efa9f77..d1340b5 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java @@ -43,10 +43,10 @@ import static org.junit.Assume.assumeTrue; public class ZipTest { - + @Rule public BuildFileRule buildRule = new BuildFileRule(); - + //instance variable to allow cleanup ZipFile zfPrefixAddsDir = null; @@ -60,42 +60,42 @@ public class ZipTest { @Test public void test1() { try { - buildRule.executeTarget("test1"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test1"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test2() { try { - buildRule.executeTarget("test2"); - fail("BuildException expected: required argument not specified"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test2"); + fail("BuildException expected: required argument not specified"); + } catch (BuildException ex) { + //TODO assert value + } } @Test public void test3() { try { - buildRule.executeTarget("test3"); - fail("BuildException expected: zip cannot include itself"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test3"); + fail("BuildException expected: zip cannot include itself"); + } catch (BuildException ex) { + //TODO assert value + } } @Test @Ignore("Previously commented out") public void test4() { try { - buildRule.executeTarget("test4"); - fail("BuildException expected: zip cannot include itself"); - } catch (BuildException ex) { - //TODO assert value - } + buildRule.executeTarget("test4"); + fail("BuildException expected: zip cannot include itself"); + } catch (BuildException ex) { + //TODO assert value + } } @After @@ -157,7 +157,7 @@ public class ZipTest { @Test public void testUpdateIsNecessary() { buildRule.executeTarget("testUpdateIsNecessary"); - assertContains("Updating", buildRule.getLog()); + assertContains("Updating", buildRule.getLog()); } // Bugzilla Report 18403 @@ -202,7 +202,7 @@ public class ZipTest { @Test public void testZipEmptyCreate() { buildRule.executeTarget("zipEmptyCreate"); - assertContains("Note: creating empty", buildRule.getLog()); + assertContains("Note: creating empty", buildRule.getLog()); } // Bugzilla Report 25513 @Test http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java index 505decd..df75067 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java @@ -1,62 +1,62 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.email; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.FileUtils; -import org.junit.After; -import org.junit.Test; - -public class MessageTest { - private static final File f = new File(System.getProperty("java.io.tmpdir"), - "message.txt"); - /** - * test for bugzilla 48932 - */ - @Test - public void testPrintStreamDoesNotGetClosed() throws IOException { - Message ms = new Message(); - Project p = new Project(); - ms.setProject(p); - ms.addText("hi, this is an email"); - FileOutputStream fis = null; - try { - fis = new FileOutputStream(f); - ms.print(new PrintStream(fis)); - fis.write(120); - } finally { - FileUtils.close(fis); - } - - } - - @After - public void tearDown() { - if (f.exists()) { - FileUtils fu = FileUtils.getFileUtils(); - fu.tryHardToDelete(f); - } - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.email; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; +import org.junit.After; +import org.junit.Test; + +public class MessageTest { + private static final File f = new File(System.getProperty("java.io.tmpdir"), + "message.txt"); + /** + * test for bugzilla 48932 + */ + @Test + public void testPrintStreamDoesNotGetClosed() throws IOException { + Message ms = new Message(); + Project p = new Project(); + ms.setProject(p); + ms.addText("hi, this is an email"); + FileOutputStream fis = null; + try { + fis = new FileOutputStream(f); + ms.print(new PrintStream(fis)); + fis.write(120); + } finally { + FileUtils.close(fis); + } + + } + + @After + public void tearDown() { + if (f.exists()) { + FileUtils fu = FileUtils.getFileUtils(); + fu.tryHardToDelete(f); + } + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index 47abcfe..9258448 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -1,216 +1,216 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.FileUtilities; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; -import java.io.FilenameFilter; - -import static org.apache.tools.ant.AntAssert.assertContains; -import static org.apache.tools.ant.AntAssert.assertNotContains; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * If you want to run tests, it is highly recommended - * to download ANTLR (www.antlr.org), build the 'antlrall.jar' jar - * with <code>make antlr-all.jar</code> and drop the jar (about 300KB) into - * Ant lib. - * - Running w/ the default antlr.jar (70KB) does not work (missing class) - * - * Unless of course you specify the ANTLR classpath in your - * system classpath. (see ANTLR install.html) - * - */ -public class ANTLRTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "antlr.xml"); - } - - @Test - public void test1() { - try { - buildRule.executeTarget("test1"); - fail("required argument, target, missing"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test2() { - try { - buildRule.executeTarget("test2"); - fail("Invalid output directory"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test3() { - buildRule.executeTarget("test3"); - } - - @Test - public void test4() { - buildRule.executeTarget("test4"); - } - - @Test - public void test5() { - // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'" - // since it needs to run java.g first before java.tree.g - try { - buildRule.executeTarget("test5"); - fail("ANTLR returned: 1"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test6() { - buildRule.executeTarget("test6"); - } - - @Test - public void test7() { - try { - buildRule.executeTarget("test7"); - fail("Unable to determine generated class"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - /** - * This is a negative test for the super grammar (glib) option. - */ - @Test - public void test8() { - try { - buildRule.executeTarget("test8"); - fail("Invalid super grammar file"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - /** - * This is a positive test for the super grammar (glib) option. ANTLR - * will throw an error if everything is not correct. - */ - @Test - public void test9() { - buildRule.executeTarget("test9"); - } - - /** - * This test creates an html-ized version of the calculator grammar. - * The sanity check is simply whether or not an html file was generated. - */ - @Test - public void test10() { - buildRule.executeTarget("test10"); - File outputDirectory = new File(buildRule.getProject().getProperty("output")); - String[] calcFiles = outputDirectory.list(new HTMLFilter()); - assertTrue(calcFiles.length > 0); - } - - /** - * This is just a quick sanity check to run the diagnostic option and - * make sure that it doesn't throw any funny exceptions. - */ - @Test - public void test11() { - buildRule.executeTarget("test11"); - } - - /** - * This is just a quick sanity check to run the trace option and - * make sure that it doesn't throw any funny exceptions. - */ - @Test - public void test12() { - buildRule.executeTarget("test12"); - } - - /** - * This is just a quick sanity check to run all the rest of the - * trace options (traceLexer, traceParser, and traceTreeWalker) to - * make sure that they don't throw any funny exceptions. - */ - @Test - public void test13() { - buildRule.executeTarget("test13"); - } - - @Test - public void testNoRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - buildRule.executeTarget("noRecompile"); - assertContains("Skipped grammar file.", buildRule.getFullLog()); - } - - @Test - public void testNormalRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); - - buildRule.executeTarget("normalRecompile"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - } - - @Test - // Bugzilla Report 12961 - public void testSupergrammarChangeRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); - - buildRule.executeTarget("supergrammarChangeRecompile"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - } - -} - -class HTMLFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.endsWith("html"); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.FileUtilities; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; +import java.io.FilenameFilter; + +import static org.apache.tools.ant.AntAssert.assertContains; +import static org.apache.tools.ant.AntAssert.assertNotContains; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * If you want to run tests, it is highly recommended + * to download ANTLR (www.antlr.org), build the 'antlrall.jar' jar + * with <code>make antlr-all.jar</code> and drop the jar (about 300KB) into + * Ant lib. + * - Running w/ the default antlr.jar (70KB) does not work (missing class) + * + * Unless of course you specify the ANTLR classpath in your + * system classpath. (see ANTLR install.html) + * + */ +public class ANTLRTest { + + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "antlr.xml"); + } + + @Test + public void test1() { + try { + buildRule.executeTarget("test1"); + fail("required argument, target, missing"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test2() { + try { + buildRule.executeTarget("test2"); + fail("Invalid output directory"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test3() { + buildRule.executeTarget("test3"); + } + + @Test + public void test4() { + buildRule.executeTarget("test4"); + } + + @Test + public void test5() { + // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'" + // since it needs to run java.g first before java.tree.g + try { + buildRule.executeTarget("test5"); + fail("ANTLR returned: 1"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test6() { + buildRule.executeTarget("test6"); + } + + @Test + public void test7() { + try { + buildRule.executeTarget("test7"); + fail("Unable to determine generated class"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + /** + * This is a negative test for the super grammar (glib) option. + */ + @Test + public void test8() { + try { + buildRule.executeTarget("test8"); + fail("Invalid super grammar file"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + /** + * This is a positive test for the super grammar (glib) option. ANTLR + * will throw an error if everything is not correct. + */ + @Test + public void test9() { + buildRule.executeTarget("test9"); + } + + /** + * This test creates an html-ized version of the calculator grammar. + * The sanity check is simply whether or not an html file was generated. + */ + @Test + public void test10() { + buildRule.executeTarget("test10"); + File outputDirectory = new File(buildRule.getProject().getProperty("output")); + String[] calcFiles = outputDirectory.list(new HTMLFilter()); + assertTrue(calcFiles.length > 0); + } + + /** + * This is just a quick sanity check to run the diagnostic option and + * make sure that it doesn't throw any funny exceptions. + */ + @Test + public void test11() { + buildRule.executeTarget("test11"); + } + + /** + * This is just a quick sanity check to run the trace option and + * make sure that it doesn't throw any funny exceptions. + */ + @Test + public void test12() { + buildRule.executeTarget("test12"); + } + + /** + * This is just a quick sanity check to run all the rest of the + * trace options (traceLexer, traceParser, and traceTreeWalker) to + * make sure that they don't throw any funny exceptions. + */ + @Test + public void test13() { + buildRule.executeTarget("test13"); + } + + @Test + public void testNoRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + buildRule.executeTarget("noRecompile"); + assertContains("Skipped grammar file.", buildRule.getFullLog()); + } + + @Test + public void testNormalRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); + + buildRule.executeTarget("normalRecompile"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + } + + @Test + // Bugzilla Report 12961 + public void testSupergrammarChangeRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); + + buildRule.executeTarget("supergrammarChangeRecompile"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + } + +} + +class HTMLFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith("html"); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java index 8f2f494..4e1ee7a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java @@ -1,104 +1,104 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileNotFoundException; -import java.net.URL; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.tools.ant.util.FileUtils; -import org.junit.Before; -import org.junit.Test; -import org.w3c.dom.Document; - -/** - * Abtract testcase for XSLTLiaison. - * Override createLiaison for each XSLTLiaison. - * - * <a href="[email protected]">Stephane Bailliez</a> - */ -public abstract class AbstractXSLTLiaisonTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - protected XSLTLiaison liaison; - - @Before - public void setUp() throws Exception { - liaison = createLiaison(); - } - - // to override - protected abstract XSLTLiaison createLiaison() throws Exception ; - - /** load the file from the caller classloader that loaded this class */ - protected File getFile(String name) throws FileNotFoundException { - URL url = getClass().getResource(name); - if (url == null){ - throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); - } - return new File(FILE_UTILS.fromURI(url.toExternalForm())); - } - - /** keep it simple stupid */ - @Test - public void testTransform() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); - liaison.setStylesheet(xsl); - liaison.addParam("param", "value"); - File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); - File out = new File("xsltliaison.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - } finally { - out.delete(); - } - } - - @Test - public void testEncoding() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); - liaison.setStylesheet(xsl); - File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); - File out = new File("xsltliaison-encoding.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - Document doc = parseXML(out); - assertEquals("root",doc.getDocumentElement().getNodeName()); - assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); - assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); - } finally { - out.delete(); - } - } - - public Document parseXML(File file) throws Exception { - DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); - return dbuilder.parse(file); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URL; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.apache.tools.ant.taskdefs.XSLTLiaison; +import org.apache.tools.ant.util.FileUtils; +import org.junit.Before; +import org.junit.Test; +import org.w3c.dom.Document; + +/** + * Abtract testcase for XSLTLiaison. + * Override createLiaison for each XSLTLiaison. + * + * <a href="[email protected]">Stephane Bailliez</a> + */ +public abstract class AbstractXSLTLiaisonTest { + + private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + + protected XSLTLiaison liaison; + + @Before + public void setUp() throws Exception { + liaison = createLiaison(); + } + + // to override + protected abstract XSLTLiaison createLiaison() throws Exception ; + + /** load the file from the caller classloader that loaded this class */ + protected File getFile(String name) throws FileNotFoundException { + URL url = getClass().getResource(name); + if (url == null){ + throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); + } + return new File(FILE_UTILS.fromURI(url.toExternalForm())); + } + + /** keep it simple stupid */ + @Test + public void testTransform() throws Exception { + File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); + liaison.setStylesheet(xsl); + liaison.addParam("param", "value"); + File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); + File out = new File("xsltliaison.tmp"); + out.deleteOnExit(); // just to be sure + try { + liaison.transform(in, out); + } finally { + out.delete(); + } + } + + @Test + public void testEncoding() throws Exception { + File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); + liaison.setStylesheet(xsl); + File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); + File out = new File("xsltliaison-encoding.tmp"); + out.deleteOnExit(); // just to be sure + try { + liaison.transform(in, out); + Document doc = parseXML(out); + assertEquals("root",doc.getDocumentElement().getNodeName()); + assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); + assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); + } finally { + out.delete(); + } + } + + public Document parseXML(File file) throws Exception { + DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); + return dbuilder.parse(file); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/0ed7f4ab/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java index 834f173..8802022 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java @@ -1,48 +1,48 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests the examples of the <script> task docs. - * - * @since Ant 1.5.2 - */ -public class BeanShellScriptTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml"); - } - - @Test - public void testCanLoad() { - buildRule.executeTarget("useBeanshell"); - assertEquals("I'm here", buildRule.getLog()); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests the examples of the <script> task docs. + * + * @since Ant 1.5.2 + */ +public class BeanShellScriptTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml"); + } + + @Test + public void testCanLoad() { + buildRule.executeTarget("useBeanshell"); + assertEquals("I'm here", buildRule.getLog()); + } + +}
