geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsis...@apache.org
Subject svn commit: r407437 - /geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java
Date Thu, 18 May 2006 02:17:08 GMT
Author: jsisson
Date: Wed May 17 19:17:08 2006
New Revision: 407437

URL: http://svn.apache.org/viewvc?rev=407437&view=rev
Log:
ensure inputstream is closed in finally block

Modified:
    geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java

Modified: geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java?rev=407437&r1=407436&r2=407437&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java
(original)
+++ geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java
Wed May 17 19:17:08 2006
@@ -21,8 +21,8 @@
 import java.net.URL;
 import java.util.List;
 import java.util.ArrayList;
+import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.StringWriter;
 import java.io.Writer;
 
@@ -32,7 +32,6 @@
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 
 /**
  * @version $Rev:$ $Date:$
@@ -72,19 +71,30 @@
 
     private void test(String testName) throws Exception {
         InputStream srcXml = classLoader.getResourceAsStream(testName + ".xml");
-        Writer targetXml = new StringWriter();
-        new Upgrade1_0To1_1().upgrade(srcXml, targetXml);
-
-        String targetString = targetXml.toString();
-        XmlObject targetXmlObject = XmlObject.Factory.parse(targetString);
-        URL expectedOutputXml = classLoader.getResource(testName + "_result.xml");
-        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
-        List problems = new ArrayList();
-        boolean ok = compareXmlObjects(targetXmlObject, expected, problems);
-        if (!ok) {
-            System.out.println(targetString);
+        try {
+            Writer targetXml = new StringWriter();
+            new Upgrade1_0To1_1().upgrade(srcXml, targetXml);
+        
+            String targetString = targetXml.toString();
+            XmlObject targetXmlObject = XmlObject.Factory.parse(targetString);
+            URL expectedOutputXml = classLoader.getResource(testName + "_result.xml");
+            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+            List problems = new ArrayList();
+            boolean ok = compareXmlObjects(targetXmlObject, expected, problems);
+            if (!ok) {
+                System.out.println(targetString);
+            }
+            assertTrue("Differences: " + problems, ok);
+        } finally {
+            if (srcXml != null)
+            {
+                try {
+                    srcXml.close();
+                } catch (IOException ignored) {
+                    // ignored
+                }
+            }
         }
-        assertTrue("Differences: " + problems, ok);
     }
 
     private boolean compareXmlObjects(XmlObject xmlObject, XmlObject expectedObject, List
problems) {



Mime
View raw message