You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/15 12:47:39 UTC

svn commit: r386058 [4/49] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/archive/make/common/ modules/archive/src/test/java/tests/ modules/archive/src/test/java/tests/api/ modules/archive/src/test/java/tests/api/java/ modules/archive/s...

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,480 @@
+/* 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 tests.api.java.util.zip;
+
+import java.util.TimeZone;
+import java.util.zip.ZipEntry;
+
+import tests.support.resource.Support_Resources;
+
+public class ZipEntryTest extends junit.framework.TestCase {
+	// zip file hyts_ZipFile.zip must be included as a resource
+	java.util.zip.ZipEntry zentry;
+
+	java.util.zip.ZipFile zfile;
+
+	private static String platformId = System.getProperty(
+			"com.ibm.oti.configuration", "JDK")
+			+ System.getProperty("java.vm.version");
+
+	static final String tempFileName = platformId + "zfzezi.zip";
+
+	long orgSize;
+
+	long orgCompressedSize;
+
+	long orgCrc;
+
+	long orgTime;
+
+	String orgComment;
+
+	/**
+	 * @tests java.util.zip.ZipEntry#ZipEntry(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.util.zip.ZipEntry(java.lang.String)
+		zentry = zfile.getEntry("File3.txt");
+		assertTrue("Failed to create ZipEntry", zentry != null);
+		try {
+			zentry = zfile.getEntry(null);
+			fail("NullPointerException not thrown");
+		} catch (NullPointerException e) {
+		}
+		StringBuffer s = new StringBuffer();
+		for (int i = 0; i < 65535; i++)
+			s.append('a');
+		try {
+			zentry = new ZipEntry(s.toString());
+		} catch (IllegalArgumentException e) {
+			fail("Unexpected IllegalArgumentException During Test.");
+		}
+		try {
+			s.append('a');
+			zentry = new ZipEntry(s.toString());
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+		try {
+			String n = null;
+			zentry = new ZipEntry(n);
+			fail("NullPointerException not thrown");
+		} catch (NullPointerException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getComment()
+	 */
+	public void test_getComment() {
+		// Test for method java.lang.String java.util.zip.ZipEntry.getComment()
+		ZipEntry zipEntry = new ZipEntry("zippy.zip");
+		assertTrue("Incorrect Comment Returned.", zipEntry.getComment() == null);
+		zipEntry.setComment("This Is A Comment");
+		assertTrue("Incorrect Comment Returned.", zipEntry.getComment().equals(
+				"This Is A Comment"));
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getCompressedSize()
+	 */
+	public void test_getCompressedSize() {
+		// Test for method long java.util.zip.ZipEntry.getCompressedSize()
+		assertTrue("Incorrect compressed size returned", zentry
+				.getCompressedSize() == orgCompressedSize);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getCrc()
+	 */
+	public void test_getCrc() {
+		// Test for method long java.util.zip.ZipEntry.getCrc()
+		assertTrue("Failed to get Crc", zentry.getCrc() == orgCrc);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getExtra()
+	 */
+	public void test_getExtra() {
+		// Test for method byte [] java.util.zip.ZipEntry.getExtra()
+		assertTrue("Incorrect extra information returned",
+				zentry.getExtra() == null);
+		byte[] ba = { 'T', 'E', 'S', 'T' };
+		zentry = new ZipEntry("test.tst");
+		zentry.setExtra(ba);
+		assertTrue("Incorrect Extra Information Returned.",
+				zentry.getExtra() == ba);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getMethod()
+	 */
+	public void test_getMethod() {
+		// Test for method int java.util.zip.ZipEntry.getMethod()
+		zentry = zfile.getEntry("File1.txt");
+		assertTrue("Incorrect compression method returned",
+				zentry.getMethod() == java.util.zip.ZipEntry.STORED);
+		zentry = zfile.getEntry("File3.txt");
+		assertTrue("Incorrect compression method returned",
+				zentry.getMethod() == java.util.zip.ZipEntry.DEFLATED);
+		zentry = new ZipEntry("test.tst");
+		assertTrue("Incorrect Method Returned.", zentry.getMethod() == -1);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getName()
+	 */
+	public void test_getName() {
+		// Test for method java.lang.String java.util.zip.ZipEntry.getName()
+		assertTrue(
+				"Incorrect name returned - Note return result somewhat ambiguous in spec",
+				zentry.getName().equals("File1.txt"));
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getSize()
+	 */
+	public void test_getSize() {
+		// Test for method long java.util.zip.ZipEntry.getSize()
+		assertTrue("Incorrect size returned", zentry.getSize() == orgSize);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#getTime()
+	 */
+	public void test_getTime() {
+		// Test for method long java.util.zip.ZipEntry.getTime()
+		assertTrue("Failed to get time", zentry.getTime() == orgTime);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#isDirectory()
+	 */
+	public void test_isDirectory() {
+		// Test for method boolean java.util.zip.ZipEntry.isDirectory()
+		assertTrue("Entry should not answer true to isDirectory", !zentry
+				.isDirectory());
+		zentry = new ZipEntry("Directory/");
+		assertTrue("Entry should answer true to isDirectory", zentry
+				.isDirectory());
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setComment(java.lang.String)
+	 */
+	public void test_setCommentLjava_lang_String() {
+		// Test for method void
+		// java.util.zip.ZipEntry.setComment(java.lang.String)
+		zentry = zfile.getEntry("File1.txt");
+		zentry.setComment("Set comment using api");
+		assertTrue("Comment not correctly set", zentry.getComment().equals(
+				"Set comment using api"));
+		String n = null;
+		zentry.setComment(n);
+		assertTrue("Comment not correctly set", zentry.getComment() == null);
+		StringBuffer s = new StringBuffer();
+		for (int i = 0; i < 0xFFFF; i++)
+			s.append('a');
+		try {
+			zentry.setComment(s.toString());
+		} catch (IllegalArgumentException e) {
+			fail("Unexpected IllegalArgumentException During Test.");
+		}
+		try {
+			s.append('a');
+			zentry.setComment(s.toString());
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setCompressedSize(long)
+	 */
+	public void test_setCompressedSizeJ() {
+		// Test for method void java.util.zip.ZipEntry.setCompressedSize(long)
+		zentry.setCompressedSize(orgCompressedSize + 10);
+		assertTrue("Set compressed size failed",
+				zentry.getCompressedSize() == (orgCompressedSize + 10));
+		zentry.setCompressedSize(0);
+		assertTrue("Set compressed size failed",
+				zentry.getCompressedSize() == 0);
+		zentry.setCompressedSize(-25);
+		assertTrue("Set compressed size failed",
+				zentry.getCompressedSize() == -25);
+		zentry.setCompressedSize(4294967296l);
+		assertTrue("Set compressed size failed",
+				zentry.getCompressedSize() == 4294967296l);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setCrc(long)
+	 */
+	public void test_setCrcJ() {
+		// Test for method void java.util.zip.ZipEntry.setCrc(long)
+		zentry.setCrc(orgCrc + 100);
+		assertTrue("Failed to set Crc", zentry.getCrc() == (orgCrc + 100));
+		zentry.setCrc(0);
+		assertTrue("Failed to set Crc", zentry.getCrc() == 0);
+		try {
+			zentry.setCrc(-25);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+		try {
+			zentry.setCrc(4294967295l);
+		} catch (IllegalArgumentException e) {
+			fail("Unexpected IllegalArgumentException during test");
+		}
+		try {
+			zentry.setCrc(4294967296l);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setExtra(byte[])
+	 */
+	public void test_setExtra$B() {
+		// Test for method void java.util.zip.ZipEntry.setExtra(byte [])
+		zentry = zfile.getEntry("File1.txt");
+		zentry.setExtra("Test setting extra information".getBytes());
+		assertTrue("Extra information not written properly", new String(zentry
+				.getExtra(), 0, zentry.getExtra().length)
+				.equals("Test setting extra information"));
+		zentry = new ZipEntry("test.tst");
+		byte[] ba = new byte[0xFFFF];
+		try {
+			zentry.setExtra(ba);
+		} catch (IllegalArgumentException e) {
+			fail("Unexpected IllegalArgumentException during test");
+		}
+		try {
+			ba = new byte[0xFFFF + 1];
+			zentry.setExtra(ba);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+
+		// One constructor
+		ZipEntry zeInput = new ZipEntry("InputZIP");
+		byte[] extraB = { 'a', 'b', 'd', 'e' };
+		zeInput.setExtra(extraB);
+		assertEquals(extraB, zeInput.getExtra());
+		assertEquals(extraB[3], zeInput.getExtra()[3]);
+		assertEquals(extraB.length, zeInput.getExtra().length);
+
+		// test another constructor
+		ZipEntry zeOutput = new ZipEntry(zeInput);
+		assertEquals(zeInput.getExtra()[3], zeOutput.getExtra()[3]);
+		assertEquals(zeInput.getExtra().length, zeOutput.getExtra().length);
+		assertEquals(extraB[3], zeOutput.getExtra()[3]);
+		assertEquals(extraB.length, zeOutput.getExtra().length);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setMethod(int)
+	 */
+	public void test_setMethodI() {
+		// Test for method void java.util.zip.ZipEntry.setMethod(int)
+		zentry = zfile.getEntry("File3.txt");
+		zentry.setMethod(zentry.STORED);
+		assertTrue("Failed to set compression method",
+				zentry.getMethod() == zentry.STORED);
+		zentry.setMethod(zentry.DEFLATED);
+		assertTrue("Failed to set compression method",
+				zentry.getMethod() == zentry.DEFLATED);
+		try {
+			int error = 1;
+			zentry = new ZipEntry("test.tst");
+			zentry.setMethod(error);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setSize(long)
+	 */
+	public void test_setSizeJ() {
+		// Test for method void java.util.zip.ZipEntry.setSize(long)
+		zentry.setSize(orgSize + 10);
+		assertTrue("Set size failed", zentry.getSize() == (orgSize + 10));
+		zentry.setSize(0);
+		assertTrue("Set size failed", zentry.getSize() == 0);
+		try {
+			zentry.setSize(-25);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+		try {
+			zentry.setCrc(4294967295l);
+		} catch (IllegalArgumentException e) {
+			fail("Unexpected IllegalArgumentException during test");
+		}
+		try {
+			zentry.setCrc(4294967296l);
+			fail("IllegalArgumentException not thrown");
+		} catch (IllegalArgumentException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#setTime(long)
+	 */
+	public void test_setTimeJ() {
+		// Test for method void java.util.zip.ZipEntry.setTime(long)
+		zentry.setTime(orgTime + 10000);
+		assertTrue("Test 1: Failed to set time: " + zentry.getTime(), zentry
+				.getTime() == (orgTime + 10000));
+		zentry.setTime(orgTime - 10000);
+		assertTrue("Test 2: Failed to set time: " + zentry.getTime(), zentry
+				.getTime() == (orgTime - 10000));
+		TimeZone zone = TimeZone.getDefault();
+		try {
+			TimeZone.setDefault(TimeZone.getTimeZone("EST"));
+			zentry.setTime(0);
+			assertTrue("Test 3: Failed to set time: " + zentry.getTime(),
+					zentry.getTime() == 315550800000L);
+			TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+			assertTrue("Test 3a: Failed to set time: " + zentry.getTime(),
+					zentry.getTime() == 315532800000L);
+			zentry.setTime(0);
+			TimeZone.setDefault(TimeZone.getTimeZone("EST"));
+			assertTrue("Test 3b: Failed to set time: " + zentry.getTime(),
+					zentry.getTime() == 315550800000L);
+
+			zentry.setTime(-25);
+			assertTrue("Test 4: Failed to set time: " + zentry.getTime(),
+					zentry.getTime() == 315550800000L);
+			zentry.setTime(4354837200000L);
+			assertTrue("Test 5: Failed to set time: " + zentry.getTime(),
+					zentry.getTime() == 315550800000L);
+		} finally {
+			TimeZone.setDefault(zone);
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String java.util.zip.ZipEntry.toString()
+		assertTrue("Returned incorrect entry name", zentry.toString().indexOf(
+				"File1.txt") >= 0);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#ZipEntry(java.util.zip.ZipEntry)
+	 */
+	public void test_ConstructorLjava_util_zip_ZipEntry() {
+		// Test for method java.util.zip.ZipEntry(util.zip.ZipEntry)
+		zentry.setSize(2);
+		zentry.setCompressedSize(4);
+		zentry.setComment("Testing");
+		ZipEntry zentry2 = new ZipEntry(zentry);
+		assertTrue("ZipEntry Created With Incorrect Size.",
+				zentry2.getSize() == 2);
+		assertTrue("ZipEntry Created With Incorrect Compressed Size.", zentry2
+				.getCompressedSize() == 4);
+		assertTrue("ZipEntry Created With Incorrect Comment.", zentry2
+				.getComment().equals("Testing"));
+		assertTrue("ZipEntry Created With Incorrect Crc.",
+				zentry2.getCrc() == orgCrc);
+		assertTrue("ZipEntry Created With Incorrect Time.",
+				zentry2.getTime() == orgTime);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipEntry#clone()
+	 */
+	public void test_clone() {
+		// Test for method java.util.zip.ZipEntry.clone()
+		Object obj = zentry.clone();
+		assertTrue("toString()", obj.toString().equals(zentry.toString()));
+		assertTrue("hashCode()", obj.hashCode() == zentry.hashCode());
+
+		// One constructor
+		ZipEntry zeInput = new ZipEntry("InputZIP");
+		byte[] extraB = { 'a', 'b', 'd', 'e' };
+		zeInput.setExtra(extraB);
+		assertEquals(extraB, zeInput.getExtra());
+		assertEquals(extraB[3], zeInput.getExtra()[3]);
+		assertEquals(extraB.length, zeInput.getExtra().length);
+
+		// test Clone()
+		ZipEntry zeOutput = (ZipEntry) zeInput.clone();
+		assertEquals(zeInput.getExtra()[3], zeOutput.getExtra()[3]);
+		assertEquals(zeInput.getExtra().length, zeOutput.getExtra().length);
+		assertEquals(extraB[3], zeOutput.getExtra()[3]);
+		assertEquals(extraB.length, zeOutput.getExtra().length);
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+
+	protected void setUp() {
+		java.io.File f = null;
+		try {
+			byte[] rbuf = new byte[2000];
+			// Create a local copy of the file since some tests want to alter
+			// information.
+			f = new java.io.File(tempFileName);
+			// Create absolute filename as ZipFile does not resolve using
+			// user.dir
+			f = new java.io.File(f.getAbsolutePath());
+			f.delete();
+			java.io.InputStream is = Support_Resources
+					.getStream("hyts_ZipFile.zip");
+			java.io.FileOutputStream fos = new java.io.FileOutputStream(f);
+			rbuf = new byte[(int) is.available()];
+			is.read(rbuf, 0, rbuf.length);
+			fos.write(rbuf, 0, rbuf.length);
+			is.close();
+			fos.close();
+			zfile = new java.util.zip.ZipFile(f);
+			zentry = zfile.getEntry("File1.txt");
+			orgSize = zentry.getSize();
+			orgCompressedSize = zentry.getCompressedSize();
+			orgCrc = zentry.getCrc();
+			orgTime = zentry.getTime();
+			orgComment = zentry.getComment();
+		} catch (Exception e) {
+			System.out.println("Exception during ZipFile setup <"
+					+ f.getAbsolutePath() + ">: ");
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+
+	protected void tearDown() {
+		try {
+			if (zfile != null)
+				zfile.close();
+			java.io.File f = new java.io.File(tempFileName);
+			f.delete();
+		} catch (java.io.IOException e) {
+			System.out.println("Exception durnig tearDown");
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,292 @@
+/* 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 tests.api.java.util.zip;
+
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import tests.support.Support_PlatformFile;
+import tests.support.resource.Support_Resources;
+
+public class ZipFileTest extends junit.framework.TestCase {
+
+	// the file hyts_zipFile.zip in setup must be included as a resource
+	String tempFileName;
+
+	private java.util.zip.ZipFile zfile;
+
+	/**
+	 * @tests java.util.zip.ZipFile#ZipFile(java.io.File)
+	 */
+	public void test_ConstructorLjava_io_File() {
+		// Test for method java.util.zip.ZipFile(java.io.File)
+		assertTrue("Used to test", true);
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#ZipFile(java.io.File, int)
+	 */
+	public void test_ConstructorLjava_io_FileI() {
+		try {
+			zfile.close(); // about to reopen the same temp file
+			File file = new File(tempFileName);
+			ZipFile zip = new ZipFile(file, ZipFile.OPEN_DELETE
+					| ZipFile.OPEN_READ);
+			zip.close();
+			assertTrue("Zip should not exist", !file.exists());
+		} catch (IOException e) {
+			fail("Unexpected exception: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#ZipFile(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.util.zip.ZipFile(java.lang.String)
+		/*
+		 * try { zfile = new java.util.zip.ZipFile(zipName); zfile.close(); }
+		 * catch (java.io.IOException e) {fail( "Failed to construct
+		 * ZipFile" );}
+		 */
+	}
+
+	protected ZipEntry test_finalize1(ZipFile zip) {
+		return zip.getEntry("File1.txt");
+	}
+
+	protected ZipFile test_finalize2(File file) {
+		try {
+			return new ZipFile(file);
+		} catch (IOException e) {
+			fail("Unexpected exception: " + e);
+		}
+		return null;
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#finalize()
+	 */
+	public void test_finalize() {
+		try {
+			InputStream in = Support_Resources.getStream("hyts_ZipFile.zip");
+			File file = Support_Resources.createTempFile(".jar");
+			OutputStream out = new FileOutputStream(file);
+			int result;
+			byte[] buf = new byte[4096];
+			while ((result = in.read(buf)) != -1)
+				out.write(buf, 0, result);
+			in.close();
+			out.close();
+			/*
+			 * ZipFile zip = new ZipFile(file); ZipEntry entry1 =
+			 * zip.getEntry("File1.txt"); assertTrue("Did not find entry",
+			 * entry1 != null); entry1 = null; zip = null;
+			 */
+
+			assertTrue("Did not find entry",
+					test_finalize1(test_finalize2(file)) != null);
+			System.gc();
+			System.gc();
+			System.runFinalization();
+			file.delete();
+			assertTrue("Zip should not exist", !file.exists());
+		} catch (IOException e) {
+			fail("Unexpected exception: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#close()
+	 */
+	public void test_close() {
+		// Test for method void java.util.zip.ZipFile.close()
+		try {
+			zfile.close();
+			zfile.getInputStream(zfile.getEntry("ztest/file1.txt"));
+		} catch (Exception e) {
+			return;
+		}
+		fail("Close test failed");
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#entries()
+	 */
+	public void test_entries() {
+		// Test for method java.util.Enumeration java.util.zip.ZipFile.entries()
+		java.util.Enumeration enumer = zfile.entries();
+		int c = 0;
+		while (enumer.hasMoreElements()) {
+			++c;
+			enumer.nextElement();
+		}
+		assertTrue("Incorrect number of entries returned: " + c, c == 6);
+
+		try {
+			Enumeration enumeration = zfile.entries();
+			zfile.close();
+			zfile = null;
+			boolean pass = false;
+			try {
+				enumeration.hasMoreElements();
+			} catch (IllegalStateException e) {
+				pass = true;
+			}
+			assertTrue("did not detect closed jar file", pass);
+		} catch (Exception e) {
+			fail("Exception during entries test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#getEntry(java.lang.String)
+	 */
+	public void test_getEntryLjava_lang_String() {
+		// Test for method java.util.zip.ZipEntry
+		// java.util.zip.ZipFile.getEntry(java.lang.String)
+		java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
+		assertTrue("Could not obtain ZipEntry", zentry != null);
+
+		zentry = zfile.getEntry("testdir1/File1.txt");
+		assertTrue("Could not obtain ZipEntry: testdir1/File1.txt",
+				zentry != null);
+		try {
+			int r;
+			InputStream in;
+			zentry = zfile.getEntry("testdir1/");
+			assertTrue("Could not obtain ZipEntry: testdir1/", zentry != null);
+			in = zfile.getInputStream(zentry);
+			assertTrue("testdir1/ should not have null input stream",
+					in != null);
+			r = in.read();
+			in.close();
+			assertTrue("testdir1/ should not contain data", r == -1);
+
+			zentry = zfile.getEntry("testdir1");
+			assertTrue("Could not obtain ZipEntry: testdir1", zentry != null);
+			in = zfile.getInputStream(zentry);
+			assertTrue("testdir1 should not have null input stream", in != null);
+			r = in.read();
+			in.close();
+			assertTrue("testdir1 should not contain data", r == -1);
+
+			zentry = zfile.getEntry("testdir1/testdir1");
+			assertTrue("Could not obtain ZipEntry: testdir1/testdir1",
+					zentry != null);
+			in = zfile.getInputStream(zentry);
+			byte[] buf = new byte[256];
+			r = in.read(buf);
+			in.close();
+			assertTrue("incorrect contents", new String(buf, 0, r)
+					.equals("This is also text"));
+		} catch (IOException e) {
+			fail("Unexpected: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#getInputStream(java.util.zip.ZipEntry)
+	 */
+	public void test_getInputStreamLjava_util_zip_ZipEntry() {
+		// Test for method java.io.InputStream
+		// java.util.zip.ZipFile.getInputStream(java.util.zip.ZipEntry)
+		java.io.InputStream is = null;
+		try {
+			java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
+			is = zfile.getInputStream(zentry);
+			byte[] rbuf = new byte[1000];
+			int r;
+			is.read(rbuf, 0, r = (int) zentry.getSize());
+			assertTrue("getInputStream read incorrect data", new String(rbuf,
+					0, r).equals("This is text"));
+		} catch (java.io.IOException e) {
+			fail("IOException during getInputStream");
+		} finally {
+			try {
+				is.close();
+			} catch (java.io.IOException e) {
+				fail("Failed to close input stream");
+			}
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipFile#getName()
+	 */
+	public void test_getName() {
+		// Test for method java.lang.String java.util.zip.ZipFile.getName()
+		assertTrue("Returned incorrect name: " + zfile.getName(), zfile
+				.getName().equals(tempFileName));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		try {
+			byte[] rbuf = new byte[2000];
+			// Create a local copy of the file since some tests want to alter
+			// information.
+			tempFileName = System.getProperty("user.dir");
+			String separator = System.getProperty("file.separator");
+			if (tempFileName.charAt(tempFileName.length() - 1) == separator
+					.charAt(0))
+				tempFileName = Support_PlatformFile.getNewPlatformFile(
+						tempFileName, "gabba.zip");
+			else
+				tempFileName = Support_PlatformFile.getNewPlatformFile(
+						tempFileName + separator, "gabba.zip");
+
+			File f = new File(tempFileName);
+			f.delete();
+			InputStream is = Support_Resources.getStream("hyts_ZipFile.zip");
+			FileOutputStream fos = new FileOutputStream(f);
+			rbuf = new byte[(int) is.available()];
+			is.read(rbuf, 0, rbuf.length);
+			fos.write(rbuf, 0, rbuf.length);
+			is.close();
+			fos.close();
+			zfile = new ZipFile(f);
+		} catch (Exception e) {
+			System.out.println("Exception during ZipFile setup:");
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+		try {
+			if (zfile != null)
+				// Note zfile is a user-defined zip file used by other tests and
+				// should not be deleted
+				zfile.close();
+		} catch (Exception e) {
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,158 @@
+/* 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 tests.api.java.util.zip;
+
+
+
+import java.util.zip.ZipInputStream;
+
+import tests.support.resource.Support_Resources;
+
+public class ZipInputStreamTest extends junit.framework.TestCase {
+	// the file hyts_zipFile.zip used in setup needs to included as a resource
+	java.util.zip.ZipFile zfile;
+
+	java.util.zip.ZipEntry zentry;
+
+	java.util.zip.ZipInputStream zis;
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#ZipInputStream(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		// Test for method java.util.zip.ZipInputStream(java.io.InputStream)
+		try {
+			zentry = zis.getNextEntry();
+			zis.closeEntry();
+		} catch (java.io.IOException e) {
+			fail("Failed to create ZipInputStream");
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#close()
+	 */
+	public void test_close() {
+		// Test for method void java.util.zip.ZipInputStream.close()
+		try {
+			zis.close();
+			byte[] rbuf = new byte[10];
+			zis.read(rbuf, 0, 1);
+		} catch (java.io.IOException e) {
+			return;
+		}
+		fail("Read data after stream was closed--is this an error?");
+	}
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#closeEntry()
+	 */
+	public void test_closeEntry() {
+		// Test for method void java.util.zip.ZipInputStream.closeEntry()
+		try {
+			zentry = zis.getNextEntry();
+			zis.closeEntry();
+		} catch (java.io.IOException e) {
+			fail("Exception during closeEntry test");
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#getNextEntry()
+	 */
+	public void test_getNextEntry() {
+		// Test for method java.util.zip.ZipEntry
+		// java.util.zip.ZipInputStream.getNextEntry()
+		try {
+			assertTrue("getNextEntry failed", zis.getNextEntry() != null);
+		} catch (java.io.IOException e) {
+			fail("Exception during getNextEntry test");
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#read(byte[], int, int)
+	 */
+	public void test_read$BII() {
+		// Test for method int java.util.zip.ZipInputStream.read(byte [], int,
+		// int)
+		try {
+			zentry = zis.getNextEntry();
+			byte[] rbuf = new byte[(int) zentry.getSize()];
+			int r = zis.read(rbuf, 0, rbuf.length);
+			new String(rbuf, 0, r);
+			assertTrue("Failed to read entry", r == 12);
+		} catch (java.io.IOException e) {
+			fail("Exception during read test");
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipInputStream#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.util.zip.ZipInputStream.skip(long)
+		try {
+			zentry = zis.getNextEntry();
+			byte[] rbuf = new byte[(int) zentry.getSize()];
+			zis.skip(2);
+			int r = zis.read(rbuf, 0, rbuf.length);
+			assertTrue("Failed to skip data", r == 10);
+		} catch (java.io.IOException e) {
+			fail("Unexpected1: " + e);
+		}
+
+		try {
+			zentry = zis.getNextEntry();
+			zentry = zis.getNextEntry();
+			long s = zis.skip(1025);
+			assertTrue("invalid skip: " + s, s == 1025);
+		} catch (java.io.IOException e) {
+			fail("Unexpected2: " + e);
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+
+		try {
+			java.io.InputStream is = Support_Resources
+					.getStream("hyts_ZipFile.zip");
+			if (is == null)
+				System.out.println("file hyts_ZipFile.zip can not be found");
+			zis = new ZipInputStream(is);
+		} catch (Exception e) {
+			System.out.println("Exception during ZipFile setup:");
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+
+		if (zis != null)
+			try {
+				zis.close();
+			} catch (Exception e) {
+			}
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,274 @@
+/* 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 tests.api.java.util.zip;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+public class ZipOutputStreamTest extends junit.framework.TestCase {
+
+	ZipOutputStream zos;
+
+	ByteArrayOutputStream bos;
+
+	ZipInputStream zis;
+
+	static final String data = "HelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorldHelloWorld";
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#close()
+	 */
+	public void test_close() {
+		boolean thrown = false;
+		try {
+			zos.close();
+		} catch (ZipException e) {
+			// Correct
+			thrown = true;
+		} catch (IOException e) {
+			fail("Exception closing on stream with no entries");
+		}
+		if (!thrown)
+			fail("Close on empty stream failed to throw exception");
+		try {
+			zos = new ZipOutputStream(bos);
+			zos.putNextEntry(new ZipEntry("XX"));
+			zos.closeEntry();
+			zos.close();
+		} catch (IOException e) {
+			fail("Exception during close test: " + e.toString());
+		}
+
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#closeEntry()
+	 */
+	public void test_closeEntry() {
+		try {
+			ZipEntry ze = new ZipEntry("testEntry");
+			ze.setTime(System.currentTimeMillis());
+			zos.putNextEntry(ze);
+			zos.write("Hello World".getBytes());
+			zos.closeEntry();
+			assertTrue("closeEntry failed to update required fields", ze
+					.getSize() == 11
+					&& ze.getCompressedSize() == 13);
+
+		} catch (IOException e) {
+			fail("Exception during closeEntry: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#finish()
+	 */
+	public void test_finish() {
+		try {
+			ZipEntry ze = new ZipEntry("test");
+			zos.putNextEntry(ze);
+			zos.write("Hello World".getBytes());
+			zos.finish();
+			assertTrue("Finish failed to closeCurrentEntry", ze.getSize() == 11);
+		} catch (IOException e) {
+			fail("Exception during finish test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#putNextEntry(java.util.zip.ZipEntry)
+	 */
+	public void test_putNextEntryLjava_util_zip_ZipEntry() {
+		try {
+			ZipEntry ze = new ZipEntry("testEntry");
+			ze.setTime(System.currentTimeMillis());
+			zos.putNextEntry(ze);
+			zos.write("Hello World".getBytes());
+			zos.closeEntry();
+			zos.close();
+			zis = new ZipInputStream(
+					new ByteArrayInputStream(bos.toByteArray()));
+			ZipEntry ze2 = zis.getNextEntry();
+			zis.closeEntry();
+			assertTrue("Failed to write correct entry", ze.getName().equals(
+					ze2.getName())
+					&& ze.getCrc() == ze2.getCrc());
+			try {
+				zos.putNextEntry(ze);
+			} catch (IOException e) {
+				// Correct
+				return;
+			}
+			fail(
+					"Entry with incorrect setting failed to throw exception");
+		} catch (IOException e) {
+			fail("Exception during putNextEntry: " + e.toString());
+		}
+
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#setComment(java.lang.String)
+	 */
+	public void test_setCommentLjava_lang_String() {
+		// There is no way to get the comment back, so no way to determine if
+		// the comment is set correct
+		try {
+			zos.setComment("test setComment");
+		} catch (Exception e) {
+			fail("Trying to set comment failed");
+		}
+		try {
+			zos.setComment(new String(new byte[0xFFFF + 1]));
+			fail("Comment over 0xFFFF in length should throw exception");
+		} catch (IllegalArgumentException e) {
+			// Passed
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#setLevel(int)
+	 */
+	public void test_setLevelI() {
+		try {
+			ZipEntry ze = new ZipEntry("test");
+			zos.putNextEntry(ze);
+			zos.write(data.getBytes());
+			zos.closeEntry();
+			long csize = ze.getCompressedSize();
+			zos.setLevel(9); // Max Compression
+			zos.putNextEntry(ze = new ZipEntry("test2"));
+			zos.write(data.getBytes());
+			zos.closeEntry();
+			assertTrue("setLevel failed", csize <= ze.getCompressedSize());
+		} catch (IOException e) {
+			fail("Exception during setLevel test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#setMethod(int)
+	 */
+	public void test_setMethodI() {
+		try {
+			ZipEntry ze = new ZipEntry("test");
+			zos.setMethod(zos.STORED);
+			CRC32 tempCrc = new CRC32();
+			tempCrc.update(data.getBytes());
+			ze.setCrc(tempCrc.getValue());
+			ze.setSize(new String(data).length());
+			zos.putNextEntry(ze);
+			zos.write(data.getBytes());
+			zos.closeEntry();
+			long csize = ze.getCompressedSize();
+			zos.setMethod(zos.DEFLATED);
+			zos.putNextEntry(ze = new ZipEntry("test2"));
+			zos.write(data.getBytes());
+			zos.closeEntry();
+			assertTrue("setLevel failed", csize >= ze.getCompressedSize());
+		} catch (IOException e) {
+			fail("Exception during setLevel test: " + e.toString());
+		}
+	}
+
+	/**
+	 * @tests java.util.zip.ZipOutputStream#write(byte[], int, int)
+	 */
+	public void test_write$BII() {
+		try {
+			ZipEntry ze = new ZipEntry("test");
+			zos.putNextEntry(ze);
+			zos.write(data.getBytes());
+			zos.closeEntry();
+			zos.close();
+			zos = null;
+			zis = new ZipInputStream(
+					new ByteArrayInputStream(bos.toByteArray()));
+			zis.getNextEntry();
+			byte[] b = new byte[data.length()];
+			int r = 0;
+			int count = 0;
+			while (count != b.length
+					&& (r = zis.read(b, count, b.length)) != -1)
+				count += r;
+			zis.closeEntry();
+			assertTrue("Write failed to write correct bytes", new String(b)
+					.equals(data));
+		} catch (IOException e) {
+			fail("Exception during write test: " + e.toString());
+		}
+
+		try {
+			File f = File.createTempFile("testZip", "tst");
+			f.deleteOnExit();
+			FileOutputStream stream = new FileOutputStream(f);
+			ZipOutputStream zip = new ZipOutputStream(stream);
+			zip.setMethod(ZipEntry.STORED);
+
+			try {
+				zip.putNextEntry(new ZipEntry("Second"));
+				fail("Not set an entry. Should have thrown ZipException.");
+			} catch (Exception e) {
+				assertTrue(e instanceof ZipException);
+			} // We have not set an entry
+
+			try {
+				// We try to write data without entry
+				zip.write(new byte[2]);
+				fail("Writing data without an entry. Should have thrown IOException");
+			} catch (Exception e) {
+				assertTrue(e instanceof IOException);
+			}
+
+			try {
+				// Try to write without an entry and with nonsense offset and
+				// length
+				zip.write(new byte[2], 0, 12);
+				fail("Writing data without an entry. Should have thrown IndexOutOfBoundsException");
+			} catch (Exception e) {
+				assertTrue("Caught a " + e.getClass().getName(),
+						e instanceof IndexOutOfBoundsException);
+			}
+		} catch (IOException e) {
+			fail("ERROR: " + e);
+		}
+	}
+
+	protected void setUp() {
+		zos = new ZipOutputStream(bos = new ByteArrayOutputStream());
+	}
+
+	protected void tearDown() {
+
+		try {
+			if (zos != null)
+				zos.close();
+			if (zis != null)
+				zis.close();
+		} catch (Exception e) {
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/archive/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/archive/AllTests.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/archive/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/test/java/tests/archive/AllTests.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,38 @@
+/* Copyright 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 tests.archive;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all tests for the Archive project.
+ */
+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(tests.api.java.util.jar.AllTests.suite());
+		suite.addTest(tests.api.java.util.zip.AllTests.suite());
+		// $JUnit-END$
+		return suite;
+	}
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml?rev=386058&r1=386057&r2=386058&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/make/common/build.xml Wed Mar 15 03:46:17 2006
@@ -59,6 +59,7 @@
 					<include name="*.jar" />
 				</fileset>
 			</bootclasspath>
+			<classpath location="../../../../build/tests" />
 		</javac>
 	</target>
 
@@ -68,28 +69,93 @@
         <mkdir dir="${hy.tests.reports}" />
 
         <junit fork="yes"
-            forkmode="once"
-            printsummary="withOutAndErr"
-            errorproperty="test.error"
-            showoutput="on"
-            dir="${hy.luni.bin.test}"
-            jvm="${hy.target}/jre/bin/java">
+               forkmode="once"
+               printsummary="withOutAndErr"
+               errorproperty="test.error"
+               showoutput="on"
+               dir="${hy.luni.bin.test}"
+               jvm="${hy.target}/jre/bin/java">
+          
+	    <jvmarg value="-showversion"/>
 
-			<jvmarg value="-showversion"/>
+            <!-- Required by various tests that set security manager etc -->
+            <jvmarg value="-Djava.security.policy=../../../../support/src/test/resources/config/testing.policy" />
+
+            <!-- Required for running the java.net unit tests -->
+            <jvmarg value="-Dtest.ini.file=../../../../src/test/resources/config/localhosttest.ini" />
 
             <env key="JAVA_HOME" value="${hy.target}/jre"/>
 
             <classpath>
-				<pathelement path="${hy.luni.bin.test}"/>
-			</classpath>
+	        <pathelement path="${hy.luni.bin.test}"/>
+	    </classpath>
 
-		<formatter type="xml" />
+	    <formatter type="xml" />
 
-		<batchtest todir="${hy.tests.reports}" haltonfailure="no">
-			<fileset dir="${hy.luni.src.test.java}">
-				<include name="**/*Test.java"/>
-			</fileset>
-		</batchtest>
+	    <batchtest todir="${hy.tests.reports}" haltonfailure="no">
+	        <fileset dir="${hy.luni.src.test.java}">
+		    <include name="**/*Test.java"/>
+                    <exclude name="**/BufferedInputStreamTest.java"/>
+                    <exclude name="**/BufferedReaderTest.java"/>
+                    <exclude name="**/BufferedWriterTest.java"/>
+                    <exclude name="**/FileInputStreamTest.java"/>
+                    <exclude name="**/FileTest.java"/>
+                    <exclude name="**/FilterInputStreamTest.java"/>
+                    <exclude name="**/InputStreamReaderTest.java"/>
+                    <exclude name="**/NotSerializableExceptionTest.java"/>
+                    <exclude name="**/ObjectInputStreamTest.java"/>
+                    <exclude name="**/ObjectOutputStreamTest.java"/>
+                    <exclude name="**/OutputStreamWriterTest.java"/>
+                    <exclude name="**/PipedInputStreamTest.java"/>
+                    <exclude name="**/PrintWriterTest.java"/>
+                    <exclude name="**/RandomAccessFileTest.java"/>
+                    <exclude name="**/StreamTokenizerTest.java"/>
+                    <exclude name="**/ArrayIndexOutOfBoundsExceptionTest.java"/>
+                    <exclude name="**/AssertionErrorTest.java"/>
+                    <exclude name="**/ClassLoaderTest.java"/>
+                    <exclude name="**/ClassTest.java"/>
+                    <exclude name="**/PackageTest.java"/>
+                    <exclude name="**/ProcessTest.java"/>
+                    <exclude name="**/StringTest.java"/>
+                    <exclude name="**/FieldTest.java"/>
+                    <exclude name="**/ProxyTest.java"/>
+                    <exclude name="**/ConnectExceptionTest.java"/>
+                    <exclude name="**/DatagramPacketTest.java"/>
+                    <exclude name="**/DatagramSocketTest.java"/>
+                    <exclude name="**/HttpURLConnectionTest.java"/>
+                    <exclude name="**/InetAddressTest.java"/>
+                    <exclude name="**/JarURLConnectionTest.java"/>
+                    <exclude name="**/MulticastSocketTest.java"/>
+                    <exclude name="**/ServerSocketTest.java"/>
+                    <exclude name="**/SocketImplTest.java"/>
+                    <exclude name="**/SocketPermissionTest.java"/>
+                    <exclude name="**/SocketTest.java"/>
+                    <exclude name="**/URISyntaxExceptionTest.java"/>
+                    <exclude name="**/URLClassLoaderTest.java"/>
+                    <exclude name="**/URLConnectionTest.java"/>
+                    <exclude name="**/URLDecoderTest.java"/>
+                    <exclude name="**/URLEncoderTest.java"/>
+                    <exclude name="**/URLTest.java"/>
+                    <exclude name="**/ArrayListTest.java"/>
+                    <exclude name="**/ArraysTest.java"/>
+                    <exclude name="**/CalendarTest.java"/>
+                    <exclude name="**/CollectionsTest.java"/>
+                    <exclude name="**/HashMapTest.java"/>
+                    <exclude name="**/HashtableTest.java"/>
+                    <exclude name="**/IdentityHashMapTest.java"/>
+                    <exclude name="**/LinkedHashMapTest.java"/>
+                    <exclude name="**/LinkedListTest.java"/>
+                    <exclude name="**/ListResourceBundleTest.java"/>
+                    <exclude name="**/LocaleTest.java"/>
+                    <exclude name="**/PropertiesTest.java"/>
+                    <exclude name="**/ResourceBundleTest.java"/>
+                    <exclude name="**/TimeZoneTest.java"/>
+                    <exclude name="**/TreeMapTest.java"/>
+                    <exclude name="**/VectorTest.java"/>
+                    <exclude name="**/WeakHashMapTest.java"/>
+                    <exclude name="**/NYITest.java"/>
+		</fileset>
+	    </batchtest>
 	</junit>
     </target>
 	

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/AllTests.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/AllTests.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,91 @@
+/* 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 tests.api.java.io;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * 
+ */
+public class AllTests {
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("Tests for java.io");
+		// $JUnit-BEGIN$
+		suite.addTestSuite(InputStreamReaderTest.class);
+		suite.addTestSuite(OutputStreamWriterTest.class);
+		suite.addTestSuite(OpenRandomFileTest.class);
+
+		suite.addTestSuite(BufferedInputStreamTest.class);
+		suite.addTestSuite(BufferedOutputStreamTest.class);
+		suite.addTestSuite(BufferedReaderTest.class);
+		suite.addTestSuite(BufferedWriterTest.class);
+		suite.addTestSuite(ByteArrayInputStreamTest.class);
+		suite.addTestSuite(ByteArrayOutputStreamTest.class);
+		suite.addTestSuite(CharArrayReaderTest.class);
+		suite.addTestSuite(CharArrayWriterTest.class);
+		suite.addTestSuite(CharConversionExceptionTest.class);
+		suite.addTestSuite(DataInputStreamTest.class);
+		suite.addTestSuite(DataOutputStreamTest.class);
+		suite.addTestSuite(EOFExceptionTest.class);
+		suite.addTestSuite(FileTest.class);
+		suite.addTestSuite(FileDescriptorTest.class);
+		suite.addTestSuite(FileInputStreamTest.class);
+		suite.addTestSuite(FileNotFoundExceptionTest.class);
+		suite.addTestSuite(FileOutputStreamTest.class);
+		suite.addTestSuite(FilePermissionTest.class);
+		suite.addTestSuite(FileReaderTest.class);
+		suite.addTestSuite(FileWriterTest.class);
+		suite.addTestSuite(FilterInputStreamTest.class);
+		suite.addTestSuite(FilterOutputStreamTest.class);
+		suite.addTestSuite(InterruptedIOExceptionTest.class);
+		suite.addTestSuite(InvalidClassExceptionTest.class);
+		suite.addTestSuite(IOExceptionTest.class);
+		suite.addTestSuite(LineNumberInputStreamTest.class);
+		suite.addTestSuite(LineNumberReaderTest.class);
+		suite.addTestSuite(NotActiveExceptionTest.class);
+		suite.addTestSuite(NotSerializableExceptionTest.class);
+		suite.addTestSuite(ObjectInputStreamTest.class);
+		suite.addTestSuite(ObjectOutputStreamTest.class);
+		suite.addTestSuite(ObjectStreamClassTest.class);
+		suite.addTestSuite(ObjectStreamFieldTest.class);
+		suite.addTestSuite(PipedInputStreamTest.class);
+		suite.addTestSuite(PipedOutputStreamTest.class);
+		suite.addTestSuite(PipedReaderTest.class);
+		suite.addTestSuite(PipedWriterTest.class);
+		suite.addTestSuite(PrintStreamTest.class);
+		suite.addTestSuite(PrintWriterTest.class);
+		suite.addTestSuite(PushbackInputStreamTest.class);
+		suite.addTestSuite(PushbackReaderTest.class);
+		suite.addTestSuite(RandomAccessFileTest.class);
+		suite.addTestSuite(SequenceInputStreamTest.class);
+		suite.addTestSuite(SerializablePermissionTest.class);
+		suite.addTestSuite(StreamCorruptedExceptionTest.class);
+		suite.addTestSuite(StreamTokenizerTest.class);
+		suite.addTestSuite(StringBufferInputStreamTest.class);
+		suite.addTestSuite(StringReaderTest.class);
+		suite.addTestSuite(StringWriterTest.class);
+		suite.addTestSuite(SyncFailedExceptionTest.class);
+		suite.addTestSuite(UnsupportedEncodingExceptionTest.class);
+		suite.addTestSuite(UTFDataFormatExceptionTest.class);
+		suite.addTestSuite(WriteAbortedExceptionTest.class);
+		suite.addTestSuite(SerializationStressTest.class);
+		// $JUnit-END$
+
+		return suite;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,360 @@
+/* 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 tests.api.java.io;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import tests.support.Support_PlatformFile;
+
+public class BufferedInputStreamTest extends junit.framework.TestCase {
+
+	public String fileName;
+
+	private java.io.BufferedInputStream is;
+
+	private java.io.FileInputStream isFile;
+
+	byte[] ibuf = new byte[4096];
+
+	public String fileString = "Test_All_Tests\nTest_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_lang_Class
 NotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Obj
 ect\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_SocketE
 xception\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+
+	/**
+	 * @tests java.io.BufferedInputStream#BufferedInputStream(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		// Test for method java.io.BufferedInputStream(java.io.InputStream)
+		assertTrue("Cannot run any tests without one", true);
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#BufferedInputStream(java.io.InputStream,
+	 *        int)
+	 */
+	public void test_ConstructorLjava_io_InputStreamI() {
+		// Test for method java.io.BufferedInputStream(java.io.InputStream, int)
+		boolean exceptionFired = false;
+		try {
+			// Create buffer with exact size of file
+			is = new java.io.BufferedInputStream(isFile, this.fileString
+					.length());
+			// Ensure buffer gets filled by evaluating one read
+			is.read();
+			// Close underlying FileInputStream, all but 1 buffered bytes should
+			// still be available.
+			isFile.close();
+			// Read the remaining buffered characters, no IOException should
+			// occur.
+			is.skip(this.fileString.length() - 2);
+			is.read();
+			try {
+				// is.read should now throw an exception because it will have to
+				// be filled.
+				is.read();
+			} catch (java.io.IOException e) {
+				exceptionFired = true;
+			}
+			assertTrue("Exception should have been triggered by read()",
+					exceptionFired);
+		} catch (java.io.IOException e) {
+			fail("Exception during test_1_Constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#available()
+	 */
+	public void test_available() {
+		// Test for method int java.io.BufferedInputStream.available()
+		try {
+			assertTrue("Returned incorrect number of available bytes", is
+					.available() == fileString.length());
+		} catch (java.io.IOException e) {
+			fail("Exception during available test");
+		}
+
+		// Test that a closed stream throws an IOE for available()
+		BufferedInputStream bis = new BufferedInputStream(
+				new ByteArrayInputStream(new byte[] { 'h', 'e', 'l', 'l', 'o',
+						' ', 't', 'i', 'm' }));
+		int available;
+		try {
+			available = bis.available();
+			bis.close();
+		} catch (IOException ex) {
+			fail();
+			return; // never reached.
+		}
+		assertTrue(available != 0);
+
+		try {
+			bis.available();
+			fail("Expected test to throw IOE.");
+		} catch (IOException ex) {
+			// expected
+		} catch (Throwable ex) {
+			fail("Expected test to throw IOE not "
+					+ ex.getClass().getName());
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.BufferedInputStream.close()
+		new BufferedInputStream(isFile);
+		new BufferedInputStream(isFile);
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#mark(int)
+	 */
+	public void test_markI() {
+		// Test for method void java.io.BufferedInputStream.mark(int)
+		byte[] buf1 = new byte[100];
+		byte[] buf2 = new byte[100];
+		try {
+			is.skip(3000);
+			is.mark(1000);
+			is.read(buf1, 0, buf1.length);
+			is.reset();
+			is.read(buf2, 0, buf2.length);
+			is.reset();
+			assertTrue("Failed to mark correct position", new String(buf1, 0,
+					buf1.length).equals(new String(buf2, 0, buf2.length)));
+
+		} catch (java.io.IOException e) {
+			fail("Exception during mark test");
+		}
+
+		byte[] bytes = new byte[256];
+		for (int i = 0; i < 256; i++)
+			bytes[i] = (byte) i;
+		InputStream in = new BufferedInputStream(
+				new ByteArrayInputStream(bytes), 12);
+		try {
+			in.skip(6);
+			in.mark(14);
+			in.read(new byte[14], 0, 14);
+			in.reset();
+			assertTrue("Wrong bytes", in.read() == 6 && in.read() == 7);
+		} catch (IOException e) {
+			fail("Exception during mark test 2");
+		}
+
+		in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
+		try {
+			in.skip(6);
+			in.mark(8);
+			in.skip(7);
+			in.reset();
+			assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);
+		} catch (IOException e) {
+			fail("Exception during mark test 3");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#markSupported()
+	 */
+	public void test_markSupported() {
+		// Test for method boolean java.io.BufferedInputStream.markSupported()
+		assertTrue("markSupported returned incorrect value", is.markSupported());
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.BufferedInputStream.read()
+
+		try {
+
+			int c = is.read();
+			assertTrue("read returned incorrect char", c == fileString
+					.charAt(0));
+		} catch (java.io.IOException e) {
+			fail("Exception during read test" + e.toString());
+		}
+
+		byte[] bytes = new byte[256];
+		for (int i = 0; i < 256; i++)
+			bytes[i] = (byte) i;
+		InputStream in = new BufferedInputStream(
+				new ByteArrayInputStream(bytes), 12);
+		try {
+			assertTrue("Wrong initial byte", in.read() == 0); // Fill the
+			// buffer
+			byte[] buf = new byte[14];
+			in.read(buf, 0, 14); // Read greater than the buffer
+			assertTrue("Wrong block read data", new String(buf, 0, 14)
+					.equals(new String(bytes, 1, 14)));
+			assertTrue("Wrong bytes", in.read() == 15); // Check next byte
+		} catch (IOException e) {
+			fail("Exception during read test 2");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#read(byte[], int, int)
+	 */
+	public void test_read$BII() {
+		// Test for method int java.io.BufferedInputStream.read(byte [], int,
+		// int)
+		byte[] buf1 = new byte[100];
+		try {
+			is.skip(3000);
+			is.mark(1000);
+			is.read(buf1, 0, buf1.length);
+			assertTrue("Failed to read correct data", new String(buf1, 0,
+					buf1.length).equals(fileString.substring(3000, 3100)));
+
+		} catch (java.io.IOException e) {
+			fail("Exception during read test");
+		}
+
+		BufferedInputStream bufin = new BufferedInputStream(new InputStream() {
+			int size = 2, pos = 0;
+
+			byte[] contents = new byte[size];
+
+			public int read() throws IOException {
+				if (pos >= size)
+					throw new IOException("Read past end of data");
+				return contents[pos++];
+			}
+
+			public int read(byte[] buf, int off, int len) throws IOException {
+				if (pos >= size)
+					throw new IOException("Read past end of data");
+				int toRead = len;
+				if (toRead > available())
+					toRead = available();
+				System.arraycopy(contents, pos, buf, off, toRead);
+				pos += toRead;
+				return toRead;
+			}
+
+			public int available() {
+				return size - pos;
+			}
+		});
+		try {
+			bufin.read();
+			int result = bufin.read(new byte[2], 0, 2);
+			assertTrue("Incorrect result: " + result, result == 1);
+		} catch (IOException e) {
+			fail("Unexpected: " + e);
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.BufferedInputStream.reset()
+
+		byte[] buf1 = new byte[10];
+		byte[] buf2 = new byte[10];
+		try {
+			is.mark(2000);
+			is.read(buf1, 0, 10);
+			is.reset();
+			is.read(buf2, 0, 10);
+			is.reset();
+			assertTrue("Reset failed", new String(buf1, 0, buf1.length)
+					.equals(new String(buf2, 0, buf2.length)));
+
+			BufferedInputStream bIn = new BufferedInputStream(
+					new ByteArrayInputStream("1234567890".getBytes()));
+			bIn.mark(10);
+			for (int i = 0; i < 11; i++) {
+				bIn.read();
+			}
+			bIn.reset();
+
+		} catch (java.io.IOException e) {
+			fail("Exception during reset test");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedInputStream#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.BufferedInputStream.skip(long)
+		byte[] buf1 = new byte[10];
+		try {
+			is.mark(2000);
+			is.skip(1000);
+			is.read(buf1, 0, buf1.length);
+			is.reset();
+			assertTrue("Failed to skip to correct position", new String(buf1,
+					0, buf1.length).equals(fileString.substring(1000, 1010)));
+		} catch (java.io.IOException e) {
+			fail("Exception during skip test");
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+
+		try {
+			fileName = System.getProperty("user.dir");
+			String separator = System.getProperty("file.separator");
+			if (fileName.charAt(fileName.length() - 1) == separator.charAt(0))
+				fileName = Support_PlatformFile.getNewPlatformFile(fileName,
+						"input.tst");
+			else
+				fileName = Support_PlatformFile.getNewPlatformFile(fileName
+						+ separator, "input.tst");
+			java.io.OutputStream fos = new java.io.FileOutputStream(fileName);
+			fos.write(fileString.getBytes());
+			fos.close();
+			isFile = new java.io.FileInputStream(fileName);
+			is = new java.io.BufferedInputStream(isFile);
+		} catch (java.io.IOException e) {
+			System.out.println("Exception during setup");
+			e.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+
+		try {
+			is.close();
+		} catch (Exception e) {
+			System.out.println("Exception during BIS tearDown");
+		}
+		try {
+			java.io.File f = new java.io.File(fileName);
+			f.delete();
+		} catch (Exception e) {
+			System.out.println("Exception during BIS tearDown");
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,155 @@
+/* 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 tests.api.java.io;
+
+import java.io.ByteArrayOutputStream;
+
+public class BufferedOutputStreamTest extends junit.framework.TestCase {
+
+	private java.io.OutputStream os;
+
+	java.io.ByteArrayOutputStream baos;
+
+	java.io.ByteArrayInputStream bais;
+
+	public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_lang_Class
 NotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Obj
 ect\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_SocketE
 xception\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+
+	/**
+	 * @tests java.io.BufferedOutputStream#BufferedOutputStream(java.io.OutputStream)
+	 */
+	public void test_ConstructorLjava_io_OutputStream() {
+		// Test for method java.io.BufferedOutputStream(java.io.OutputStream)
+		try {
+			baos = new java.io.ByteArrayOutputStream();
+			os = new java.io.BufferedOutputStream(baos);
+			os.write(fileString.getBytes(), 0, 500);
+		} catch (java.io.IOException e) {
+			fail("Constrcutor test failed");
+		}
+
+	}
+
+	/**
+	 * @tests java.io.BufferedOutputStream#BufferedOutputStream(java.io.OutputStream,
+	 *        int)
+	 */
+	public void test_ConstructorLjava_io_OutputStreamI() {
+		// Test for method java.io.BufferedOutputStream(java.io.OutputStream,
+		// int)
+		try {
+			baos = new java.io.ByteArrayOutputStream();
+			os = new java.io.BufferedOutputStream(baos, 1024);
+			os.write(fileString.getBytes(), 0, 500);
+		} catch (java.io.IOException e) {
+			fail("IOException during Constrcutor test");
+		}
+
+	}
+
+	/**
+	 * @tests java.io.BufferedOutputStream#flush()
+	 */
+	public void test_flush() {
+		// Test for method void java.io.BufferedOutputStream.flush()
+
+		try {
+			baos = new ByteArrayOutputStream();
+			os = new java.io.BufferedOutputStream(baos, 600);
+			os.write(fileString.getBytes(), 0, 500);
+			os.flush();
+			assertTrue("Bytes not written after flush",
+					((ByteArrayOutputStream) baos).size() == 500);
+		} catch (java.io.IOException e) {
+			fail("Flush test failed");
+		}
+	}
+
+	/**
+	 * @tests java.io.BufferedOutputStream#write(byte[], int, int)
+	 */
+	public void test_write$BII() {
+		// Test for method void java.io.BufferedOutputStream.write(byte [], int,
+		// int)
+		try {
+			os = new java.io.BufferedOutputStream(
+					baos = new java.io.ByteArrayOutputStream());
+			os.write(fileString.getBytes(), 0, 500);
+			bais = new java.io.ByteArrayInputStream(baos.toByteArray());
+			assertTrue("Bytes written, not buffered", bais.available() == 0);
+			os.flush();
+			bais = new java.io.ByteArrayInputStream(baos.toByteArray());
+			assertTrue("Bytes not written after flush", bais.available() == 500);
+			os.write(fileString.getBytes(), 500, 513);
+			bais = new java.io.ByteArrayInputStream(baos.toByteArray());
+			assertTrue("Bytes not written when buffer full",
+					bais.available() >= 1000);
+			byte[] wbytes = new byte[1013];
+			bais.read(wbytes, 0, 1013);
+			assertTrue("Incorrect bytes written", fileString.substring(0, 1013)
+					.equals(new String(wbytes, 0, wbytes.length)));
+		} catch (java.io.IOException e) {
+			fail("Flush test failed");
+		}
+
+	}
+
+	/**
+	 * @tests java.io.BufferedOutputStream#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.BufferedOutputStream.write(int)
+
+		try {
+			baos = new java.io.ByteArrayOutputStream();
+			os = new java.io.BufferedOutputStream(baos);
+			os.write('t');
+			bais = new java.io.ByteArrayInputStream(baos.toByteArray());
+			assertTrue("Byte written, not buffered", bais.available() == 0);
+			os.flush();
+			bais = new java.io.ByteArrayInputStream(baos.toByteArray());
+			assertTrue("Byte not written after flush", bais.available() == 1);
+			byte[] wbytes = new byte[1];
+			bais.read(wbytes, 0, 1);
+			assertTrue("Incorrect byte written", wbytes[0] == 't');
+		} catch (java.io.IOException e) {
+			fail("Write test failed");
+		}
+	}
+
+	/**
+	 * 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() {
+		try {
+			if (bais != null)
+				bais.close();
+			if (os != null)
+				os.close();
+			if (baos != null)
+				baos.close();
+		} catch (Exception e) {
+			System.out.println("Exception during tearDown" + e.toString());
+		}
+	}
+}