You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2017/12/01 20:48:55 UTC
[2/6] ant git commit: Checkstyle: mostly whitespace
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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 4f9d565..0076c6d 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
@@ -22,7 +22,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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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 a07daf2..28e1386 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 (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
@@ -124,15 +124,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/866ce9f5/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/866ce9f5/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/866ce9f5/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 b31af33..0e4f009 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,11 +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);
+ ReaderInputStream r = new ReaderInputStream(new StringReader(s), encoding);
for (int i = 0; i < expected.length; ++i) {
int expect = expected[i] & 0xFF;
int read = r.read();
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/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"};
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
index cf7d9b7..4c3220a 100644
--- a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
@@ -17,21 +17,24 @@
*/
package org.apache.tools.ant.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Vector;
import org.junit.Test;
-import static org.junit.Assert.*;
-
/**
* Test for StringUtils
*/
public class StringUtilsTest {
@Test
- public void testSplit(){
+ public void testSplit() {
final String data = "a,b,,";
Vector<String> res = StringUtils.split(data, ',');
assertEquals(4, res.size());
@@ -42,7 +45,7 @@ public class StringUtilsTest {
}
@Test
- public void testSplitLines(){
+ public void testSplitLines() {
final String data = "a\r\nb\nc\nd\ne";
Vector<String> res = StringUtils.lineSplit(data);
assertEquals(5, res.size());
@@ -63,42 +66,42 @@ public class StringUtilsTest {
@Test
public void testEndsWithBothEmpty() {
- assertTrue( StringUtils.endsWith( new StringBuffer(), "") );
+ assertTrue(StringUtils.endsWith(new StringBuffer(), ""));
}
@Test
public void testEndsWithEmptyString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") );
+ assertTrue(StringUtils.endsWith(new StringBuffer("12234545"), ""));
}
@Test
public void testEndsWithShorterString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78"));
+ assertTrue(StringUtils.endsWith(new StringBuffer("12345678"), "78"));
}
@Test
public void testEndsWithSameString() {
- assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123"));
+ assertTrue(StringUtils.endsWith(new StringBuffer("123"), "123"));
}
@Test
public void testEndsWithLongerString() {
- assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245"));
+ assertFalse(StringUtils.endsWith(new StringBuffer("12"), "1245"));
}
@Test
public void testEndsWithNoMatch() {
- assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789"));
+ assertFalse(StringUtils.endsWith(new StringBuffer("12345678"), "789"));
}
@Test
public void testEndsWithEmptyBuffer() {
- assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") );
+ assertFalse(StringUtils.endsWith(new StringBuffer(""), "12345667"));
}
@Test
public void testEndsWithJDKPerf() {
- StringBuffer buf = getFilledBuffer(1024*300, 'a');
+ StringBuffer buf = getFilledBuffer(1024 * 300, 'a');
for (int i = 0; i < 1000; i++) {
assertTrue(buf.toString().endsWith("aa"));
}
@@ -106,7 +109,7 @@ public class StringUtilsTest {
@Test
public void testEndsWithPerf() {
- StringBuffer buf = getFilledBuffer(1024*300, 'a');
+ StringBuffer buf = getFilledBuffer(1024 * 300, 'a');
for (int i = 0; i < 1000; i++) {
assertTrue(StringUtils.endsWith(buf, "aa"));
}
@@ -114,7 +117,9 @@ public class StringUtilsTest {
private StringBuffer getFilledBuffer(int size, char ch) {
StringBuffer buf = new StringBuffer(size);
- for (int i = 0; i < size; i++) { buf.append(ch); };
+ for (int i = 0; i < size; i++) {
+ buf.append(ch);
+ }
return buf;
}
@@ -140,15 +145,13 @@ public class StringUtilsTest {
String suffix = "Suffix";
String input = prefix + name + suffix;
assertEquals(
- "Does not remove the suffix right.",
- prefix + name,
- StringUtils.removeSuffix(input, suffix)
- );
+ "Does not remove the suffix right.",
+ prefix + name,
+ StringUtils.removeSuffix(input, suffix));
assertEquals(
- "Should leave the string unattended.",
- prefix + name + suffix,
- StringUtils.removeSuffix(input, "bla")
- );
+ "Should leave the string unattended.",
+ prefix + name + suffix,
+ StringUtils.removeSuffix(input, "bla"));
}
@Test
@@ -157,36 +160,32 @@ public class StringUtilsTest {
String name = "Name";
String suffix = "Suffix";
String input = prefix + name + suffix;
- assertEquals(
- "Does not remove the prefix right.",
- name + suffix,
- StringUtils.removePrefix(input, prefix)
- );
- assertEquals(
- "Should leave the string unattended.",
- prefix + name + suffix,
- StringUtils.removePrefix(input, "bla")
- );
+ assertEquals("Does not remove the prefix right.",
+ name + suffix,
+ StringUtils.removePrefix(input, prefix));
+ assertEquals("Should leave the string unattended.",
+ prefix + name + suffix,
+ StringUtils.removePrefix(input, "bla"));
}
-
+
@Test
public void testJoin() {
assertEquals("a, b, c", StringUtils.join(Arrays.asList("a", "b", "c"), ", "));
}
-
+
@Test
public void testJoinEmptyArray() {
- assertEquals("", StringUtils.join(new String[]{}, ", "));
+ assertEquals("", StringUtils.join(new String[] {}, ", "));
}
-
+
@Test
public void testJoinNullCollection() {
- assertEquals("", StringUtils.join((Collection<String>)null, ", "));
+ assertEquals("", StringUtils.join((Collection<String>) null, ", "));
}
@Test
public void testJoinNullArray() {
- assertEquals("", StringUtils.join((String[])null, ", "));
+ assertEquals("", StringUtils.join((String[]) null, ", "));
}
@Test
@@ -195,22 +194,22 @@ public class StringUtilsTest {
}
@Test
- public void testTrimToNullWithNullInput(){
+ public void testTrimToNullWithNullInput() {
assertNull(StringUtils.trimToNull(null));
}
@Test
- public void testTrimToNullWithEmptyInput(){
+ public void testTrimToNullWithEmptyInput() {
assertNull(StringUtils.trimToNull(""));
}
@Test
- public void testTrimToNullWithBlankSpaceInput(){
+ public void testTrimToNullWithBlankSpaceInput() {
assertNull(StringUtils.trimToNull(" "));
}
@Test
- public void testTrimToNullWithInputPaddedWithSpace(){
- assertEquals("aaBcDeF",StringUtils.trimToNull(" aaBcDeF "));
+ public void testTrimToNullWithInputPaddedWithSpace() {
+ assertEquals("aaBcDeF", StringUtils.trimToNull(" aaBcDeF "));
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java
index 7586950..c59154d 100644
--- a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java
@@ -29,7 +29,7 @@ public class UnPackageNameMapperTest {
UnPackageNameMapper mapper = new UnPackageNameMapper();
mapper.setFrom("TEST-*.xml");
mapper.setTo("*.java");
- String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml";
+ String file = "TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml";
String result = mapper.mapFileName(file)[0];
String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java");
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java
index 3340b59..b93beb3 100644
--- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java
@@ -59,5 +59,6 @@ public class JakartaRegexpMatcherTest extends RegexpMatcherTest {
/**
* Fails for "default" mode.
*/
- protected void doEndTest2(String text) {}
+ protected void doEndTest2(String text) {
+ }
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java
index 078fbb1..8edc13c 100644
--- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java
@@ -40,7 +40,7 @@ public class JakartaRegexpRegexpTest extends RegexpTest {
try {
super.testWindowsLineSeparator2();
fail("Should trigger when this bug is fixed. {@since 1.2}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -51,12 +51,13 @@ public class JakartaRegexpRegexpTest extends RegexpTest {
try {
super.testUnixLineSeparator();
fail("Should trigger once this bug is fixed. {@since 1.2}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
/**
* Fails for "default" mode.
*/
- protected void doEndTest2(String text) {}
+ protected void doEndTest2(String text) {
+ }
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java
index c042e71..40f6dca 100644
--- a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java
@@ -40,7 +40,7 @@ public class Jdk14RegexpMatcherTest extends RegexpMatcherTest {
try {
super.testParagraphCharacter();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -48,7 +48,7 @@ public class Jdk14RegexpMatcherTest extends RegexpMatcherTest {
try {
super.testLineSeparatorCharacter();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -56,7 +56,7 @@ public class Jdk14RegexpMatcherTest extends RegexpMatcherTest {
try {
super.testStandaloneCR();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -64,7 +64,7 @@ public class Jdk14RegexpMatcherTest extends RegexpMatcherTest {
try {
super.testWindowsLineSeparator();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java
index 2b60406..5f5342e 100644
--- a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java
@@ -40,7 +40,7 @@ public class Jdk14RegexpRegexpTest extends RegexpTest {
try {
super.testParagraphCharacter();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -48,7 +48,7 @@ public class Jdk14RegexpRegexpTest extends RegexpTest {
try {
super.testLineSeparatorCharacter();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -56,7 +56,7 @@ public class Jdk14RegexpRegexpTest extends RegexpTest {
try {
super.testStandaloneCR();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
@@ -64,7 +64,7 @@ public class Jdk14RegexpRegexpTest extends RegexpTest {
try {
super.testWindowsLineSeparator();
fail("Should trigger once fixed. {@since JDK 1.4RC1}");
- } catch (AssertionFailedError e){
+ } catch (AssertionFailedError e) {
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
index 0950827..3129e68 100644
--- a/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
+++ b/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
@@ -35,7 +35,9 @@ public abstract class RegexpMatcherTest extends TestCase {
public abstract RegexpMatcher getImplementation();
- protected final RegexpMatcher getReg() {return reg;}
+ protected final RegexpMatcher getReg() {
+ return reg;
+ }
public RegexpMatcherTest(String name) {
super(name);
@@ -152,7 +154,7 @@ public abstract class RegexpMatcherTest extends TestCase {
public void testMultiVersusSingleLine() throws IOException {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("Line1").append(UNIX_LINE);
buf.append("starttest Line2").append(UNIX_LINE);
buf.append("Line3 endtest").append(UNIX_LINE);
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java b/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java
index 50e0e57..88b500a 100644
--- a/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java
+++ b/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
public class CBZip2StreamTest {
+ @SuppressWarnings("resource")
@Test
public void testNullPointer() throws IOException {
try {