harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r996816 [2/2] - in /harmony/enhanced/java/branches/java6: ./ classlib/ classlib/depends/libs/ classlib/modules/pack200/src/main/java/org/apache/harmony/pack200/ classlib/modules/pack200/src/main/java/org/apache/harmony/unpack200/ classlib/m...
Date Tue, 14 Sep 2010 10:28:22 GMT
Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/NewAttributeBandsTest.java
Tue Sep 14 10:28:21 2010
@@ -24,14 +24,12 @@ import java.util.List;
 import junit.framework.TestCase;
 
 import org.apache.harmony.pack200.AttributeDefinitionBands;
+import org.apache.harmony.pack200.AttributeDefinitionBands.AttributeDefinition;
 import org.apache.harmony.pack200.CPUTF8;
 import org.apache.harmony.pack200.Codec;
 import org.apache.harmony.pack200.CpBands;
 import org.apache.harmony.pack200.NewAttribute;
 import org.apache.harmony.pack200.NewAttributeBands;
-import org.apache.harmony.pack200.Pack200Exception;
-import org.apache.harmony.pack200.SegmentHeader;
-import org.apache.harmony.pack200.AttributeDefinitionBands.AttributeDefinition;
 import org.apache.harmony.pack200.NewAttributeBands.Call;
 import org.apache.harmony.pack200.NewAttributeBands.Callable;
 import org.apache.harmony.pack200.NewAttributeBands.Integral;
@@ -39,6 +37,8 @@ import org.apache.harmony.pack200.NewAtt
 import org.apache.harmony.pack200.NewAttributeBands.Replication;
 import org.apache.harmony.pack200.NewAttributeBands.Union;
 import org.apache.harmony.pack200.NewAttributeBands.UnionCase;
