harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r397192 [1/3] - in /incubator/harmony/enhanced/classlib/trunk: modules/archive/src/test/java/org/apache/harmony/archive/ modules/archive/src/test/java/org/apache/harmony/archive/tests/ modules/archive/src/test/java/org/apache/harmony/archiv...
Date Wed, 26 Apr 2006 13:04:23 GMT
Author: gharley
Date: Wed Apr 26 06:04:19 2006
New Revision: 397192

URL: http://svn.apache.org/viewcvs?rev=397192&view=rev
Log:
Merge all archive tests into one package whose name meets naming convention. Other modules to follow.

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/AllTests.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CRC32Test.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedInputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/CheckedOutputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterOutputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/DeflaterTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPInputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/GZIPOutputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterInputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/InflaterTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipEntryTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipFileTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipInputStreamTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/ZipOutputStreamTest.java   (with props)
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/
Modified:
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/main/AllTests.java

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/AllTests.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/AllTests.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,37 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AllTests.suite());
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("All Archive test suites");
+        // $JUnit-BEGIN$
+        suite.addTest(org.apache.harmony.archive.tests.java.util.jar.AllTests
+                .suite());
+        suite.addTest(org.apache.harmony.archive.tests.java.util.zip.AllTests
+                .suite());
+        // $JUnit-END$
+        return suite;
+    }
+}

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,45 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite for java.util.jar package.
+ */
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+                "Suite org.apache.harmony.archive.tests.java.util.jar");
+		// $JUnit-BEGIN$
+        suite.addTestSuite(AttributesNameTest.class);
+		suite.addTestSuite(AttributesTest.class);
+		suite.addTestSuite(JarEntryTest.class);
+		suite.addTestSuite(JarExceptionTest.class);
+		suite.addTestSuite(JarFileTest.class);
+		suite.addTestSuite(JarInputStreamTest.class);
+		suite.addTestSuite(JarOutputStreamTest.class);
+		suite.addTestSuite(ManifestTest.class);
+		// $JUnit-END$
+		return suite;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,37 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.util.jar.Attributes;
+
+import junit.framework.TestCase;
+
+public class AttributesNameTest extends TestCase {
+
+	/**
+	 * @tests java.util.jar.Attributes.Name#Name(java.lang.String)
+	 */
+	public void test_AttributesName_Constructor() {
+		// Regression for HARMONY-85
+		try {
+			new Attributes.Name(
+					"01234567890123456789012345678901234567890123456789012345678901234567890");
+			fail("Assert 0: should have thrown IllegalArgumentException");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesNameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,307 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+import java.util.jar.Attributes;
+
+public class AttributesTest extends junit.framework.TestCase {
+
+	Attributes a;
+
+	/**
+	 * @tests java.util.jar.Attributes#Attributes()
+	 */
+	public void test_Constructor() {
+		// Test for method java.util.jar.Attributes()
+		assertTrue("Used to test", true);
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#Attributes(java.util.jar.Attributes)
+	 */
+	public void test_ConstructorLjava_util_jar_Attributes() {
+		Attributes a2 = new Attributes(a);
+		assertTrue("not equal", a.equals(a2));
+		a.putValue("1", "one(1)");
+		assertTrue("equal", !a.equals(a2));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#clear()
+	 */
+	public void test_clear() {
+		// Test for method void java.util.jar.Attributes.clear()
+		a.clear();
+		assertNull("a) All entries should be null after clear",
+				a.get("1"));
+		assertNull("b) All entries should be null after clear",
+				a.get("2"));
+		assertNull("c) All entries should be null after clear",
+				a.get("3"));
+		assertNull("d) All entries should be null after clear",
+				a.get("4"));
+		assertTrue("Should not contain any keys", !a.containsKey("1"));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#containsKey(java.lang.Object)
+	 */
+	public void test_containsKeyLjava_lang_Object() {
+		// Test for method boolean
+		// java.util.jar.Attributes.containsKey(java.lang.Object)
+		assertTrue("a) Should have returned false", !a.containsKey(new Integer(
+				1)));
+		assertTrue("b) Should have returned false", !a.containsKey("0"));
+		assertTrue("Should have returned true", a
+				.containsKey(new Attributes.Name("1")));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#containsValue(java.lang.Object)
+	 */
+	public void test_containsValueLjava_lang_Object() {
+		// Test for method boolean
+		// java.util.jar.Attributes.containsValue(java.lang.Object)
+		assertTrue("Should have returned false", !a.containsValue("One"));
+		assertTrue("Should have returned true", a.containsValue("one"));
+
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#entrySet()
+	 */
+	public void test_entrySet() {
+		// Test for method java.util.Set java.util.jar.Attributes.entrySet()
+		Set entrySet = a.entrySet();
+		Set keySet = new HashSet();
+		Set valueSet = new HashSet();
+		Iterator i;
+		assertTrue("Wrong size--Wanted: 4, got: " + entrySet.size(), entrySet
+				.size() == 4);
+		i = entrySet.iterator();
+		while (i.hasNext()) {
+			java.util.Map.Entry e;
+			e = (Map.Entry) i.next();
+			keySet.add(e.getKey());
+			valueSet.add(e.getValue());
+		}
+
+		assertTrue("a) Should contain entry", valueSet.contains("one"));
+		assertTrue("b) Should contain entry", valueSet.contains("two"));
+		assertTrue("c) Should contain entry", valueSet.contains("three"));
+		assertTrue("d) Should contain entry", valueSet.contains("four"));
+
+		assertTrue("a) Should contain key", keySet
+				.contains(new Attributes.Name("1")));
+		assertTrue("b) Should contain key", keySet
+				.contains(new Attributes.Name("2")));
+		assertTrue("c) Should contain key", keySet
+				.contains(new Attributes.Name("3")));
+		assertTrue("d) Should contain key", keySet
+				.contains(new Attributes.Name("4")));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#get(java.lang.Object)
+	 */
+	public void test_getLjava_lang_Object() {
+		// Test for method java.lang.Object
+		// java.util.jar.Attributes.get(java.lang.Object)
+		assertEquals("a) Incorrect value returned", "one", a.getValue("1"));
+		assertNull("b) Incorrect value returned", a.getValue("0"));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#isEmpty()
+	 */
+	public void test_isEmpty() {
+		// Test for method boolean java.util.jar.Attributes.isEmpty()
+		assertTrue("Should not be empty", !a.isEmpty());
+		a.clear();
+		assertTrue("a) Should be empty", a.isEmpty());
+		a = new Attributes();
+		assertTrue("b) Should be empty", a.isEmpty());
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#keySet()
+	 */
+	public void test_keySet() {
+		// Test for method java.util.Set java.util.jar.Attributes.keySet()
+		Set s = a.keySet();
+		assertTrue("Wrong size--Wanted: 4, got: " + s.size(), s.size() == 4);
+		assertTrue("a) Should contain entry", s.contains(new Attributes.Name(
+				"1")));
+		assertTrue("b) Should contain entry", s.contains(new Attributes.Name(
+				"2")));
+		assertTrue("c) Should contain entry", s.contains(new Attributes.Name(
+				"3")));
+		assertTrue("d) Should contain entry", s.contains(new Attributes.Name(
+				"4")));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#putAll(java.util.Map)
+	 */
+	public void test_putAllLjava_util_Map() {
+		// Test for method void java.util.jar.Attributes.putAll(java.util.Map)
+		Attributes b = new Attributes();
+		b.putValue("3", "san");
+		b.putValue("4", "shi");
+		b.putValue("5", "go");
+		b.putValue("6", "roku");
+		a.putAll(b);
+		assertEquals("Should not have been replaced", 
+				"one", a.getValue("1"));
+		assertEquals("Should have been replaced", "san", a.getValue("3"));
+		assertEquals("Should have been added", "go", a.getValue("5"));
+        
+        Attributes atts = new Attributes();
+        assertNull("Assert 0: ",
+                atts.put(Attributes.Name.CLASS_PATH, "tools.jar"));
+        assertNull("Assert 1: ", 
+                atts.put(Attributes.Name.MANIFEST_VERSION, "1"));
+
+        Attributes atts2 = new Attributes();
+        atts2.putAll(atts);
+
+        assertEquals("Assert 2:", "tools.jar", 
+                atts2.get(Attributes.Name.CLASS_PATH));
+        assertEquals("Assert 3: ", "1", 
+                atts2.get(Attributes.Name.MANIFEST_VERSION));
+
+        try {
+            atts.putAll(Collections.EMPTY_MAP);
+            fail("Assert 4: no class cast from attrib parameter");
+        } catch (ClassCastException e) {
+            // Expected
+        }
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#remove(java.lang.Object)
+	 */
+	public void test_removeLjava_lang_Object() {
+		// Test for method java.lang.Object
+		// java.util.jar.Attributes.remove(java.lang.Object)
+		a.remove(new Attributes.Name("1"));
+		a.remove(new Attributes.Name("3"));
+		assertNull("Should have been removed", a.getValue("1"));
+		assertEquals("Should not have been removed", 
+				"four", a.getValue("4"));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#size()
+	 */
+	public void test_size() {
+		// Test for method int java.util.jar.Attributes.size()
+		assertEquals("Incorrect size returned", 4, a.size());
+		a.clear();
+		assertTrue("Should have returned 0 size, but got: " + a.size(), a
+				.size() == 0);
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#values()
+	 */
+	public void test_values() {
+		// Test for method java.util.Collection
+		// java.util.jar.Attributes.values()
+		Collection valueCollection = a.values();
+		assertTrue("a) Should contain entry", valueCollection.contains("one"));
+		assertTrue("b) Should contain entry", valueCollection.contains("two"));
+		assertTrue("c) Should contain entry", valueCollection.contains("three"));
+		assertTrue("d) Should contain entry", valueCollection.contains("four"));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#clone()
+	 */
+	public void test_clone() {
+		Attributes a2 = (Attributes) a.clone();
+		assertTrue("not equal", a.equals(a2));
+		a.putValue("1", "one(1)");
+		assertTrue("equal", !a.equals(a2));
+	}
+
+	/**
+	 * @tests java.util.jar.Attributes#equals(java.lang.Object)
+	 */
+	public void test_equalsLjava_lang_Object() {
+		Attributes.Name n1 = new Attributes.Name("name"), n2 = new Attributes.Name(
+				"Name");
+		assertTrue("Names not equal", n1.equals(n2));
+
+		Attributes a1 = new Attributes();
+		a1.putValue("one", "1");
+		a1.putValue("two", "2");
+		Attributes a2 = new Attributes();
+		a2.putValue("One", "1");
+		a2.putValue("TWO", "2");
+		assertTrue("not equal", a1.equals(a2));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		a = new Attributes();
+		a.putValue("1", "one");
+		a.putValue("2", "two");
+		a.putValue("3", "three");
+		a.putValue("4", "four");
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+    
+    /*
+     * @tests java.util.jar.Attributes.put(java.lang.Object, java.lang.Object)
+     */
+    public void test_putLjava_lang_ObjectLjava_lang_Object() {
+        Attributes atts = new Attributes();
+        assertNull("Assert 0: ",
+                atts.put(Attributes.Name.CLASS_PATH, "tools.jar"));
+        assertEquals("Assert 1: ", "tools.jar", 
+                atts.getValue(Attributes.Name.CLASS_PATH));
+
+        // Regression for HARMONY-79
+        try {
+            atts.put("not a name", "value");
+            fail("Assert 2: no class cast from key parameter");
+        } catch (ClassCastException e) {
+            // Expected
+        }
+
+        try {
+            atts.put(Attributes.Name.CLASS_PATH, Boolean.TRUE);
+            fail("Assert 3: no class cast from value parameter");
+        } catch (ClassCastException e) {
+            // Expected
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/AttributesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,138 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.File;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import tests.support.resource.Support_Resources;
+
+public class JarEntryTest extends junit.framework.TestCase {
+
+	java.util.zip.ZipEntry zipEntry;
+
+	java.util.jar.JarEntry jarEntry;
+
+	java.util.jar.JarFile jarFile;
+
+	final String jarName = "hyts_patch.jar";
+
+	final String entryName = "foo/bar/A.class";
+
+	final String entryName2 = "Blah.txt";
+
+	final String attJarName = "hyts_att.jar";
+
+	final String attEntryName = "HasAttributes.txt";
+
+	final String attEntryName2 = "NoAttributes.txt";
+
+	File resources;
+
+	/**
+	 * @tests java.util.jar.JarEntry#JarEntry(java.util.zip.ZipEntry)
+	 */
+	public void test_ConstructorLjava_util_zip_ZipEntry() {
+		// Test for method java.util.jar.JarEntry(java.util.zip.ZipEntry)
+		assertNotNull("Jar file is null", jarFile);
+		zipEntry = jarFile.getEntry(entryName);
+		assertNotNull("Zip entry is null", zipEntry);
+		jarEntry = new JarEntry(zipEntry);
+		assertNotNull("Jar entry is null", jarEntry);
+		assertTrue("Wrong entry constucted--wrong name", jarEntry.getName()
+				.equals(entryName));
+		assertEquals("Wrong entry constucted--wrong size",
+				311, jarEntry.getSize());
+	}
+
+	/**
+	 * @tests java.util.jar.JarEntry#getAttributes()
+	 */
+	public void test_getAttributes() {
+		// Test for method java.util.jar.Attributes
+		// java.util.jar.JarEntry.getAttributes()
+		JarFile attrJar = null;
+		File file = null;
+		try {
+			Support_Resources.copyFile(resources, null, attJarName);
+			file = new File(resources, attJarName);
+			attrJar = new JarFile(file);
+		} catch (Exception e) {
+			assertTrue(file + " does not exist", file.exists());
+			fail("Exception opening file: " + e.toString());
+		}
+
+		try {
+			jarEntry = attrJar.getJarEntry(attEntryName);
+			assertNotNull("Should have Manifest attributes", jarEntry
+					.getAttributes());
+		} catch (Exception e) {
+			fail("Exception during 2nd test: " + e.toString());
+		}
+
+		try {
+			jarEntry = attrJar.getJarEntry(attEntryName2);
+			assertNull("Shouldn't have any Manifest attributes", jarEntry
+					.getAttributes());
+			attrJar.close();
+		} catch (Exception e) {
+			fail("Exception during 1st test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.jar.JarEntry#getCertificates()
+	 */
+	public void test_getCertificates() {
+		// Test for method java.security.cert.Certificate []
+		// java.util.jar.JarEntry.getCertificates()
+		zipEntry = jarFile.getEntry(entryName2);
+		jarEntry = new JarEntry(zipEntry);
+		assertNull("Shouldn't have any Certificates", jarEntry
+				.getCertificates());
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+
+	protected void setUp() {
+		try {
+			resources = Support_Resources.createTempFolder();
+			Support_Resources.copyFile(resources, null, jarName);
+			jarFile = new JarFile(new File(resources, jarName));
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail("Exception during setup: " + e.toString());
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+
+	protected void tearDown() {
+		try {
+			if (jarFile != null)
+				jarFile.close();
+		} catch (java.io.IOException e) {
+			System.out.println("Exception during tearDown");
+		}
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarEntryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,53 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.IOException;
+import java.util.jar.Manifest;
+
+public class JarExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.util.jar.JarException#JarException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.util.jar.JarException(java.lang.String)
+		try {
+			new Manifest(new java.io.ByteArrayInputStream(
+					"jlkasj dl: dsklf jlks dslka : fdsfsd\n\n\n\ndsfas"
+							.getBytes()));
+			fail("Should have thrown exception");
+		} catch (IOException e) {
+			// correct
+		} catch (Exception e) {
+			fail("Threw the wrong exception: " + e.toString());
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,563 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import tests.support.Support_PlatformFile;
+import tests.support.resource.Support_Resources;
+
+public class JarFileTest extends junit.framework.TestCase {
+
+	java.util.zip.ZipEntry zipEntry;
+
+	java.util.jar.JarEntry jarEntry;
+
+	java.util.jar.JarFile jarFile;
+
+	final String jarName = "hyts_patch.jar"; // a 'normal' jar file
+
+	// same as patch.jar but without a manifest file
+	final String jarName2 = "hyts_patch2.jar"; 
+
+	final String jarName3 = "hyts_manifest1.jar";
+
+	final String jarName4 = "hyts_signed.jar";
+
+	final String entryName = "foo/bar/A.class";
+
+	final String entryName2 = "Blah.txt";
+
+	final String entryName3 = "coucou/FileAccess.class";
+
+	File resources;
+
+	/**
+	 * @tests java.util.jar.JarFile#JarFile(java.io.File)
+	 */
+	public void test_ConstructorLjava_io_File() {
+		// Test for method java.util.jar.JarFile(java.io.File)
+		/*
+		 * try { assertTrue("Error in created file", new JarFile(new
+		 * java.io.File(jarName)).getEntry(entryName).getName().equals(entryName)); }
+		 * catch (Exception e) { fail("Exception during test: " +
+		 * e.toString()); }
+		 */
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#JarFile(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.util.jar.JarFile(java.lang.String)
+		/*
+		 * try { assertTrue("Error in created file", new
+		 * JarFile(jarName).getEntry(entryName).getName().equals(entryName)); }
+		 * catch (Exception e) { fail("Exception during test: " +
+		 * e.toString()); }
+		 */
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#entries()
+	 */
+	public void test_entries() {
+		// Test for method java.util.Enumeration java.util.jar.JarFile.entries()
+
+		/*
+		 * Note only (and all of) the following should be contained in the file
+		 * META-INF/ META-INF/MANIFEST.MF foo/ foo/bar/ foo/bar/A.class Blah.txt
+		 */
+
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			JarFile jarFile = new JarFile(new File(resources, jarName));
+			Enumeration e = jarFile.entries();
+			int i = 0;
+			while (e.hasMoreElements()) {
+				i++;
+				e.nextElement();
+			}
+			jarFile.close();
+			assertTrue("Wrong number of elements--wanted 6, got: " + i, i == 6);
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			JarFile jarFile = new JarFile(new File(resources, jarName));
+			Enumeration enumeration = jarFile.entries();
+			jarFile.close();
+			boolean pass = false;
+			try {
+				enumeration.hasMoreElements();
+			} catch (IllegalStateException e) {
+				pass = true;
+			}
+			assertTrue("hasMoreElements did not detect closed jar file", pass);
+			Support_Resources.copyFile(resources, null, jarName);
+			jarFile = new JarFile(new File(resources, jarName));
+			enumeration = jarFile.entries();
+			jarFile.close();
+			pass = false;
+			try {
+				enumeration.nextElement();
+			} catch (IllegalStateException e) {
+				pass = true;
+			}
+			assertTrue("nextElement did not detect closed jar file", pass);
+		} catch (Exception e) {
+			fail("Exception during entries test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#getJarEntry(java.lang.String)
+	 */
+	public void test_getJarEntryLjava_lang_String() {
+		// Test for method java.util.jar.JarEntry
+		// java.util.jar.JarFile.getJarEntry(java.lang.String)
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			JarFile jarFile = new JarFile(new File(resources, jarName));
+			assertEquals("Error in returned entry", 311, jarFile.getEntry(entryName)
+					.getSize());
+			jarFile.close();
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+
+		// tests for signed jars
+		// test all signed jars in the /Testres/Internal/SignedJars directory
+		String jarDirUrl = Support_Resources
+				.getResourceURL("/../internalres/signedjars");
+		Vector signedJars = new Vector();
+		try {
+			InputStream is = new URL(jarDirUrl + "/jarlist.txt").openStream();
+			while (is.available() > 0) {
+				StringBuffer linebuff = new StringBuffer(80); // Typical line
+				// length
+				done: while (true) {
+					int nextByte = is.read();
+					switch (nextByte) {
+					case -1:
+						break done;
+					case (byte) '\r':
+						if (linebuff.length() == 0) {
+							// ignore
+						}
+						break done;
+					case (byte) '\n':
+						if (linebuff.length() == 0) {
+							// ignore
+						}
+						break done;
+					default:
+						linebuff.append((char) nextByte);
+					}
+				}
+				if (linebuff.length() == 0) {
+					break;
+				}
+				String line = linebuff.toString();
+				signedJars.add(line);
+			}
+			is.close();
+		} catch (IOException e) {
+			// no list of jars found
+		}
+
+		for (int i = 0; i < signedJars.size(); i++) {
+			String jarName = (String) signedJars.get(i);
+			try {
+				File file = Support_Resources.getExternalLocalFile(jarDirUrl
+						+ "/" + jarName);
+				JarFile jarFile = new JarFile(file, true);
+				boolean foundCerts = false;
+				Enumeration e = jarFile.entries();
+				while (e.hasMoreElements()) {
+					JarEntry entry = (JarEntry) e.nextElement();
+					InputStream is = jarFile.getInputStream(entry);
+					is.skip(100000);
+					is.close();
+					Certificate[] certs = entry.getCertificates();
+					if (certs != null && certs.length > 0) {
+						foundCerts = true;
+						break;
+					}
+				}
+				assertTrue(
+						"No certificates found during signed jar test for jar \""
+								+ jarName + "\"", foundCerts);
+			} catch (IOException e) {
+				fail("Exception during signed jar test for jar \""
+						+ jarName + "\": " + e.toString());
+			}
+		}
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#getManifest()
+	 */
+	public void test_getManifest() {
+		// Test for method java.util.jar.Manifest
+		// java.util.jar.JarFile.getManifest()
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			JarFile jarFile = new JarFile(new File(resources, jarName));
+			assertNotNull("Error--Manifest not returned",
+					jarFile.getManifest());
+			jarFile.close();
+		} catch (Exception e) {
+			fail("Exception during 1st test: " + e.toString());
+		}
+		try {
+			Support_Resources.copyFile(resources, null, jarName2);
+			JarFile jarFile = new JarFile(new File(resources, jarName2));
+			assertNull("Error--should have returned null", jarFile
+					.getManifest());
+			jarFile.close();
+		} catch (Exception e) {
+			fail("Exception during 2nd test: " + e.toString());
+		}
+
+		try {
+			// jarName3 was created using the following test
+			Support_Resources.copyFile(resources, null, jarName3);
+			JarFile jarFile = new JarFile(new File(resources, jarName3));
+			assertNotNull("Should find manifest without verifying", jarFile
+					.getManifest());
+			jarFile.close();
+		} catch (Exception e) {
+			fail("Exception during 3rd test: " + e.toString());
+		}
+
+		try {
+			// this is used to create jarName3 used in the previous test
+			Manifest manifest = new Manifest();
+			Attributes attributes = manifest.getMainAttributes();
+			attributes.put(new Attributes.Name("Manifest-Version"), "1.0");
+			ByteArrayOutputStream manOut = new ByteArrayOutputStream();
+			manifest.write(manOut);
+			byte[] manBytes = manOut.toByteArray();
+			File file = new File(Support_PlatformFile.getNewPlatformFile(
+					"hyts_manifest1", ".jar"));
+			JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(
+					file.getAbsolutePath()));
+			ZipEntry entry = new ZipEntry("META-INF/");
+			entry.setSize(0);
+			jarOut.putNextEntry(entry);
+			entry = new ZipEntry(JarFile.MANIFEST_NAME);
+			entry.setSize(manBytes.length);
+			jarOut.putNextEntry(entry);
+			jarOut.write(manBytes);
+			entry = new ZipEntry("myfile");
+			entry.setSize(1);
+			jarOut.putNextEntry(entry);
+			jarOut.write(65);
+			jarOut.close();
+			JarFile jar = new JarFile(file.getAbsolutePath(), false);
+			assertNotNull("Should find manifest without verifying", jar
+					.getManifest());
+			jar.close();
+			file.delete();
+		} catch (IOException e) {
+			fail("IOException 3");
+		}
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
+	 */
+	public void test_getInputStreamLjava_util_jar_JarEntry() {
+		File localFile = null;
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			localFile = new File(resources, jarName);
+		} catch (Exception e) {
+			fail("Failed to create local file: " + e);
+		}
+
+		byte[] b = new byte[1024];
+		try {
+			JarFile jf = new JarFile(localFile);
+			java.io.InputStream is = jf.getInputStream(jf.getEntry(entryName));
+			jf.close();
+			assertTrue("Returned invalid stream", is.available() > 0);
+			int r = is.read(b, 0, 1024);
+			is.close();
+			StringBuffer sb = new StringBuffer(r);
+			for (int i = 0; i < r; i++) {
+				sb.append((char) (b[i] & 0xff));
+			}
+			String contents = sb.toString();
+			assertTrue("Incorrect stream read", contents.indexOf("bar") > 0);
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+
+		try {
+			JarFile jf = new JarFile(localFile);
+			InputStream in = jf.getInputStream(new JarEntry("invalid"));
+			assertNull("Got stream for non-existent entry", in);
+		} catch (Exception e) {
+			fail("Exception during test 2: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry)
+	 */
+	public void test_getInputStreamLjava_util_jar_JarEntry_subtest0() {
+		File signedFile = null;
+		try {
+			Support_Resources.copyFile(resources, null, jarName4);
+			signedFile = new File(resources, jarName4);
+		} catch (Exception e) {
+			fail("Failed to create local file 2: " + e);
+		}
+
+		try {
+			JarFile jar = new JarFile(signedFile);
+			JarEntry entry = new JarEntry(entryName3);
+			InputStream in = jar.getInputStream(entry);
+			in.read();
+		} catch (Exception e) {
+			fail("Exception during test 3: " + e);
+		}
+
+		try {
+			JarFile jar = new JarFile(signedFile);
+			JarEntry entry = new JarEntry(entryName3);
+			InputStream in = jar.getInputStream(entry);
+			in.read(new byte[1077]);
+			assertNull("found certificates", entry.getCertificates());
+		} catch (Exception e) {
+			fail("Exception during test 4: " + e);
+		}
+
+		boolean exception = false;
+		try {
+			JarFile jar = new JarFile(signedFile);
+			JarEntry entry = new JarEntry(entryName3);
+			entry.setSize(1076);
+			InputStream in = jar.getInputStream(entry);
+			in.read(new byte[2048]);
+		} catch (SecurityException e) {
+			exception = true;
+		} catch (Exception e) {
+			fail("Exception during test 5: " + e);
+		}
+		assertTrue("Failed to throw SecurityException", exception);
+	}
+
+    /*
+     * The jar created by 1.4 which does not provide a
+     * algorithm-Digest-Manifest-Main-Attributes entry in .SF file.
+     */
+    public void test_Jar_created_before_java_5() throws IOException {
+        String modifiedJarName = "Created_by_1_4.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            jarFile.getInputStream(zipEntry);
+        }
+    }
+
+    /* The jar is intact, then everything is all right. */
+    public void test_JarFile_Integrate_Jar() throws IOException {
+        String modifiedJarName = "Integrate.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            jarFile.getInputStream(zipEntry);
+        }
+    }
+
+    /*
+     * If another entry is inserted into Manifest, no security exception will be
+     * thrown out.
+     */
+    public void test_JarFile_InsertEntry_in_Manifest_Jar() throws IOException {
+        String modifiedJarName = "Inserted_Entry_Manifest.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        int count = 0;
+        while (entries.hasMoreElements()) {
+
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            jarFile.getInputStream(zipEntry);
+            count++;
+        }
+        assertEquals(5, count);
+    }
+
+    /*
+     * If another entry is inserted into Manifest, no security exception will be
+     * thrown out.
+     */
+    public void test_Inserted_Entry_Manifest_with_DigestCode()
+            throws IOException {
+        String modifiedJarName = "Inserted_Entry_Manifest_with_DigestCode.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        int count = 0;
+        while (entries.hasMoreElements()) {
+
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            jarFile.getInputStream(zipEntry);
+            count++;
+        }
+        assertEquals(5, count);
+    }
+
+    /*
+     * The content of Test.class is modified, jarFile.getInputStream will not
+     * throw security Exception, but it will anytime before the inputStream got
+     * from getInputStream method has been read to end.
+     */
+    public void test_JarFile_Modified_Class() throws IOException {
+        String modifiedJarName = "Modified_Class.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            jarFile.getInputStream(zipEntry);
+        }
+        /* The content of Test.class has been tampered. */
+        ZipEntry zipEntry = jarFile.getEntry("Test.class");
+        InputStream in = jarFile.getInputStream(zipEntry);
+        byte[] buffer = new byte[1024];
+        try {
+            while (in.available() > 0) {
+                in.read(buffer);
+            }
+            fail("should throw Security Excetpion");
+        } catch (SecurityException e) {
+            // desired
+        }
+    }
+
+    /*
+     * In the Modified.jar, the main attributes of META-INF/MANIFEST.MF is
+     * tampered manually. Hence the RI 5.0 JarFile.getInputStream of any
+     * JarEntry will throw security exception, but the apache harmony will not.
+     */
+    public void test_JarFile_Modified_Manifest_MainAttributes()
+            throws IOException {
+        String modifiedJarName = "Modified_Manifest_MainAttributes.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            try {
+                jarFile.getInputStream(zipEntry);
+                fail("should throw Security Excetpion");
+            } catch (SecurityException e) {
+                // desired
+            }
+        }
+    }
+
+    /*
+     * It is all right in our original JarFile. If the Entry Attributes, for
+     * example Test.class in our jar, the jarFile.getInputStream will throw
+     * Security Exception.
+     */
+    public void test_JarFile_Modified_Manifest_EntryAttributes()
+            throws IOException {
+        String modifiedJarName = "Modified_Manifest_EntryAttributes.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            try {
+                jarFile.getInputStream(zipEntry);
+                fail("should throw Security Excetpion");
+            } catch (SecurityException e) {
+                // desired
+            }
+        }
+    }
+
+    /*
+     * If the content of the .SA file is modified, no matter what it resides,
+     * JarFile.getInfputStream of any JarEntry will throw Security Exception.
+     */
+    public void test_JarFile_Modified_SF_EntryAttributes() throws IOException {
+        String modifiedJarName = "Modified_SF_EntryAttributes.jar";
+        Support_Resources.copyFile(resources, null, modifiedJarName);
+        JarFile jarFile = new JarFile(new File(resources, modifiedJarName),
+                true);
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry zipEntry = (ZipEntry) entries.nextElement();
+            try {
+                jarFile.getInputStream(zipEntry);
+                fail("should throw Security Excetpion");
+            } catch (SecurityException e) {
+                // desired
+            }
+        }
+    }
+    
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		resources = Support_Resources.createTempFolder();
+
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,362 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import tests.support.resource.Support_Resources;
+
+public class JarInputStreamTest extends junit.framework.TestCase {
+	// a 'normal' jar file
+	String jarName;
+
+	// same as patch.jar but without a manifest file
+	String jarName2;
+
+	final String entryName = "foo/bar/A.class";
+
+	final String entryName2 = "Blah.txt";
+
+    private static int indexofDSA = 2;
+
+    private static int indexofTESTCLASS = 4;
+
+    private static int totalEntries = 4;
+
+	/**
+	 * @tests java.util.jar.JarInputStream#JarInputStream(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		// Test for method java.util.jar.JarInputStream(java.io.InputStream)
+		try {
+			java.io.InputStream is = new URL(jarName).openConnection()
+					.getInputStream();
+			boolean hasCorrectEntry = false;
+			JarInputStream jis = new JarInputStream(is);
+			assertNotNull("The jar input stream should have a manifest", jis
+					.getManifest());
+			JarEntry je = jis.getNextJarEntry();
+			while (je != null) {
+				if (je.getName().equals(entryName))
+					hasCorrectEntry = true;
+				je = jis.getNextJarEntry();
+			}
+			assertTrue(
+					"The jar input stream does not contain the correct entries",
+					hasCorrectEntry);
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+
+	}
+
+	/**
+	 * @tests java.util.jar.JarInputStream#getManifest()
+	 */
+	public void test_getManifest() {
+		// Test for method java.util.jar.Manifest
+		// java.util.jar.JarInputStream.getManifest()
+		try {
+			Manifest m;
+
+			java.io.InputStream is = new URL(jarName2).openConnection()
+					.getInputStream();
+			JarInputStream jis = new JarInputStream(is);
+			m = jis.getManifest();
+			assertNull("The jar input stream should not have a manifest",
+					m);
+
+			is = new URL(jarName).openConnection().getInputStream();
+			jis = new JarInputStream(is);
+			m = jis.getManifest();
+			assertNotNull("The jar input stream should have a manifest", m);
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+
+	}
+
+	/**
+	 * @tests java.util.jar.JarInputStream#getNextJarEntry()
+	 */
+	public void test_getNextJarEntry() {
+		// Test for method java.util.jar.JarEntry
+		// java.util.jar.JarInputStream.getNextJarEntry()
+		final Set desired = new HashSet(Arrays.asList(new String[] { "foo/",
+				"foo/bar/", "foo/bar/A.class", "Blah.txt" }));
+		Set actual = new HashSet();
+		try {
+			java.io.InputStream is = new URL(jarName).openConnection()
+					.getInputStream();
+			JarInputStream jis = new JarInputStream(is);
+			JarEntry je = jis.getNextJarEntry();
+			while (je != null) {
+				actual.add(je.toString());
+				je = jis.getNextJarEntry();
+			}
+		} catch (Exception e) {
+			fail("Exception during test: " + e.toString());
+		}
+		assertTrue("Set of entries is not correct", actual.equals(desired));
+	}
+
+    public void test_JarInputStream_Integrate_Jar_getNextEntry()
+            throws IOException {
+        String intJarName = Support_Resources.getURL("Integrate.jar");
+        java.io.InputStream is = new URL(intJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        ZipEntry entry = null;
+        int count = 0;
+        while (count == 0 || entry != null) {
+            count++;
+            entry = jin.getNextEntry();
+        }
+        assertEquals(totalEntries + 1, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_Class_getNextEntry()
+            throws IOException {
+        String modJarName = Support_Resources.getURL("Modified_Class.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        ZipEntry zipEntry = null;
+
+        int count = 0;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            try {
+                zipEntry = jin.getNextEntry();
+                if (count == indexofTESTCLASS + 1)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofTESTCLASS + 1)
+                    throw e;
+
+            }
+        }
+        assertEquals(totalEntries + 2, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_Manifest_MainAttributes_getNextEntry()
+            throws IOException {
+        String modJarName = Support_Resources.getURL("Modified_Manifest_MainAttributes.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        ZipEntry zipEntry = null;
+
+        final int indexofDSA = 2;
+        final int totalEntries = 4;
+        int count = 0;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            try {
+                zipEntry = jin.getNextEntry();
+                if (count == indexofDSA + 1)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofDSA + 1)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 2, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_Manifest_EntryAttributes_getNextEntry()
+            throws IOException {
+        String modJarName = Support_Resources
+                .getURL("Modified_Manifest_EntryAttributes.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        ZipEntry zipEntry = null;
+
+        int count = 0;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            try {
+                zipEntry = jin.getNextEntry();
+                if (count == indexofDSA + 1)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofDSA + 1)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 2, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_SF_EntryAttributes_getNextEntry()
+            throws IOException {
+        String modJarName = Support_Resources
+                .getURL("Modified_SF_EntryAttributes.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        ZipEntry zipEntry = null;
+
+        int count = 0;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            try {
+                zipEntry = jin.getNextEntry();
+                if (count == indexofDSA + 1)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofDSA + 1)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 2, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_Class_read() throws IOException {
+        String modJarName = Support_Resources.getURL("Modified_Class.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        int count = 0;
+        ZipEntry zipEntry = null;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            zipEntry = jin.getNextEntry();
+            byte[] buffer = new byte[1024];
+            try {
+                int length = 0;
+                while (length >= 0) {
+                    length = jin.read(buffer);
+                }
+                if (count == indexofTESTCLASS)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count < indexofTESTCLASS)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 1, count);
+        jin.close();
+    }
+
+    public void test_Integrate_Jar_read() throws IOException {
+        String intJarName = Support_Resources.getURL("Integrate.jar");
+        java.io.InputStream is = new URL(intJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        int count = 0;
+        ZipEntry zipEntry = null;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            zipEntry = jin.getNextEntry();
+            byte[] buffer = new byte[1024];
+            int length = 0;
+            while (length >= 0) {
+                length = jin.read(buffer);
+            }
+
+        }
+        assertEquals(totalEntries + 1, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_Manifest_MainAttributes_read()
+            throws IOException {
+        String modJarName = Support_Resources
+                .getURL("Modified_Manifest_MainAttributes.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        int count = 0;
+        ZipEntry zipEntry = null;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            zipEntry = jin.getNextEntry();
+            byte[] buffer = new byte[1024];
+            try {
+                int length = 0;
+                while (length >= 0) {
+                    length = jin.read(buffer);
+                }
+                if (count == indexofDSA)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofDSA)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 1, count);
+        jin.close();
+    }
+
+    public void test_JarInputStream_Modified_SF_EntryAttributes_read()
+            throws IOException {
+        String modJarName = Support_Resources
+                .getURL("Modified_SF_EntryAttributes.jar");
+        java.io.InputStream is = new URL(modJarName).openConnection()
+                .getInputStream();
+        JarInputStream jin = new JarInputStream(is, true);
+        int count = 0;
+        ZipEntry zipEntry = null;
+        while (count == 0 || zipEntry != null) {
+            count++;
+            zipEntry = jin.getNextEntry();
+            byte[] buffer = new byte[1024];
+            try {
+                int length = 0;
+                while (length >= 0) {
+                    length = jin.read(buffer);
+                }
+                if (count == indexofDSA)
+                    fail("Should throw Security Exception");
+            } catch (SecurityException e) {
+                if (count != indexofDSA)
+                    throw e;
+            }
+        }
+        assertEquals(totalEntries + 1, count);
+        jin.close();
+    }    
+    
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		jarName = Support_Resources.getURL("morestuff/hyts_patch.jar");
+		jarName2 = Support_Resources.getURL("morestuff/hyts_patch2.jar");
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,115 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import tests.support.Support_Exec;
+import tests.support.resource.Support_Resources;
+
+public class JarOutputStreamTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.util.jar.JarOutputStream#putNextEntry(java.util.zip.ZipEntry)
+	 */
+	public void test_putNextEntryLjava_util_zip_ZipEntry() {
+		// testClass file`s actual extension is .class, since having .class
+		// extension files in source dir causes
+		// problems on eclipse, the extension is changed into .ser or it can be
+		// anything. The file is being
+		// read by inputstream and being written to other file,
+		// as long as the content of the file is not changed, the extension does
+		// not matter
+		final String testClass = "hyts_mainClass.ser";
+		final String entryName = "foo/bar/execjartest/MainClass.class";
+
+		// test whether specifying the main class in the manifest
+		// works using either /'s or .'s as a separator
+		final String[] manifestMain = { "foo.bar.execjartest.MainClass",
+				"foo/bar/execjartest/MainClass" };
+
+		for (int i = 0; i < manifestMain.length; i++) {
+
+			// create the manifest
+			Manifest newman = new Manifest();
+			Attributes att = newman.getMainAttributes();
+			att.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+			att.put(Attributes.Name.MAIN_CLASS, manifestMain[i]);
+
+			File outputJar = null;
+			JarOutputStream jout = null;
+
+			try {
+				// open the output jarfile
+				outputJar = File.createTempFile("hyts_", ".jar");
+				jout = new JarOutputStream(new FileOutputStream(outputJar),
+						newman);
+				jout.putNextEntry(new JarEntry(entryName));
+			} catch (Exception e) {
+				fail("Error creating JarOutputStream: " + e);
+			}
+			File resources = Support_Resources.createTempFolder();
+			try {
+				// read in the class file, and output it to the jar
+				Support_Resources.copyFile(resources, null, testClass);
+				URL jarURL = new URL((new File(resources, testClass)).toURL()
+						.toString());
+				InputStream jis = jarURL.openStream();
+
+				byte[] bytes = new byte[1024];
+				int len;
+				while ((len = jis.read(bytes)) != -1)
+					jout.write(bytes, 0, len);
+
+				jout.flush();
+				jout.close();
+				jis.close();
+			} catch (Exception e) {
+				fail("Error writing JAR file for testing: " + e);
+			}
+			String res = null;
+			// set up the VM parameters
+			String[] args = new String[2];
+			args[0] = "-jar";
+			args[1] = outputJar.getAbsolutePath();
+
+			try {
+				// execute the JAR and read the result
+				res = Support_Exec.execJava(args, null, true);
+			} catch (Exception e) {
+				fail("Exception executing test JAR: " + e);
+			}
+
+			assertTrue("Error executing JAR test on: " + manifestMain[i]
+					+ ". Result returned was incorrect.", res
+					.startsWith("TEST"));
+			outputJar.delete();
+		}
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/JarOutputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,207 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.jar;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import tests.support.resource.Support_Resources;
+
+public class ManifestTest extends junit.framework.TestCase {
+
+	final String jarName = "hyts_patch.jar";
+
+	final String attJarName = "hyts_att.jar";
+
+	Manifest m, m2;
+
+	File resources;
+
+	/**
+	 * @tests java.util.jar.Manifest#Manifest()
+	 */
+	public void test_Constructor() {
+		// Test for method java.util.jar.Manifest()
+		Manifest emptyManifest = new Manifest();
+		assertTrue("Should have no entries", emptyManifest.getEntries()
+				.isEmpty());
+		assertTrue("Should have no main attributes", emptyManifest
+				.getMainAttributes().isEmpty());
+	}
+
+	/**
+	 * @tests java.util.jar.Manifest#Manifest(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		// Test for method java.util.jar.Manifest(java.io.InputStream)
+		/*
+		 * ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		 * m2.write(baos); InputSteam is = new ByteArrayInputStream
+		 * (baos.toByteArray()); Manifest myManifest = new Manifest (is);
+		 * assertTrue("Manifests should be equal", myManifest.equals(m2));
+		 */
+
+		Manifest manifest = null;
+		try {
+			manifest = new Manifest(new URL(Support_Resources
+					.getURL("manifest/hyts_MANIFEST.MF")).openStream());
+		} catch (MalformedURLException e) {
+			fail("Malformed URL");
+		} catch (IOException e) {
+			fail("IOException");
+		}
+		Attributes main = manifest.getMainAttributes();
+		assertEquals("Bundle-Name not correct", "ClientSupport", main.getValue("Bundle-Name")
+				);
+		assertEquals("Bundle-Description not correct",
+				
+								"Provides SessionService, AuthenticationService. Extends RegistryService.", main
+						.getValue("Bundle-Description")
+						);
+		assertEquals("Bundle-Activator not correct", 
+				"com.ibm.ive.eccomm.client.support.ClientSupportActivator", main.getValue(
+				"Bundle-Activator"));
+		assertEquals("Import-Package not correct",
+				
+								"com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client", main
+						.getValue("Import-Package")
+						);
+		assertEquals("Import-Service not correct",
+				
+								"org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService", main
+						.getValue("Import-Service")
+						);
+		assertEquals("Export-Package not correct",
+				
+								"com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0", main
+						.getValue("Export-Package")
+						);
+		assertEquals("Export-Service not correct",
+				
+								"com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService", main
+						.getValue("Export-Service")
+						);
+		assertEquals("Bundle-Vendor not correct", "IBM", main.getValue("Bundle-Vendor")
+				);
+		assertEquals("Bundle-Version not correct", "1.2.0", main
+				.getValue("Bundle-Version"));
+	}
+
+	/**
+	 * @tests java.util.jar.Manifest#clear()
+	 */
+	public void test_clear() {
+		// Test for method void java.util.jar.Manifest.clear()
+		m2.clear();
+		assertTrue("Should have no entries", m2.getEntries().isEmpty());
+		assertTrue("Should have no main attributes", m2.getMainAttributes()
+				.isEmpty());
+	}
+
+	/**
+	 * @tests java.util.jar.Manifest#getAttributes(java.lang.String)
+	 */
+	public void test_getAttributesLjava_lang_String() {
+		// Test for method java.util.jar.Attributes
+		// java.util.jar.Manifest.getAttributes(java.lang.String)
+		assertNull("Should not exist",
+				m2.getAttributes("Doesn't Exist"));
+		assertEquals("Should exist", "OK", m2.getAttributes("HasAttributes.txt").get(
+				new Attributes.Name("MyAttribute")));
+	}
+
+	/**
+	 * @tests java.util.jar.Manifest#getEntries()
+	 */
+	public void test_getEntries() {
+		// Test for method java.util.Map java.util.jar.Manifest.getEntries()
+		Map myMap = m2.getEntries();
+		assertNull("Shouldn't exist", myMap.get("Doesn't exist"));
+		assertEquals("Should exist",
+				"OK", ((Attributes) myMap.get("HasAttributes.txt")).get(
+						new Attributes.Name("MyAttribute")));
+
+	}
+
+	/**
+	 * @tests java.util.jar.Manifest#getMainAttributes()
+	 */
+	public void test_getMainAttributes() {
+		// Test for method java.util.jar.Attributes
+		// java.util.jar.Manifest.getMainAttributes()
+		Attributes a = m.getMainAttributes();
+		assertEquals("Manifest_Version should return 1.0", "1.0", a.get(
+				Attributes.Name.MANIFEST_VERSION));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		resources = Support_Resources.createTempFolder();
+		try {
+			Support_Resources.copyFile(resources, null, jarName);
+			JarFile jarFile = new JarFile(new File(resources, jarName));
+			m = jarFile.getManifest();
+			jarFile.close();
+			Support_Resources.copyFile(resources, null, attJarName);
+			jarFile = new JarFile(new File(resources, attJarName));
+			m2 = jarFile.getManifest();
+			jarFile.close();
+		} catch (Exception e) {
+			fail("Exception during setup: " + e.toString());
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+    
+    /**
+     * @tests {@link java.util.jar.Manifest#read(java.io.InputStream)
+     */
+    public void test_readLjava_io_InputStream() {
+        // Regression for HARMONY-89
+        InputStream is = new InputStreamImpl();
+        try {
+            new Manifest().read(is);
+            fail("Assert 0: Should have thrown IOException");
+        } catch (IOException e) {
+            // expected
+        }
+    }
+
+    // helper class
+    class InputStreamImpl extends InputStream {
+        public InputStreamImpl() {
+            super();
+        }
+
+        public int read() {
+            return 0;
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/jar/ManifestTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,165 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.zip;
+
+import java.util.zip.Adler32;
+
+public class Adler32Test extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.util.zip.Adler32#Adler32()
+	 */
+	public void test_Constructor() {
+		// test method of java.util.zip.Adler32()
+		Adler32 adl = new Adler32();
+		assertEquals("Constructor of adl32 failed", 1, adl.getValue());
+	}
+
+	/**
+	 * @tests java.util.zip.Adler32#getValue()
+	 */
+	public void test_getValue() {
+		// test methods of java.util.zip.getValue()
+		Adler32 adl = new Adler32();
+		assertEquals("GetValue should return a zero as a result of construction an object of Adler32",
+				1, adl.getValue());
+
+		adl.reset();
+		adl.update(1);
+		// System.out.print("value of adl"+adl.getValue());
+		// The value of the adl should be 131074
+		assertEquals("update(int) failed to update the checksum to the correct value ",
+				131074, adl.getValue());
+		adl.reset();
+		assertEquals("reset failed to reset the checksum value to zero", 1, adl
+				.getValue());
+
+		adl.reset();
+		adl.update(Integer.MIN_VALUE);
+		// System.out.print("value of adl " + adl.getValue());
+		// The value of the adl should be 65537
+		assertEquals("update(min) failed to update the checksum to the correct value ",
+				65537L, adl.getValue());
+	}
+
+	/**
+	 * @tests java.util.zip.Adler32#reset()
+	 */
+	public void test_reset() {
+		// test methods of java.util.zip.reset()
+		Adler32 adl = new Adler32();
+		adl.update(1);
+		// System.out.print("value of adl"+adl.getValue());
+		// The value of the adl should be 131074
+		assertEquals("update(int) failed to update the checksum to the correct value ",
+				131074, adl.getValue());
+		adl.reset();
+		assertEquals("reset failed to reset the checksum value to zero", 1, adl
+				.getValue());
+	}
+
+	/**
+	 * @tests java.util.zip.Adler32#update(int)
+	 */
+	public void test_updateI() {
+		// test methods of java.util.zip.update(int)
+		Adler32 adl = new Adler32();
+		adl.update(1);
+		// The value of the adl should be 131074
+		assertEquals("update(int) failed to update the checksum to the correct value ",
+				131074, adl.getValue());
+
+		adl.reset();
+		adl.update(Integer.MAX_VALUE);
+		// System.out.print("value of adl " + adl.getValue());
+		// The value of the adl should be 16777472
+		assertEquals("update(max) failed to update the checksum to the correct value ",
+				16777472L, adl.getValue());
+
+		adl.reset();
+		adl.update(Integer.MIN_VALUE);
+		// System.out.print("value of adl " + adl.getValue());
+		// The value of the adl should be 65537
+		assertEquals("update(min) failed to update the checksum to the correct value ",
+				65537L, adl.getValue());
+
+	}
+
+	/**
+	 * @tests java.util.zip.Adler32#update(byte[])
+	 */
+	public void test_update$B() {
+		// test method of java.util.zip.update(byte[])
+		byte byteArray[] = { 1, 2 };
+		Adler32 adl = new Adler32();
+		adl.update(byteArray);
+		// System.out.print("value of adl"+adl.getValue());
+		// The value of the adl should be 393220
+		assertEquals("update(byte[]) failed to update the checksum to the correct value ",
+				393220, adl.getValue());
+
+		adl.reset();
+		byte byteEmpty[] = new byte[10000];
+		adl.update(byteEmpty);
+		// System.out.print("value of adl"+adl.getValue());
+		// The value of the adl should be 655360001
+		assertEquals("update(byte[]) failed to update the checksum to the correct value ",
+				655360001L, adl.getValue());
+
+	}
+
+	/**
+	 * @tests java.util.zip.Adler32#update(byte[], int, int)
+	 */
+	public void test_update$BII() {
+		// test methods of java.util.zip.update(byte[],int,int)
+		byte[] byteArray = { 1, 2, 3 };
+		Adler32 adl = new Adler32();
+		int off = 2;// accessing the 2nd element of byteArray
+		int len = 1;
+		int lenError = 3;
+		int offError = 4;
+		adl.update(byteArray, off, len);
+		// System.out.print("value of adl"+adl.getValue());
+		// The value of the adl should be 262148
+		assertEquals("update(byte[],int,int) failed to update the checksum to the correct value ",
+				262148, adl.getValue());
+		int r = 0;
+
+		try {
+			adl.update(byteArray, off, lenError);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			r = 1;
+		}
+		assertEquals("update(byte[],int,int) failed b/c lenError>byte[].length-off",
+				1, r);
+
+		try {
+			adl.update(byteArray, offError, len);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			r = 2;
+		}
+		assertEquals("update(byte[],int,int) failed b/c offError>byte[].length",
+				2, r);
+
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/Adler32Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java?rev=397192&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java Wed Apr 26 06:04:19 2006
@@ -0,0 +1,51 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.archive.tests.java.util.zip;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite for java.util.zip package.
+ */
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+                "Suite org.apache.harmony.archive.tests.java.util.jar");
+		// $JUnit-BEGIN$
+		suite.addTestSuite(Adler32Test.class);
+		suite.addTestSuite(CheckedInputStreamTest.class);
+		suite.addTestSuite(CheckedOutputStreamTest.class);
+		suite.addTestSuite(CRC32Test.class);
+        suite.addTestSuite(DeflaterOutputStreamTest.class);
+		suite.addTestSuite(DeflaterTest.class);
+		suite.addTestSuite(GZIPInputStreamTest.class);
+		suite.addTestSuite(GZIPOutputStreamTest.class);
+        suite.addTestSuite(InflaterInputStreamTest.class);
+		suite.addTestSuite(InflaterTest.class);
+		suite.addTestSuite(ZipEntryTest.class);
+		suite.addTestSuite(ZipFileTest.class);
+		suite.addTestSuite(ZipInputStreamTest.class);
+		suite.addTestSuite(ZipOutputStreamTest.class);
+		// $JUnit-END$
+		return suite;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/org/apache/harmony/archive/tests/java/util/zip/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message