harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r386058 [16/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/...
Date Wed, 15 Mar 2006 11:47:39 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SerializationStressTest5.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SerializationStressTest5.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SerializationStressTest5.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SerializationStressTest5.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,379 @@
+/* Copyright 2001, 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.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Vector;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class SerializationStressTest5 extends SerializationStressTest {
+
+	transient Throwable current;
+
+	// Use this for retrieving a list of any Throwable Classes that did not get
+	// tested.
+	transient Vector missedV = new Vector();
+
+	transient Class[][] params = new Class[][] { { String.class },
+			{ Throwable.class }, { Exception.class },
+			{ String.class, Exception.class }, { String.class, int.class },
+			{ String.class, String.class, String.class },
+			{ String.class, Error.class },
+			{ int.class, boolean.class, boolean.class, int.class, int.class },
+			{} };
+
+	transient Object[][] args = new Object[][] {
+			{ "message" },
+			{ new Throwable() },
+			{ new Exception("exception") },
+			{ "message", new Exception("exception") },
+			{ "message", new Integer(5) },
+			{ "message", "message", "message" },
+			{ "message", new Error("error") },
+			{ new Integer(5), new Boolean(false), new Boolean(false),
+					new Integer(5), new Integer(5) }, {} };
+
+	public SerializationStressTest5(String name) {
+		super(name);
+	}
+
+	public void test_writeObject_Throwables() {
+		try {
+			oos.close();
+		} catch (IOException e) {
+		}
+
+		File javaDir = findJavaDir();
+
+		Vector classFilesVector = new Vector();
+		if (javaDir != null)
+			findClassFiles(javaDir, classFilesVector);
+		else
+			findClassFilesFromZip(classFilesVector);
+
+		if (classFilesVector.size() == 0) {
+			fail("No Class Files Found.");
+		}
+
+		File[] classFilesArray = new File[classFilesVector.size()];
+		classFilesVector.copyInto(classFilesArray);
+
+		Class[] throwableClasses = findThrowableClasses(classFilesArray);
+		findParam(throwableClasses);
+
+		// Use this to print out the list of Throwable classes that weren't
+		// tested.
+		/*
+		 * System.out.println(); Class[] temp = new Class[missedV.size()];
+		 * missedV.copyInto(temp); for (int i = 0; i < temp.length; i++)
+		 * System.out.println(i+1 + ": " + temp[i].getName());
+		 */
+	}
+
+	private File[] makeClassPathArray() {
+		String classPath;
+		if (System.getProperty("java.vendor").startsWith("IBM"))
+			classPath = System.getProperty("com.ibm.oti.system.class.path");
+		else
+			classPath = System.getProperty("sun.boot.class.path");
+		int instanceOfSep = -1;
+		int nextInstance = classPath.indexOf(File.pathSeparatorChar,
+				instanceOfSep + 1);
+		Vector elms = new Vector();
+		while (nextInstance != -1) {
+			elms.add(new File(classPath.substring(instanceOfSep + 1,
+					nextInstance)));
+			instanceOfSep = nextInstance;
+			nextInstance = classPath.indexOf(File.pathSeparatorChar,
+					instanceOfSep + 1);
+		}
+		elms.add(new File(classPath.substring(instanceOfSep + 1)));
+		File[] result = new File[elms.size()];
+		elms.copyInto(result);
+		return result;
+	}
+
+	private File findJavaDir() {
+		File[] files = makeClassPathArray();
+		for (int i = 0; i < files.length; i++) {
+			if (files[i].isDirectory()) {
+				String[] tempFileNames = files[i].list();
+				for (int j = 0; j < tempFileNames.length; j++) {
+					File tempfile = new File(files[i], tempFileNames[j]);
+					if (tempfile.isDirectory()
+							&& tempFileNames[j].equals("java")) {
+						String[] subdirNames = tempfile.list();
+						for (int k = 0; k < subdirNames.length; k++) {
+							File subdir = new File(tempfile, subdirNames[k]);
+							if (subdir.isDirectory()
+									&& subdirNames[k].equals("lang")) {
+								return tempfile;
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	private void findClassFiles(File dir, Vector v) {
+		String[] classFileNames = dir.list();
+		for (int i = 0; i < classFileNames.length; i++) {
+			File file = new File(dir, classFileNames[i]);
+			if (file.isDirectory())
+				findClassFiles(file, v);
+			else if (classFileNames[i].endsWith(".class"))
+				v.add(file);
+		}
+	}
+
+	private Class[] findThrowableClasses(File[] files) {
+		Class thrClass = Throwable.class;
+		Vector resultVector = new Vector();
+		String slash = System.getProperty("file.separator");
+		String begTarget = slash + "java" + slash;
+		String endTarget = ".class";
+		for (int i = 0; i < files.length; i++) {
+			String fileName = files[i].getPath();
+			int instOfBegTarget = fileName.indexOf(begTarget);
+			int instOfEndTarget = fileName.indexOf(endTarget);
+			fileName = fileName.substring(instOfBegTarget + 1, instOfEndTarget);
+			fileName = fileName.replace(slash.charAt(0), '.');
+			try {
+				Class theClass = Class.forName(fileName, false, ClassLoader
+						.getSystemClassLoader());
+				if (thrClass.isAssignableFrom(theClass)) {
+					// java.lang.VirtualMachineError is abstract.
+					// java.io.ObjectStreamException is abstract
+					// java.beans.PropertyVetoException needs a
+					// java.beans.PropertyChangeEvent as a parameter
+					if (!fileName.equals("java.lang.VirtualMachineError")
+							&& !fileName
+									.equals("java.io.ObjectStreamException")
+							&& !fileName
+									.equals("java.beans.PropertyVetoException"))
+						resultVector.add(theClass);
+				}
+			} catch (ClassNotFoundException e) {
+				fail("ClassNotFoundException : " + fileName);
+			}
+		}
+		Class[] result = new Class[resultVector.size()];
+		resultVector.copyInto(result);
+		return result;
+	}
+
+	private void initClass(Class thrC, int num) {
+		Constructor[] cons = thrC.getConstructors();
+		for (int i = 0; i < cons.length; i++) {
+			try {
+				Throwable obj = (Throwable) cons[i].newInstance(args[num]);
+				t_Class(obj, num);
+				break;
+			} catch (IllegalArgumentException e) {
+				// This error should be caught until the correct args is hit.
+			} catch (IllegalAccessException e) {
+				fail(
+						"IllegalAccessException while creating instance of: "
+								+ thrC.getName());
+			} catch (InstantiationException e) {
+				fail(
+						"InstantiationException while creating instance of: "
+								+ thrC.getName());
+			} catch (InvocationTargetException e) {
+				fail(
+						"InvocationTargetException while creating instance of: "
+								+ thrC.getName());
+			}
+			if (i == cons.length - 1) {
+				fail(
+						"Failed to create newInstance of: " + thrC.getName());
+			}
+		}
+	}
+
+	public String getDumpName() {
+		if (current == null) {
+			dumpCount++;
+			return getName();
+		}
+		return getName() + "_" + current.getClass().getName();
+	}
+
+	private void t_Class(Throwable objToSave, int argsNum) {
+		current = objToSave;
+		Object objLoaded = null;
+		try {
+			if (DEBUG)
+				System.out.println("Obj = " + objToSave);
+			try {
+				objLoaded = dumpAndReload(objToSave);
+			} catch (FileNotFoundException e) {
+				// Must be using xload, ignore missing Throwables
+				System.out.println("Ignoring: "
+						+ objToSave.getClass().getName());
+				return;
+			}
+
+			// Has to have worked
+			boolean equals;
+			equals = objToSave.getClass().equals(objLoaded.getClass());
+			assertTrue(MSG_TEST_FAILED + objToSave, equals);
+			if (argsNum == 0 || (argsNum >= 3 && argsNum <= 7)) {
+				equals = ((Throwable) objToSave).getMessage().equals(
+						((Throwable) objLoaded).getMessage());
+				assertTrue("Message Test: " + MSG_TEST_FAILED + objToSave,
+						equals);
+			} else {
+				// System.out.println(((Throwable)objToSave).getMessage());
+				equals = ((Throwable) objToSave).getMessage() == null;
+				assertTrue("Null Test 1: (args=" + argsNum + ") "
+						+ MSG_TEST_FAILED + objToSave, equals);
+				equals = ((Throwable) objLoaded).getMessage() == null;
+				assertTrue("Null Test 2: (args=" + argsNum + ") "
+						+ MSG_TEST_FAILED + objToSave, equals);
+			}
+		} catch (IOException e) {
+			fail("Unexpected IOException in checkIt() : " + e.getMessage());
+		} catch (ClassNotFoundException e) {
+			fail(e.toString() + " - testing " + objToSave.getClass().getName());
+		}
+	}
+
+	private void findParam(Class[] thrC) {
+		for (int i = 0; i < thrC.length; i++) {
+			Constructor con = null;
+			for (int j = 0; j < params.length; j++) {
+				try {
+					con = thrC[i].getConstructor(params[j]);
+				} catch (NoSuchMethodException e) {
+					// This Error will be caught until the right param is found.
+				}
+
+				if (con != null) {
+					// If the param was found, initialize the Class
+					initClass(thrC[i], j);
+					break;
+				}
+				// If the param not found then add to missed Vector.
+				if (j == params.length - 1)
+					missedV.add(thrC[i]);
+			}
+		}
+	}
+
+	private void findClassFilesFromZip(Vector v) {
+		String slash = System.getProperty("file.separator");
+		String javaHome = System.getProperty("java.home");
+		if (!javaHome.endsWith(slash))
+			javaHome += slash;
+
+		String[] wanted = { "java" + slash + "io", "java" + slash + "lang",
+				"java" + slash + "math", "java" + slash + "net",
+				"java" + slash + "security", "java" + slash + "text",
+				"java" + slash + "util", "java" + slash + "beans",
+				"java" + slash + "rmi",
+				// One or more class files in awt make the VM hang after being
+				// loaded.
+				// "java" + slash + "awt",
+				"java" + slash + "sql",
+		// These are (possibly) all of the throwable classes in awt
+		/*
+		 * "java\\awt\\AWTError", "java\\awt\\AWTException",
+		 * "java\\awt\\color\\CMMException",
+		 * "java\\awt\\color\\ProfileDataException",
+		 * "java\\awt\\datatransfer\\MimeTypeParseException",
+		 * "java\\awt\\datatransfer\\UnsupportedFlavorException",
+		 * "java\\awt\\dnd\\InvalidDnDOperationException",
+		 * "java\\awt\\FontFormatException",
+		 * "java\\awt\\geom\\IllegalPathStateException",
+		 * "java\\awt\\geom\\NoninvertibleTransformException",
+		 * "java\\awt\\IllegalComponentStateException",
+		 * "java\\awt\\image\\ImagingOpException",
+		 * "java\\awt\\image\\RasterFormatException",
+		 * "java\\awt\\print\\PrinterAbortException",
+		 * "java\\awt\\print\\PrinterException",
+		 * "java\\awt\\print\\PrinterIOException"
+		 */
+		};
+
+		File[] files = makeClassPathArray();
+		FileInputStream fis = null;
+		ZipInputStream zis = null;
+		ZipEntry ze = null;
+		for (int i = 0; i < files.length; i++) {
+			String fileName = files[i].getPath();
+			if (files[i].exists() && files[i].isFile()
+					&& fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
+				try {
+					fis = new FileInputStream(files[i].getPath());
+				} catch (FileNotFoundException e) {
+					fail("FileNotFoundException trying to open "
+							+ files[i].getPath());
+				}
+				zis = new ZipInputStream(fis);
+				while (true) {
+					try {
+						ze = zis.getNextEntry();
+					} catch (IOException e) {
+						fail("IOException while getting next zip entry: "
+								+ e);
+					}
+					if (ze == null)
+						break;
+					String zeName = ze.getName();
+					if (zeName.endsWith(".class")) {
+						zeName = zeName.replace('/', slash.charAt(0));
+						for (int j = 0; j < wanted.length; j++) {
+							if (zeName.startsWith(wanted[j])) {
+								// When finding class files from directories the
+								// program saves them as files.
+								// To stay consistent we will turn the ZipEntry
+								// classes into instances of files.
+								File tempF = new File(javaHome + zeName);
+								// Making sure that the same class is not added
+								// twice.
+								boolean duplicate = false;
+								for (int k = 0; k < v.size(); k++) {
+									if (v.get(k).equals(tempF))
+										duplicate = true;
+								}
+								if (!duplicate)
+									v.add(tempF);
+								break;
+							}
+						}
+					}
+				}
+				;
+				try {
+					zis.close();
+					fis.close();
+				} catch (IOException e) {
+					fail(
+							"IOException while trying to close InputStreams: "
+									+ e);
+				}
+			}
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamCorruptedExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamCorruptedExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamCorruptedExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamCorruptedExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,78 @@
+/* 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.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.StreamCorruptedException;
+
+public class StreamCorruptedExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.StreamCorruptedException#StreamCorruptedException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.StreamCorruptedException()
+
+		try {
+			ObjectInputStream ois = new ObjectInputStream(
+					new ByteArrayInputStream(
+							"kLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLl"
+									.getBytes()));
+			ois.readObject();
+		} catch (StreamCorruptedException e) {
+			// Correct
+			return;
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+		fail("Failed to throw exception for non serialized stream");
+	}
+
+	/**
+	 * @tests java.io.StreamCorruptedException#StreamCorruptedException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.StreamCorruptedException(java.lang.String)
+		try {
+			ObjectInputStream ois = new ObjectInputStream(
+					new ByteArrayInputStream(
+							"kLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLl"
+									.getBytes()));
+			ois.readObject();
+		} catch (StreamCorruptedException e) {
+			// Correct
+			return;
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+		fail("Failed to throw exception for non serialized stream");
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,445 @@
+/* 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.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.StreamTokenizer;
+import java.io.StringBufferInputStream;
+
+import tests.support.Support_StringReader;
+
+public class StreamTokenizerTest extends junit.framework.TestCase {
+	Support_StringReader r;
+
+	StreamTokenizer st;
+
+	String testString;
+
+	/**
+	 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.InputStream)
+	 */
+	public void test_ConstructorLjava_io_InputStream() {
+		st = new StreamTokenizer(new StringBufferInputStream(
+				"/comments\n d 8 'h'"));
+		try {
+			assertTrue(
+					"nextTokent() should return the character d skiping the comments",
+					st.nextToken() == StreamTokenizer.TT_WORD
+							&& st.sval.equals("d"));
+			assertTrue("the next token returned should be the digit 8", st
+					.nextToken() == StreamTokenizer.TT_NUMBER
+					&& st.nval == 8.0);
+			assertTrue("the next token returned should be the quote character",
+					st.nextToken() == 39 && st.sval.equals("h"));
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#StreamTokenizer(java.io.Reader)
+	 */
+	public void test_ConstructorLjava_io_Reader() {
+		setTest("/testing\n d 8 'h' ");
+		try {
+			assertTrue(
+					"nextTokent() should return the character d skiping the comments",
+					st.nextToken() == StreamTokenizer.TT_WORD
+							&& st.sval.equals("d"));
+			assertTrue("the next token returned should be the digit 8", st
+					.nextToken() == StreamTokenizer.TT_NUMBER
+					&& st.nval == 8.0);
+			assertTrue("the next token returned should be the quote character",
+					st.nextToken() == 39 && st.sval.equals("h"));
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#commentChar(int)
+	 */
+	public void test_commentCharI() {
+		setTest("*comment \n / 8 'h' ");
+		st.ordinaryChar('/');
+		st.commentChar('*');
+		try {
+			assertTrue(
+					"nextTokent() did not return the character / skiping the comments starting with *",
+					st.nextToken() == 47);
+			assertTrue("the next token returned should be the digit 8", st
+					.nextToken() == StreamTokenizer.TT_NUMBER
+					&& st.nval == 8.0);
+			assertTrue("the next token returned should be the quote character",
+					st.nextToken() == 39 && st.sval.equals("h"));
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#eolIsSignificant(boolean)
+	 */
+	public void test_eolIsSignificantZ() {
+		setTest("d 8\n");
+		try {
+			// by default end of line characters are not significant
+			assertTrue("nextToken did not return d",
+					st.nextToken() == StreamTokenizer.TT_WORD
+							&& st.sval.equals("d"));
+			assertTrue("nextToken did not return 8",
+					st.nextToken() == StreamTokenizer.TT_NUMBER
+							&& st.nval == 8.0);
+			assertTrue("nextToken should be the end of file",
+					st.nextToken() == StreamTokenizer.TT_EOF);
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+		setTest("d\n");
+		st.eolIsSignificant(true);
+		try {
+			// end of line characters are significant
+			assertTrue("nextToken did not return d",
+					st.nextToken() == StreamTokenizer.TT_WORD
+							&& st.sval.equals("d"));
+			assertTrue("nextToken is the end of line",
+					st.nextToken() == StreamTokenizer.TT_EOL);
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#lineno()
+	 */
+	public void test_lineno() {
+		setTest("d\n 8\n");
+		try {
+			assertTrue("the lineno should be 1", st.lineno() == 1);
+			st.nextToken();
+			st.nextToken();
+			assertTrue("the lineno should be 2", st.lineno() == 2);
+			st.nextToken();
+			assertTrue("the next line no should be 3", st.lineno() == 3);
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#lowerCaseMode(boolean)
+	 */
+	public void test_lowerCaseModeZ() {
+		// SM.
+		setTest("HELLOWORLD");
+		st.lowerCaseMode(true);
+		try {
+			st.nextToken();
+			assertTrue("sval not converted to lowercase.", st.sval
+					.equals("helloworld"));
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#nextToken()
+	 */
+	public void test_nextToken() {
+		// SM.
+		setTest("\r\n/* fje fje 43.4 f \r\n f g */  456.459 \r\n"
+				+ "Hello  / 	\r\n \r\n \n \r \257 Hi \'Hello World\'");
+		st.ordinaryChar('/');
+		st.slashStarComments(true);
+		try {
+			st.nextToken();
+			assertTrue("Wrong Token type1: " + (char) st.ttype,
+					st.ttype == StreamTokenizer.TT_NUMBER);
+			st.nextToken();
+			assertTrue("Wrong Token type2: " + st.ttype,
+					st.ttype == StreamTokenizer.TT_WORD);
+			st.nextToken();
+			assertTrue("Wrong Token type3: " + st.ttype, st.ttype == '/');
+			st.nextToken();
+			assertTrue("Wrong Token type4: " + st.ttype,
+					st.ttype == StreamTokenizer.TT_WORD);
+			st.nextToken();
+			assertTrue("Wrong Token type5: " + st.ttype,
+					st.ttype == StreamTokenizer.TT_WORD);
+			st.nextToken();
+			assertTrue("Wrong Token type6: " + st.ttype, st.ttype == '\'');
+			assertTrue("Wrong Token type7: " + st.ttype, st.sval
+					.equals("Hello World"));
+			st.nextToken();
+			assertTrue("Wrong Token type8: " + st.ttype, st.ttype == -1);
+
+		} catch (IOException e) {
+			fail(
+					"IOException occured while trying to read an input stream - constructor");
+		}
+
+		try {
+			final PipedInputStream pin = new PipedInputStream();
+			PipedOutputStream pout = new PipedOutputStream(pin);
+			pout.write("hello\n\r\r".getBytes());
+			StreamTokenizer s = new StreamTokenizer(pin);
+			s.eolIsSignificant(true);
+			assertTrue("Wrong token 1,1",
+					s.nextToken() == StreamTokenizer.TT_WORD
+							&& s.sval.equals("hello"));
+			assertTrue("Wrong token 1,2", s.nextToken() == '\n');
+			assertTrue("Wrong token 1,3", s.nextToken() == '\n');
+			assertTrue("Wrong token 1,4", s.nextToken() == '\n');
+			pout.close();
+			assertTrue("Wrong token 1,5",
+					s.nextToken() == StreamTokenizer.TT_EOF);
+		} catch (IOException e) {
+			fail("IOException during test 1 : " + e.getMessage());
+		}
+
+		try {
+			StreamTokenizer tokenizer = new StreamTokenizer(
+					new Support_StringReader("\n \r\n#"));
+			tokenizer.ordinaryChar('\n'); // make \n ordinary
+			tokenizer.eolIsSignificant(true);
+			assertTrue("Wrong token 2,1", tokenizer.nextToken() == '\n');
+			assertTrue("Wrong token 2,2", tokenizer.nextToken() == '\n');
+			assertTrue("Wrong token 2,3", tokenizer.nextToken() == '#');
+		} catch (IOException e) {
+			fail("IOException during test 2 : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#ordinaryChar(int)
+	 */
+	public void test_ordinaryCharI() {
+		// SM.
+		setTest("Ffjein 893");
+		try {
+			st.ordinaryChar('F');
+			st.nextToken();
+			assertTrue("OrdinaryChar failed." + (char) st.ttype,
+					st.ttype == 'F');
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#ordinaryChars(int, int)
+	 */
+	public void test_ordinaryCharsII() {
+		// SM.
+		setTest("azbc iof z 893");
+		st.ordinaryChars('a', 'z');
+		try {
+			assertTrue("OrdinaryChars failed.", st.nextToken() == 'a');
+			assertTrue("OrdinaryChars failed.", st.nextToken() == 'z');
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#parseNumbers()
+	 */
+	public void test_parseNumbers() {
+		// SM
+		setTest("9.9 678");
+		try {
+			assertTrue("Base behavior failed.",
+					st.nextToken() == StreamTokenizer.TT_NUMBER);
+			st.ordinaryChars('0', '9');
+			assertTrue("setOrdinary failed.", st.nextToken() == '6');
+			st.parseNumbers();
+			assertTrue("parseNumbers failed.",
+					st.nextToken() == StreamTokenizer.TT_NUMBER);
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#pushBack()
+	 */
+	public void test_pushBack() {
+		// SM.
+		setTest("Hello 897");
+		try {
+			st.nextToken();
+			st.pushBack();
+			assertTrue("PushBack failed.",
+					st.nextToken() == StreamTokenizer.TT_WORD);
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#quoteChar(int)
+	 */
+	public void test_quoteCharI() {
+		// SM
+		setTest("<Hello World<    HelloWorldH");
+		st.quoteChar('<');
+		try {
+			assertTrue("QuoteChar failed.", st.nextToken() == '<');
+			assertTrue("QuoteChar failed.", st.sval.equals("Hello World"));
+			st.quoteChar('H');
+			st.nextToken();
+			assertTrue("QuoteChar failed for word.", st.sval
+					.equals("elloWorld"));
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#resetSyntax()
+	 */
+	public void test_resetSyntax() {
+		// SM
+		setTest("H 9\' ello World");
+		try {
+			st.resetSyntax();
+			assertTrue("resetSyntax failed1." + (char) st.ttype,
+					st.nextToken() == 'H');
+			assertTrue("resetSyntax failed1." + (char) st.ttype,
+					st.nextToken() == ' ');
+			assertTrue("resetSyntax failed2." + (char) st.ttype,
+					st.nextToken() == '9');
+			assertTrue("resetSyntax failed3." + (char) st.ttype,
+					st.nextToken() == '\'');
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#slashSlashComments(boolean)
+	 */
+	public void test_slashSlashCommentsZ() {
+		// SM.
+		setTest("// foo \r\n /fiji \r\n -456");
+		st.ordinaryChar('/');
+		st.slashSlashComments(true);
+		try {
+			assertTrue("Test failed.", st.nextToken() == '/');
+			assertTrue("Test failed.",
+					st.nextToken() == StreamTokenizer.TT_WORD);
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#slashStarComments(boolean)
+	 */
+	public void test_slashStarCommentsZ() {
+		setTest("/* foo \r\n /fiji \r\n*/ -456");
+		st.ordinaryChar('/');
+		st.slashStarComments(true);
+		try {
+			assertTrue("Test failed.",
+					st.nextToken() == StreamTokenizer.TT_NUMBER);
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#toString()
+	 */
+	public void test_toString() {
+		setTest("ABC Hello World");
+		try {
+			st.nextToken();
+		} catch (Exception e) {
+		}
+		assertTrue("toString failed." + st.toString(), st.toString().equals(
+				"Token[ABC], line 1"));
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#whitespaceChars(int, int)
+	 */
+	public void test_whitespaceCharsII() {
+		setTest("azbc iof z 893");
+		st.whitespaceChars('a', 'z');
+		try {
+			assertTrue("OrdinaryChar failed.",
+					st.nextToken() == StreamTokenizer.TT_NUMBER);
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StreamTokenizer#wordChars(int, int)
+	 */
+	public void test_wordCharsII() {
+		setTest("A893 -9B87");
+		st.wordChars('0', '9');
+		try {
+			assertTrue("WordChar failed1.",
+					st.nextToken() == StreamTokenizer.TT_WORD);
+			assertTrue("WordChar failed2.", st.sval.equals("A893"));
+			assertTrue("WordChar failed3.",
+					st.nextToken() == StreamTokenizer.TT_NUMBER);
+			st.nextToken();
+			assertTrue("WordChar failed4.", st.sval.equals("B87"));
+
+			setTest("    Hello World");
+			st.wordChars(' ', ' ');
+			st.nextToken();
+			assertTrue("WordChars failed for whitespace.", st.sval
+					.equals("Hello World"));
+
+			setTest("    Hello World\r\n  \'Hello World\' Hello\' World");
+			st.wordChars(' ', ' ');
+			st.wordChars('\'', '\'');
+			st.nextToken();
+			assertTrue("WordChars failed for whitespace: " + st.sval, st.sval
+					.equals("Hello World"));
+			st.nextToken();
+			assertTrue("WordChars failed for quote1: " + st.sval, st.sval
+					.equals("\'Hello World\' Hello\' World"));
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	private void setTest(String s) {
+		testString = s;
+		r = new Support_StringReader(testString);
+		st = new StreamTokenizer(r);
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,95 @@
+/* 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.StringBufferInputStream;
+
+public class StringBufferInputStreamTest extends junit.framework.TestCase {
+
+	StringBufferInputStream sbis;
+
+	/**
+	 * @tests java.io.StringBufferInputStream#StringBufferInputStream(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.StringBufferInputStream(java.lang.String)
+	}
+
+	/**
+	 * @tests java.io.StringBufferInputStream#available()
+	 */
+	public void test_available() {
+		// Test for method int java.io.StringBufferInputStream.available()
+		assertTrue("Returned incorrect number of available bytes", sbis
+				.available() == 11);
+	}
+
+	/**
+	 * @tests java.io.StringBufferInputStream#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.StringBufferInputStream.read()
+		byte[] buf = new byte[5];
+		sbis.skip(6);
+		sbis.read(buf, 0, 5);
+		assertTrue("Returned incorrect chars", new String(buf).equals("World"));
+	}
+
+	/**
+	 * @tests java.io.StringBufferInputStream#read(byte[], int, int)
+	 */
+	public void test_read$BII() {
+		// Test for method int java.io.StringBufferInputStream.read(byte [],
+		// int, int)
+		assertTrue("Read returned incorrect char", sbis.read() == 'H');
+	}
+
+	/**
+	 * @tests java.io.StringBufferInputStream#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.StringBufferInputStream.reset()
+		long s = sbis.skip(6);
+		assertTrue("Unable to skip correct umber of chars", s == 6);
+		sbis.reset();
+		assertTrue("Failed to reset", sbis.read() == 'H');
+	}
+
+	/**
+	 * @tests java.io.StringBufferInputStream#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.StringBufferInputStream.skip(long)
+		long s = sbis.skip(6);
+		assertTrue("Unable to skip correct umber of chars", s == 6);
+		assertTrue("Skip positioned at incorrect char", sbis.read() == 'W');
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		sbis = new StringBufferInputStream("Hello World");
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,190 @@
+/* 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.IOException;
+import java.io.StringReader;
+
+public class StringReaderTest extends junit.framework.TestCase {
+
+	String testString = "This is a test string";
+
+	StringReader sr;
+
+	/**
+	 * @tests java.io.StringReader#StringReader(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.StringReader(java.lang.String)
+		assertTrue("Used in tests", true);
+	}
+
+	/**
+	 * @tests java.io.StringReader#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.StringReader.close()
+		try {
+			sr = new StringReader(testString);
+			sr.close();
+			char[] buf = new char[10];
+			sr.read(buf, 0, 2);
+			fail("Close failed");
+		} catch (java.io.IOException e) {
+			return;
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#mark(int)
+	 */
+	public void test_markI() {
+		// Test for method void java.io.StringReader.mark(int)
+		try {
+			sr = new StringReader(testString);
+			sr.skip(5);
+			sr.mark(0);
+			sr.skip(5);
+			sr.reset();
+			char[] buf = new char[10];
+			sr.read(buf, 0, 2);
+			assertTrue("Failed to return to mark", new String(buf, 0, 2)
+					.equals(testString.substring(5, 7)));
+		} catch (Exception e) {
+			fail("Exception during mark test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#markSupported()
+	 */
+	public void test_markSupported() {
+		// Test for method boolean java.io.StringReader.markSupported()
+
+		sr = new StringReader(testString);
+		assertTrue("markSupported returned false", sr.markSupported());
+	}
+
+	/**
+	 * @tests java.io.StringReader#read()
+	 */
+	public void test_read() {
+		// Test for method int java.io.StringReader.read()
+		try {
+			sr = new StringReader(testString);
+			int r = sr.read();
+			assertTrue("Failed to read char", r == 'T');
+			sr = new StringReader(new String(new char[] { '\u8765' }));
+			assertTrue("Wrong double byte char", sr.read() == '\u8765');
+		} catch (Exception e) {
+			fail("Exception during read test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#read(char[], int, int)
+	 */
+	public void test_read$CII() {
+		// Test for method int java.io.StringReader.read(char [], int, int)
+		try {
+			sr = new StringReader(testString);
+			char[] buf = new char[testString.length()];
+			int r = sr.read(buf, 0, testString.length());
+			assertTrue("Failed to read chars", r == testString.length());
+			assertTrue("Read chars incorrectly", new String(buf, 0, r)
+					.equals(testString));
+		} catch (Exception e) {
+			fail("Exception during read test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#ready()
+	 */
+	public void test_ready() {
+		// Test for method boolean java.io.StringReader.ready()
+		try {
+			sr = new StringReader(testString);
+			assertTrue("Steam not ready", sr.ready());
+			sr.close();
+			int r = 0;
+			try {
+				sr.ready();
+			} catch (IOException e) {
+				r = 1;
+			}
+			assertTrue("Expected IOException not thrown in read()", r == 1);
+		} catch (IOException e) {
+			fail("IOException during ready test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#reset()
+	 */
+	public void test_reset() {
+		// Test for method void java.io.StringReader.reset()
+		try {
+			sr = new StringReader(testString);
+			sr.skip(5);
+			sr.mark(0);
+			sr.skip(5);
+			sr.reset();
+			char[] buf = new char[10];
+			sr.read(buf, 0, 2);
+			assertTrue("Failed to reset properly", new String(buf, 0, 2)
+					.equals(testString.substring(5, 7)));
+		} catch (Exception e) {
+			fail("Exception during reset test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringReader#skip(long)
+	 */
+	public void test_skipJ() {
+		// Test for method long java.io.StringReader.skip(long)
+		try {
+			sr = new StringReader(testString);
+			sr.skip(5);
+			char[] buf = new char[10];
+			sr.read(buf, 0, 2);
+			assertTrue("Failed to skip properly", new String(buf, 0, 2)
+					.equals(testString.substring(5, 7)));
+		} catch (Exception e) {
+			fail("Exception during skip test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * 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 {
+			sr.close();
+		} catch (Exception e) {
+		}
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,134 @@
+/* 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.IOException;
+import java.io.StringWriter;
+
+public class StringWriterTest extends junit.framework.TestCase {
+
+	StringWriter sw;
+
+	/**
+	 * @tests java.io.StringWriter#StringWriter()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.StringWriter()
+		assertTrue("Used in tests", true);
+	}
+
+	/**
+	 * @tests java.io.StringWriter#close()
+	 */
+	public void test_close() {
+		// Test for method void java.io.StringWriter.close()
+		try {
+			sw.close();
+		} catch (IOException e) {
+			fail("IOException closing StringWriter : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.StringWriter#flush()
+	 */
+	public void test_flush() {
+		// Test for method void java.io.StringWriter.flush()
+		sw.flush();
+		sw.write('c');
+		assertTrue("Failed to flush char", sw.toString().equals("c"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#getBuffer()
+	 */
+	public void test_getBuffer() {
+		// Test for method java.lang.StringBuffer
+		// java.io.StringWriter.getBuffer()
+
+		sw.write("This is a test string");
+		StringBuffer sb = sw.getBuffer();
+		assertTrue("Incorrect buffer returned", sb.toString().equals(
+				"This is a test string"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String java.io.StringWriter.toString()
+		sw.write("This is a test string");
+		assertTrue("Incorrect string returned", sw.toString().equals(
+				"This is a test string"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#write(char[], int, int)
+	 */
+	public void test_write$CII() {
+		// Test for method void java.io.StringWriter.write(char [], int, int)
+		char[] c = new char[1000];
+		"This is a test string".getChars(0, 21, c, 0);
+		sw.write(c, 0, 21);
+		assertTrue("Chars not written properly", sw.toString().equals(
+				"This is a test string"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#write(int)
+	 */
+	public void test_writeI() {
+		// Test for method void java.io.StringWriter.write(int)
+		sw.write('c');
+		assertTrue("Char not written properly", sw.toString().equals("c"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#write(java.lang.String)
+	 */
+	public void test_writeLjava_lang_String() {
+		// Test for method void java.io.StringWriter.write(java.lang.String)
+		sw.write("This is a test string");
+		assertTrue("String not written properly", sw.toString().equals(
+				"This is a test string"));
+	}
+
+	/**
+	 * @tests java.io.StringWriter#write(java.lang.String, int, int)
+	 */
+	public void test_writeLjava_lang_StringII() {
+		// Test for method void java.io.StringWriter.write(java.lang.String,
+		// int, int)
+		sw.write("This is a test string", 2, 2);
+		assertTrue("String not written properly", sw.toString().equals("is"));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+
+		sw = new StringWriter();
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SyncFailedExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SyncFailedExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SyncFailedExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/SyncFailedExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,59 @@
+/* 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.File;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
+import java.io.SyncFailedException;
+
+public class SyncFailedExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.SyncFailedException#SyncFailedException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.SyncFailedException(java.lang.String)
+		File f = null;
+		try {
+			f = new File(System.getProperty("user.dir"), "synfail.tst");
+			FileOutputStream fos = new FileOutputStream(f.getPath());
+			FileDescriptor fd = fos.getFD();
+			fos.close();
+			fd.sync();
+		} catch (SyncFailedException e) {
+			f.delete();
+			return;
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+		fail("Failed to generate expected Exception");
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UTFDataFormatExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UTFDataFormatExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UTFDataFormatExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UTFDataFormatExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,81 @@
+/* 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;
+import java.io.DataOutputStream;
+import java.io.UTFDataFormatException;
+
+public class UTFDataFormatExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.UTFDataFormatException#UTFDataFormatException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.UTFDataFormatException()
+		try {
+			int stringBufferSize = 70000;
+			int loopCount = 66;
+			StringBuffer sb = new StringBuffer(stringBufferSize);
+			for (int i = 0; i < (loopCount); i++)
+				sb
+						.append("qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqwertyuioplkjhgqwertyuiopasdfghjklzxcvbnmlkjhgfdsaqwertyuioplkjhg");
+			DataOutputStream dos = new DataOutputStream(
+					new ByteArrayOutputStream());
+			dos.writeUTF(sb.toString());
+		} catch (UTFDataFormatException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exeption during Constructor test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.io.UTFDataFormatException#UTFDataFormatException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.io.UTFDataFormatException(java.lang.String)
+		try {
+			int stringBufferSize = 70000;
+			int loopCount = 66;
+			StringBuffer sb = new StringBuffer(stringBufferSize);
+			for (int i = 0; i < (loopCount); i++)
+				sb
+						.append("qwertyuiopasdfghjklzxcvbnmlkjhgfdsaqwertyuioplkjhgqwertyuiopasdfghjklzxcvbnmlkjhgfdsaqwertyuioplkjhg");
+			DataOutputStream dos = new DataOutputStream(
+					new ByteArrayOutputStream());
+			dos.writeUTF(sb.toString());
+		} catch (UTFDataFormatException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exeption during Constructor test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UnsupportedEncodingExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UnsupportedEncodingExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UnsupportedEncodingExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/UnsupportedEncodingExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,70 @@
+/* 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;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+
+public class UnsupportedEncodingExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.UnsupportedEncodingException#UnsupportedEncodingException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.io.UnsupportedEncodingException()
+		try {
+			new OutputStreamWriter(new ByteArrayOutputStream(), "BogusEncoding");
+		} catch (UnsupportedEncodingException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during UnsupportedEncodingException test"
+					+ e.toString());
+		}
+		fail("Failed to generate expected exception");
+	}
+
+	/**
+	 * @tests java.io.UnsupportedEncodingException#UnsupportedEncodingException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method
+		// java.io.UnsupportedEncodingException(java.lang.String)
+		try {
+			new OutputStreamWriter(new ByteArrayOutputStream(), "BogusEncoding");
+		} catch (UnsupportedEncodingException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during UnsupportedEncodingException test"
+					+ e.toString());
+		}
+		fail("Failed to generate expected exception");
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/WriteAbortedExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/WriteAbortedExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/WriteAbortedExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/WriteAbortedExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,71 @@
+/* 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.WriteAbortedException;
+
+public class WriteAbortedExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.io.WriteAbortedException#WriteAbortedException(java.lang.String,
+	 *        java.lang.Exception)
+	 */
+	public void test_ConstructorLjava_lang_StringLjava_lang_Exception() {
+		// Test for method java.io.WriteAbortedException(java.lang.String,
+		// java.lang.Exception)
+		try {
+			if (true)
+				throw new WriteAbortedException("HelloWorld",
+						new WriteAbortedException("ByeWorld", null));
+		} catch (WriteAbortedException e) {
+			return;
+		}
+		fail("Failed to generate expected Exception");
+	}
+
+	/**
+	 * @tests java.io.WriteAbortedException#getMessage()
+	 */
+	public void test_getMessage() {
+		// Test for method java.lang.String
+		// java.io.WriteAbortedException.getMessage()
+		try {
+			if (true)
+				throw new WriteAbortedException("HelloWorld",
+						new WriteAbortedException("ByeWorld", null));
+		} catch (WriteAbortedException e) {
+			assertTrue("WriteAbortedException::getMessage() failed"
+					+ e.getMessage(), e.getMessage().equals(
+					"HelloWorld; java.io.WriteAbortedException: ByeWorld"));
+			return;
+		}
+		fail("Failed to generate expected Exception");
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile Wed Mar 15 03:46:17 2006
@@ -0,0 +1 @@
+This is a test message with Unicode character. \u4e2d\u56fd is China's name in Chinese

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile-utf8.txt
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile-utf8.txt?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile-utf8.txt (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile-utf8.txt Wed Mar 15 03:46:17 2006
@@ -0,0 +1 @@
+This is a test message with Unicode character. 中国 is China's name in Chinese
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile.txt
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile.txt?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile.txt (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/testfile.txt Wed Mar 15 03:46:17 2006
@@ -0,0 +1 @@
+This is a test message with Unicode character. Öйú is China's name in Chinese
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AllTests.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,107 @@
+/* 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 tests.api.java.lang;
+
+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("Tests for java.lang");
+		// $JUnit-BEGIN$
+		suite.addTestSuite(ArrayCopyTest.class);
+		suite.addTestSuite(HelloWorldTest.class);
+
+		suite.addTestSuite(ArithmeticExceptionTest.class);
+		suite.addTestSuite(ArrayIndexOutOfBoundsExceptionTest.class);
+		suite.addTestSuite(ArrayStoreExceptionTest.class);
+		suite.addTestSuite(AssertionErrorTest.class);
+		suite.addTestSuite(BooleanTest.class);
+		suite.addTestSuite(ByteTest.class);
+		suite.addTestSuite(CharacterTest.class);
+		suite.addTestSuite(ClassTest.class);
+		suite.addTestSuite(ClassCastExceptionTest.class);
+		suite.addTestSuite(ClassLoaderTest.class);
+		suite.addTestSuite(ClassNotFoundExceptionTest.class);
+		suite.addTestSuite(CloneNotSupportedExceptionTest.class);
+		suite.addTestSuite(CompilerTest.class);
+		suite.addTestSuite(DoubleTest.class);
+		suite.addTestSuite(ErrorTest.class);
+		suite.addTestSuite(ExceptionTest.class);
+		suite.addTestSuite(ExceptionInInitializerErrorTest.class);
+		suite.addTestSuite(FloatTest.class);
+		suite.addTestSuite(IllegalAccessErrorTest.class);
+		suite.addTestSuite(IllegalAccessExceptionTest.class);
+		suite.addTestSuite(IllegalArgumentExceptionTest.class);
+		suite.addTestSuite(IllegalMonitorStateExceptionTest.class);
+		suite.addTestSuite(IllegalStateExceptionTest.class);
+		suite.addTestSuite(IllegalThreadStateExceptionTest.class);
+		suite.addTestSuite(IncompatibleClassChangeErrorTest.class);
+		suite.addTestSuite(IndexOutOfBoundsExceptionTest.class);
+		suite.addTestSuite(InheritableThreadLocalTest.class);
+		suite.addTestSuite(InstantiationErrorTest.class);
+		suite.addTestSuite(InstantiationExceptionTest.class);
+		suite.addTestSuite(IntegerTest.class);
+		suite.addTestSuite(InternalErrorTest.class);
+		suite.addTestSuite(InterruptedExceptionTest.class);
+		suite.addTestSuite(LinkageErrorTest.class);
+		suite.addTestSuite(LongTest.class);
+		suite.addTestSuite(MathTest.class);
+		suite.addTestSuite(NegativeArraySizeExceptionTest.class);
+		suite.addTestSuite(NoClassDefFoundErrorTest.class);
+		suite.addTestSuite(NoSuchFieldErrorTest.class);
+		suite.addTestSuite(NoSuchFieldExceptionTest.class);
+		suite.addTestSuite(NoSuchMethodErrorTest.class);
+		suite.addTestSuite(NoSuchMethodExceptionTest.class);
+		suite.addTestSuite(NullPointerExceptionTest.class);
+		suite.addTestSuite(NumberTest.class);
+		suite.addTestSuite(NumberFormatExceptionTest.class);
+		suite.addTestSuite(ObjectTest.class);
+		suite.addTestSuite(OutOfMemoryErrorTest.class);
+		suite.addTestSuite(PackageTest.class);
+		suite.addTestSuite(ProcessTest.class);
+		suite.addTestSuite(RuntimeTest.class);
+		suite.addTestSuite(RuntimeExceptionTest.class);
+		suite.addTestSuite(RuntimePermissionTest.class);
+		suite.addTestSuite(SecurityExceptionTest.class);
+		suite.addTestSuite(SecurityManagerTest.class);
+		suite.addTestSuite(ShortTest.class);
+		suite.addTestSuite(StackOverflowErrorTest.class);
+		suite.addTestSuite(StrictMathTest.class);
+		suite.addTestSuite(StringTest.class);
+		suite.addTestSuite(StringBufferTest.class);
+		suite.addTestSuite(StringIndexOutOfBoundsExceptionTest.class);
+		suite.addTestSuite(SystemTest.class);
+		suite.addTestSuite(ThreadTest.class);
+		suite.addTestSuite(ThreadDeathTest.class);
+		suite.addTestSuite(ThreadGroupTest.class);
+		suite.addTestSuite(ThreadLocalTest.class);
+		suite.addTestSuite(ThrowableTest.class);
+		suite.addTestSuite(UnknownErrorTest.class);
+		suite.addTestSuite(UnsatisfiedLinkErrorTest.class);
+		suite.addTestSuite(UnsupportedOperationExceptionTest.class);
+		suite.addTestSuite(VerifyErrorTest.class);
+		suite.addTestSuite(VirtualMachineErrorTest.class);
+		// $JUnit-END$
+
+		return suite;
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArithmeticExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArithmeticExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArithmeticExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArithmeticExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,69 @@
+/* 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.lang;
+
+public class ArithmeticExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.lang.ArithmeticException#ArithmeticException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.lang.ArithmeticException()
+		try {
+			try {
+				int i = 100;
+				i /= 0;
+			} catch (ArithmeticException e) {
+				return;
+			}
+			fail("Failed to generate expected exception");
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * @tests java.lang.ArithmeticException#ArithmeticException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.lang.ArithmeticException(java.lang.String)
+		try {
+			try {
+				int i = 100;
+				i /= 0;
+			} catch (ArithmeticException e) {
+				return;
+			}
+			fail("Failed to generate expected exception");
+		} catch (Exception e) {
+			fail("Exception during test : " + e.getMessage());
+		}
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayCopyTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayCopyTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayCopyTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,31 @@
+/* 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.api.java.lang;
+
+import junit.framework.TestCase;
+
+/**
+ * Testing arraycopy behavior.
+ */
+public class ArrayCopyTest extends TestCase {
+
+	public void testArrayCopy() {
+		char[][] source = new char[][] { { 'H', 'e', 'l', 'l', 'o' },
+				{ 'W', 'o', 'r', 'l', 'd' } };
+		char[][] dest = new char[2][];
+		System.arraycopy(source, 0, dest, 0, 2);
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,84 @@
+/* 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.lang;
+
+public class ArrayIndexOutOfBoundsExceptionTest extends
+		junit.framework.TestCase {
+
+	/**
+	 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.lang.ArrayIndexOutOfBoundsException()
+		int r = 0;
+		try {
+			byte[] b = new byte[1];
+			byte z = b[2];
+			if (z > 0)
+				; // use z so we don't get an unused variable warning
+		} catch (ArrayIndexOutOfBoundsException e) {
+			r = 1;
+		}
+		assertTrue("failed to generate ArrayIndexOutOfBoundsException", r == 1);
+	}
+
+	/**
+	 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(int)
+	 */
+	public void test_ConstructorI() {
+		try {
+			if (true)
+				throw new ArrayIndexOutOfBoundsException(-1);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			assertTrue(
+					"toString of ArrayIndexOutOfBoundsException did not reveal offending position",
+					e.toString().indexOf("-1", 0) >= 0);
+		}
+	}
+
+	/**
+	 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method
+		// java.lang.ArrayIndexOutOfBoundsException(java.lang.String)
+		int r = 0;
+		try {
+			byte[] b = new byte[1];
+			byte z = b[2];
+			if (z > 0)
+				; // use z so we don't get an unused variable warning
+		} catch (ArrayIndexOutOfBoundsException e) {
+			r = 1;
+		}
+		assertTrue("failed to generate ArrayIndexOutOfBoundsException", r == 1);
+
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayStoreExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayStoreExceptionTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayStoreExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ArrayStoreExceptionTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,81 @@
+/* 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.lang;
+
+public class ArrayStoreExceptionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.lang.ArrayStoreException#ArrayStoreException()
+	 */
+	public void test_Constructor() {
+		// Test for method java.lang.ArrayStoreException()
+
+		class ASClass extends Object {
+			void store(Object array[], Object elm) {
+				array[0] = elm;
+			}
+		}
+
+		try {
+			Exception x[] = new Exception[9];
+			new ASClass().store(x, new Object());
+		} catch (ArrayStoreException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during ArrayStoreException test : "
+					+ e.getMessage());
+		}
+		fail("Failed to generate expected exception");
+	}
+
+	/**
+	 * @tests java.lang.ArrayStoreException#ArrayStoreException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.lang.ArrayStoreException(java.lang.String)
+
+		class ASClass extends Object {
+			void store(Object array[], Object elm) {
+				array[0] = elm;
+			}
+		}
+
+		try {
+			Exception x[] = new Exception[9];
+			new ASClass().store(x, new Object());
+		} catch (ArrayStoreException e) {
+			return;
+		} catch (Exception e) {
+			fail("Exception during ArrayStoreException test : "
+					+ e.getMessage());
+		}
+		fail("Failed to generate expected exception");
+	}
+
+	/**
+	 * 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() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,31 @@
+/* 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.lang;
+
+public class AssertionErrorTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.lang.AssertionError#AssertionError(java.lang.Object)
+	 */
+	public void test_ObjectConstructor() {
+		AssertionError error = new AssertionError(new String("hi"));
+		assertTrue("non-null cause", error.getCause() == null);
+		assertTrue(error.getMessage().equals("hi"));
+		Exception exc = new NullPointerException();
+		error = new AssertionError(exc);
+		assertTrue("non-null cause", error.getCause() == exc);
+		assertTrue(error.getMessage().equals(exc.toString()));
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,149 @@
+/* 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.lang;
+
+import java.util.Properties;
+
+public class BooleanTest extends junit.framework.TestCase {
+
+	Boolean t = new Boolean(true);
+
+	Boolean t2 = new Boolean(true);
+
+	Boolean f = new Boolean(false);
+
+	/**
+	 * @tests java.lang.Boolean#Boolean(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method java.lang.Boolean(java.lang.String)
+		Boolean truth = new Boolean("true");
+		Boolean falsehood = new Boolean("false");
+		Boolean bogus = new Boolean("bogus");
+		Boolean nulled = new Boolean((String) null);
+
+		assertTrue("Wrong value in Boolean", truth.booleanValue() == true);
+		assertTrue("Wrong value in Boolean", falsehood.booleanValue() == false);
+		assertTrue("Bogus boolean has wrong value", bogus.equals(f));
+		assertTrue("Null boolean has wrong value", nulled.equals(f));
+	}
+
+	/**
+	 * @tests java.lang.Boolean#Boolean(boolean)
+	 */
+	public void test_ConstructorZ() {
+		// Test for method java.lang.Boolean(boolean)
+		Boolean truth = new Boolean(true);
+		Boolean falsehood = new Boolean(false);
+
+		assertTrue("Wrong value in Boolean", truth.booleanValue() == true);
+		assertTrue("Wrong value in Boolean", falsehood.booleanValue() == false);
+		assertTrue("Constructed Boolean which doesn't equal.", truth.equals(t));
+		assertTrue("Constructed Boolean which doesn't equal.", falsehood
+				.equals(f));
+	}
+
+	/**
+	 * @tests java.lang.Boolean#booleanValue()
+	 */
+	public void test_booleanValue() {
+		// Test for method boolean java.lang.Boolean.booleanValue()
+		assertTrue("Wrong value in Boolean", t.booleanValue() == true);
+		assertTrue("Wrong value in Boolean", f.booleanValue() == false);
+	}
+
+	/**
+	 * @tests java.lang.Boolean#equals(java.lang.Object)
+	 */
+	public void test_equalsLjava_lang_Object() {
+		// Test for method boolean java.lang.Boolean.equals(java.lang.Object)
+		assertTrue("Booleans not equal to itself", t.equals(t));
+		assertTrue("Boolean not equal to boolean of same sense", t.equals(t2));
+		assertTrue("Boolean equals boolean of opposite sense", !t.equals(f));
+		assertTrue("Boolean equals random other object", !t
+				.equals(new Object()));
+		assertTrue("Boolean equals null", !t.equals((Object) null));
+	}
+
+	/**
+	 * @tests java.lang.Boolean#getBoolean(java.lang.String)
+	 */
+	public void test_getBooleanLjava_lang_String() {
+		// Test for method boolean
+		// java.lang.Boolean.getBoolean(java.lang.String)
+		Properties p = System.getProperties();
+		p.put("Blah", "true");
+		p.put("Blah2", "TRuE");
+		p.put("Blah3", "yes");
+		p.put("Blah4", "TRUE ");
+		assertTrue("a) Should have returned true", Boolean.getBoolean("Blah"));
+		assertTrue("b) Should have returned true", Boolean.getBoolean("Blah2"));
+		assertTrue("c) Should have returned false", !Boolean
+				.getBoolean("Blah3"));
+		assertTrue("d) Should have returned false", !Boolean
+				.getBoolean("Blah4"));
+	}
+
+	/**
+	 * @tests java.lang.Boolean#hashCode()
+	 */
+	public void test_hashCode() {
+		// Test for method int java.lang.Boolean.hashCode()
+
+		// Known values. See comments in java.lang.Boolean.hashCode().
+		assertTrue("Incorrect hash for true Boolean.", t.hashCode() == 1231);
+		assertTrue("Incorrect hash for false Boolean.", f.hashCode() == 1237);
+	}
+
+	/**
+	 * @tests java.lang.Boolean#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String java.lang.Boolean.toString()
+		assertTrue("Boolean true value printed wrong.", t.toString().equals(
+				"true"));
+		assertTrue("Boolean false value printed wrong.", f.toString().equals(
+				"false"));
+	}
+
+	/**
+	 * @tests java.lang.Boolean#valueOf(java.lang.String)
+	 */
+	public void test_valueOfLjava_lang_String() {
+		// Test for method java.lang.Boolean
+		// java.lang.Boolean.valueOf(java.lang.String)
+		assertTrue("Failed to parse true to true", Boolean.valueOf("true")
+				.booleanValue());
+		assertTrue("Failed to parse miked case true to true", Boolean.valueOf(
+				"TrUe").booleanValue());
+		assertTrue("parsed non-true to true", !Boolean.valueOf("ddddd")
+				.booleanValue());
+	}
+
+	/**
+	 * 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() {
+	}
+}



Mime
View raw message