You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2014/07/20 06:08:17 UTC

[1/2] git commit: properly close stream in test

Repository: ant
Updated Branches:
  refs/heads/master af875267e -> 956b80a68


properly close stream in test


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/49655353
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/49655353
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/49655353

Branch: refs/heads/master
Commit: 4965535328781e63aacbf211d2e96a8462ea133a
Parents: af87526
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 20 06:04:24 2014 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 20 06:04:24 2014 +0200

----------------------------------------------------------------------
 .../org/apache/tools/ant/taskdefs/ManifestTest.java     | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/49655353/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
index aa9432c..76e14b3 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
@@ -288,16 +288,22 @@ public class ManifestTest {
         value = mainSection.getAttributeValue(NOT_LONG_NAME);
         assertEquals("NOT_LONG_NAME_VALUE_MISMATCH", VALUE, value);
         
-        BufferedReader in = new BufferedReader(new FileReader(expandedManifest));
-        
         Set set = new HashSet();
+        FileReader fin = new FileReader(expandedManifest);
+        try {
+        BufferedReader in = new BufferedReader(fin);
+        
         String read = in.readLine();
         while (read != null)
         {
             set.add(read);
             read = in.readLine();
         }
-        
+            in.close();
+        } finally {
+            fin.close();
+        }
+
         assertTrue("Manifest file should have contained string ", set
                 .remove(" NOT_LONG"));
         assertTrue("Manifest file should have contained string ", set


[2/2] git commit: whitespace

Posted by bo...@apache.org.
whitespace


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/956b80a6
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/956b80a6
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/956b80a6

Branch: refs/heads/master
Commit: 956b80a6871d9dc8987fb62addac9345fa17399c
Parents: 4965535
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun Jul 20 06:07:04 2014 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun Jul 20 06:07:04 2014 +0200

----------------------------------------------------------------------
 .../apache/tools/ant/taskdefs/ManifestTest.java | 165 +++++++++----------
 1 file changed, 82 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/956b80a6/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
index 76e14b3..6e79432 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
@@ -45,7 +45,7 @@ import static org.junit.Assert.fail;
  *
  */
 public class ManifestTest {
-    
+
     @Rule
     public final BuildFileRule buildRule = new BuildFileRule();
 
@@ -108,11 +108,11 @@ public class ManifestTest {
     @Test
     public void test3() {
         try {
-			buildRule.executeTarget("test3");
-			fail("BuildException expected: Manifest is invalid - no colon on header line");
-		} catch (BuildException ex) {
-			assertContains("Invalid Manifest", ex.getMessage());
-		}
+            buildRule.executeTarget("test3");
+            fail("BuildException expected: Manifest is invalid - no colon on header line");
+        } catch (BuildException ex) {
+            assertContains("Invalid Manifest", ex.getMessage());
+        }
     }
 
     /**
@@ -121,11 +121,11 @@ public class ManifestTest {
     @Test
     public void test4() {
         try {
-			buildRule.executeTarget("test4");
-			fail("BuildException expected: Manifest is invalid - section starts with continuation line");
-		} catch (BuildException ex) {
-			assertContains("Invalid Manifest", ex.getMessage());
-		}
+            buildRule.executeTarget("test4");
+            fail("BuildException expected: Manifest is invalid - section starts with continuation line");
+        } catch (BuildException ex) {
+            assertContains("Invalid Manifest", ex.getMessage());
+        }
    }
 
     /**
@@ -145,11 +145,11 @@ public class ManifestTest {
     @Test
     public void test6() {
         try {
-			buildRule.executeTarget("test6");
-			fail("BuildException expected: Manifest is invalid - section starts with incorrect attribute");
-		} catch (BuildException ex) {
-			assertContains("Invalid Manifest", ex.getMessage());
-		}
+            buildRule.executeTarget("test6");
+            fail("BuildException expected: Manifest is invalid - section starts with incorrect attribute");
+        } catch (BuildException ex) {
+            assertContains("Invalid Manifest", ex.getMessage());
+        }
         String output = buildRule.getLog();
         boolean hasWarning = output.indexOf("Manifest sections should start with a \"Name\" attribute") != -1;
         assertTrue("Expected warning about section not starting with Name: attribute", hasWarning);
@@ -189,12 +189,12 @@ public class ManifestTest {
     @Test
     public void test9() {
         try {
-			buildRule.executeTarget("test9");
-			fail("BuildException expected: Construction is invalid - Name attribute should not be used");
-		} catch (BuildException ex) {
-			assertContains("Specify the section name using the \"name\" attribute of the <section> element",
-                    ex.getMessage());
-		}
+            buildRule.executeTarget("test9");
+            fail("BuildException expected: Construction is invalid - Name attribute should not be used");
+        } catch (BuildException ex) {
+            assertContains("Specify the section name using the \"name\" attribute of the <section> element",
+                           ex.getMessage());
+        }
     }
 
     /**
@@ -203,11 +203,11 @@ public class ManifestTest {
     @Test
     public void test10() {
         try {
-			buildRule.executeTarget("test10");
-			fail("BuildException expected: Attribute has no name");
-		} catch (BuildException ex) {
-			assertContains("Attributes must have name and value", ex.getMessage());
-		}
+            buildRule.executeTarget("test10");
+            fail("BuildException expected: Attribute has no name");
+        } catch (BuildException ex) {
+            assertContains("Attributes must have name and value", ex.getMessage());
+        }
     }
 
     /**
@@ -216,11 +216,11 @@ public class ManifestTest {
     @Test
     public void test11() {
         try {
-			buildRule.executeTarget("test11");
-			fail("BuildException expected: Attribute has no value");
-		} catch (BuildException ex) {
-			assertContains("Attributes must have name and value", ex.getMessage());
-		}
+            buildRule.executeTarget("test11");
+            fail("BuildException expected: Attribute has no value");
+        } catch (BuildException ex) {
+            assertContains("Attributes must have name and value", ex.getMessage());
+        }
     }
 
     /**
@@ -229,11 +229,11 @@ public class ManifestTest {
     @Test
     public void test12() {
         try {
-			buildRule.executeTarget("test12");
-			fail("BuildException expected: Section with no name");
-		} catch (BuildException ex) {
-			assertContains("Sections must have a name", ex.getMessage());
-		}
+            buildRule.executeTarget("test12");
+            fail("BuildException expected: Section with no name");
+        } catch (BuildException ex) {
+            assertContains("Sections must have a name", ex.getMessage());
+        }
     }
 
     /**
@@ -242,11 +242,11 @@ public class ManifestTest {
     @Test
     public void test13() {
         try {
-			buildRule.executeTarget("test13");
-			fail("BuildException expected: Duplicate Attribute");
-		} catch (BuildException ex) {
-			assertContains("The attribute \"Test\" may not occur more than once in the same section", ex.getMessage());
-		}
+            buildRule.executeTarget("test13");
+            fail("BuildException expected: Duplicate Attribute");
+        } catch (BuildException ex) {
+            assertContains("The attribute \"Test\" may not occur more than once in the same section", ex.getMessage());
+        }
     }
 
     /**
@@ -280,25 +280,24 @@ public class ManifestTest {
         String classpath = mainSection.getAttributeValue("class-path");
         assertEquals("Class-Path attribute was not set correctly - ",
             LONG_LINE, classpath);
-        
+
         String value = mainSection.getAttributeValue(LONG_68_NAME);
         assertEquals("LONG_68_NAME_VALUE_MISMATCH", VALUE, value);
         value = mainSection.getAttributeValue(LONG_70_NAME);
         assertEquals("LONG_70_NAME_VALUE_MISMATCH", VALUE, value);
         value = mainSection.getAttributeValue(NOT_LONG_NAME);
         assertEquals("NOT_LONG_NAME_VALUE_MISMATCH", VALUE, value);
-        
+
         Set set = new HashSet();
         FileReader fin = new FileReader(expandedManifest);
         try {
-        BufferedReader in = new BufferedReader(fin);
-        
-        String read = in.readLine();
-        while (read != null)
-        {
-            set.add(read);
-            read = in.readLine();
-        }
+            BufferedReader in = new BufferedReader(fin);
+
+            String read = in.readLine();
+            while (read != null) {
+                set.add(read);
+                read = in.readLine();
+            }
             in.close();
         } finally {
             fin.close();
@@ -368,11 +367,11 @@ public class ManifestTest {
     @Test
     public void testNoFile() {
         try {
-			buildRule.executeTarget("testNoFile");
-			fail("BuildException expected: file is required");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testNoFile");
+            fail("BuildException expected: file is required");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     /**
@@ -411,57 +410,57 @@ public class ManifestTest {
     @Test
     public void testFrom() {
         buildRule.executeTarget("testFrom");
-		assertContains(Manifest.ERROR_FROM_FORBIDDEN, buildRule.getLog());
+        assertContains(Manifest.ERROR_FROM_FORBIDDEN, buildRule.getLog());
     }
 
     @Test
     public void testIllegalName() {
         try {
-			buildRule.executeTarget("testIllegalName");
-			fail("BuildException expected: Manifest attribute names must not contain ' '");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testIllegalName");
+            fail("BuildException expected: Manifest attribute names must not contain ' '");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     @Test
     public void testIllegalNameInSection() {
         try {
-			buildRule.executeTarget("testIllegalNameInSection");
-			fail("BuildException expected: Manifest attribute names must not contain ' '");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testIllegalNameInSection");
+            fail("BuildException expected: Manifest attribute names must not contain ' '");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     @Test
     public void testIllegalNameBegin() {
         try {
-			buildRule.executeTarget("testIllegalNameInSection");
-			fail("BuildException expected: Manifest attribute names must not start with '-' at the begin.");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testIllegalNameInSection");
+            fail("BuildException expected: Manifest attribute names must not start with '-' at the begin.");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     @Test
     public void testIllegalName2() {
         try {
-			buildRule.executeTarget("testIllegalName");
-			fail("BuildException expected: Manifest attribute names must not contain '.'");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testIllegalName");
+            fail("BuildException expected: Manifest attribute names must not contain '.'");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     @Test
     public void testIllegalName3() {
         try {
-			buildRule.executeTarget("testIllegalName");
-			fail("BuildException expected: Manifest attribute names must not contain '*'");
-		} catch (BuildException ex) {
-			//TODO assert value
-		}
+            buildRule.executeTarget("testIllegalName");
+            fail("BuildException expected: Manifest attribute names must not contain '*'");
+        } catch (BuildException ex) {
+            //TODO assert value
+        }
     }
 
     /**