harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r478908 - in /harmony/enhanced/classlib/trunk/modules/archive: ./ src/test/java/org/apache/harmony/archive/tests/internal/pack200/ src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/
Date Fri, 24 Nov 2006 16:29:50 GMT
Author: apetrenko
Date: Fri Nov 24 08:29:49 2006
New Revision: 478908

URL: http://svn.apache.org/viewvc?view=rev&rev=478908
Log:
Patch for HARMONY-2246 "[classlib][pack200] Ongoing implementation"

Added:
    harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/
    harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ClassFileEntryTest.java
    harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ConstantPoolTest.java
Modified:
    harmony/enhanced/classlib/trunk/modules/archive/build.xml
    harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/AllTests.java

Modified: harmony/enhanced/classlib/trunk/modules/archive/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/build.xml?view=diff&rev=478908&r1=478907&r2=478908
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/archive/build.xml Fri Nov 24 08:29:49 2006
@@ -232,6 +232,7 @@
 
                 <fileset dir="${hy.archive.src.test.java}">
                     <include name="**/*Test.java"/>
+		    <exclude name="org/apache/harmony/archive/tests/internal/pack200/SegmentTest.java"
/>
                 </fileset>
             </batchtest>
         </junit>

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/AllTests.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/AllTests.java?view=diff&rev=478908&r1=478907&r2=478908
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/AllTests.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/AllTests.java
Fri Nov 24 08:29:49 2006
@@ -18,6 +18,9 @@
 // NOTE: Do not use generics in this code; it needs to run on JVMs < 1.5
 // NOTE: Do not extract strings as messages; this code is still a work-in-progress
 // NOTE: Also, don't get rid of 'else' statements for the hell of it ...
