harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r651261 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests: ArchiveTest.java SegmentTest.java
Date Thu, 24 Apr 2008 13:25:44 GMT
Author: sjanuary
Date: Thu Apr 24 06:25:40 2008
New Revision: 651261

URL: http://svn.apache.org/viewvc?rev=651261&view=rev
Log:
Pack200 - adapting tests so they don't fail when the system doesn't have java or javap on
the path

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
    harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java?rev=651261&r1=651260&r2=651261&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
Thu Apr 24 06:25:40 2008
@@ -72,6 +72,7 @@
         JarEntry entry = jarFile
                 .getJarEntry("bin/test/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest$BaseRowSetImpl.class");
         assertNotNull(entry);
+        try {
         Process process2 = Runtime
                 .getRuntime()
                 .exec(
@@ -79,23 +80,31 @@
                                 + file.getName()
                                 + " bin/test/org.apache.harmony.sql.tests.javax.sql.rowset.BaseRowSetTest$BaseRowSetImpl",
                         new String[] {}, file.getParentFile());
-        BufferedReader reader1 = new BufferedReader(new InputStreamReader(
-                process2.getInputStream()));
-        InputStream javapCompareFile = Archive.class
-                .getResourceAsStream("/org/apache/harmony/pack200/tests/sqlJavap.out");
-        BufferedReader reader2 = new BufferedReader(new InputStreamReader(
-                javapCompareFile));
-        String line1 = reader1.readLine();
-        String line2 = reader2.readLine();
-        int i = 1;
-        while (line1 != null || line2 != null) {
-            assertEquals(line2, line1);
-            line1 = reader1.readLine();
-            line2 = reader2.readLine();
-            i++;
+
+            BufferedReader reader1 = new BufferedReader(new InputStreamReader(
+                    process2.getInputStream()));
+            InputStream javapCompareFile = Archive.class
+                    .getResourceAsStream("/org/apache/harmony/pack200/tests/sqlJavap.out");
+            BufferedReader reader2 = new BufferedReader(new InputStreamReader(
+                    javapCompareFile));
+            String line1 = reader1.readLine();
+            String line2 = reader2.readLine();
+            int i = 1;
+            while (line1 != null || line2 != null) {
+                assertEquals(line2, line1);
+                line1 = reader1.readLine();
+                line2 = reader2.readLine();
+                i++;
+            }
+            reader1.close();
+            reader2.close();
+        } catch (IOException e) {
+            if(e.getMessage().startsWith("Unable to start program")) {
+                System.out.println("Warning: org.apache.harmony.unpack200.tests.ArchiveTest.testWithSql()
was not completed as javap could not be found");
+            } else {
+                throw e;
+            }
         }
-        reader1.close();
-        reader2.close();
     }
 
     // Test with an archive containing Harmony's Pack200 module, packed with -E1
@@ -175,7 +184,7 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
-        file.delete();
+//        file.delete();
     }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java?rev=651261&r1=651260&r2=651261&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/SegmentTest.java
Thu Apr 24 06:25:40 2008
@@ -90,43 +90,52 @@
         JarEntry entry = jarFile
                 .getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
         assertNotNull(entry);
-        Process process = Runtime
-                .getRuntime()
-                .exec(
-                        "java -cp "
-                                + file.getName()
-                                + " org.apache.harmony.archive.tests.internal.pack200.HelloWorld",
-                        new String[] {}, file.getParentFile());
-        BufferedReader reader = new BufferedReader(new InputStreamReader(
-                process.getInputStream()));
-        String line = reader.readLine();
-        assertEquals("Hello world", line);
-        reader.close();
-
-        Process process2 = Runtime
-                .getRuntime()
-                .exec(
-                        "javap -c -verbose -classpath "
-                                + file.getName()
-                                + " org.apache.harmony.archive.tests.internal.pack200.HelloWorld",
-                        new String[] {}, file.getParentFile());
-        BufferedReader reader1 = new BufferedReader(new InputStreamReader(process2
-                .getInputStream()));
-        InputStream javapCompareFile = Segment.class
-                .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorldJavap.out");
-        BufferedReader reader2 = new BufferedReader(new InputStreamReader(
-                javapCompareFile));
-        String line1 = reader1.readLine();
-        String line2 = reader2.readLine();
-        int i = 1;
-        while (line1 != null || line2 != null) {
-            assertEquals(line2, line1);
-            line1 = reader1.readLine();
-            line2 = reader2.readLine();
-            i++;
+        
+        try {
+            Process process = Runtime
+                    .getRuntime()
+                    .exec(
+                            "java -cp "
+                                    + file.getName()
+                                    + " org.apache.harmony.archive.tests.internal.pack200.HelloWorld",
+                            new String[] {}, file.getParentFile());
+            BufferedReader reader = new BufferedReader(new InputStreamReader(
+                    process.getInputStream()));
+            String line = reader.readLine();
+            assertEquals("Hello world", line);
+            reader.close();
+    
+            Process process2 = Runtime
+                    .getRuntime()
+                    .exec(
+                            "javap -c -verbose -classpath "
+                                    + file.getName()
+                                    + " org.apache.harmony.archive.tests.internal.pack200.HelloWorld",
+                            new String[] {}, file.getParentFile());
+            BufferedReader reader1 = new BufferedReader(new InputStreamReader(process2
+                    .getInputStream()));
+            InputStream javapCompareFile = Segment.class
+                    .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorldJavap.out");
+            BufferedReader reader2 = new BufferedReader(new InputStreamReader(
+                    javapCompareFile));
+            String line1 = reader1.readLine();
+            String line2 = reader2.readLine();
+            int i = 1;
+            while (line1 != null || line2 != null) {
+                assertEquals(line2, line1);
+                line1 = reader1.readLine();
+                line2 = reader2.readLine();
+                i++;
+            }
+            reader1.close();
+            reader2.close();
+        } catch (IOException e) {
+            if (e.getMessage().startsWith("Unable to start program")) {
+                System.out.println("Warning: org.apache.harmony.unpack200.tests.SegmentTest.testHelloWorld()
was not completed as java or javap could not be found");
+            } else {
+                throw e;
+            }
         }
-        reader1.close();
-        reader2.close();
     }
 
 }



Mime
View raw message