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:56 UTC
[3/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/taskdefs/optional/junit/JUnitTestRunnerTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
index 7c0fa16..2579c82 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
@@ -17,10 +17,11 @@
*/
package org.apache.tools.ant.taskdefs.optional.junit;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -36,13 +37,11 @@ import org.junit.Test;
* They must be enhanced with time.
*
*/
-public class JUnitTestRunnerTest{
-
-
+public class JUnitTestRunnerTest {
// check that a valid method name generates no errors
@Test
- public void testValidMethod(){
+ public void testValidMethod() {
TestRunner runner = createRunnerForTestMethod(ValidMethodTestCase.class,"testA");
runner.run();
assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode());
@@ -50,7 +49,7 @@ public class JUnitTestRunnerTest{
// check that having an invalid method name generates an error
@Test
- public void testInvalidMethod(){
+ public void testInvalidMethod() {
TestRunner runner = createRunnerForTestMethod(InvalidMethodTestCase.class,"testInvalid");
runner.run();
String error = runner.getFormatter().getError();
@@ -60,7 +59,7 @@ public class JUnitTestRunnerTest{
// check that having no suite generates no errors
@Test
- public void testNoSuite(){
+ public void testNoSuite() {
TestRunner runner = createRunner(NoSuiteTestCase.class);
runner.run();
assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode());
@@ -68,7 +67,7 @@ public class JUnitTestRunnerTest{
// check that a suite generates no errors
@Test
- public void testSuite(){
+ public void testSuite() {
TestRunner runner = createRunner(SuiteTestCase.class);
runner.run();
assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode());
@@ -76,7 +75,7 @@ public class JUnitTestRunnerTest{
// check that an invalid suite generates an error.
@Test
- public void testInvalidSuite(){
+ public void testInvalidSuite() {
TestRunner runner = createRunner(InvalidSuiteTestCase.class);
runner.run();
String error = runner.getFormatter().getError();
@@ -87,7 +86,7 @@ public class JUnitTestRunnerTest{
// check that something which is not a testcase generates no errors
// at first even though this is incorrect.
@Test
- public void testNoTestCase(){
+ public void testNoTestCase() {
TestRunner runner = createRunner(NoTestCase.class);
runner.run();
// On junit3 this is a FAILURE, on junit4 this is an ERROR
@@ -102,7 +101,7 @@ public class JUnitTestRunnerTest{
// check that an exception in the constructor is noticed
@Test
- public void testInvalidTestCase(){
+ public void testInvalidTestCase() {
TestRunner runner = createRunner(InvalidTestCase.class);
runner.run();
// On junit3 this is a FAILURE, on junit4 this is an ERROR
@@ -118,7 +117,7 @@ public class JUnitTestRunnerTest{
// check that JUnit 4 synthetic AssertionFailedError gets message and cause from AssertionError
@Test
- public void testJUnit4AssertionError(){
+ public void testJUnit4AssertionError() {
TestRunner runner = createRunnerForTestMethod(AssertionErrorTest.class,"throwsAssertionError");
runner.run();
@@ -130,12 +129,12 @@ public class JUnitTestRunnerTest{
assertEquals("cause message", cause.getMessage());
}
- protected TestRunner createRunner(Class<?> clazz){
+ protected TestRunner createRunner(Class<?> clazz) {
return new TestRunner(new JUnitTest(clazz.getName()), null,
true, true, true);
}
- protected TestRunner createRunnerForTestMethod(Class<?> clazz, String method){
+ protected TestRunner createRunnerForTestMethod(Class<?> clazz, String method) {
return new TestRunner(new JUnitTest(clazz.getName()), new String[] {method},
true, true, true);
}
@@ -144,7 +143,7 @@ public class JUnitTestRunnerTest{
private final static class TestRunner extends JUnitTestRunner {
private ResultFormatter formatter = new ResultFormatter();
TestRunner(JUnitTest test, String[] methods, boolean haltonerror,
- boolean filtertrace, boolean haltonfailure){
+ boolean filtertrace, boolean haltonfailure) {
super(test, methods, haltonerror, filtertrace, haltonfailure,
false, false, TestRunner.class.getClassLoader());
// use the classloader that loaded this class otherwise
@@ -152,7 +151,7 @@ public class JUnitTestRunnerTest{
// is ran in non-forked mode.
addFormatter(formatter);
}
- ResultFormatter getFormatter(){
+ ResultFormatter getFormatter() {
return formatter;
}
}
@@ -161,13 +160,20 @@ public class JUnitTestRunnerTest{
private final static class ResultFormatter implements JUnitResultFormatter {
private AssertionFailedError failure;
private Throwable error;
- public void setSystemOutput(String output){}
- public void setSystemError(String output){}
- public void startTestSuite(JUnitTest suite) throws BuildException{}
- public void endTestSuite(JUnitTest suite) throws BuildException{}
- public void setOutput(java.io.OutputStream out){}
- public void startTest(junit.framework.Test t) {}
- public void endTest(junit.framework.Test test) {}
+ public void setSystemOutput(String output) {
+ }
+ public void setSystemError(String output) {
+ }
+ public void startTestSuite(JUnitTest suite) throws BuildException{
+ }
+ public void endTestSuite(JUnitTest suite) throws BuildException{
+ }
+ public void setOutput(OutputStream out) {
+ }
+ public void startTest(junit.framework.Test t) {
+ }
+ public void endTest(junit.framework.Test test) {
+ }
public void addFailure(junit.framework.Test test, AssertionFailedError t) {
failure = t;
}
@@ -177,8 +183,8 @@ public class JUnitTestRunnerTest{
public void addError(junit.framework.Test test, Throwable t) {
error = t;
}
- String getError(){
- if (error == null){
+ String getError() {
+ if (error == null) {
return "";
}
StringWriter sw = new StringWriter();
@@ -191,54 +197,64 @@ public class JUnitTestRunnerTest{
}
public static class InvalidMethodTestCase extends TestCase {
- public InvalidMethodTestCase(String name){ super(name); }
- public void testA(){
+ public InvalidMethodTestCase(String name) {
+ super(name);
+ }
+ public void testA() {
throw new NullPointerException("thrown on purpose");
}
}
public static class ValidMethodTestCase extends TestCase {
- public ValidMethodTestCase(String name){ super(name); }
- public void testA(){
+ public ValidMethodTestCase(String name) {
+ super(name);
+ }
+ public void testA() {
// expected to be executed
}
- public void testB(){
+ public void testB() {
// should not be executed
throw new NullPointerException("thrown on purpose");
}
}
public static class InvalidTestCase extends TestCase {
- public InvalidTestCase(String name){
+ public InvalidTestCase(String name) {
super(name);
throw new NullPointerException("thrown on purpose");
}
}
public static class NoSuiteTestCase extends TestCase {
- public NoSuiteTestCase(String name){ super(name); }
- public void testA(){}
+ public NoSuiteTestCase(String name) {
+ super(name);
+ }
+ public void testA() {
+ }
}
public static class SuiteTestCase extends NoSuiteTestCase {
- public SuiteTestCase(String name){ super(name); }
- public static junit.framework.Test suite(){
+ public SuiteTestCase(String name) {
+ super(name);
+ }
+ public static junit.framework.Test suite() {
return new TestSuite(SuiteTestCase.class);
}
}
public static class InvalidSuiteTestCase extends NoSuiteTestCase {
- public InvalidSuiteTestCase(String name){ super(name); }
- public static junit.framework.Test suite(){
+ public InvalidSuiteTestCase(String name) {
+ super(name);
+ }
+ public static junit.framework.Test suite() {
throw new NullPointerException("thrown on purpose");
}
}
public static class AssertionErrorTest {
- @Test public void throwsAssertionError() {
- AssertionError assertionError = new AssertionError("failure message");
- assertionError.initCause(new RuntimeException("cause message"));
- throw assertionError;
+ @Test
+ public void throwsAssertionError() {
+ throw new AssertionError("failure message", new RuntimeException("cause message"));
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
index 2f3fdb7..a4b8ce9 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
@@ -32,12 +32,9 @@ public class JUnitVersionHelperTest {
@Test
public void testMyOwnName() {
assertEquals("testMyOwnName",
- JUnitVersionHelper.getTestCaseName(
- JUnit4TestAdapterCache.getDefault().asTest(
- Description.createTestDescription(JUnitVersionHelperTest.class, "testMyOwnName")
- )
- )
- );
+ JUnitVersionHelper.getTestCaseName(JUnit4TestAdapterCache.getDefault()
+ .asTest(Description.createTestDescription(JUnitVersionHelperTest.class,
+ "testMyOwnName"))));
}
@Test
@@ -76,27 +73,38 @@ public class JUnitVersionHelperTest {
}
public static class Foo implements junit.framework.Test {
- public int countTestCases() {return 0;}
- public void run(TestResult result) {}
+ public int countTestCases() {
+ return 0;
+ }
+ public void run(TestResult result) {
+ }
}
public static class Foo1 extends Foo {
- public String getName() {return "I'm a foo";}
+ public String getName() {
+ return "I'm a foo";
+ }
}
public static class Foo2 extends Foo {
- public int getName() {return 1;}
+ public int getName() {
+ return 1;
+ }
}
public static class Foo3 extends Foo {
}
public static class Foo4 extends Foo {
- public String name() {return "I'm a foo, too";}
+ public String name() {
+ return "I'm a foo, too";
+ }
}
public static class Foo5 extends TestCase {
- public String getName() {return "overridden getName";}
+ public String getName() {
+ return "overridden getName";
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
index 1509894..ab8ccda 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
@@ -17,7 +17,6 @@
*/
package org.apache.tools.ant.taskdefs.optional.junit;
-
import org.junit.Test;
public class Sleeper {
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
index c8636b0..c3530ae 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
@@ -44,7 +44,9 @@ public class XMLResultAggregatorTest {
}
final File d = new File(System.getProperty("java.io.tmpdir"), "XMLResultAggregatorTest");
if (d.exists()) {
- new Delete() {{removeDir(d);}}; // is there no utility method for this?
+ new Delete() {
+ { removeDir(d); }
+ }; // is there no utility method for this?
}
assertTrue(d.getAbsolutePath(), d.mkdir());
File xml = new File(d, "x.xml");
@@ -72,7 +74,8 @@ public class XMLResultAggregatorTest {
FileSet fs = new FileSet();
fs.setFile(xml);
task.addFileSet(fs);
- /* getResourceAsStream override unnecessary on JDK 7. Ought to work around JAXP #6723276 in JDK 6, but causes a TypeCheckError in FunctionCall for reasons TBD:
+ /* getResourceAsStream override unnecessary on JDK 7.
+ * Ought to work around JAXP #6723276 in JDK 6, but causes a TypeCheckError in FunctionCall for reasons TBD:
Thread.currentThread().setContextClassLoader(new ClassLoader(ClassLoader.getSystemClassLoader().getParent()) {
public InputStream getResourceAsStream(String name) {
if (name.startsWith("META-INF/services/")) {
@@ -85,7 +88,10 @@ public class XMLResultAggregatorTest {
// Use the JRE's Xerces, not lib/optional/xerces.jar:
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader().getParent());
// Tickle #51668:
- System.setSecurityManager(new SecurityManager() {public void checkPermission(Permission perm) {}});
+ System.setSecurityManager(new SecurityManager() {
+ public void checkPermission(Permission perm) {
+ }
+ });
task.execute();
assertTrue(new File(d, "index.html").isFile());
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
index c7fab26..f8c89f2 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
@@ -60,7 +60,7 @@ public class FTPTest {
private FTPClient ftp;
- private boolean loginSuceeded = false;
+ private boolean loginSucceeded = false;
private String loginFailureMessage;
@@ -95,7 +95,7 @@ public class FTPTest {
if (connectionSucceeded) {
try {
ftp.login(remoteUser, password);
- loginSuceeded = true;
+ loginSucceeded = true;
} catch (IOException ioe) {
loginFailureMessage = "could not log on to " + remoteHost + " as user " + remoteUser;
}
@@ -105,7 +105,7 @@ public class FTPTest {
@After
public void tearDown() {
try {
- if (ftp!= null) {
+ if (ftp != null) {
ftp.disconnect();
}
} catch (IOException ioe) {
@@ -118,8 +118,7 @@ public class FTPTest {
boolean result = true;
try {
ftp.cwd(remoteDir);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
System.out.println("could not change directory to " + remoteTmpDir);
result = false;
}
@@ -128,45 +127,42 @@ public class FTPTest {
@Test
public void test1() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha"});
ds.scan();
- compareFiles(ds, new String[] {} ,new String[] {"alpha"});
+ compareFiles(ds, new String[] {}, new String[] {"alpha"});
}
@Test
public void test2() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha/"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void test3() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
- new String[] {"alpha", "alpha/beta",
- "alpha/beta/gamma"});
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
+ new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void testFullPathMatchesCaseSensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
@@ -177,34 +173,32 @@ public class FTPTest {
@Test
public void testFullPathMatchesCaseInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setCaseSensitive(false);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
- new String[] {});
+ compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {});
}
@Test
public void test2ButCaseInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"ALPHA/"});
ds.setCaseSensitive(false);
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void test2bisButCaseInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
@@ -241,10 +235,10 @@ public class FTPTest {
@Test
public void testGetFollowSymlinksTrue() {
Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("ftp-get-directory-symbolic-link");
- FileSet fsDestination = (FileSet) buildRule.getProject().getReference("fileset-destination-without-selector");
+ FileSet fsDestination = buildRule.getProject().getReference("fileset-destination-without-selector");
DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject());
dsDestination.scan();
compareFiles(dsDestination, new String[] {"alpha/beta/gamma/gamma.xml"},
@@ -254,20 +248,19 @@ public class FTPTest {
@Test
public void testGetFollowSymlinksFalse() {
Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("ftp-get-directory-no-symbolic-link");
FileSet fsDestination = (FileSet) buildRule.getProject().getReference("fileset-destination-without-selector");
DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject());
dsDestination.scan();
- compareFiles(dsDestination, new String[] {},
- new String[] {});
+ compareFiles(dsDestination, new String[] {}, new String[] {});
}
@Test
public void testAllowSymlinks() {
Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("symlink-setup");
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
@@ -282,7 +275,7 @@ public class FTPTest {
@Test
public void testProhibitSymlinks() {
Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("symlink-setup");
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
@@ -296,7 +289,7 @@ public class FTPTest {
@Test
public void testFileSymlink() {
Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("symlink-file-setup");
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
@@ -311,10 +304,9 @@ public class FTPTest {
// father and child pattern test
@Test
public void testOrderOfIncludePatternsIrrelevant() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
- String [] expectedFiles = {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"};
+ String [] expectedFiles = {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"};
String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" };
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
@@ -331,49 +323,43 @@ public class FTPTest {
@Test
public void testPatternsDifferInCaseScanningSensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha/", "ALPHA/"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void testPatternsDifferInCaseScanningInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha/", "ALPHA/"});
ds.setCaseSensitive(false);
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void testFullpathDiffersInCaseScanningSensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
- ds.setIncludes(new String[] {
- "alpha/beta/gamma/gamma.xml",
- "alpha/beta/gamma/GAMMA.XML"
- });
+ ds.setIncludes(new String[] {"alpha/beta/gamma/gamma.xml", "alpha/beta/gamma/GAMMA.XML"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
- new String[] {});
+ compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {});
}
@Test
public void testFullpathDiffersInCaseScanningInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
@@ -389,7 +375,7 @@ public class FTPTest {
@Test
public void testParentDiffersInCaseScanningSensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
@@ -402,89 +388,63 @@ public class FTPTest {
@Test
public void testParentDiffersInCaseScanningInsensitive() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"});
ds.setCaseSensitive(false);
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml"},
- new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"},
+ new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
}
@Test
public void testExcludeOneFile() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
- ds.setIncludes(new String[] {
- "**/*.xml"
- });
- ds.setExcludes(new String[] {
- "alpha/beta/b*xml"
- });
+ ds.setIncludes(new String[] {"**/*.xml"});
+ ds.setExcludes(new String[] {"alpha/beta/b*xml"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"},
- new String[] {});
+ compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {});
}
@Test
public void testExcludeHasPrecedence() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
- ds.setIncludes(new String[] {
- "alpha/**"
- });
- ds.setExcludes(new String[] {
- "alpha/**"
- });
+ ds.setIncludes(new String[] {"alpha/**"});
+ ds.setExcludes(new String[] {"alpha/**"});
ds.scan();
- compareFiles(ds, new String[] {},
- new String[] {});
-
+ compareFiles(ds, new String[] {}, new String[] {});
}
@Test
public void testAlternateIncludeExclude() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
- ds.setIncludes(new String[] {
- "alpha/**",
- "alpha/beta/gamma/**"
- });
- ds.setExcludes(new String[] {
- "alpha/beta/**"
- });
+ ds.setIncludes(new String[] {"alpha/**", "alpha/beta/gamma/**"});
+ ds.setExcludes(new String[] {"alpha/beta/**"});
ds.scan();
- compareFiles(ds, new String[] {},
- new String[] {"alpha"});
-
+ compareFiles(ds, new String[] {}, new String[] {"alpha"});
}
@Test
public void testAlternateExcludeInclude() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
- ds.setExcludes(new String[] {
- "alpha/**",
- "alpha/beta/gamma/**"
- });
- ds.setIncludes(new String[] {
- "alpha/beta/**"
- });
+ ds.setExcludes(new String[] {"alpha/**", "alpha/beta/gamma/**"});
+ ds.setIncludes(new String[] {"alpha/beta/**"});
ds.scan();
- compareFiles(ds, new String[] {},
- new String[] {});
-
+ compareFiles(ds, new String[] {}, new String[] {});
}
/**
@@ -492,26 +452,23 @@ public class FTPTest {
*/
@Test
public void testChildrenOfExcludedDirectory() {
- Assume.assumeTrue(loginFailureMessage, loginSuceeded);
+ Assume.assumeTrue(loginFailureMessage, loginSucceeded);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
buildRule.getProject().executeTarget("children-of-excluded-dir-setup");
FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp);
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setExcludes(new String[] {"alpha/**"});
ds.scan();
- compareFiles(ds, new String[] {"delta/delta.xml"},
- new String[] {"delta"});
+ compareFiles(ds, new String[] {"delta/delta.xml"}, new String[] {"delta"});
ds = myFTPTask.newScanner(ftp);
Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp"));
ds.setExcludes(new String[] {"alpha"});
ds.scan();
- compareFiles(ds, new String[] {"alpha/beta/beta.xml",
- "alpha/beta/gamma/gamma.xml",
- "delta/delta.xml"},
+ compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml",
+ "delta/delta.xml"},
new String[] {"alpha/beta", "alpha/beta/gamma", "delta"});
-
}
/**
@@ -634,11 +591,8 @@ public class FTPTest {
*/
@Test
public void testConfiguration1() {
- int[] expectedCounts = {
- 1,1,0,1,0,0,0
- };
+ int[] expectedCounts = {1, 1, 0, 1, 0, 0, 0};
performConfigTest("configuration.1", expectedCounts);
-
}
/**
@@ -646,11 +600,8 @@ public class FTPTest {
*/
@Test
public void testConfiguration2() {
- int[] expectedCounts = {
- 1,0,0,1,1,0,0
- };
+ int[] expectedCounts = {1, 0, 0, 1, 1, 0, 0};
performConfigTest("configuration.2", expectedCounts);
-
}
/**
@@ -658,18 +609,13 @@ public class FTPTest {
*/
@Test
public void testConfiguration3() {
- int[] expectedCounts = {
- 1,0,1,0,0,1,0
- };
+ int[] expectedCounts = {1, 0, 1, 0, 0, 1, 0};
performConfigTest("configuration.3", expectedCounts);
-
}
@Test
public void testConfigurationLang() {
- int[] expectedCounts = {
- 1,1,0,0,0,0,1
- };
+ int[] expectedCounts = {1, 1, 0, 0, 0, 0, 1};
performConfigTest("configuration.lang.good", expectedCounts);
try {
@@ -684,9 +630,7 @@ public class FTPTest {
*/
@Test
public void testConfigurationNone() {
- int[] expectedCounts = {
- 0,0,0,0,0,0,0
- };
+ int[] expectedCounts = {0, 0, 0, 0, 0, 0, 0};
performConfigTest("configuration.none", expectedCounts);
}
@@ -700,17 +644,17 @@ public class FTPTest {
"custom config: system key = WINDOWS",
"custom config: default date format = yyyy/MM/dd HH:mm",
"custom config: server language code = de"
-
};
LogCounter counter = new LogCounter();
- for (int i=0; i < messages.length; i++) {
- counter.addLogMessageToSearch(messages[i]);
+ for (String message : messages) {
+ counter.addLogMessageToSearch(message);
}
buildRule.getProject().addBuildListener(counter);
buildRule.getProject().executeTarget(target);
- for (int i=0; i < messages.length; i++) {
- assertEquals("target "+target+":message "+ i, expectedCounts[i], counter.getMatchCount(messages[i]));
+ for (int i = 0; i < messages.length; i++) {
+ assertEquals("target " + target + ":message " + i,
+ expectedCounts[i], counter.getMatchCount(messages[i]));
}
}
@@ -726,26 +670,26 @@ public class FTPTest {
private void compareFiles(DirectoryScanner ds, String[] expectedFiles,
String[] expectedDirectories) {
- String includedFiles[] = ds.getIncludedFiles();
- String includedDirectories[] = ds.getIncludedDirectories();
+ String[] includedFiles = ds.getIncludedFiles();
+ String[] includedDirectories = ds.getIncludedDirectories();
assertEquals("file present: ", expectedFiles.length,
includedFiles.length);
assertEquals("directories present: ", expectedDirectories.length,
includedDirectories.length);
- for (int counter=0; counter < includedFiles.length; counter++) {
+ for (int counter = 0; counter < includedFiles.length; counter++) {
includedFiles[counter] = includedFiles[counter].replace(File.separatorChar, '/');
}
Arrays.sort(includedFiles);
- for (int counter=0; counter < includedDirectories.length; counter++) {
+ for (int counter = 0; counter < includedDirectories.length; counter++) {
includedDirectories[counter] = includedDirectories[counter]
.replace(File.separatorChar, '/');
}
Arrays.sort(includedDirectories);
- for (int counter=0; counter < includedFiles.length; counter++) {
+ for (int counter = 0; counter < includedFiles.length; counter++) {
assertEquals(expectedFiles[counter], includedFiles[counter]);
}
- for (int counter=0; counter < includedDirectories.length; counter++) {
+ for (int counter = 0; counter < includedDirectories.length; counter++) {
assertEquals(expectedDirectories[counter], includedDirectories[counter]);
counter++;
}
@@ -771,31 +715,34 @@ public class FTPTest {
}
protected void getFile(FTPClient ftp, String dir, String filename)
- throws IOException, BuildException
- {
+ throws IOException, BuildException {
if (this.simulatedFailuresLeft > 0) {
this.simulatedFailuresLeft--;
throw new IOException("Simulated failure for testing");
}
super.getFile(ftp, dir, filename);
}
+
protected void executeRetryable(RetryHandler h, Retryable r,
- String filename) throws IOException
- {
+ String filename) throws IOException {
+
this.simulatedFailuresLeft = this.numberOfFailuresToSimulate;
super.executeRetryable(h, r, filename);
}
}
+
public static class oneFailureFTP extends myRetryableFTP {
public oneFailureFTP() {
super(1);
}
}
+
public static class twoFailureFTP extends myRetryableFTP {
public twoFailureFTP() {
super(2);
}
}
+
public static class threeFailureFTP extends myRetryableFTP {
public threeFailureFTP() {
super(3);
@@ -807,6 +754,7 @@ public class FTPTest {
super(new Random().nextInt(Short.MAX_VALUE));
}
}
+
public void testGetWithSelectorRetryable1() {
buildRule.getProject().addTaskDefinition("ftp", oneFailureFTP.class);
try {
@@ -864,14 +812,15 @@ public class FTPTest {
};
LogCounter counter = new LogCounter();
- for (int i=0; i < messages.length; i++) {
- counter.addLogMessageToSearch(messages[i]);
+ for (String message : messages) {
+ counter.addLogMessageToSearch(message);
}
buildRule.getProject().addBuildListener(counter);
buildRule.getProject().executeTarget(target);
- for (int i=0; i < messages.length; i++) {
- assertEquals("target "+target+":message "+ i, expectedCounts[i], counter.getMatchCount(messages[i]));
+ for (int i = 0; i < messages.length; i++) {
+ assertEquals("target " + target + ":message " + i,
+ expectedCounts[i], counter.getMatchCount(messages[i]));
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
index c45ec17..1354e52 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
@@ -320,7 +320,7 @@ public class SOSTest {
try {
buildRule.executeTarget(target);
fail(errorMessage);
- } catch(BuildException ex) {
+ } catch (BuildException ex) {
assertEquals(exceptionMessage, ex.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
index 2e00042..7694ce5 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
@@ -60,27 +60,26 @@ import static org.junit.Assert.fail;
*/
public class ScpTest {
+ private Scp scpTask;
private File tempDir;
private String sshHostUri = System.getProperty("scp.host");
- private int port = Integer.parseInt( System.getProperty( "scp.port", "22" ) );
+ private int port = Integer.parseInt(System.getProperty("scp.port", "22"));
private String knownHosts = System.getProperty("scp.known.hosts");
private List cleanUpList = new ArrayList();
- public ScpTest() {
+ @Before
+ public void setUp() {
+ scpTask = createTask();
if (System.getProperty("scp.tmp") != null) {
tempDir = new File(System.getProperty("scp.tmp"));
}
- }
-
- @Before
- public void setUp() {
cleanUpList.clear();
}
@After
public void tearDown() {
- for( Iterator i = cleanUpList.iterator(); i.hasNext(); ) {
+ for (Iterator i = cleanUpList.iterator(); i.hasNext();) {
File file = (File) i.next();
file.delete();
}
@@ -92,77 +91,73 @@ public class ScpTest {
File uploadFile = createTemporaryFile();
// upload
- Scp scpTask = createTask();
- scpTask.setFile( uploadFile.getPath() );
- scpTask.setTodir( sshHostUri );
+ scpTask.setFile(uploadFile.getPath());
+ scpTask.setTodir(sshHostUri);
scpTask.execute();
- File testFile = new File( tempDir.getPath() + File.separator +
- "download-testSingleFileUploadAndDownload.test" );
- addCleanup(testFile );
+ File testFile = new File(tempDir.getPath() + File.separator +
+ "download-testSingleFileUploadAndDownload.test");
+ addCleanup(testFile);
assertFalse("Assert that the testFile does not exist.", testFile.exists());
// download
scpTask = createTask();
- scpTask.setFile( sshHostUri + "/" + uploadFile.getName() );
- scpTask.setTodir( testFile.getPath() );
+ scpTask.setFile(sshHostUri + "/" + uploadFile.getName());
+ scpTask.setTodir(testFile.getPath());
scpTask.execute();
- assertTrue( "Assert that the testFile exists.", testFile.exists() );
- compareFiles( uploadFile, testFile );
+ assertTrue("Assert that the testFile exists.", testFile.exists());
+ compareFiles(uploadFile, testFile);
}
@Test
public void testMultiUploadAndDownload() throws IOException {
assertNotNull("system property scp.tmp must be set", tempDir);
List uploadList = new ArrayList();
- for( int i = 0; i < 5; i++ ) {
- uploadList.add( createTemporaryFile() );
+ for (int i = 0; i < 5; i++) {
+ uploadList.add(createTemporaryFile());
}
- Scp scp = createTask();
FilenameSelector selector = new FilenameSelector();
- selector.setName( "scp*" );
+ selector.setName("scp*");
FileSet fileset = new FileSet();
- fileset.setDir( tempDir );
- fileset.addFilename( selector );
- scp.addFileset( fileset );
- scp.setTodir( sshHostUri );
- scp.execute();
+ fileset.setDir(tempDir);
+ fileset.addFilename(selector);
+ scpTask.addFileset(fileset);
+ scpTask.setTodir(sshHostUri);
+ scpTask.execute();
- File multi = new File( tempDir, "multi" );
+ File multi = new File(tempDir, "multi");
multi.mkdir();
- addCleanup( multi );
+ addCleanup(multi);
- Scp scp2 = createTask();
- scp2.setFile( sshHostUri + "/scp*" );
- scp2.setTodir( multi.getPath() );
- scp2.execute();
+ scpTask = createTask();
+ scpTask.setFile(sshHostUri + "/scp*");
+ scpTask.setTodir(multi.getPath());
+ scpTask.execute();
FilesMatch match = new FilesMatch();
- for( Iterator i = uploadList.iterator(); i.hasNext(); ) {
- File f = (File)i.next();
- match.setFile1( f );
- File f2 = new File( multi, f.getName() );
- match.setFile2( f2 );
- assertTrue("Assert file '" + f.getPath() + "' and file '" +
- f2.getPath() + "'", match.eval() );
+ for (Iterator i = uploadList.iterator(); i.hasNext();) {
+ File f = (File) i.next();
+ match.setFile1(f);
+ File f2 = new File(multi, f.getName());
+ match.setFile2(f2);
+ assertTrue("Assert file '" + f.getPath() + "' and file '"
+ + f2.getPath() + "'", match.eval());
}
}
@Test
public void testMultiResourceCollectionUpload() throws IOException {
assertNotNull("system property scp.tmp must be set", tempDir);
- List uploadList = new ArrayList();
+ List<File> uploadList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
uploadList.add(createTemporaryFile());
}
- Scp scp = createTask();
-
// reverse order resource collection
Sort sort = new Sort();
- sort.setProject(scp.getProject());
+ sort.setProject(scpTask.getProject());
Reverse reverse = new Reverse();
reverse.add(new Name());
sort.add(reverse);
@@ -170,56 +165,53 @@ public class ScpTest {
FilenameSelector selector = new FilenameSelector();
selector.setName("scp*");
FileSet fileset = new FileSet();
- fileset.setProject(scp.getProject());
+ fileset.setProject(scpTask.getProject());
fileset.setDir(tempDir);
fileset.addFilename(selector);
sort.add(fileset);
- scp.add(sort);
+ scpTask.add(sort);
- scp.setTodir(sshHostUri);
- scp.execute();
+ scpTask.setTodir(sshHostUri);
+ scpTask.execute();
}
@Test
public void testRemoteToDir() throws IOException {
- Scp scpTask = createTask();
// first try an invalid URI
try {
- scpTask.setRemoteTodir( "host:/a/path/without/an/at" );
+ scpTask.setRemoteTodir("host:/a/path/without/an/at");
fail("Expected a BuildException to be thrown due to invalid"
+ " remoteToDir");
- }
- catch (BuildException e)
- {
+ } catch (BuildException e) {
// expected
//TODO we should be asserting a value in here
}
// And this one should work
- scpTask.setRemoteTodir( "user:password@host:/a/path/with/an/at" );
+ scpTask.setRemoteTodir("user:password@host:/a/path/with/an/at");
// no exception
}
- public void addCleanup( File file ) {
- cleanUpList.add( file );
+ private void addCleanup(File file) {
+ cleanUpList.add(file);
}
private void compareFiles(File src, File dest) {
FilesMatch match = new FilesMatch();
- match.setFile1( src );
- match.setFile2( dest );
+ match.setFile1(src);
+ match.setFile2(dest);
- assertTrue( "Assert files are equal.", match.eval() );
+ assertTrue("Assert files are equal.", match.eval());
}
private File createTemporaryFile() throws IOException {
File uploadFile;
- uploadFile = File.createTempFile( "scp", "test", tempDir );
- FileWriter writer = new FileWriter( uploadFile );
+ uploadFile = File.createTempFile("scp", "test", tempDir);
+ FileWriter writer = new FileWriter(uploadFile);
writer.write("Can you hear me now?\n");
writer.close();
- addCleanup( uploadFile );
+ addCleanup(uploadFile);
return uploadFile;
}
@@ -227,13 +219,13 @@ public class ScpTest {
Scp scp = new Scp();
Project p = new Project();
p.init();
- scp.setProject( p );
- if( knownHosts != null ) {
- scp.setKnownhosts( knownHosts );
+ scp.setProject(p);
+ if (knownHosts != null) {
+ scp.setKnownhosts(knownHosts);
} else {
- scp.setTrust( true );
+ scp.setTrust(true);
}
- scp.setPort( port );
+ scp.setPort(port);
return scp;
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
index e36d683..b5f4bbf 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
@@ -17,11 +17,11 @@
*/
/*
- * Since the initial version of this file was deveolped on the clock on
+ * Since the initial version of this file was developed on the clock on
* an NSF grant I should say the following boilerplate:
*
* This material is based upon work supported by the National Science
- * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and
+ * Foundation under Grant No. EIA-0196404. Any opinions, findings, and
* conclusions or recommendations expressed in this material are those
* of the author and do not necessarily reflect the views of the
* National Science Foundation.
@@ -192,7 +192,7 @@ public class SymlinkTest {
buildRule.executeTarget("test-fileutils");
SymbolicLinkUtils su = SymbolicLinkUtils.getSymbolicLinkUtils();
- java.io.File f = new File(buildRule.getOutputDir(), "file1");
+ File f = new File(buildRule.getOutputDir(), "file1");
assertTrue(f.exists());
assertFalse(f.isDirectory());
assertTrue(f.isFile());
@@ -260,7 +260,7 @@ public class SymlinkTest {
f.getName()));
// it is not possible to find out that symbolic links pointing
- // to inexistent files or directories are symbolic links
+ // to nonexistent files or directories are symbolic links
// it used to be possible to detect this on Mac
// this is not true under Snow Leopard and JDK 1.5
// Removing special handling of MacOS until someone shouts
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java
index aa96d8d..772c6c1 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java
@@ -65,7 +65,7 @@ public class MSVSSTest implements MSVSSConstants {
private Project project;
@Before
- public void setUp(){
+ public void setUp() {
project = new Project();
project.setBasedir(".");
project.init();
@@ -82,8 +82,7 @@ public class MSVSSTest implements MSVSSConstants {
@Test
public void testGetCommandLine() {
String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_GET, DS_VSS_PROJECT_PATH,
- MSVSS.FLAG_OVERRIDE_WORKING_DIR + project.getBaseDir()
- .getAbsolutePath()
+ MSVSS.FLAG_OVERRIDE_WORKING_DIR + project.getBaseDir().getAbsolutePath()
+ File.separator + LOCAL_PATH, MSVSS.FLAG_AUTORESPONSE_DEF,
MSVSS.FLAG_RECURSION, MSVSS.FLAG_VERSION + VERSION, MSVSS.FLAG_LOGIN
+ VSS_USERNAME + "," + VSS_PASSWORD, FLAG_FILETIME_UPDATED, FLAG_SKIP_WRITABLE};
@@ -238,7 +237,7 @@ public class MSVSSTest implements MSVSSConstants {
// Get today's date
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z");
- sdf.setTimeZone( TimeZone.getTimeZone("GMT") );
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String expected = sdf.format(date);
// Set up a VSSHistory task
@@ -270,7 +269,7 @@ public class MSVSSTest implements MSVSSConstants {
try {
buildRule.executeTarget(target);
fail(failMessage);
- } catch(BuildException ex) {
+ } catch (BuildException ex) {
assertEquals(exceptionMessage, ex.getMessage());
}
}
@@ -462,8 +461,8 @@ public class MSVSSTest implements MSVSSConstants {
// Count the number of empty strings
int cnt = 0;
- for (int i = 0; i < genLength; i++) {
- if (sGeneratedCmdLine[i].equals("")) {
+ for (String argument : sGeneratedCmdLine) {
+ if (argument.equals("")) {
cnt++;
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java b/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
index 4f95c35..6dfbcf6 100644
--- a/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
@@ -69,13 +69,13 @@ public class AddTypeTest {
@Test
public void testNestedB() {
buildRule.executeTarget("nested.b");
- AntAssert.assertContains( "add B called", buildRule.getLog());
+ AntAssert.assertContains("add B called", buildRule.getLog());
}
@Test
public void testNestedC() {
buildRule.executeTarget("nested.c");
- AntAssert.assertContains( "add C called", buildRule.getLog());
+ AntAssert.assertContains("add C called", buildRule.getLog());
}
@Test
@@ -91,19 +91,19 @@ public class AddTypeTest {
@Test
public void testConditionType() {
buildRule.executeTarget("condition.type");
- AntAssert.assertContains( "beforeafter", buildRule.getLog());
+ AntAssert.assertContains("beforeafter", buildRule.getLog());
}
@Test
public void testConditionTask() {
buildRule.executeTarget("condition.task");
- AntAssert.assertContains( "My Condition execution", buildRule.getLog());
+ AntAssert.assertContains("My Condition execution", buildRule.getLog());
}
@Test
public void testConditionConditionType() {
buildRule.executeTarget("condition.condition.type");
- AntAssert.assertContains( "My Condition eval", buildRule.getLog());
+ AntAssert.assertContains("My Condition eval", buildRule.getLog());
}
@Test
@@ -137,19 +137,25 @@ public class AddTypeTest {
// The following will be used as types and tasks
- public static interface A {}
- public static interface B {}
- public static interface C extends A {}
- public static interface AB extends A, B {}
+ public interface A {
+ }
+ public interface B {
+ }
+ public interface C extends A {
+ }
+ public interface AB extends A, B {
+ }
- public static class AImpl implements A{}
- public static class BImpl implements B{}
- public static class CImpl implements C{}
- public static class ABImpl implements AB{}
+ public static class AImpl implements A {
+ }
+ public static class BImpl implements B {
+ }
+ public static class CImpl implements C {
+ }
+ public static class ABImpl implements AB {
+ }
- public static class NestedContainer
- extends Task
- {
+ public static class NestedContainer extends Task {
public void add(A el) {
log("add A called");
}
@@ -161,9 +167,7 @@ public class AddTypeTest {
}
}
- public static class MyCondition
- implements Condition
- {
+ public static class MyCondition implements Condition {
Project project;
public void setProject(Project project) {
this.project = project;
@@ -177,8 +181,7 @@ public class AddTypeTest {
}
}
- public static class MyValue
- {
+ public static class MyValue {
private String text = "NOT SET YET";
public void addText(String text) {
this.text = text;
@@ -188,9 +191,7 @@ public class AddTypeTest {
}
}
- public static class MyAddConfigured
- extends Task
- {
+ public static class MyAddConfigured extends Task {
MyValue value;
public void addConfigured(MyValue value) {
log("value is " + value);
@@ -204,9 +205,7 @@ public class AddTypeTest {
}
}
- public static class MyAddConfiguredValue
- extends Task
- {
+ public static class MyAddConfiguredValue extends Task {
MyValue value;
public void addConfiguredValue(MyValue value) {
log("value is " + value);
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java b/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java
index 03d0c97..5e54f45 100644
--- a/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java
@@ -43,14 +43,14 @@ public class AssertionsTest {
/**
* runs a test and expects an assertion thrown in forked code
- * @param target
+ * @param target String
*/
private void expectAssertion(String target) {
try {
buildRule.executeTarget(target);
fail("BuildException should have been thrown by assertion fail in task");
} catch (BuildException ex) {
- assertContains("assertion not thrown in "+target, "Java returned: 1", ex.getMessage());
+ assertContains("assertion not thrown in " + target, "Java returned: 1", ex.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
index abfb70f..53aa27c 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
@@ -88,7 +88,7 @@ public class CommandlineJavaTest {
c.createClasspath(project).setLocation(project.resolveFile("build.xml"));
c.createClasspath(project).setLocation(project.resolveFile(
- System.getProperty(MagicNames.ANT_HOME)+"/lib/ant.jar"));
+ System.getProperty(MagicNames.ANT_HOME) + "/lib/ant.jar"));
s = c.getCommandline();
assertEquals("with classpath", 6, s.length);
// assertEquals("with classpath", "java", s[0]);
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
index e8e4442..ce728e8 100644
--- a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
@@ -35,8 +35,8 @@ public class CommandlineTest {
public void testTokenizer() {
String[] s = Commandline.translateCommandline("1 2 3");
assertEquals("Simple case", 3, s.length);
- for (int i=0; i<3; i++) {
- assertEquals(""+(i+1), s[i]);
+ for (int i = 0; i < 3; i++) {
+ assertEquals("" + (i + 1), s[i]);
}
s = Commandline.translateCommandline("");
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java b/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
index 31b56f9..aeb7911 100644
--- a/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
@@ -36,24 +36,28 @@ public class DescriptionTest {
@Test
public void test1() {
buildRule.configureProject("src/etc/testcases/types/description1.xml");
- assertEquals("Single description failed", "Test Project Description", buildRule.getProject().getDescription());
+ assertEquals("Single description failed", "Test Project Description",
+ buildRule.getProject().getDescription());
}
@Test
public void test2() {
buildRule.configureProject("src/etc/testcases/types/description2.xml");
- assertEquals("Multi line description failed", "Multi Line\nProject Description", buildRule.getProject().getDescription());
+ assertEquals("Multi line description failed", "Multi Line\nProject Description",
+ buildRule.getProject().getDescription());
}
@Test
public void test3() {
buildRule.configureProject("src/etc/testcases/types/description3.xml");
- assertEquals("Multi instance description failed", "Multi Instance Project Description", buildRule.getProject().getDescription());
+ assertEquals("Multi instance description failed", "Multi Instance Project Description",
+ buildRule.getProject().getDescription());
}
@Test
public void test4() {
buildRule.configureProject("src/etc/testcases/types/description4.xml");
- assertEquals("Multi instance nested description failed", "Multi Instance Nested Project Description", buildRule.getProject().getDescription());
+ assertEquals("Multi instance nested description failed", "Multi Instance Nested Project Description",
+ buildRule.getProject().getDescription());
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
index dcb8a78..b20412e 100644
--- a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
@@ -36,11 +36,11 @@ public class EnumeratedAttributeTest {
@Test
public void testContains() {
EnumeratedAttribute t1 = new TestNormal();
- for (int i=0; i<expected.length; i++) {
- assertTrue(expected[i]+" is in TestNormal",
- t1.containsValue(expected[i]));
- assertTrue(expected[i].toUpperCase()+" is in TestNormal",
- !t1.containsValue(expected[i].toUpperCase()));
+ for (String value : expected) {
+ assertTrue(value + " is in TestNormal",
+ t1.containsValue(value));
+ assertTrue(value.toUpperCase() + " is in TestNormal",
+ !t1.containsValue(value.toUpperCase()));
}
assertTrue("TestNormal doesn\'t have \"d\" attribute",
!t1.containsValue("d"));
@@ -64,11 +64,11 @@ public class EnumeratedAttributeTest {
@Test
public void testExceptions() {
EnumeratedAttribute t1 = new TestNormal();
- for (int i=0; i<expected.length; i++) {
+ for (String value : expected) {
try {
- t1.setValue(expected[i]);
+ t1.setValue(value);
} catch (BuildException be) {
- fail("unexpected exception for value "+expected[i]);
+ fail("unexpected exception for value " + value);
}
}
try {
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
index 9a17687..7cf905e 100644
--- a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
@@ -84,7 +84,7 @@ public class FilterSetTest {
@Test
public void testRecursive() {
String result = "it works line";
- String line="@test@ line";
+ String line = "@test@ line";
FilterSet fs = new FilterSet();
fs.addFilter("test", "@test1@");
fs.addFilter("test1","@test2@");
@@ -221,13 +221,14 @@ public class FilterSetTest {
byte[] buffer1 = new byte[BUF_SIZE];
byte[] buffer2 = new byte[BUF_SIZE];
+ @SuppressWarnings("resource")
FileInputStream fis1 = new FileInputStream(file1);
+ @SuppressWarnings("resource")
FileInputStream fis2 = new FileInputStream(file2);
- int index = 0;
int read = 0;
while ((read = fis1.read(buffer1)) != -1) {
fis2.read(buffer2);
- for (int i = 0; i < read; ++i, ++index) {
+ for (int i = 0; i < read; ++i) {
if (buffer1[i] != buffer2[i]) {
return false;
}
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/types/PathTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/types/PathTest.java b/src/tests/junit/org/apache/tools/ant/types/PathTest.java
index 2ad1819..20c0b3a 100644
--- a/src/tests/junit/org/apache/tools/ant/types/PathTest.java
+++ b/src/tests/junit/org/apache/tools/ant/types/PathTest.java
@@ -325,7 +325,7 @@ public class PathTest {
@Test
public void testSetLocation() {
Path p = new Path(project);
- p.setLocation(new File(File.separatorChar+"a"));
+ p.setLocation(new File(File.separatorChar + "a"));
String[] l = p.list();
if (isUnixStyle) {
assertEquals(1, l.length);
@@ -359,7 +359,7 @@ public class PathTest {
}
@Test
- public void testEmpyPath() {
+ public void testEmptyPath() {
Path p = new Path(project, "");
String[] l = p.list();
assertEquals("0 after construction", 0, l.length);
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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/866ce9f5/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));