+import org.apache.harmony.archive.tests.internal.pack200.bytecode.ClassFileEntryTest;
+import org.apache.harmony.archive.tests.internal.pack200.bytecode.ConstantPoolTest;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 /**
@@ -35,8 +38,10 @@
 		// $JUnit-BEGIN$
 		suite.addTestSuite(AttributeLayoutMapTest.class);
 		suite.addTestSuite(AttributeLayoutTest.class);
+		suite.addTestSuite(ClassFileEntryTest.class);
 		suite.addTestSuite(CodecEncodingTest.class);
 		suite.addTestSuite(CodecTest.class);
+		suite.addTestSuite(ConstantPoolTest.class);
 		suite.addTestSuite(PopulationCodecTest.class);
 		suite.addTestSuite(SegmentOptionsTest.class);
 		suite.addTestSuite(SegmentTest.class);

Added: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ClassFileEntryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ClassFileEntryTest.java?view=auto&rev=478908
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ClassFileEntryTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ClassFileEntryTest.java
Fri Nov 24 08:29:49 2006
@@ -0,0 +1,75 @@
+package org.apache.harmony.archive.tests.internal.pack200.bytecode;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.archive.internal.pack200.bytecode.CPDouble;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPFloat;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPInteger;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPLong;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPMember;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPString;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPUTF8;
+import org.apache.harmony.archive.internal.pack200.bytecode.SourceFileAttribute;
+
+public class ClassFileEntryTest extends TestCase {
+	public void testUTF8() {
+		CPUTF8 u1 = new CPUTF8(new String("thing")); //$NON-NLS-1$
+		CPUTF8 u2 = new CPUTF8(new String("thing")); //$NON-NLS-1$
+		CPUTF8 u3 = new CPUTF8(new String("otherthing")); //$NON-NLS-1$
+		checkEquality(u1, u2, "thing", u3);
+	}
+	private void checkEquality(Object equal1, Object equal2, String toString, Object unequal)
{
+		assertEquals(equal1,equal2);
+		assertEquals(equal1.hashCode(),equal2.hashCode());
+		assertTrue(equal1.toString().indexOf(toString)>=0); //$NON-NLS-1$
+		assertFalse(equal1.equals(unequal));
+		assertFalse(equal2.equals(unequal));
+		assertFalse(unequal.equals(equal1));
+		assertFalse(unequal.equals(equal2));
+	}
+	public void testSourceAttribute() {
+		SourceFileAttribute sfa1 = new SourceFileAttribute(new String("Thing.java")); //$NON-NLS-1$
+		SourceFileAttribute sfa2 = new SourceFileAttribute(new String("Thing.java")); //$NON-NLS-1$
+		SourceFileAttribute sfa3 = new SourceFileAttribute(new String("OtherThing.java")); //$NON-NLS-1$
+		checkEquality(sfa1,sfa2,"Thing.java",sfa3); //$NON-NLS-1$
+	}
+	public void testCPInteger() {
+		CPInteger cp1 = new CPInteger(new Integer(3));
+		CPInteger cp2 = new CPInteger(new Integer(3));
+		CPInteger cp3 = new CPInteger(new Integer(5));
+		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
+	}
+	public void testCPLong() {
+		CPLong cp1 = new CPLong(new Long(3));
+		CPLong cp2 = new CPLong(new Long(3));
+		CPLong cp3 = new CPLong(new Long(5));
+		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
+	}
+	public void testCPDouble() {
+		CPDouble cp1 = new CPDouble(new Double(3));
+		CPDouble cp2 = new CPDouble(new Double(3));
+		CPDouble cp3 = new CPDouble(new Double(5));
+		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
+	}
+	public void testCPFloat() {
+		CPFloat cp1 = new CPFloat(new Float(3));
+		CPFloat cp2 = new CPFloat(new Float(3));
+		CPFloat cp3 = new CPFloat(new Float(5));
+		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
+	}
+	public void testCPString() {
+		CPString cp1 = new CPString(new String("3"));
+		CPString cp2 = new CPString(new String("3"));
+		CPString cp3 = new CPString(new String("5"));
+		checkEquality(cp1,cp2,"3",cp3); //$NON-NLS-1$
+	}
+	public void testCPField() {
+		CPMember cp1 = new CPMember("Name:I", 0, null);
+		CPMember cp2 = new CPMember("Name:I", 0, null);
+		CPMember cp3 = new CPMember("Name:Z", 0, null);
+		CPMember cp4 = new CPMember("GName:I", 0, null);
+		checkEquality(cp1,cp2,"Name",cp3); //$NON-NLS-1$
+		checkEquality(cp1,cp2,"I",cp4); //$NON-NLS-1$
+	}
+
+}

Added: harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ConstantPoolTest.java?view=auto&rev=478908
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ConstantPoolTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/internal/pack200/bytecode/ConstantPoolTest.java
Fri Nov 24 08:29:49 2006
@@ -0,0 +1,37 @@
+package org.apache.harmony.archive.tests.internal.pack200.bytecode;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.archive.internal.pack200.bytecode.CPMember;
+import org.apache.harmony.archive.internal.pack200.bytecode.CPUTF8;
+import org.apache.harmony.archive.internal.pack200.bytecode.ClassConstantPool;
+
+public class ConstantPoolTest extends TestCase {
+	private ClassConstantPool pool;
+
+	public void setUp() {
+		pool = new ClassConstantPool();
+	}
+	public void testDuplicateUTF8() {
+		CPUTF8 u1 = new CPUTF8("thing");
+		CPUTF8 u2 = new CPUTF8("thing");
+		pool.add(u1);
+		pool.add(u2);
+		assertEquals(1,pool.size());
+	}
+	public void testDuplicateField() {
+		CPMember cp1 = new CPMember("name:I",0,null);
+		pool.add(cp1);
+		assertEquals(2,pool.size());
+		CPMember cp2 = new CPMember("name:I",0,null);
+		pool.add(cp2);
+		assertEquals(2,pool.size());
+	}
+	public void testIndex() {
+		pool.add(new CPUTF8("OtherThing"));
+		CPUTF8 u1 = new CPUTF8("thing");
+		pool.add(u1);
+		pool.resolve();
+		assertTrue(pool.indexOf(u1) > 0);
+	}
+}



Mime
View raw message