Browse Source

Statically import string contains assertions

master
Gintas Grigelionis 7 years ago
parent
commit
cdb0348e9d
16 changed files with 76 additions and 73 deletions
  1. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
  2. +5
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
  3. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
  4. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
  5. +8
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
  6. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
  7. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java
  8. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java
  9. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java
  10. +6
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
  11. +9
    -9
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
  12. +8
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java
  13. +11
    -11
      src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
  14. +6
    -5
      src/tests/junit/org/apache/tools/ant/types/PolyTest.java
  15. +2
    -2
      src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
  16. +2
    -2
      src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java

+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java View File

@@ -17,7 +17,6 @@
*/ */
package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.AntAssert;
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;
@@ -26,6 +25,7 @@ import org.junit.Test;


import java.io.File; import java.io.File;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;


@@ -57,7 +57,7 @@ public class AbstractCvsTaskTest {
File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile"); File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
assertFalse("starting empty", f.exists()); assertFalse("starting empty", f.exists());
buildRule.executeTarget("package-attribute"); buildRule.executeTarget("package-attribute");
AntAssert.assertContains("U src/Makefile", buildRule.getLog());
assertContains("U src/Makefile", buildRule.getLog());
assertTrue("now it is there", f.exists()); assertTrue("now it is there", f.exists());
} }


@@ -66,7 +66,7 @@ public class AbstractCvsTaskTest {
File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile"); File f = new File(buildRule.getProject().getProperty("output") + "/src/Makefile");
assertFalse("starting empty", f.exists()); assertFalse("starting empty", f.exists());
buildRule.executeTarget("tag-attribute"); buildRule.executeTarget("tag-attribute");
AntAssert.assertContains("OPENBSD_5_3", buildRule.getLog());
assertContains("OPENBSD_5_3", buildRule.getLog());
assertTrue("now it is there", f.exists()); assertTrue("now it is there", f.exists());
} }
} }

+ 5
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java View File

@@ -22,7 +22,6 @@ import java.io.File;


import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;


import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.BuildFileRule;
@@ -35,6 +34,7 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


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.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@@ -290,7 +290,7 @@ public class AntTest {
buildRule.getProject().setUserProperty("test", "7"); buildRule.getProject().setUserProperty("test", "7");
buildRule.executeTarget("test-property-override-inheritall-start"); buildRule.executeTarget("test-property-override-inheritall-start");


AntAssert.assertContains("The value of test is 7", buildRule.getLog());
assertContains("The value of test is 7", buildRule.getLog());
} }


@Test @Test
@@ -298,20 +298,20 @@ public class AntTest {
buildRule.getProject().setUserProperty("test", "7"); buildRule.getProject().setUserProperty("test", "7");
buildRule.executeTarget("test-property-override-no-inheritall-start"); buildRule.executeTarget("test-property-override-no-inheritall-start");


AntAssert.assertContains("The value of test is 7", buildRule.getLog());
assertContains("The value of test is 7", buildRule.getLog());
} }


@Test @Test
public void testOverrideWinsInheritAll() { public void testOverrideWinsInheritAll() {
buildRule.executeTarget("test-property-override-inheritall-start"); buildRule.executeTarget("test-property-override-inheritall-start");


AntAssert.assertContains("The value of test is 4", buildRule.getLog());
assertContains("The value of test is 4", buildRule.getLog());
} }


@Test @Test
public void testOverrideWinsNoInheritAll() { public void testOverrideWinsNoInheritAll() {
buildRule.executeTarget("test-property-override-no-inheritall-start"); buildRule.executeTarget("test-property-override-no-inheritall-start");
AntAssert.assertContains("The value of test is 4", buildRule.getLog());
assertContains("The value of test is 4", buildRule.getLog());
} }


@Test @Test


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java View File

@@ -18,7 +18,6 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.AntAssert;
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;
@@ -27,6 +26,7 @@ import org.junit.Test;


