harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r572686 [3/3] - in /harmony/enhanced/classlib/trunk/modules/pack200/src: main/java/org/apache/harmony/pack200/ test/java/org/apache/harmony/pack200/tests/
Date Tue, 04 Sep 2007 13:54:47 GMT
Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java?rev=572686&r1=572685&r2=572686&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/AttributeLayoutTest.java
Tue Sep  4 06:54:46 2007
@@ -23,6 +23,7 @@
 import org.apache.harmony.pack200.AttributeLayout;
 import org.apache.harmony.pack200.Pack200Exception;
 import org.apache.harmony.pack200.Segment;
+import org.apache.harmony.pack200.SegmentConstantPool;
 
 public class AttributeLayoutTest extends TestCase {
 	public class TestSegment extends Segment {
@@ -32,7 +33,7 @@
 					{ "Zero", "One" }, // UTF-8
 					{ "Ein", "Zwei" }, // Signature
 			};
-			return new SegmentConstantPool() {
+			return new SegmentConstantPool(null) {
 				public Object getValue(int cp, long index) {
 					if (index == -1)
 						return null;
@@ -55,30 +56,30 @@
 	public void testLayoutRU() throws Pack200Exception {
 		AttributeLayout layout = new AttributeLayout("RU",AttributeLayout.CONTEXT_CLASS,"RU", 1);
 		Segment segment = new TestSegment();
-		assertNull(layout.getValue(-1, segment));
-		assertEquals("Zero",layout.getValue(0, segment));
-		assertEquals("One",layout.getValue(1, segment));
+		assertNull(layout.getValue(-1, segment.getConstantPool()));
+		assertEquals("Zero",layout.getValue(0, segment.getConstantPool()));
+		assertEquals("One",layout.getValue(1, segment.getConstantPool()));
 	}
 	public void testLayoutRUN() throws Pack200Exception {
 		AttributeLayout layout = new AttributeLayout("RUN",AttributeLayout.CONTEXT_CLASS,"RUN",
1);
 		Segment segment = new TestSegment();
-		assertNull(layout.getValue(0, segment));
-		assertEquals("Zero",layout.getValue(1, segment));
-		assertEquals("One",layout.getValue(2, segment));
+		assertNull(layout.getValue(0, segment.getConstantPool()));
+		assertEquals("Zero",layout.getValue(1, segment.getConstantPool()));
+		assertEquals("One",layout.getValue(2, segment.getConstantPool()));
 	}
 	public void testLayoutRS() throws Pack200Exception {
 		AttributeLayout layout = new AttributeLayout("RS",AttributeLayout.CONTEXT_CLASS,"RS", 1);
 		Segment segment = new TestSegment();
-		assertNull(layout.getValue(-1, segment));
-		assertEquals("Ein",layout.getValue(0, segment));
-		assertEquals("Zwei",layout.getValue(1, segment));
+		assertNull(layout.getValue(-1, segment.getConstantPool()));
+		assertEquals("Ein",layout.getValue(0, segment.getConstantPool()));
+		assertEquals("Zwei",layout.getValue(1, segment.getConstantPool()));
 	}
 	public void testLayoutRSN() throws Pack200Exception {
 		AttributeLayout layout = new AttributeLayout("RSN",AttributeLayout.CONTEXT_CLASS,"RSN",
1);
 		Segment segment = new TestSegment();
-		assertNull(layout.getValue(0, segment));
-		assertEquals("Ein",layout.getValue(1, segment));
-		assertEquals("Zwei",layout.getValue(2, segment));
+		assertNull(layout.getValue(0, segment.getConstantPool()));
+		assertEquals("Ein",layout.getValue(1, segment.getConstantPool()));
+		assertEquals("Zwei",layout.getValue(2, segment.getConstantPool()));
 	}
 	public boolean throwsException(String name, int context, String layout) {
 		try {

Added: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java?rev=572686&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
Tue Sep  4 06:54:46 2007
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.pack200.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.pack200.BHSDCodec;
+import org.apache.harmony.pack200.BandSet;
+import org.apache.harmony.pack200.Codec;
+import org.apache.harmony.pack200.Pack200Exception;
+import org.apache.harmony.pack200.Segment;
+
+public class BandSetTest extends TestCase {
+    
+    private BandSet bandSet = new BandSet(new Segment()) {
+
+        public void pack(OutputStream outputStream) {
+            // TODO Auto-generated method stub
+            
+        }
+
+        public void unpack(InputStream inputStream) throws IOException, Pack200Exception
{
+            // TODO Auto-generated method stub
+            
+        }
+    };
+    
+    public void testDecodeBandInt() throws IOException, Pack200Exception {
+        BHSDCodec codec = Codec.BYTE1;
+        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78};
+        InputStream in = new ByteArrayInputStream(bytes);
+        int[] ints = bandSet.decodeBandInt("Test Band", in, codec, 4);
+        for (int i = 0; i < ints.length; i++) {
+            assertEquals("Wrong value in position " + i, ints[i], bytes[i]);
+        }
+    }
+    
+    public void testDecodeBandLong() throws IOException, Pack200Exception {
+        BHSDCodec codec = Codec.BYTE1;
+        byte[] bytes = new byte[]{(byte)3,(byte)56,(byte)122,(byte)78, Byte.MAX_VALUE, Byte.MIN_VALUE};
+        InputStream in = new ByteArrayInputStream(bytes);
+        long[] longs = bandSet.decodeBandLong("Test Band", in, codec, 4);
+        for (int i = 0; i < longs.length; i++) {
+            assertEquals("Wrong value in position " + i, longs[i], bytes[i]);
+        }        
+        //TODO: Should test this with other Codecs.
+    }
+    
+    public void testParseFlags1() {
+        
+    }
+    
+    public void testParseFlags2() {
+        
+    }
+    
+    public void testParseFlags3() {
+        
+    }
+    
+    public void testParseReferences1() {
+        
+    }
+    
+    public void testParseReferences2() {
+        
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/BandSetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message