http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java b/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java index 1e43fe1..7ff8565 100644 --- a/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java @@ -101,7 +101,7 @@ public class PermissionsTest { String s = System.getProperty("user.home"); System.setProperty("user.home", s); fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ + } catch (SecurityException e) { // Was expected, test passes } finally { perms.restoreSecurityManager(); @@ -115,7 +115,7 @@ public class PermissionsTest { try { System.getProperty("os.name"); fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ + } catch (SecurityException e) { // Was expected, test passes } finally { perms.restoreSecurityManager(); @@ -129,7 +129,7 @@ public class PermissionsTest { try { System.setProperty("line.separator",ls); fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ + } catch (SecurityException e) { //TODO assert exception message // Was expected, test passes } finally { @@ -144,7 +144,7 @@ public class PermissionsTest { try { System.out.println("If this is the last line on standard out the testExit f.a.i.l.e.d"); System.exit(3); - fail("Totaly impossible that this fail is ever executed. Please let me know if it is!"); + fail("Totally impossible that this fail is ever executed. Please let me know if it is!"); } catch (ExitException e) { if (e.getStatus() != 3) { fail("Received wrong exit status in Exit Exception.");
http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/PolyTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/PolyTest.java b/src/tests/junit/org/apache/tools/ant/types/PolyTest.java index 8dd132a..73ffff4 100644 --- a/src/tests/junit/org/apache/tools/ant/types/PolyTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/PolyTest.java @@ -39,7 +39,7 @@ public class PolyTest { @Test public void testFileSet() { buildRule.executeTarget("fileset"); - AntAssert.assertContains( "types.FileSet", buildRule.getLog()); + AntAssert.assertContains("types.FileSet", buildRule.getLog()); } @Test @@ -51,16 +51,17 @@ public class PolyTest { @Test public void testPath() { buildRule.executeTarget("path"); - AntAssert.assertContains( "types.Path", buildRule.getLog()); + AntAssert.assertContains("types.Path", buildRule.getLog()); } @Test public void testPathAntType() { buildRule.executeTarget("path-ant-type"); - AntAssert.assertContains( "types.PolyTest$MyPath", buildRule.getLog()); + AntAssert.assertContains("types.PolyTest$MyPath", buildRule.getLog()); } - public static class MyFileSet extends FileSet {} + public static class MyFileSet extends FileSet { + } public static class MyPath extends Path { public MyPath(Project project) { http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java index f4c2abe..b7bfa5d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java @@ -73,7 +73,7 @@ public class RedirectorElementTest { @Test public void testLogInputString() { buildRule.executeTarget("testLogInputString"); - if (buildRule.getLog().indexOf("testLogInputString can-cat") >=0 ) { + if (buildRule.getLog().indexOf("testLogInputString can-cat") >= 0) { AntAssert.assertContains("Using input string", buildRule.getFullLog()); } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java index b66335a..25a653d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java @@ -50,7 +50,7 @@ public class ResourceOutputTest { public void setUp() { project = new Project(); project.init(); - project.setUserProperty("basedir" , basedir.getAbsolutePath()); + project.setUserProperty("basedir", basedir.getAbsolutePath()); } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java index b30168a..efaa474 100644 --- a/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java @@ -43,7 +43,7 @@ public class TarFileSetTest extends AbstractFileSetTest { @Test public final void testAttributes() { - TarFileSet f = (TarFileSet)getInstance(); + TarFileSet f = (TarFileSet) getInstance(); //check that dir and src are incompatible f.setSrc(new File("example.tar")); try { @@ -54,7 +54,7 @@ public class TarFileSetTest extends AbstractFileSetTest { } catch (BuildException be) { assertEquals("Cannot set both dir and src attributes",be.getMessage()); } - f = (TarFileSet)getInstance(); + f = (TarFileSet) getInstance(); //check that dir and src are incompatible f.setDir(new File("examples")); try { @@ -66,7 +66,7 @@ public class TarFileSetTest extends AbstractFileSetTest { assertEquals("Cannot set both dir and src attributes",be.getMessage()); } //check that fullpath and prefix are incompatible - f = (TarFileSet)getInstance(); + f = (TarFileSet) getInstance(); f.setSrc(new File("example.tar")); f.setPrefix("/examples"); try { @@ -77,7 +77,7 @@ public class TarFileSetTest extends AbstractFileSetTest { } catch (BuildException be) { assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); } - f = (TarFileSet)getInstance(); + f = (TarFileSet) getInstance(); f.setSrc(new File("example.tar")); f.setFullpath("/doc/manual/index.html"); try { @@ -89,7 +89,7 @@ public class TarFileSetTest extends AbstractFileSetTest { assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); } // check that reference tarfilesets cannot have specific attributes - f = (TarFileSet)getInstance(); + f = (TarFileSet) getInstance(); f.setRefid(new Reference(getProject(), "test")); try { f.setSrc(new File("example.tar")); @@ -101,18 +101,22 @@ public class TarFileSetTest extends AbstractFileSetTest { + "attribute when using refid", be.getMessage()); } // check that a reference tarfileset gets the same attributes as the original - f = (TarFileSet)getInstance(); + f = (TarFileSet) getInstance(); f.setSrc(new File("example.tar")); f.setPrefix("/examples"); f.setFileMode("600"); f.setDirMode("530"); getProject().addReference("test",f); - TarFileSet zid=(TarFileSet)getInstance(); + TarFileSet zid = (TarFileSet) getInstance(); zid.setRefid(new Reference(getProject(), "test")); - assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject()))); - assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); - assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject())); - assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject())); + assertTrue("src attribute copied by copy constructor", + zid.getSrc(getProject()).equals(f.getSrc(getProject()))); + assertTrue("prefix attribute copied by copy constructor", + f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); + assertTrue("file mode attribute copied by copy constructor", + f.getFileMode(getProject()) == zid.getFileMode(getProject())); + assertTrue("dir mode attribute copied by copy constructor", + f.getDirMode(getProject()) == zid.getDirMode(getProject())); } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java index c1adc30..2422c79 100644 --- a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java @@ -120,7 +120,6 @@ public class XMLCatalogTest { @Test public void testNonExistentEntry() throws IOException, SAXException, TransformerException { - ResourceLocation dtd = new ResourceLocation(); dtd.setPublicId("PUBLIC ID ONE"); dtd.setLocation("i/dont/exist.dtd"); @@ -175,8 +174,8 @@ public class XMLCatalogTest { catalog.setRefid(new Reference(project, "catalog")); try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); + @SuppressWarnings("unused") + InputSource result = catalog.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); fail("Can make XMLCatalog a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", @@ -198,8 +197,7 @@ public class XMLCatalogTest { catalog1.setRefid(new Reference(project, "catalog2")); try { - catalog1.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); + catalog1.resolveEntity("PUBLIC ID ONE", "i/dont/exist.dtd"); fail("Can make circular reference"); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", @@ -222,10 +220,7 @@ public class XMLCatalogTest { InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", "nap:chemical+brothers"); assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); - - + assertEquals(toURLString(dtdFile), result.getSystemId()); } @Test @@ -241,14 +236,12 @@ public class XMLCatalogTest { InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", "nap:chemical+brothers"); assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); + assertEquals(toURLString(dtdFile), result.getSystemId()); } @Test public void testEntryReference() throws IOException, SAXException, TransformerException { - String publicId = "-//stevo//DTD doc 1.0//EN"; String sysid = "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; @@ -278,23 +271,18 @@ public class XMLCatalogTest { catalog1.setRefid(new Reference(project, "catalog")); catalog2.setRefid(new Reference(project, "catalog1")); - InputSource isResult = catalog2.resolveEntity(publicId, - "nap:chemical+brothers"); + InputSource isResult = catalog2.resolveEntity(publicId, "nap:chemical+brothers"); assertNotNull(isResult); - assertEquals(toURLString(dtdFile), - isResult.getSystemId()); - + assertEquals(toURLString(dtdFile), isResult.getSystemId()); Source result = catalog.resolve(uri, null); assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); + assertEquals(toURLString(xmlFile), result.getSystemId()); } @Test public void testNestedCatalog() throws IOException, SAXException, TransformerException { - String publicId = "-//stevo//DTD doc 1.0//EN"; String dtdLoc = "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; @@ -316,22 +304,18 @@ public class XMLCatalogTest { XMLCatalog catalog1 = newCatalog(); catalog1.addConfiguredXMLCatalog(catalog); - InputSource isResult = catalog1.resolveEntity(publicId, - "nap:chemical+brothers"); + InputSource isResult = catalog1.resolveEntity(publicId, "nap:chemical+brothers"); assertNotNull(isResult); - assertEquals(toURLString(dtdFile), - isResult.getSystemId()); + assertEquals(toURLString(dtdFile), isResult.getSystemId()); Source result = catalog.resolve(uri, null); assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); + assertEquals(toURLString(xmlFile), result.getSystemId()); } @Test public void testResolverBase() throws MalformedURLException, TransformerException { - String uri = "http://foo.com/bar/blah.xml"; String uriLoc = "etc/testcases/taskdefs/optional/xml/about.xml"; String base = toURLString(project.getBaseDir()) + "/src/"; @@ -344,15 +328,12 @@ public class XMLCatalogTest { Source result = catalog.resolve(uri, base); assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); + assertEquals(toURLString(xmlFile), result.getSystemId()); } @Test public void testClasspath() throws IOException, TransformerException, SAXException { - - String publicId = "-//stevo//DTD doc 1.0//EN"; String dtdLoc = "testcases/taskdefs/optional/xml/doc.dtd"; String path1 = project.getBaseDir().toString() + "/src/etc"; @@ -377,8 +358,7 @@ public class XMLCatalogTest { aPath.append(new Path(project, path2)); catalog.setClasspath(aPath); - InputSource isResult = catalog.resolveEntity(publicId, - "nap:chemical+brothers"); + InputSource isResult = catalog.resolveEntity(publicId, "nap:chemical+brothers"); assertNotNull(isResult); String resultStr1 = new URL(isResult.getSystemId()).getFile(); assertTrue(toURLString(dtdFile).endsWith(resultStr1)); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java index e7b14c1..f9265fe 100644 --- a/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.fail; /** * JUnit 3 testcases for org.apache.tools.ant.types.ZipFileSet. * - * <p>This doesn't actually test much, mainly reference handling. + * <p>This doesn't actually test much, mainly reference handling.</p> * */ @@ -42,7 +42,7 @@ public class ZipFileSetTest extends AbstractFileSetTest { @Test public final void testAttributes() { - ZipFileSet f = (ZipFileSet)getInstance(); + ZipFileSet f = (ZipFileSet) getInstance(); //check that dir and src are incompatible f.setSrc(new File("example.zip")); try { @@ -51,9 +51,9 @@ public class ZipFileSetTest extends AbstractFileSetTest { + f.getDataTypeName() + " when a src is already present"); } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); + assertEquals("Cannot set both dir and src attributes", be.getMessage()); } - f = (ZipFileSet)getInstance(); + f = (ZipFileSet) getInstance(); //check that dir and src are incompatible f.setDir(new File("examples")); try { @@ -62,10 +62,10 @@ public class ZipFileSetTest extends AbstractFileSetTest { + f.getDataTypeName() + " when a dir is already present"); } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); + assertEquals("Cannot set both dir and src attributes", be.getMessage()); } //check that fullpath and prefix are incompatible - f = (ZipFileSet)getInstance(); + f = (ZipFileSet) getInstance(); f.setSrc(new File("example.zip")); f.setPrefix("/examples"); try { @@ -76,7 +76,7 @@ public class ZipFileSetTest extends AbstractFileSetTest { } catch (BuildException be) { assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); } - f = (ZipFileSet)getInstance(); + f = (ZipFileSet) getInstance(); f.setSrc(new File("example.zip")); f.setFullpath("/doc/manual/index.html"); try { @@ -88,7 +88,7 @@ public class ZipFileSetTest extends AbstractFileSetTest { assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); } // check that reference zipfilesets cannot have specific attributes - f = (ZipFileSet)getInstance(); + f = (ZipFileSet) getInstance(); f.setRefid(new Reference(getProject(), "test")); try { f.setSrc(new File("example.zip")); @@ -100,18 +100,22 @@ public class ZipFileSetTest extends AbstractFileSetTest { + "attribute when using refid", be.getMessage()); } // check that a reference zipfileset gets the same attributes as the original - f = (ZipFileSet)getInstance(); + f = (ZipFileSet) getInstance(); f.setSrc(new File("example.zip")); f.setPrefix("/examples"); f.setFileMode("600"); f.setDirMode("530"); getProject().addReference("test",f); - ZipFileSet zid=(ZipFileSet)getInstance(); + ZipFileSet zid = (ZipFileSet) getInstance(); zid.setRefid(new Reference(getProject(), "test")); - assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject()))); - assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); - assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject())); - assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject())); + assertTrue("src attribute copied by copy constructor", + zid.getSrc(getProject()).equals(f.getSrc(getProject()))); + assertTrue("prefix attribute copied by copy constructor", + f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); + assertEquals("file mode attribute copied by copy constructor", + f.getFileMode(getProject()), zid.getFileMode(getProject())); + assertEquals("dir mode attribute copied by copy constructor", + f.getDirMode(getProject()), zid.getDirMode(getProject())); } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java b/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java index a982bcb..a52cabf 100644 --- a/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java +++ b/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java @@ -80,7 +80,7 @@ public class MapperResult extends Task { if (result == null) { flattened = NULL_MAPPER_RESULT; } else { - StringBuffer b = new StringBuffer(); + StringBuilder b = new StringBuilder(); for (int i = 0; i < result.length; ++i) { if (i != 0) { b.append("|"); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java index 10fa131..690ace6 100644 --- a/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java @@ -20,7 +20,6 @@ package org.apache.tools.ant.types.resources; import java.io.File; import org.apache.tools.ant.Project; - import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java index f91077a..9e99872 100644 --- a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java @@ -23,7 +23,6 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; - import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.ResourceCollection; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java index a9593f0..f848f7d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import java.io.File; +import java.io.IOException; import static org.apache.tools.ant.FileUtilities.getFileContents; import static org.junit.Assert.assertEquals; @@ -46,7 +47,7 @@ public class TarResourceTest { } @Test - public void testUncompressSource() throws java.io.IOException { + public void testUncompressSource() throws IOException { buildRule.executeTarget("uncompressSource"); assertEquals(getFileContents(buildRule.getProject().resolveFile("../../asf-logo.gif")), getFileContents(new File(buildRule.getProject().getProperty("output"), "asf-logo.gif"))); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java index d5613b2..643dbeb 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java @@ -20,7 +20,6 @@ package org.apache.tools.ant.types.selectors; import java.io.File; - import org.apache.tools.ant.BuildFileRule; @@ -100,21 +99,20 @@ public class BaseSelectorRule extends BuildFileRule { * a string of "T"s amd "F"s. */ public String mirrorSelectionString(FileSelector selector) { - return selectionString(mirrordir,mirrorfiles,selector); + return selectionString(mirrordir, mirrorfiles, selector); } /** * Worker method for the two convenience methods above. Applies a * selector on a set of files passed in and returns a string of - * "T"s amd "F"s from applying the selector to each file. + * "T"s and "F"s from applying the selector to each file. */ public String selectionString(File basedir, File[] files, FileSelector selector) { StringBuilder buf = new StringBuilder(); for (int x = 0; x < files.length; x++) { - if (selector.isSelected(basedir,filenames[x],files[x])) { + if (selector.isSelected(basedir, filenames[x], files[x])) { buf.append('T'); - } - else { + } else { buf.append('F'); } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java index 2332778..e9c0e99 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java @@ -79,7 +79,7 @@ public abstract class BaseSelectorTest extends BuildFileTest { */ public BaseSelector getSelector() { BaseSelector selector = getInstance(); - selector.setProject( getProject() ); + selector.setProject(getProject()); return selector; } @@ -135,12 +135,11 @@ public abstract class BaseSelectorTest extends BuildFileTest { * "T"s amd "F"s from applying the selector to each file. */ public String selectionString(File basedir, File[] files, FileSelector selector) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); for (int x = 0; x < files.length; x++) { - if (selector.isSelected(basedir,filenames[x],files[x])) { + if (selector.isSelected(basedir, filenames[x], files[x])) { buf.append('T'); - } - else { + } else { buf.append('F'); } } @@ -173,13 +172,10 @@ public abstract class BaseSelectorTest extends BuildFileTest { int length1 = expected.length(); int length2 = result.length(); int min = (length1 > length2) ? length2 : length1; - StringBuffer sb = new StringBuffer(); - for (int i=0; i<min; i++) { - sb.append( - (expected.charAt(i) == result.charAt(i)) - ? "-" - : "X" - ); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < min; i++) { + sb.append((expected.charAt(i) == result.charAt(i)) + ? "-" : "X"); } return sb.toString(); } @@ -193,12 +189,12 @@ public abstract class BaseSelectorTest extends BuildFileTest { * separated with semicolons ';' */ public String resolve(String filelist) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int min = (filenames.length > filelist.length()) ? filelist.length() : filenames.length; - for (int i=0; i<min; i++) { - if ('X'==filelist.charAt(i)) { + for (int i = 0; i < min; i++) { + if ('X' == filelist.charAt(i)) { sb.append(filenames[i]); sb.append(";"); } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java index e622be1..f1d7ca9 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java @@ -45,7 +45,8 @@ public class DateSelectorTest { public void testValidate() { DateSelector s = new DateSelector(); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for required fields"); } catch (BuildException be1) { assertEquals("You must provide a datetime or the number of " @@ -55,7 +56,8 @@ public class DateSelectorTest { s = new DateSelector(); s.setDatetime("01/01/1969 01:01 AM"); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for Datetime being in the " + "allowable range"); } catch (BuildException be2) { @@ -67,7 +69,8 @@ public class DateSelectorTest { s = new DateSelector(); s.setDatetime("this is not a date"); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for Datetime being in a " + "valid format"); } catch (BuildException be3) { @@ -84,7 +87,8 @@ public class DateSelectorTest { params[0] = param; s.setParameters(params); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for valid parameter element"); } catch (BuildException be4) { assertEquals("Invalid parameter garbage in", be4.getMessage()); @@ -97,7 +101,8 @@ public class DateSelectorTest { params[0] = param; s.setParameters(params); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for valid millis parameter"); } catch (BuildException be5) { assertEquals("Invalid millisecond setting garbage out", @@ -111,7 +116,8 @@ public class DateSelectorTest { params[0] = param; s.setParameters(params); try { - s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("DateSelector did not check for valid granularity parameter"); } catch (BuildException be6) { assertEquals("Invalid granularity setting garbage out", @@ -204,8 +210,9 @@ public class DateSelectorTest { // setup the modified timestamp to match what the test needs, although be aware that the 3rd and 4th // files don't exist so can't be changed, so don't try and loop over them - for (int i = 1; i <=2; i++) { - Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime - (3*60*60*100))); + for (int i = 1; i <= 2; i++) { + Assume.assumeTrue("Cannot setup file times for test", + selectorRule.getMirrorFiles()[i].setLastModified(testtime - (3 * 60 * 60 * 100))); } @@ -218,7 +225,8 @@ public class DateSelectorTest { s.setWhen(before); s.setGranularity(2); for (int i = 7; i <= 10; i++) { - Assume.assumeTrue("Cannot setup file times for test", selectorRule.getMirrorFiles()[i].setLastModified(testtime + (3*60*60*100))); + Assume.assumeTrue("Cannot setup file times for test", + selectorRule.getMirrorFiles()[i].setLastModified(testtime + (3 * 60 * 60 * 100))); } results = selectorRule.mirrorSelectionString(s); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java index 526a5bf..3c7e429 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java @@ -140,8 +140,6 @@ public class DepthSelectorTest { s.setMax(1); results = selectorRule.selectionString(s); assertEquals("FFFFFTTTFFFT", results); - - } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java index 357fe49..09483bf 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java @@ -71,45 +71,41 @@ public class FilenameSelectorTest { FilenameSelector s; String results; + s = new FilenameSelector(); + s.setName("no match possible"); + results = selectorRule.selectionString(s); + assertEquals("FFFFFFFFFFFF", results); - s = new FilenameSelector(); - s.setName("no match possible"); - results = selectorRule.selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = new FilenameSelector(); - s.setName("*.gz"); - results = selectorRule.selectionString(s); - // This is turned off temporarily. There appears to be a bug - // in SelectorUtils.matchPattern() where it is recursive on - // Windows even if no ** is in pattern. - //assertEquals("FFFTFFFFFFFF", results); // Unix - // vs - //assertEquals("FFFTFFFFTFFF", results); // Windows - - s = new FilenameSelector(); - s.setName("**/*.gz"); - s.setNegate(true); - results = selectorRule.selectionString(s); - assertEquals("TTTFTTTFFTTT", results); - - s = new FilenameSelector(); - s.setName("**/*.GZ"); - s.setCasesensitive(false); - results = selectorRule.selectionString(s); - assertEquals("FFFTFFFTTFFF", results); - - s = new FilenameSelector(); - Parameter param1 = new Parameter(); - param1.setName("name"); - param1.setValue("**/*.bz2"); - Parameter[] params = {param1}; - s.setParameters(params); - results = selectorRule.selectionString(s); - assertEquals("FFTFFFFFFTTF", results); + s = new FilenameSelector(); + s.setName("*.gz"); + results = selectorRule.selectionString(s); + // This is turned off temporarily. There appears to be a bug + // in SelectorUtils.matchPattern() where it is recursive on + // Windows even if no ** is in pattern. + //assertEquals("FFFTFFFFFFFF", results); // Unix + // vs + //assertEquals("FFFTFFFFTFFF", results); // Windows + s = new FilenameSelector(); + s.setName("**/*.gz"); + s.setNegate(true); + results = selectorRule.selectionString(s); + assertEquals("TTTFTTTFFTTT", results); + s = new FilenameSelector(); + s.setName("**/*.GZ"); + s.setCasesensitive(false); + results = selectorRule.selectionString(s); + assertEquals("FFFTFFFTTFFF", results); + s = new FilenameSelector(); + Parameter param1 = new Parameter(); + param1.setName("name"); + param1.setValue("**/*.bz2"); + Parameter[] params = {param1}; + s.setParameters(params); + results = selectorRule.selectionString(s); + assertEquals("FFTFFFFFFTTF", results); } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java b/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java index 359a179..81e379a 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/MockCache.java @@ -47,11 +47,11 @@ public class MockCache implements Cache { saved = true; } public Object get(Object key) { - log(".get("+key+")"); + log(".get(" + key + ")"); return key; } public void put(Object key, Object value) { - log(".put("+key+", "+value+")"); + log(".put(" + key + ", " + value + ")"); saved = false; } public Iterator<String> iterator() { @@ -63,6 +63,8 @@ public class MockCache implements Cache { } private void log(String msg) { - if (debug) System.out.println(this+msg); + if (debug) { + System.out.println(this + msg); + } } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java index aa04b09..496b7ae 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java @@ -19,8 +19,8 @@ package org.apache.tools.ant.types.selectors; -// Java import java.io.File; +import java.io.FileWriter; import java.text.RuleBasedCollator; import java.util.Comparator; import java.util.Iterator; @@ -168,19 +168,19 @@ public class ModifiedSelectorTest { @Test public void testCustomAlgorithm() { String algo = getAlgoName("org.apache.tools.ant.types.selectors.modifiedselector.HashvalueAlgorithm"); - assertTrue("Wrong algorithm used: "+algo, algo.startsWith("HashvalueAlgorithm")); + assertTrue("Wrong algorithm used: " + algo, algo.startsWith("HashvalueAlgorithm")); } @Test public void testCustomAlgorithm2() { String algo = getAlgoName("org.apache.tools.ant.types.selectors.MockAlgorithm"); - assertTrue("Wrong algorithm used: "+algo, algo.startsWith("MockAlgorithm")); + assertTrue("Wrong algorithm used: " + algo, algo.startsWith("MockAlgorithm")); } @Test public void testCustomClasses() { - Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home") ); + Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home")); BFT bft = new BFT(); bft.setUp(); try { @@ -261,13 +261,19 @@ public class ModifiedSelectorTest { sel.isSelected(base, "file2", file2); assertFalse("Cache must not be saved after 2nd selection.", cache.saved); switch (kind) { - case 1 : project.fireTaskFinished(); break; - case 2 : project.fireTargetFinished(); break; - case 3 : project.fireBuildFinished(); break; + case 1 : + project.fireTaskFinished(); + break; + case 2 : + project.fireTargetFinished(); + break; + case 3 : + project.fireBuildFinished(); + break; } - assertTrue("Cache must be saved after " + kinds[kind-1] + "Finished-Event.", cache.saved); + assertTrue("Cache must be saved after " + kinds[kind - 1] + "Finished-Event.", cache.saved); - // MockCache doesnt create a file - therefore no cleanup needed + // MockCache doesn't create a file - therefore no cleanup needed } @@ -291,8 +297,12 @@ public class ModifiedSelectorTest { int posEnd = s1.indexOf(" comparator="); String algo = s1.substring(posStart, posEnd); // '<' and '>' are only used if the algorithm has properties - if (algo.startsWith("<")) algo = algo.substring(1); - if (algo.endsWith(">")) algo = algo.substring(0, algo.length()-1); + if (algo.startsWith("<")) { + algo = algo.substring(1); + } + if (algo.endsWith(">")) { + algo = algo.substring(0, algo.length() - 1); + } // return the clean value return algo; } @@ -436,10 +446,10 @@ public class ModifiedSelectorTest { Object returned = it2.next(); boolean ok = (key1.equals(returned) || key2.equals(returned)); String msg = "Iterator returned unexpected value." - + " key1.equals(returned)="+key1.equals(returned) - + " key2.equals(returned)="+key2.equals(returned) - + " returned="+returned - + " ok="+ok; + + " key1.equals(returned)=" + key1.equals(returned) + + " key2.equals(returned)=" + key2.equals(returned) + + " returned=" + returned + + " ok=" + ok; assertTrue(msg, ok); // clear the cache @@ -533,25 +543,20 @@ public class ModifiedSelectorTest { } - - // ============== testcases for the comparator implementations ============== - @Test public void testEqualComparator() { EqualComparator comp = new EqualComparator(); doTest(comp); } - @Test public void testRuleComparator() { - RuleBasedCollator comp = (RuleBasedCollator)RuleBasedCollator.getInstance(); + RuleBasedCollator comp = (RuleBasedCollator) RuleBasedCollator.getInstance(); doTest(comp); } - @Test public void testEqualComparatorViaSelector() { ModifiedSelector s = new ModifiedSelector(); @@ -565,7 +570,6 @@ public class ModifiedSelectorTest { } } - @Test @Ignore("not yet supported see note in selector") public void testRuleComparatorViaSelector() { @@ -580,14 +584,12 @@ public class ModifiedSelectorTest { } } - @Test @Ignore("same logic as on algorithm, no testcases created") public void testCustomComparator() { // same logic as on algorithm, no testcases created } - @Test public void testResourceSelectorSimple() { BFT bft = new BFT(); @@ -637,20 +639,18 @@ public class ModifiedSelectorTest { assertTrue("Comparator gave wrong value.", comp.compare(o2, o3) == 0); } - // ===================== scenario tests ===================== - /** * Tests whether the seldirs attribute is used. */ @Test public void testSeldirs() { ModifiedSelector s = new ModifiedSelector(); - StringBuffer sbTrue = new StringBuffer(); - StringBuffer sbFalse = new StringBuffer(); - for (int i=0; i<selectorRule.getFiles().length; i++) { - if (selectorRule.getFiles()[i].isDirectory()) { + StringBuilder sbTrue = new StringBuilder(); + StringBuilder sbFalse = new StringBuilder(); + for (File file : selectorRule.getFiles()) { + if (file.isDirectory()) { sbTrue.append("T"); sbFalse.append("F"); } else { @@ -670,16 +670,15 @@ public class ModifiedSelectorTest { s.getCache().delete(); } - /** * Complex test scenario using default values (DigestAlgorithm with MD5, * PropertiesfileCache with file=cache.properties, EqualComparator - * and update=true). <ol> - * <li> try fist time --> should select all </li> - * <li> try second time --> should select no files (only directories) </li> - * <li> modify timestamp of one file and content of a nother one </li> - * <li> try third time --> should select only the file with modified - * content </li> + * and update=true). + * <ol><li>try fist time --> should select all</li> + * <li>try second time --> should select no files (only directories)</li> + * <li>modify timestamp of one file and content of another one</li> + * <li>try third time --> should select only the file with modified + * content</li></ol> */ @Test public void testScenario1() { @@ -718,9 +717,9 @@ public class ModifiedSelectorTest { // AccessObject to the test-Ant-environment bft = new BFT(); // give some values (via property file) to that environment - bft.writeProperties("f2name="+f2name); - bft.writeProperties("f3name="+f3name); - bft.writeProperties("f4name="+f4name); + bft.writeProperties("f2name=" + f2name); + bft.writeProperties("f3name=" + f3name); + bft.writeProperties("f4name=" + f4name); // call the target for making the files dirty bft.doTarget("modifiedselectortest-makeDirty"); @@ -737,13 +736,19 @@ public class ModifiedSelectorTest { // Mark all files which should be selected as (T)rue and all others // as (F)alse. Directories are always selected so they always are // (T)rue. - StringBuffer expected = new StringBuffer(); - for (int i=0; i<selectorRule.getFiles().length; i++) { + StringBuilder expected = new StringBuilder(); + for (int i = 0; i < selectorRule.getFiles().length; i++) { String ch = "F"; - if (selectorRule.getFiles()[i].isDirectory()) ch = "T"; // f2name shouldn't be selected: only timestamp has changed! - if (selectorRule.getFilenames()[i].equalsIgnoreCase(f3name)) ch = "T"; - if (selectorRule.getFilenames()[i].equalsIgnoreCase(f4name)) ch = "T"; + if (selectorRule.getFiles()[i].isDirectory()) { + ch = "T"; + } + if (selectorRule.getFilenames()[i].equalsIgnoreCase(f3name)) { + ch = "T"; + } + if (selectorRule.getFilenames()[i].equalsIgnoreCase(f4name)) { + ch = "T"; + } expected.append(ch); } @@ -751,35 +756,36 @@ public class ModifiedSelectorTest { "Wrong files selected. Differing files: " // info text + resolve(diff(expected.toString(), results)), // list of files expected.toString(), // expected result - results // result - ); - + results); // result } finally { // cleanup the environment - if (s!=null) s.getCache().delete(); - if (bft!=null) bft.deletePropertiesfile(); + if (s != null) { + s.getCache().delete(); + } + if (bft != null) { + bft.deletePropertiesfile(); + } } } /** * This scenario is based on scenario 1, but does not use any - * default value and its based on <custom> selector. Used values are:<ul> - * <li><b>Cache: </b> Propertyfile, - * cachefile={java.io.tmpdir}/mycache.txt </li> - * <li><b>Algorithm: </b> Digest - * algorithm=SHA, Provider=null </li> - * <li><b>Comparator: </b> java.text.RuleBasedCollator - * <li><b>Update: </b> true </li> + * default value and its based on <custom> selector. Used values are: + * <ul><li><b>Cache:</b> Propertyfile, + * cachefile={java.io.tmpdir}/mycache.txt</li> + * <li><b>Algorithm:</b> Digest + * algorithm=SHA, Provider=null</li> + * <li><b>Comparator:</b> java.text.RuleBasedCollator</li> + * <li><b>Update:</b> true</li></ul> */ @Test @Ignore("RuleBasedCollator not yet supported - see Selector:375 note") public void testScenario2() { ExtendSelector s = new ExtendSelector(); BFT bft = new BFT(); - String cachefile = System.getProperty("java.io.tmpdir")+"/mycache.txt"; + String cachefile = System.getProperty("java.io.tmpdir") + "/mycache.txt"; try { - s.setClassname("org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector"); s.addParam(createParam("cache.cachefile", cachefile)); @@ -797,29 +803,34 @@ public class ModifiedSelectorTest { String f2name = "tar/bz2/asf-logo-huge.tar.bz2"; String f3name = "asf-logo.gif.md5"; String f4name = "copy.filterset.filtered"; - bft.writeProperties("f2name="+f2name); - bft.writeProperties("f3name="+f3name); - bft.writeProperties("f4name="+f4name); + bft.writeProperties("f2name=" + f2name); + bft.writeProperties("f3name=" + f3name); + bft.writeProperties("f4name=" + f4name); bft.doTarget("modifiedselectortest-makeDirty"); // third run String results = selectorRule.selectionString(s); - StringBuffer expected = new StringBuffer(); - for (int i=0; i<selectorRule.getFilenames().length; i++) { + StringBuilder expected = new StringBuilder(); + for (int i = 0; i < selectorRule.getFilenames().length; i++) { String ch = "F"; - if (selectorRule.getFiles()[i].isDirectory()) ch = "T"; - if (selectorRule.getFilenames()[i].equalsIgnoreCase(f3name)) ch = "T"; - if (selectorRule.getFilenames()[i].equalsIgnoreCase(f4name)) ch = "T"; + if (selectorRule.getFiles()[i].isDirectory()) { + ch = "T"; + } + if (selectorRule.getFilenames()[i].equalsIgnoreCase(f3name)) { + ch = "T"; + } + if (selectorRule.getFilenames()[i].equalsIgnoreCase(f4name)) { + ch = "T"; + } expected.append(ch); } assertEquals( - "Wrong files selected. Differing files: " // info text + "Wrong files selected. Differing files: " // info text + resolve(diff(expected.toString(), results)), // list of files expected.toString(), // expected result - results // result - ); + results); // result } finally { // cleanup the environment - (new java.io.File(cachefile)).delete(); + (new File(cachefile)).delete(); bft.deletePropertiesfile(); } } @@ -827,21 +838,21 @@ public class ModifiedSelectorTest { @Test public void testScenarioCoreSelectorDefaults() { - Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home") ); + Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home")); doScenarioTest("modifiedselectortest-scenario-coreselector-defaults", "cache.properties"); } @Test public void testScenarioCoreSelectorSettings() { - Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home") ); + Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home")); doScenarioTest("modifiedselectortest-scenario-coreselector-settings", "core.cache.properties"); } @Test public void testScenarioCustomSelectorSettings() { - Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home") ); + Assume.assumeNotNull("Ant home not set", selectorRule.getProject().getProperty("ant.home")); doScenarioTest("modifiedselectortest-scenario-customselector-settings", "core.cache.properties"); } @@ -862,9 +873,9 @@ public class ModifiedSelectorTest { // do the checks assertTrue("Cache file not created.", cachefile.exists()); - assertTrue("Not enough files copied on first time.", to1.list().length>5); - assertTrue("Too much files copied on second time.", to2.list().length==0); - assertTrue("Too much files copied on third time.", to3.list().length==2); + assertTrue("Not enough files copied on first time.", to1.list().length > 5); + assertTrue("Too much files copied on second time.", to2.list().length == 0); + assertTrue("Too much files copied on third time.", to3.list().length == 2); // don't catch the JUnit exceptions } finally { bft.doTarget("modifiedselectortest-scenario-clean"); @@ -934,10 +945,9 @@ public class ModifiedSelectorTest { File dir = getProject().getBaseDir(); File file = new File(dir, propfile); try { - java.io.FileWriter out = - new java.io.FileWriter(file.getAbsolutePath(), true); + FileWriter out = new FileWriter(file.getAbsolutePath(), true); out.write(line); - out.write(System.getProperty("line.separator")); + out.write(System.lineSeparator()); out.flush(); out.close(); } catch (Exception e) { @@ -946,7 +956,9 @@ public class ModifiedSelectorTest { } public void deletePropertiesfile() { - if (!isConfigured) setUp(); + if (!isConfigured) { + setUp(); + } new File(getProject().getBaseDir(), propfile).delete(); } @@ -956,8 +968,7 @@ public class ModifiedSelectorTest { cacheFile.delete(); } - }//class-BFT - + } /** * MockProject wrappes a very small ant project (one target, one task) @@ -968,7 +979,7 @@ public class ModifiedSelectorTest { private Target target; public MockProject() { - task = new Task(){ + task = new Task() { public void execute() { } }; @@ -983,22 +994,25 @@ public class ModifiedSelectorTest { public void fireBuildFinished() { super.fireBuildFinished(null); } + @SuppressWarnings("unused") public void fireSubBuildFinished() { super.fireSubBuildFinished(null); } + @SuppressWarnings("unused") public void fireTargetStarted() { super.fireTargetStarted(target); } public void fireTargetFinished() { super.fireTargetFinished(target, null); } + @SuppressWarnings("unused") public void fireTaskStarted() { super.fireTaskStarted(task); } public void fireTaskFinished() { super.fireTaskFinished(task, null); } - }//class-MockProject + } /** @@ -1026,13 +1040,9 @@ public class ModifiedSelectorTest { int length1 = expected.length(); int length2 = result.length(); int min = (length1 > length2) ? length2 : length1; - StringBuffer sb = new StringBuffer(); - for (int i=0; i<min; i++) { - sb.append( - (expected.charAt(i) == result.charAt(i)) - ? "-" - : "X" - ); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < min; i++) { + sb.append((expected.charAt(i) == result.charAt(i)) ? "-" : "X"); } return sb.toString(); } @@ -1045,14 +1055,12 @@ public class ModifiedSelectorTest { * separated with semicolons ';' */ private String resolve(String filelist) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int min = (selectorRule.getFilenames().length > filelist.length()) - ? filelist.length() - : selectorRule.getFilenames().length; - for (int i=0; i<min; i++) { - if ('X'==filelist.charAt(i)) { - sb.append(selectorRule.getFilenames()[i]); - sb.append(";"); + ? filelist.length() : selectorRule.getFilenames().length; + for (int i = 0; i < min; i++) { + if ('X' == filelist.charAt(i)) { + sb.append(selectorRule.getFilenames()[i]).append(";"); } } return sb.toString(); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java index f273334..07b664d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java @@ -122,7 +122,6 @@ public class PresentSelectorTest { results = selectorRule.selectionString(s); assertEquals("FFTFFFFFFFFF", results); - s = new PresentSelector(); subdir = new File(selectorRule.getOutputDir(), "selectortest2"); s.setTargetdir(subdir); @@ -130,8 +129,6 @@ public class PresentSelectorTest { assertEquals("TTTFFTTTTTTT", results); results = selectorRule.selectionString(s); assertEquals("TTTFFTTTTTTT", results); - - } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java index 37f41a5..23ba36f 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java @@ -130,8 +130,6 @@ public class SizeSelectorTest { SizeSelector.SizeComparisons more = new SizeSelector.SizeComparisons(); more.setValue("more"); - - s = new SizeSelector(); s.setValue(10); s.setWhen(less); @@ -185,8 +183,6 @@ public class SizeSelectorTest { s.setParameters(params); results = selectorRule.selectionString(s); assertEquals("TFFFFFFTFFTT", results); - - } @Test http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java index f775f59..1124a48 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java @@ -34,7 +34,6 @@ public class TypeSelectorTest { @Rule public BaseSelectorRule selectorRule = new BaseSelectorRule(); - /** * Test the code that validates the selector. */ @@ -42,11 +41,11 @@ public class TypeSelectorTest { public void testValidate() { TypeSelector s = new TypeSelector(); try { - s.isSelected(selectorRule.getProject().getBaseDir(), selectorRule.getFilenames()[0] ,selectorRule.getFiles()[0]); + s.isSelected(selectorRule.getProject().getBaseDir(), + selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); fail("TypeSelector did not check for required fields"); } catch (BuildException be1) { - assertEquals("The type attribute is required" - , be1.getMessage()); + assertEquals("The type attribute is required", be1.getMessage()); } } @@ -63,8 +62,6 @@ public class TypeSelectorTest { TypeSelector.FileType file = new TypeSelector.FileType(); file.setValue("file"); - - s = new TypeSelector(); s.setType(directory); results = selectorRule.selectionString(s); @@ -74,8 +71,6 @@ public class TypeSelectorTest { s.setType(file); results = selectorRule.selectionString(s); assertEquals("FTTTTTTTTTTF", results); - - } } http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java b/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java index fe09ce9..f9bf08b 100644 --- a/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java @@ -240,10 +240,7 @@ public class DOMElementWriterTest { StringWriter sw = new StringWriter(); DOMElementWriter w = - new DOMElementWriter(false, - new DOMElementWriter.XmlNamespacePolicy(false, - true) - ); + new DOMElementWriter(false, new DOMElementWriter.XmlNamespacePolicy(false, true)); w.write(root, sw, 0, " "); assertEquals("<root ns0:bar=\"baz\" xmlns:ns0=\"urn:foo2\" />" + StringUtils.LINE_SEP, sw.toString()); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java index 4f5aa84..e7edf23 100644 --- a/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java @@ -32,20 +32,20 @@ public class DateUtilsTest { @Test - public void testElapsedTime(){ - String text = DateUtils.formatElapsedTime(50*1000); + public void testElapsedTime() { + String text = DateUtils.formatElapsedTime(50 * 1000); assertEquals("50 seconds", text); - text = DateUtils.formatElapsedTime(65*1000); + text = DateUtils.formatElapsedTime(65 * 1000); assertEquals("1 minute 5 seconds", text); - text = DateUtils.formatElapsedTime(120*1000); + text = DateUtils.formatElapsedTime(120 * 1000); assertEquals("2 minutes 0 seconds", text); - text = DateUtils.formatElapsedTime(121*1000); + text = DateUtils.formatElapsedTime(121 * 1000); assertEquals("2 minutes 1 second", text); } // https://issues.apache.org/bugzilla/show_bug.cgi?id=44659 @Test - public void testLongElapsedTime(){ + public void testLongElapsedTime() { assertEquals("2926 minutes 13 seconds", DateUtils.formatElapsedTime(1000 * 175573)); assertEquals("153722867280912 minutes 55 seconds", @@ -53,7 +53,7 @@ public class DateUtilsTest { } @Test - public void testDateTimeISO(){ + public void testDateTimeISO() { TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); Calendar cal = Calendar.getInstance(timeZone); cal.set(2002,1,23,10,11,12); @@ -63,7 +63,7 @@ public class DateUtilsTest { } @Test - public void testDateISO(){ + public void testDateISO() { TimeZone timeZone = TimeZone.getTimeZone("GMT"); Calendar cal = Calendar.getInstance(timeZone); cal.set(2002,1,23); @@ -73,7 +73,7 @@ public class DateUtilsTest { } @Test - public void testTimeISODate(){ + public void testTimeISODate() { // make sure that elapsed time in set via date works TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); Calendar cal = Calendar.getInstance(timeZone); @@ -84,9 +84,9 @@ public class DateUtilsTest { } @Test - public void testTimeISO(){ + public void testTimeISO() { // make sure that elapsed time in ms works - long ms = (20*3600 + 11*60 + 12)*1000; + long ms = (20 * 3600 + 11 * 60 + 12) * 1000; String text = DateUtils.format(ms, DateUtils.ISO8601_TIME_PATTERN); assertEquals("20:11:12", text); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java b/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java index bcda609..ad1f8e0 100644 --- a/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java @@ -21,41 +21,47 @@ package org.apache.tools.ant.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + import org.junit.Test; -@SuppressWarnings("ResultOfObjectAllocationIgnored") public class DeweyDecimalTest { @Test public void parse() { assertEquals("1.2.3", new DeweyDecimal("1.2.3").toString()); } - @Test(expected=NumberFormatException.class) public void misparseEmpty() { + @Test(expected = NumberFormatException.class) + public void misparseEmpty() { new DeweyDecimal("1..2"); } - @Test(expected=NumberFormatException.class) public void misparseNonNumeric() { + @Test(expected = NumberFormatException.class) + public void misparseNonNumeric() { new DeweyDecimal("1.2.3-beta-5"); } - @Test(expected=NumberFormatException.class) public void misparseFinalDot() { + @Test(expected = NumberFormatException.class) + public void misparseFinalDot() { new DeweyDecimal("1.2."); } // TODO initial dots, empty string, null, negative numbers, ... - @Test public void testHashCode() { + @Test + public void testHashCode() { assertEquals(new DeweyDecimal("1.2.3").hashCode(), new DeweyDecimal("1.2.3").hashCode()); } - @Test public void testEquals() { + @Test + public void testEquals() { assertTrue(new DeweyDecimal("1.2.3").equals(new DeweyDecimal("1.2.3"))); assertFalse(new DeweyDecimal("1.2.3").equals(new DeweyDecimal("1.2.4"))); assertTrue(new DeweyDecimal("1.2.0").equals(new DeweyDecimal("1.2"))); assertTrue(new DeweyDecimal("1.2").equals(new DeweyDecimal("1.2.0"))); } - @Test public void compareTo() { + @Test + public void compareTo() { assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2")) > 0); assertTrue(new DeweyDecimal("1.2").compareTo(new DeweyDecimal("1.2.3")) < 0); assertTrue(new DeweyDecimal("1.2.3").compareTo(new DeweyDecimal("1.2.3")) == 0); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java index e016657..c520156 100644 --- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java @@ -44,7 +44,6 @@ public class FileUtilsTest { private File removeThis; private String root; - @Before public void setUp() { // Windows adds the drive letter in uppercase, unless you run Cygwin @@ -54,8 +53,7 @@ public class FileUtilsTest { @After public void tearDown() { if (removeThis != null && removeThis.exists()) { - if (!removeThis.delete()) - { + if (!removeThis.delete()) { removeThis.deleteOnExit(); } } @@ -69,7 +67,7 @@ public class FileUtilsTest { * behaviour and will help catch any regression in Java itself, * so is worth retaining. * @see FileUtils#setFileLastModified(java.io.File, long) - * @throws IOException + * @throws IOException if something goes wrong */ @Test public void testSetLastModified() throws IOException { @@ -87,7 +85,7 @@ public class FileUtilsTest { assertTrue(secondModTime > modTime); // number of milliseconds in a day - final int millisperday=24 * 3600 * 1000; + final int millisperday = 24 * 3600 * 1000; // in a previous version, the date of the file was set to 123456 // milliseconds since 01.01.1970 // it did not work on a computer running JDK 1.4.1_02 + Windows 2000 @@ -342,8 +340,7 @@ public class FileUtilsTest { * Test createTempFile */ @Test - public void testCreateTempFile() - { + public void testCreateTempFile() { // null parent dir File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", null, false, true); String tmploc = System.getProperty("java.io.tmpdir"); @@ -476,9 +473,7 @@ public class FileUtilsTest { if (Os.isFamily("dos") || Os.isFamily("netware")) { dosRoot = System.getProperty("user.dir") .substring(0, 3).replace(File.separatorChar, '/'); - } - else - { + } else { dosRoot = ""; } if (Os.isFamily("dos")) { @@ -554,13 +549,13 @@ public class FileUtilsTest { public void testModificationTests() { //get a time - long firstTime=System.currentTimeMillis(); + long firstTime = System.currentTimeMillis(); //add some time. We assume no OS has a granularity this bad - long secondTime=firstTime+60000; -/* + long secondTime = firstTime + 60000; + /* assertTrue("same timestamp is up to date", fu.isUpToDate(firstTime, firstTime)); - */ + */ //check that older is up to date with a newer dest assertTrue("older source files are up to date", http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java index 105c33d..7950771 100644 --- a/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java @@ -29,9 +29,9 @@ import static org.junit.Assert.assertTrue; public class JAXPUtilsTest { @Test - public void testGetSystemId(){ + public void testGetSystemId() { File file = null; - if ( File.separatorChar == '\\' ){ + if (File.separatorChar == '\\') { file = new File("d:\\jdk"); } else { file = new File("/user/local/bin"); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java index cc786ca..6b27652 100644 --- a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java @@ -57,9 +57,9 @@ public class JavaEnvUtilsTest { String j = JavaEnvUtils.getJreExecutable("java"); assertTrue(j.endsWith(".exe")); - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); + assertTrue(j + " is absolute", (new File(j)).isAbsolute()); try { - assertTrue(j+" is normalized and in the JRE dir", + assertTrue(j + " is normalized and in the JRE dir", j.startsWith(javaHome)); } catch (AssertionFailedError e) { // java.home is bogus @@ -69,12 +69,12 @@ public class JavaEnvUtilsTest { j = JavaEnvUtils.getJdkExecutable("javac"); assertTrue(j.endsWith(".exe")); try { - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); + assertTrue(j + " is absolute", (new File(j)).isAbsolute()); String javaHomeParent = - FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); - assertTrue(j+" is normalized and in the JDK dir", + FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); + assertTrue(j + " is normalized and in the JDK dir", j.startsWith(javaHomeParent)); - assertTrue(j+" is normalized and not in the JRE dir", + assertTrue(j + " is normalized and not in the JRE dir", !j.startsWith(javaHome)); } catch (AssertionFailedError e) { @@ -101,19 +101,19 @@ public class JavaEnvUtilsTest { if (!extension.equals("")) { assertTrue(j.endsWith(extension)); } - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); - assertTrue(j+" is normalized and in the JRE dir", + assertTrue(j + " is absolute", (new File(j)).isAbsolute()); + assertTrue(j + " is normalized and in the JRE dir", j.startsWith(javaHome)); j = JavaEnvUtils.getJdkExecutable("javac"); if (!extension.equals("")) { assertTrue(j.endsWith(extension)); } - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); + assertTrue(j + " is absolute", (new File(j)).isAbsolute()); String javaHomeParent = - FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); - assertTrue(j+" is normalized and in the JDK dir", + FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); + assertTrue(j + " is normalized and in the JDK dir", j.startsWith(javaHomeParent)); if ((Os.isFamily("mac") && JavaEnvUtils.getJavaVersionNumber() <= JavaEnvUtils.VERSION_1_6) @@ -125,15 +125,14 @@ public class JavaEnvUtilsTest { !j.startsWith(javaHome)); } - assertEquals("foo"+extension, + assertEquals("foo" + extension, JavaEnvUtils.getJreExecutable("foo")); - assertEquals("foo"+extension, + assertEquals("foo" + extension, JavaEnvUtils.getJdkExecutable("foo")); } @Test - public void testIsAtLeastJavaVersion() - { + public void testIsAtLeastJavaVersion() { assertTrue( "Current java version is not at least the current java version...", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.getJavaVersion())); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java index 89cd3da..48c52b3 100644 --- a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java @@ -74,7 +74,7 @@ public class LayoutPreservingPropertiesTest { lpf.setProperty(" prop one ", " leading and trailing spaces "); lpf.setProperty("prop\ttwo", "contains\ttab"); lpf.setProperty("prop\nthree", "contains\nnewline"); - lpf.setProperty("prop\rfour", "contains\rcarraige return"); + lpf.setProperty("prop\rfour", "contains\rcarriage return"); lpf.setProperty("prop\ffive", "contains\fform feed"); lpf.setProperty("prop\\six", "contains\\backslash"); lpf.setProperty("prop:seven", "contains:colon"); @@ -93,7 +93,7 @@ public class LayoutPreservingPropertiesTest { + " spaces ") > -1); assertTrue(s.indexOf("prop\\ttwo=contains\\ttab") > -1); assertTrue(s.indexOf("prop\\nthree=contains\\nnewline") > -1); - assertTrue(s.indexOf("prop\\rfour=contains\\rcarraige return") > -1); + assertTrue(s.indexOf("prop\\rfour=contains\\rcarriage return") > -1); assertTrue(s.indexOf("prop\\\\six=contains\\\\backslash") > -1); assertTrue(s.indexOf("prop\\:seven=contains\\:colon") > -1); assertTrue(s.indexOf("prop\\=eight=contains\\=equals") > -1); http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java b/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java index 1fa23e8..d4b417d 100644 --- a/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java @@ -27,7 +27,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - public class LineOrientedOutputStreamTest { private static String LINE = "This is a line"; @@ -61,21 +60,21 @@ public class LineOrientedOutputStreamTest { } @Test - public void testLineWithCariagereturnArray() throws IOException { + public void testLineWithCarriageReturnArray() throws IOException { writeByteArray(); writeAsArray('\r'); stream.assertInvoked(); } @Test - public void testLineWithCariagereturnSingleBytes() throws IOException { + public void testLineWithCarriageReturnSingleBytes() throws IOException { writeSingleBytes(); stream.write('\r'); stream.assertInvoked(); } @Test - public void testLineWithCariagereturnLinefeedArray() throws IOException { + public void testLineWithCarriageReturnLineFeedArray() throws IOException { writeByteArray(); writeAsArray('\r'); writeAsArray('\n'); @@ -83,7 +82,7 @@ public class LineOrientedOutputStreamTest { } @Test - public void testLineWithCariagereturnLinefeedSingleBytes() throws IOException { + public void testLineWithCarriageReturnLineFeedSingleBytes() throws IOException { writeSingleBytes(); stream.write('\r'); stream.write('\n'); @@ -125,9 +124,8 @@ public class LineOrientedOutputStreamTest { } private void writeSingleBytes() throws IOException { - byte[] b = LINE.getBytes(); - for (int i = 0; i < b.length; i++) { - stream.write(b[i]); + for (byte b : LINE.getBytes()) { + stream.write(b); } } @@ -150,4 +148,4 @@ public class LineOrientedOutputStreamTest { assertTrue("No output", !invoked); } } -}// LineOrientedOutputStreamTest +} http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java index bd07251..1951a8a 100644 --- a/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java @@ -43,6 +43,7 @@ public class ReaderInputStreamTest { compareBytes("a", "utf-16"); } + @SuppressWarnings("resource") @Test public void testSimpleAbc16() throws Exception { // THIS WILL FAIL. @@ -51,7 +52,7 @@ public class ReaderInputStreamTest { int pos = 0; ReaderInputStream r = new ReaderInputStream( new StringReader("abc"), "utf-16"); - for (int i = 0; true; ++i) { + while (true) { int res = r.read(); if (res == -1) { break; @@ -63,6 +64,7 @@ public class ReaderInputStreamTest { new String(bytes, 0, bytes.length, "utf-16"); } + @SuppressWarnings("resource") @Test public void testReadZero() throws Exception { ReaderInputStream r = new ReaderInputStream( @@ -88,7 +90,8 @@ public class ReaderInputStreamTest { ReaderInputStream r = null; FileInputStream utf8 = null; try { - fin = new InputStreamReader(new FileInputStream(new File(System.getProperty("root"), "src/tests/antunit/taskdefs/exec/input/iso8859-1")), + fin = new InputStreamReader(new FileInputStream(new File(System.getProperty("root"), + "src/tests/antunit/taskdefs/exec/input/iso8859-1")), "ISO8859_1"); r = new ReaderInputStream(fin, "UTF8"); @@ -99,7 +102,8 @@ public class ReaderInputStreamTest { b = r.read(); } - utf8 = new FileInputStream(new File(System.getProperty("root"), "src/tests/antunit/taskdefs/exec/expected/utf-8")); + utf8 = new FileInputStream(new File(System.getProperty("root"), + "src/tests/antunit/taskdefs/exec/expected/utf-8")); ByteArrayOutputStream expectedOS = new ByteArrayOutputStream(); b = utf8.read(); while (b > -1) { @@ -120,9 +124,10 @@ public class ReaderInputStreamTest { } } + @SuppressWarnings("resource") private void compareBytes(String s, String encoding) throws Exception { byte[] expected = s.getBytes(encoding); - + ReaderInputStream r = new ReaderInputStream( new StringReader(s), encoding); for (int i = 0; i < expected.length; ++i) { http://git-wip-us.apache.org/repos/asf/ant/blob/572a2490/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java index 96cc9cb..50247b1 100644 --- a/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java @@ -55,8 +55,12 @@ public class ResourceUtilsTest implements ResourceFactory, FileNameMapper { } /* ============ FileNameMapper interface ======================= */ - public void setFrom(String s) {} - public void setTo(String s) {} + public void setFrom(String s) { + } + + public void setTo(String s) { + } + public String[] mapFileName(String s) { return new String[] {"fred colon", "carrot ironfoundersson"}; }