import java.util.Vector; import java.util.Vector;


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.fail; import static org.junit.Assert.fail;


@@ -47,7 +47,7 @@ public class CallTargetTest {
@Test @Test
public void testInheritRefFileSet() { public void testInheritRefFileSet() {
buildRule.executeTarget("testinheritreffileset"); buildRule.executeTarget("testinheritreffileset");
AntAssert.assertContains("calltarget.xml", buildRule.getLog());
assertContains("calltarget.xml", buildRule.getLog());
} }


// see bugrep 21724 (references not passing through with antcall) // see bugrep 21724 (references not passing through with antcall)
@@ -64,7 +64,7 @@ public class CallTargetTest {
v.add("call-multi"); v.add("call-multi");
v.add("call-multi"); v.add("call-multi");
buildRule.getProject().executeTargets(v); buildRule.getProject().executeTargets(v);
AntAssert.assertContains("multi is SETmulti is SET", buildRule.getLog());
assertContains("multi is SETmulti is SET", buildRule.getLog());
} }


@Test @Test


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java View File

@@ -26,13 +26,13 @@ import java.io.InputStream;


import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;


import org.apache.tools.ant.AntAssert;
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;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


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.fail; import static org.junit.Assert.fail;


@@ -154,7 +154,7 @@ public class FixCrLfTest {
buildRule.executeTarget("testFixFileExclusive"); buildRule.executeTarget("testFixFileExclusive");
fail(FixCRLF.ERROR_FILE_AND_SRCDIR); fail(FixCRLF.ERROR_FILE_AND_SRCDIR);
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(FixCRLF.ERROR_FILE_AND_SRCDIR, ex.getMessage());
assertContains(FixCRLF.ERROR_FILE_AND_SRCDIR, ex.getMessage());
} }
} }




+ 8
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java View File

@@ -18,7 +18,6 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.AntAssert;
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.After; import org.junit.After;
@@ -26,6 +25,8 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.apache.tools.ant.AntAssert.assertNotContains;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


