harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r687281 - in /harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests: ArchiveTest.java SegmentTest.java
Date Wed, 20 Aug 2008 08:18:48 GMT
Author: sjanuary
Date: Wed Aug 20 01:18:47 2008
New Revision: 687281

URL: http://svn.apache.org/viewvc?rev=687281&view=rev
Log:
Fix pack200 tests to do the right thing for different versions of javap

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=687281&r1=687280&r2=687281&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
Wed Aug 20 01:18:47 2008
@@ -73,7 +73,7 @@
                 .getJarEntry("bin/test/org/apache/harmony/sql/tests/javax/sql/rowset/BaseRowSetTest$BaseRowSetImpl.class");
         assertNotNull(entry);
         try {
-        Process process2 = Runtime
+            Process process2 = Runtime
                 .getRuntime()
                 .exec(
                         "javap -c -verbose -classpath "
@@ -87,19 +87,20 @@
                     .getResourceAsStream("/org/apache/harmony/pack200/tests/sqlJavap.out");
             BufferedReader reader2 = new BufferedReader(new InputStreamReader(
                     javapCompareFile));
-            String line1 = reader1.readLine();
-            String line2 = reader2.readLine();
+            String line1 = readNextLine(reader1);
+            String line2 = readNextLine(reader2);
             int i = 1;
             while (line1 != null || line2 != null) {
                 assertEquals(line2, line1);
-                line1 = reader1.readLine();
-                line2 = reader2.readLine();
+                line1 = readNextLine(reader1);
+                line2 = readNextLine(reader2);
                 i++;
             }
             reader1.close();
             reader2.close();
         } catch (IOException e) {
-            if(e.getMessage().startsWith("Unable to start program")) {
+            String message = e.getMessage();
+            if (message.startsWith("Unable to start program") || message.startsWith("The
creation of the Process has just failed")) {
                 System.out.println("Warning: org.apache.harmony.unpack200.tests.ArchiveTest.testWithSql()
was not completed as javap could not be found");
             } else {
                 throw e;
@@ -107,6 +108,14 @@
         }
     }
 
+    private String readNextLine(BufferedReader reader) throws IOException {
+        String line = reader.readLine();
+        while ("".equals(line)) {
+            line = reader.readLine();
+        }
+        return line;
+    }
+
     // Test with an archive containing Harmony's Pack200 module, packed with -E1
     public void testWithPack200E1() throws Exception {
         in = Archive.class
@@ -184,7 +193,7 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
-//        file.delete();
+        file.delete();
     }
 
 }
\ No newline at end of file

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=687281&r1=687280&r2=687281&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
Wed Aug 20 01:18:47 2008
@@ -90,7 +90,7 @@
         JarEntry entry = jarFile
                 .getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
         assertNotNull(entry);
-        
+
         try {
             Process process = Runtime
                     .getRuntime()
@@ -104,7 +104,7 @@
             String line = reader.readLine();
             assertEquals("Hello world", line);
             reader.close();
-    
+
             Process process2 = Runtime
                     .getRuntime()
                     .exec(
@@ -118,19 +118,20 @@
                     .getResourceAsStream("/org/apache/harmony/pack200/tests/HelloWorldJavap.out");
             BufferedReader reader2 = new BufferedReader(new InputStreamReader(
                     javapCompareFile));
-            String line1 = reader1.readLine();
-            String line2 = reader2.readLine();
+            String line1 = readNextLine(reader1);
+            String line2 = readNextLine(reader2);
             int i = 1;
             while (line1 != null || line2 != null) {
                 assertEquals(line2, line1);
-                line1 = reader1.readLine();
-                line2 = reader2.readLine();
+                line1 = readNextLine(reader1);
+                line2 = readNextLine(reader2);
                 i++;
             }
             reader1.close();
             reader2.close();
         } catch (IOException e) {
-            if (e.getMessage().startsWith("Unable to start program")) {
+            String message = e.getMessage();
+            if (message.startsWith("Unable to start program") || message.startsWith("The
creation of the Process has just failed")) {
                 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;
@@ -138,4 +139,12 @@
         }
     }
 
+    private String readNextLine(BufferedReader reader) throws IOException {
+        String line = reader.readLine();
+        while ("".equals(line)) {
+            line = reader.readLine();
+        }
+        return line;
+    }
+
 }



Mime
View raw message