+import org.apache.harmony.pack200.Pack200Exception;
+import org.apache.harmony.pack200.SegmentHeader;
 
 /**
  * Tests for pack200 support for non-predefined attributes
@@ -200,6 +200,65 @@ public class NewAttributeBandsTest exten
         Call call = (Call) repBody.get(0);
         assertEquals(1, call.getCallableIndex());
         assertEquals(secondCallable, call.getCallable());
+        assertFalse(firstCallable.isBackwardsCallable());
+        assertFalse(secondCallable.isBackwardsCallable());
+        assertFalse(thirdCallable.isBackwardsCallable());
+    }
+
+    public void testLayoutWithBackwardsCalls() throws Exception {
+        CPUTF8 name = new CPUTF8("TestAttribute");
+        CPUTF8 layout = new CPUTF8("[NH[(1)]][KIH][(-1)]");
+        MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
+                null, null, new AttributeDefinition(35,
+                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
+        List layoutElements = newAttributeBands.getLayoutElements();
+        assertEquals(3, layoutElements.size());
+        Callable firstCallable = (Callable) layoutElements.get(0);
+        Callable secondCallable = (Callable) layoutElements.get(1);
+        Callable thirdCallable = (Callable) layoutElements.get(2);
+        List thirdBody = thirdCallable.getBody();
+        assertEquals(1, thirdBody.size());
+        Call call = (Call) thirdBody.get(0);
+        assertEquals(secondCallable, call.getCallable());
+        assertTrue(secondCallable.isBackwardsCallable());
+        assertFalse(firstCallable.isBackwardsCallable());
+        assertFalse(thirdCallable.isBackwardsCallable());
+
+        name = new CPUTF8("TestAttribute");
+        layout = new CPUTF8("[NH[(1)]][KIH][(-2)]");
+        newAttributeBands = new MockNewAttributeBands(1, null, null,
+                new AttributeDefinition(35,
+                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
+        layoutElements = newAttributeBands.getLayoutElements();
+        assertEquals(3, layoutElements.size());
+        firstCallable = (Callable) layoutElements.get(0);
+        secondCallable = (Callable) layoutElements.get(1);
+        thirdCallable = (Callable) layoutElements.get(2);
+        thirdBody = thirdCallable.getBody();
+        assertEquals(1, thirdBody.size());
+        call = (Call) thirdBody.get(0);
+        assertEquals(firstCallable, call.getCallable());
+        assertTrue(firstCallable.isBackwardsCallable());
+        assertFalse(secondCallable.isBackwardsCallable());
+        assertFalse(thirdCallable.isBackwardsCallable());
+
+        name = new CPUTF8("TestAttribute");
+        layout = new CPUTF8("[NH[(1)]][KIH][(0)]");
+        newAttributeBands = new MockNewAttributeBands(1, null, null,
+                new AttributeDefinition(35,
+                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
+        layoutElements = newAttributeBands.getLayoutElements();
+        assertEquals(3, layoutElements.size());
+        firstCallable = (Callable) layoutElements.get(0);
+        secondCallable = (Callable) layoutElements.get(1);
+        thirdCallable = (Callable) layoutElements.get(2);
+        thirdBody = thirdCallable.getBody();
+        assertEquals(1, thirdBody.size());
+        call = (Call) thirdBody.get(0);
+        assertEquals(thirdCallable, call.getCallable());
+        assertTrue(thirdCallable.isBackwardsCallable());
+        assertFalse(firstCallable.isBackwardsCallable());
+        assertFalse(secondCallable.isBackwardsCallable());
     }
 
     public void testAddAttributes() throws IOException, Pack200Exception {
@@ -208,12 +267,16 @@ public class NewAttributeBandsTest exten
         MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
                 null, null, new AttributeDefinition(35,
                         AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
-        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[]
{27}, null, 0, null));
-        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[]
{56}, null, 0, null));
-        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[]
{3}, null, 0, null));
+        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
+                "B", new byte[] { 27 }, null, 0, null));
+        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
+                "B", new byte[] { 56 }, null, 0, null));
+        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
+                "B", new byte[] { 3 }, null, 0, null));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         newAttributeBands.pack(out);
-        // BYTE1 is used for B layouts so we don't need to unpack to test the results
+        // BYTE1 is used for B layouts so we don't need to unpack to test the
+        // results
         byte[] bytes = out.toByteArray();
         assertEquals(3, bytes.length);
         assertEquals(27, bytes[0]);
@@ -221,17 +284,20 @@ public class NewAttributeBandsTest exten
         assertEquals(3, bytes[2]);
     }
 
-    public void testAddAttributesWithReplicationLayout() throws IOException, Pack200Exception
{
+    public void testAddAttributesWithReplicationLayout() throws IOException,
+            Pack200Exception {
         CPUTF8 name = new CPUTF8("TestAttribute");
         CPUTF8 layout = new CPUTF8("NB[SH]");
         MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
                 null, null, new AttributeDefinition(35,
                         AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
-        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[]
{1, 0, 100}, null, 0, null));
+        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
+                "B", new byte[] { 1, 0, 100 }, null, 0, null));
         short s = -50;
-        byte b1 = (byte)(s>>>8);
-        byte b2 = (byte)s;
-        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute", "B", new byte[]
{3, 0, 5, 0, 25, b1, b2}, null, 0, null));
+        byte b1 = (byte) (s >>> 8);
+        byte b2 = (byte) s;
+        newAttributeBands.addAttribute(new NewAttribute(null, "TestAttribute",
+                "B", new byte[] { 3, 0, 5, 0, 25, b1, b2 }, null, 0, null));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         newAttributeBands.pack(out);
         byte[] bytes = out.toByteArray();
@@ -239,7 +305,8 @@ public class NewAttributeBandsTest exten
         assertEquals(3, bytes[1]);
         byte[] band = new byte[bytes.length - 2];
         System.arraycopy(bytes, 2, band, 0, band.length);
-        int[] decoded = Codec.SIGNED5.decodeInts(4, new ByteArrayInputStream(band));
+        int[] decoded = Codec.SIGNED5.decodeInts(4, new ByteArrayInputStream(
+                band));
         assertEquals(4, decoded.length);
         assertEquals(100, decoded[0]);
         assertEquals(5, decoded[1]);

Modified: harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java?rev=996816&r1=996815&r2=996816&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
(original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/pack200/src/test/java/org/apache/harmony/unpack200/tests/ArchiveTest.java
Tue Sep 14 10:28:21 2010
@@ -19,6 +19,7 @@ package org.apache.harmony.unpack200.tes
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -65,11 +66,11 @@ public class ArchiveTest extends TestCas
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
         file = File.createTempFile("sql", ".jar");
+        file.deleteOnExit();
         out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
         JarFile jarFile = new JarFile(file);
-        file.deleteOnExit();
 
         File compareFile = new File(Archive.class.getResource(
                 "/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
@@ -172,6 +173,7 @@ public class ArchiveTest extends TestCas
         in = Archive.class
                 .getResourceAsStream("/org/apache/harmony/pack200/tests/LargeClass.pack.gz");
         file = File.createTempFile("largeClass", ".jar");
+        file.deleteOnExit();
         out = new JarOutputStream(new FileOutputStream(file));
         Archive archive = new Archive(in, out);
         archive.unpack();
@@ -196,4 +198,60 @@ public class ArchiveTest extends TestCas
         file.delete();
     }
 
+    // Test verbose, quiet and log file options.
+    public void testLoggingOptions() throws Exception {
+        // test default option, which is quiet (no output at all)
+        in = Archive.class
+                .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
+        file = File.createTempFile("logtest", ".jar");
+        file.deleteOnExit();
+        out = new JarOutputStream(new FileOutputStream(file));
+        Archive archive = new Archive(in, out);
+        File logFile = File.createTempFile("logfile", ".txt");
+        logFile.deleteOnExit();
+        archive.setLogFile(logFile.getPath());
+        archive.unpack();
+
+        // log file should be empty
+        FileReader reader = new FileReader(logFile);
+        assertFalse(reader.ready());
+        reader.close();
+
+        // test verbose
+        in = Archive.class
+                .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
+        file = File.createTempFile("logtest", ".jar");
+        file.deleteOnExit();
+        out = new JarOutputStream(new FileOutputStream(file));
+        archive = new Archive(in, out);
+        logFile = File.createTempFile("logfile", ".txt");
+        logFile.deleteOnExit();
+        archive.setLogFile(logFile.getPath());
+        archive.setVerbose(true);
+        archive.unpack();
+
+        // log file should not be empty
+        reader = new FileReader(logFile);
+        assertTrue(reader.ready());
+        reader.close();
+
+        // test setting quiet explicitly
+        in = Archive.class
+                .getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
+        file = File.createTempFile("logtest", ".jar");
+        file.deleteOnExit();
+        out = new JarOutputStream(new FileOutputStream(file));
+        archive = new Archive(in, out);
+        logFile = File.createTempFile("logfile", ".txt");
+        logFile.deleteOnExit();
+        archive.setLogFile(logFile.getPath());
+        archive.setQuiet(true);
+        archive.unpack();
+
+        // log file should be empty
+        reader = new FileReader(logFile);
+        assertFalse(reader.ready());
+        reader.close();
+    }
+
 }
\ No newline at end of file

Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 10:28:21 2010
@@ -1,5 +1,5 @@
 /harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-996210,996457,996567,996687,996798
+/harmony/enhanced/java/trunk/drlvm:929253-996210,996457,996567,996687,996798,996801
 /harmony/enhanced/trunk/drlvm:476395-929252
 /harmony/enhanced/trunk/working_vm:476396-920147
 /incubator/harmony/enhanced/trunk/drlvm:292550-476394

Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 14 10:28:21 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-996210,996457,996567,996687,996798
+/harmony/enhanced/java/trunk/jdktools:929253-996210,996457,996567,996687,996798,996801
 /harmony/enhanced/jdktools/trunk:630107-925933
 /harmony/enhanced/trunk/jdktools:476395-929252
 /harmony/enhanced/trunk/working_jdktools:476396-920147



Mime
View raw message