@@ -105,7 +106,7 @@ public class GetTest {
public void test7() { public void test7() {
try { try {
buildRule.executeTarget("test7"); buildRule.executeTarget("test7");
AntAssert.assertNotContains("Adding header", buildRule.getLog());
assertNotContains("Adding header", buildRule.getLog());


fail("userAgent may not be null or empty"); fail("userAgent may not be null or empty");
} catch (BuildException ex) { } catch (BuildException ex) {
@@ -127,21 +128,21 @@ public class GetTest {
public void testTwoHeadersAreAddedOK() { public void testTwoHeadersAreAddedOK() {
buildRule.executeTarget("testTwoHeadersAreAddedOK"); buildRule.executeTarget("testTwoHeadersAreAddedOK");
String log = buildRule.getLog(); String log = buildRule.getLog();
AntAssert.assertContains("Adding header 'header1'", log);
AntAssert.assertContains("Adding header 'header2'", log);
assertContains("Adding header 'header1'", log);
assertContains("Adding header 'header2'", log);
} }


@Test @Test
public void testEmptyHeadersAreNeverAdded() { public void testEmptyHeadersAreNeverAdded() {
buildRule.executeTarget("testEmptyHeadersAreNeverAdded"); buildRule.executeTarget("testEmptyHeadersAreNeverAdded");
AntAssert.assertNotContains("Adding header", buildRule.getLog());
assertNotContains("Adding header", buildRule.getLog());
} }


@Test @Test
public void testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded() { public void testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded() {
buildRule.executeTarget("testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded"); buildRule.executeTarget("testThatWhenMoreThanOneHeaderHaveSameNameOnlyLastOneIsAdded");
String log = buildRule.getLog(); String log = buildRule.getLog();
AntAssert.assertContains("Adding header 'header1'", log);
assertContains("Adding header 'header1'", log);


int actualHeaderCount = log.split("Adding header ").length - 1; int actualHeaderCount = log.split("Adding header ").length - 1;


@@ -151,7 +152,7 @@ public class GetTest {
@Test @Test
public void testHeaderSpaceTrimmed() { public void testHeaderSpaceTrimmed() {
buildRule.executeTarget("testHeaderSpaceTrimmed"); buildRule.executeTarget("testHeaderSpaceTrimmed");
AntAssert.assertContains("Adding header 'header1'", buildRule.getLog());
assertContains("Adding header 'header1'", buildRule.getLog());
} }


} }

+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java View File

@@ -19,7 +19,6 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;
@@ -31,6 +30,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;


@@ -236,7 +236,7 @@ public class RmicAdvancedTest {
buildRule.executeTarget("testDefaultBadClass"); buildRule.executeTarget("testDefaultBadClass");
} finally { } finally {
// don't look for much text here as it is vendor and version dependent // don't look for much text here as it is vendor and version dependent
AntAssert.assertContains("unimplemented.class", buildRule.getLog());
assertContains("unimplemented.class", buildRule.getLog());
} }
} }




+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java View File

@@ -18,13 +18,13 @@


package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import org.apache.tools.ant.AntAssert;
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;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


/** /**
@@ -66,8 +66,8 @@ public class IsFileSelectedTest {
try { try {
buildRule.executeTarget("not.selector"); buildRule.executeTarget("not.selector");
fail("Exception should have been thrown: checking for use as a selector (not allowed)"); fail("Exception should have been thrown: checking for use as a selector (not allowed)");
} catch(BuildException ex) {
AntAssert.assertContains("fileset doesn't support the nested \"isfile",
} catch (BuildException ex) {
assertContains("fileset doesn't support the nested \"isfile",
ex.getMessage()); ex.getMessage());
} }
} }


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java View File

@@ -17,7 +17,6 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import org.apache.tools.ant.AntAssert;
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;
@@ -25,6 +24,7 @@ import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


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.fail; import static org.junit.Assert.fail;


@@ -108,8 +108,8 @@ public class IsReachableTest {
try { try {
buildRule.executeTarget("testBadURL"); buildRule.executeTarget("testBadURL");
fail("Build exception expected: error in URL"); fail("Build exception expected: error in URL");
} catch(BuildException ex) {
AntAssert.assertContains(IsReachable.ERROR_BAD_URL, ex.getMessage());
} catch (BuildException ex) {
assertContains(IsReachable.ERROR_BAD_URL, ex.getMessage());
} }
} }
} }

+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java View File

@@ -17,13 +17,13 @@
*/ */
package org.apache.tools.ant.taskdefs.condition; package org.apache.tools.ant.taskdefs.condition;


import org.apache.tools.ant.AntAssert;
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;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


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.fail; import static org.junit.Assert.fail;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@@ -52,8 +52,8 @@ public class TypeFoundTest {
try { try {
buildRule.executeTarget("testUndefined"); buildRule.executeTarget("testUndefined");
fail("Build exception expected: left out the name attribute"); fail("Build exception expected: left out the name attribute");
} catch(BuildException ex) {
AntAssert.assertContains("No type specified", ex.getMessage());
} catch (BuildException ex) {
assertContains("No type specified", ex.getMessage());
} }
} }




+ 6
- 6
src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java View File

@@ -17,13 +17,13 @@
*/ */
package org.apache.tools.ant.taskdefs.optional; package org.apache.tools.ant.taskdefs.optional;


import org.apache.tools.ant.AntAssert;
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;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


/** /**
@@ -67,7 +67,7 @@ public class SchemaValidateTest {
buildRule.executeTarget("testNoEmptySchemaNamespace"); buildRule.executeTarget("testNoEmptySchemaNamespace");
fail("Empty namespace URI"); fail("Empty namespace URI");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_URI, ex.getMessage());
assertContains(SchemaValidate.SchemaLocation.ERROR_NO_URI, ex.getMessage());
} }
} }


@@ -77,7 +77,7 @@ public class SchemaValidateTest {
buildRule.executeTarget("testNoEmptySchemaLocation"); buildRule.executeTarget("testNoEmptySchemaLocation");
fail("Empty schema location"); fail("Empty schema location");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_LOCATION,
assertContains(SchemaValidate.SchemaLocation.ERROR_NO_LOCATION,
ex.getMessage()); ex.getMessage());
} }
} }
@@ -88,7 +88,7 @@ public class SchemaValidateTest {
buildRule.executeTarget("testNoFile"); buildRule.executeTarget("testNoFile");
fail("No file at file attribute"); fail("No file at file attribute");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_FILE,
assertContains(SchemaValidate.SchemaLocation.ERROR_NO_FILE,
ex.getMessage()); ex.getMessage());
} }
} }
@@ -99,7 +99,7 @@ public class SchemaValidateTest {
buildRule.executeTarget("testNoDoubleSchemaLocation"); buildRule.executeTarget("testNoDoubleSchemaLocation");
fail("Two locations for schemas"); fail("Two locations for schemas");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS,
assertContains(SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS,
ex.getMessage()); ex.getMessage());
} }
} }
@@ -110,7 +110,7 @@ public class SchemaValidateTest {
buildRule.executeTarget("testNoDuplicateSchema"); buildRule.executeTarget("testNoDuplicateSchema");
fail("duplicate schemas with different values"); fail("duplicate schemas with different values");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains(SchemaValidate.ERROR_DUPLICATE_SCHEMA,
assertContains(SchemaValidate.ERROR_DUPLICATE_SCHEMA,
ex.getMessage()); ex.getMessage());
} }
} }


+ 9
- 9
src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java View File

@@ -18,7 +18,6 @@


package org.apache.tools.ant.taskdefs.optional.image; package org.apache.tools.ant.taskdefs.optional.image;


import org.apache.tools.ant.AntAssert;
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;
import org.apache.tools.ant.util.JavaEnvUtils; import org.apache.tools.ant.util.JavaEnvUtils;
@@ -29,6 +28,7 @@ import org.junit.Test;


import java.io.File; import java.io.File;


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.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeFalse;
@@ -60,13 +60,13 @@ public class ImageTest {
@Test @Test
public void testEchoToLog() { public void testEchoToLog() {
buildRule.executeTarget("testEchoToLog"); buildRule.executeTarget("testEchoToLog");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
} }


@Test @Test
public void testSimpleScale() { public void testSimpleScale() {
buildRule.executeTarget("testSimpleScale"); buildRule.executeTarget("testSimpleScale");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());


File f = new File(buildRule.getOutputDir(), LARGEIMAGE); File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); assertTrue("Did not create " + f.getAbsolutePath(), f.exists());
@@ -75,13 +75,13 @@ public class ImageTest {
@Test @Test
public void testOverwriteTrue() { public void testOverwriteTrue() {
buildRule.executeTarget("testSimpleScale"); buildRule.executeTarget("testSimpleScale");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
File f = new File(buildRule.getOutputDir(), LARGEIMAGE); File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
assumeTrue("Could not change file modification date", assumeTrue("Could not change file modification date",
f.setLastModified(f.lastModified() - FILE_UTILS.getFileTimestampGranularity() * 2)); f.setLastModified(f.lastModified() - FILE_UTILS.getFileTimestampGranularity() * 2));
long lastModified = f.lastModified(); long lastModified = f.lastModified();
buildRule.executeTarget("testOverwriteTrue"); buildRule.executeTarget("testOverwriteTrue");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
f = new File(buildRule.getOutputDir(), LARGEIMAGE); f = new File(buildRule.getOutputDir(), LARGEIMAGE);
long overwrittenLastModified = f.lastModified(); long overwrittenLastModified = f.lastModified();
assertTrue("File was not overwritten.", lastModified < overwrittenLastModified); assertTrue("File was not overwritten.", lastModified < overwrittenLastModified);
@@ -90,11 +90,11 @@ public class ImageTest {
@Test @Test
public void testOverwriteFalse() { public void testOverwriteFalse() {
buildRule.executeTarget("testSimpleScale"); buildRule.executeTarget("testSimpleScale");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
File f = new File(buildRule.getOutputDir(), LARGEIMAGE); File f = new File(buildRule.getOutputDir(), LARGEIMAGE);
long lastModified = f.lastModified(); long lastModified = f.lastModified();
buildRule.executeTarget("testOverwriteFalse"); buildRule.executeTarget("testOverwriteFalse");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
f = new File(buildRule.getOutputDir(), LARGEIMAGE); f = new File(buildRule.getOutputDir(), LARGEIMAGE);
long overwrittenLastModified = f.lastModified(); long overwrittenLastModified = f.lastModified();
assertEquals("File was overwritten.", lastModified, overwrittenLastModified); assertEquals("File was overwritten.", lastModified, overwrittenLastModified);
@@ -103,7 +103,7 @@ public class ImageTest {
@Test @Test
public void testSimpleScaleWithMapper() { public void testSimpleScaleWithMapper() {
buildRule.executeTarget("testSimpleScaleWithMapper"); buildRule.executeTarget("testSimpleScaleWithMapper");
AntAssert.assertContains("Processing File", buildRule.getLog());
assertContains("Processing File", buildRule.getLog());
File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE);
assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); assertTrue("Did not create " + f.getAbsolutePath(), f.exists());
} }
@@ -113,7 +113,7 @@ public class ImageTest {
public void testFailOnError() { public void testFailOnError() {
try { try {
buildRule.executeTarget("testFailOnError"); buildRule.executeTarget("testFailOnError");
AntAssert.assertContains("Unable to process image stream", buildRule.getLog());
assertContains("Unable to process image stream", buildRule.getLog());
} catch (RuntimeException re) { } catch (RuntimeException re) {
assertTrue("Run time exception should say 'Unable to process image stream'. :" assertTrue("Run time exception should say 'Unable to process image stream'. :"
+ re.toString(), + re.toString(),


+ 8
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java View File

@@ -18,12 +18,13 @@


package org.apache.tools.ant.taskdefs.optional.jdepend; package org.apache.tools.ant.taskdefs.optional.jdepend;


import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.BuildFileRule;
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 static org.apache.tools.ant.AntAssert.assertContains;

/** /**
* Testcase for the JDepend optional task. * Testcase for the JDepend optional task.
* *
@@ -45,7 +46,7 @@ public class JDependTest {
@Test @Test
public void testSimple() { public void testSimple() {
buildRule.executeTarget("simple"); buildRule.executeTarget("simple");
AntAssert.assertContains("Package: org.apache.tools.ant.util.facade",
assertContains("Package: org.apache.tools.ant.util.facade",
buildRule.getOutput()); buildRule.getOutput());
} }


@@ -55,7 +56,7 @@ public class JDependTest {
@Test @Test
public void testXml() { public void testXml() {
buildRule.executeTarget("xml"); buildRule.executeTarget("xml");
AntAssert.assertContains("<DependsUpon>", buildRule.getOutput());
assertContains("<DependsUpon>", buildRule.getOutput());
} }


/** /**
@@ -65,7 +66,7 @@ public class JDependTest {
@Test @Test
public void testFork() { public void testFork() {
buildRule.executeTarget("fork"); buildRule.executeTarget("fork");
AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
} }


/** /**
@@ -74,7 +75,7 @@ public class JDependTest {
@Test @Test
public void testForkXml() { public void testForkXml() {
buildRule.executeTarget("fork-xml"); buildRule.executeTarget("fork-xml");
AntAssert.assertContains("<DependsUpon>", buildRule.getLog());
assertContains("<DependsUpon>", buildRule.getLog());
} }


/** /**
@@ -83,7 +84,7 @@ public class JDependTest {
@Test @Test
public void testTimeout() { public void testTimeout() {
buildRule.executeTarget("fork-xml"); buildRule.executeTarget("fork-xml");
AntAssert.assertContains("JDepend FAILED - Timed out", buildRule.getLog());
assertContains("JDepend FAILED - Timed out", buildRule.getLog());
} }




@@ -93,7 +94,7 @@ public class JDependTest {
@Test @Test
public void testTimeoutNot() { public void testTimeoutNot() {
buildRule.executeTarget("fork-timeout-not"); buildRule.executeTarget("fork-timeout-not");
AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog());
} }


} }

+ 11
- 11
src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java View File

@@ -18,7 +18,6 @@


package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
@@ -28,6 +27,7 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


public class AddTypeTest { public class AddTypeTest {
@@ -63,19 +63,19 @@ public class AddTypeTest {
@Test @Test
public void testNestedA() { public void testNestedA() {
buildRule.executeTarget("nested.a"); buildRule.executeTarget("nested.a");
AntAssert.assertContains("add A called", buildRule.getLog());
assertContains("add A called", buildRule.getLog());
} }


@Test @Test
public void testNestedB() { public void testNestedB() {
buildRule.executeTarget("nested.b"); buildRule.executeTarget("nested.b");
AntAssert.assertContains("add B called", buildRule.getLog());
assertContains("add B called", buildRule.getLog());
} }


@Test @Test
public void testNestedC() { public void testNestedC() {
buildRule.executeTarget("nested.c"); buildRule.executeTarget("nested.c");
AntAssert.assertContains("add C called", buildRule.getLog());
assertContains("add C called", buildRule.getLog());
} }


@Test @Test
@@ -84,26 +84,26 @@ public class AddTypeTest {
buildRule.executeTarget("nested.ab"); buildRule.executeTarget("nested.ab");
fail("Build exception expected: Should have got ambiguous"); fail("Build exception expected: Should have got ambiguous");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains("ambiguous", ex.getMessage());
assertContains("ambiguous", ex.getMessage());
} }
} }


@Test @Test
public void testConditionType() { public void testConditionType() {
buildRule.executeTarget("condition.type"); buildRule.executeTarget("condition.type");
AntAssert.assertContains("beforeafter", buildRule.getLog());
assertContains("beforeafter", buildRule.getLog());
} }


@Test @Test
public void testConditionTask() { public void testConditionTask() {
buildRule.executeTarget("condition.task"); buildRule.executeTarget("condition.task");
AntAssert.assertContains("My Condition execution", buildRule.getLog());
assertContains("My Condition execution", buildRule.getLog());
} }


@Test @Test
public void testConditionConditionType() { public void testConditionConditionType() {
buildRule.executeTarget("condition.condition.type"); buildRule.executeTarget("condition.condition.type");
AntAssert.assertContains("My Condition eval", buildRule.getLog());
assertContains("My Condition eval", buildRule.getLog());
} }


@Test @Test
@@ -112,21 +112,21 @@ public class AddTypeTest {
buildRule.executeTarget("condition.condition.task"); buildRule.executeTarget("condition.condition.task");
fail("Build exception expected: Task masking condition"); fail("Build exception expected: Task masking condition");
} catch (BuildException ex) { } catch (BuildException ex) {
AntAssert.assertContains("doesn't support the nested", ex.getMessage());
assertContains("doesn't support the nested", ex.getMessage());
} }
} }


@Test @Test
public void testAddConfigured() { public void testAddConfigured() {
buildRule.executeTarget("myaddconfigured"); buildRule.executeTarget("myaddconfigured");
AntAssert.assertContains("value is Value Setexecute: value is Value Set",
assertContains("value is Value Setexecute: value is Value Set",
buildRule.getLog()); buildRule.getLog());
} }


@Test @Test
public void testAddConfiguredValue() { public void testAddConfiguredValue() {
buildRule.executeTarget("myaddconfiguredvalue"); buildRule.executeTarget("myaddconfiguredvalue");
AntAssert.assertContains("value is Value Setexecute: value is Value Set",
assertContains("value is Value Setexecute: value is Value Set",
buildRule.getLog()); buildRule.getLog());
} }




+ 6
- 5
src/tests/junit/org/apache/tools/ant/types/PolyTest.java View File

@@ -18,7 +18,6 @@


package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import org.apache.tools.ant.AntAssert;
import org.apache.tools.ant.BuildFileRule; 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;
@@ -26,6 +25,8 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;

public class PolyTest { public class PolyTest {


@Rule @Rule
@@ -39,25 +40,25 @@ public class PolyTest {
@Test @Test
public void testFileSet() { public void testFileSet() {
buildRule.executeTarget("fileset"); buildRule.executeTarget("fileset");
AntAssert.assertContains("types.FileSet", buildRule.getLog());
assertContains("types.FileSet", buildRule.getLog());
} }


@Test @Test
public void testFileSetAntType() { public void testFileSetAntType() {
buildRule.executeTarget("fileset-ant-type"); buildRule.executeTarget("fileset-ant-type");
AntAssert.assertContains("types.PolyTest$MyFileSet", buildRule.getLog());
assertContains("types.PolyTest$MyFileSet", buildRule.getLog());
} }


@Test @Test
public void testPath() { public void testPath() {
buildRule.executeTarget("path"); buildRule.executeTarget("path");
AntAssert.assertContains("types.Path", buildRule.getLog());
assertContains("types.Path", buildRule.getLog());
} }


@Test @Test
public void testPathAntType() { public void testPathAntType() {
buildRule.executeTarget("path-ant-type"); buildRule.executeTarget("path-ant-type");
AntAssert.assertContains("types.PolyTest$MyPath", buildRule.getLog());
assertContains("types.PolyTest$MyPath", buildRule.getLog());
} }


public static class MyFileSet extends FileSet { public static class MyFileSet extends FileSet {


+ 2
- 2
src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java View File

@@ -17,7 +17,6 @@
*/ */
package org.apache.tools.ant.types; package org.apache.tools.ant.types;


import org.apache.tools.ant.AntAssert;
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.Project; import org.apache.tools.ant.Project;
@@ -25,6 +24,7 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import static org.apache.tools.ant.AntAssert.assertContains;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


@@ -74,7 +74,7 @@ public class RedirectorElementTest {
public void testLogInputString() { public void testLogInputString() {
buildRule.executeTarget("testLogInputString"); buildRule.executeTarget("testLogInputString");
if (buildRule.getLog().contains("testLogInputString can-cat")) { if (buildRule.getLog().contains("testLogInputString can-cat")) {
AntAssert.assertContains("Using input string", buildRule.getFullLog());
assertContains("Using input string", buildRule.getFullLog());
} }
} }




+ 2
- 2
src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java View File

@@ -24,7 +24,6 @@ import java.text.RuleBasedCollator;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;


import org.apache.tools.ant.AntAssert;
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.Project; import org.apache.tools.ant.Project;
@@ -47,6 +46,7 @@ import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


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.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
@@ -569,7 +569,7 @@ public class ModifiedSelectorTest {
public void testResourceSelectorSelresTrue() { public void testResourceSelectorSelresTrue() {
BFT bft = new BFT(); BFT bft = new BFT();
bft.doTarget("modifiedselectortest-ResourceSelresTrue"); bft.doTarget("modifiedselectortest-ResourceSelresTrue");
AntAssert.assertContains("does not provide an InputStream", bft.getLog());
assertContains("does not provide an InputStream", bft.getLog());
bft.deleteCachefile(); bft.deleteCachefile();
} }




Loading…
Cancel
Save