harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r633384 [12/15] - in /harmony/enhanced/classlib/branches/java6: depends/build/platform/ depends/files/ depends/files/bcprov/ doc/ doc/classlib/ make/ make/linux.ia64/ make/linux.ppc32/ make/linux.ppc64/ make/linux.x86.libstdc++6/ make/linux...
Date Tue, 04 Mar 2008 08:02:45 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -17,45 +17,52 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-public class UnknownHostExceptionTest extends junit.framework.TestCase {
+import java.net.UnknownHostException;
 
-	/**
-	 * @tests java.net.UnknownHostException#UnknownHostException()
-	 */
-	public void test_Constructor() {
-		// Test for method java.net.UnknownHostException()
-                try {
-                        java.net.InetAddress.getByName("a.b.c.x.y.z.com");
-                } catch (java.net.UnknownHostException e) {
-                        return;
-                }
-                fail("Failed to generate Exception");
-	}
-
-	/**
-	 * @tests java.net.UnknownHostException#UnknownHostException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.net.UnknownHostException(java.lang.String)
-                try {
-                        java.net.InetAddress.getByName("a.b.c.x.y.z.com");
-                } catch (java.net.UnknownHostException e) {
-                        return;
-                }
-                fail("Failed to generate 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() {
-	}
+import junit.framework.TestCase;
+
+public class UnknownHostExceptionTest extends TestCase {
+
+    /**
+     * @tests java.net.UnknownHostException#UnknownHostException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new UnknownHostException();
+            }
+            fail("Failed to generate Exception");
+        } catch (UnknownHostException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.net.UnknownHostException#UnknownHostException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        try {
+            if (true) {
+                throw new UnknownHostException("test");
+            }
+            fail("Failed to generate Exception");
+        } catch (UnknownHostException e) {
+            assertEquals("Threw exception with incorrect message", "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() {
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java Tue Mar  4 00:02:13 2008
@@ -17,53 +17,51 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-import java.net.URL;
 import java.net.UnknownServiceException;
 
-public class UnknownServiceExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
 
-	/**
-	 * @tests java.net.UnknownServiceException#UnknownServiceException()
-	 */
-	public void test_Constructor() throws Exception {
-		// Test for method java.net.UnknownServiceException()
-		try {
-			new URL("file://moo.txt").openConnection().getOutputStream();
-		} catch (UnknownServiceException e) {
-			// correct
-			return;
-		} 
-
-		fail("Exception not thrown");
-	}
-
-	/**
-	 * @tests java.net.UnknownServiceException#UnknownServiceException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.net.UnknownServiceException(java.lang.String)
-		try {
-			if (true)
-				throw new UnknownServiceException("HelloWorld");
-		} catch (UnknownServiceException e) {
-			assertTrue("Wrong exception message: " + e.toString(), e
-					.getMessage().equals("HelloWorld"));
-			return;
-		}
-		fail("Constructor 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() {
-	}
+public class UnknownServiceExceptionTest extends TestCase {
+
+    /**
+     * @tests java.net.UnknownServiceException#UnknownServiceException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new UnknownServiceException();
+            }
+            fail("Exception not thrown");
+        } catch (UnknownServiceException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.net.UnknownServiceException#UnknownServiceException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        try {
+            if (true) {
+                throw new UnknownServiceException("test");
+            }
+            fail("Constructor failed");
+        } catch (UnknownServiceException e) {
+            assertEquals("Wrong exception message", "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() {
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/HashMapTest.java Tue Mar  4 00:02:13 2008
@@ -1,674 +1,678 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.apache.harmony.luni.tests.java.util;
-
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-import tests.support.Support_MapTest2;
-import tests.support.Support_UnmodifiableCollectionTest;
-
-public class HashMapTest extends junit.framework.TestCase {
-    class MockMap extends AbstractMap {
-        public Set entrySet() {
-            return null;
-        }
-        public int size(){
-            return 0;
-        }
-    }
-    
-    private static class MockMapNull extends AbstractMap {
-        public Set entrySet() {
-            return null;
-        }
-
-        public int size() {
-            return 10;
-        }
-    }
-    
-	HashMap hm;
-
-	final static int hmSize = 1000;
-
-	static Object[] objArray;
-
-	static Object[] objArray2;
-	{
-		objArray = new Object[hmSize];
-		objArray2 = new Object[hmSize];
-		for (int i = 0; i < objArray.length; i++) {
-			objArray[i] = new Integer(i);
-			objArray2[i] = objArray[i].toString();
-		}
-	}
-
-	/**
-	 * @tests java.util.HashMap#HashMap()
-	 */
-	public void test_Constructor() {
-		// Test for method java.util.HashMap()
-		new Support_MapTest2(new HashMap()).runTest();
-
-		HashMap hm2 = new HashMap();
-		assertEquals("Created incorrect HashMap", 0, hm2.size());
-	}
-
-	/**
-	 * @tests java.util.HashMap#HashMap(int)
-	 */
-	public void test_ConstructorI() {
-		// Test for method java.util.HashMap(int)
-		HashMap hm2 = new HashMap(5);
-		assertEquals("Created incorrect HashMap", 0, hm2.size());
-		try {
-			new HashMap(-1);
-		} catch (IllegalArgumentException e) {
-			return;
-		}
-		fail(
-				"Failed to throw IllegalArgumentException for initial capacity < 0");
-
-		HashMap empty = new HashMap(0);
-		assertNull("Empty hashmap access", empty.get("nothing"));
-		empty.put("something", "here");
-		assertTrue("cannot get element", empty.get("something") == "here");
-	}
-
-	/**
-	 * @tests java.util.HashMap#HashMap(int, float)
-	 */
-	public void test_ConstructorIF() {
-		// Test for method java.util.HashMap(int, float)
-		HashMap hm2 = new HashMap(5, (float) 0.5);
-		assertEquals("Created incorrect HashMap", 0, hm2.size());
-		try {
-			new HashMap(0, 0);
-		} catch (IllegalArgumentException e) {
-			return;
-		}
-		fail(
-				"Failed to throw IllegalArgumentException for initial load factor <= 0");
-
-		HashMap empty = new HashMap(0, 0.75f);
-		assertNull("Empty hashtable access", empty.get("nothing"));
-		empty.put("something", "here");
-		assertTrue("cannot get element", empty.get("something") == "here");
-	}
-
-	/**
-	 * @tests java.util.HashMap#HashMap(java.util.Map)
-	 */
-	public void test_ConstructorLjava_util_Map() {
-		// Test for method java.util.HashMap(java.util.Map)
-		Map myMap = new TreeMap();
-		for (int counter = 0; counter < hmSize; counter++)
-			myMap.put(objArray2[counter], objArray[counter]);
-		HashMap hm2 = new HashMap(myMap);
-		for (int counter = 0; counter < hmSize; counter++)
-			assertTrue("Failed to construct correct HashMap", hm
-					.get(objArray2[counter]) == hm2.get(objArray2[counter]));
-        
-        try {
-            Map mockMap = new MockMap();
-            hm = new HashMap(mockMap);
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            //empty
-        }
-        
-        HashMap map = new HashMap();
-        map.put("a", "a");
-        SubMap map2 = new SubMap(map); 
-        assertTrue(map2.containsKey("a"));
-        assertTrue(map2.containsValue("a"));
-	}
-
-	/**
-	 * @tests java.util.HashMap#clear()
-	 */
-	public void test_clear() {
-		hm.clear();
-		assertEquals("Clear failed to reset size", 0, hm.size());
-		for (int i = 0; i < hmSize; i++)
-			assertNull("Failed to clear all elements",
-					hm.get(objArray2[i]));
-        
-		// Check clear on a large loaded map of Integer keys
-		HashMap<Integer, String> map = new HashMap<Integer, String>();
-        for (int i = -32767; i < 32768; i++) {
-            map.put(i, "foobar");
-        }
-        map.clear();
-        assertEquals("Failed to reset size on large integer map", 0, hm.size());
-        for (int i = -32767; i < 32768; i++) {
-            assertNull("Failed to clear integer map values", map.get(i));
-        }
-	}
-
-	/**
-	 * @tests java.util.HashMap#clone()
-	 */
-	public void test_clone() {
-		// Test for method java.lang.Object java.util.HashMap.clone()
-		HashMap hm2 = (HashMap) hm.clone();
-		assertTrue("Clone answered equivalent HashMap", hm2 != hm);
-		for (int counter = 0; counter < hmSize; counter++)
-			assertTrue("Clone answered unequal HashMap", hm
-					.get(objArray2[counter]) == hm2.get(objArray2[counter]));
-
-		HashMap map = new HashMap();
-		map.put("key", "value");
-		// get the keySet() and values() on the original Map
-		Set keys = map.keySet();
-		Collection values = map.values();
-		assertEquals("values() does not work", 
-				"value", values.iterator().next());
-		assertEquals("keySet() does not work", 
-				"key", keys.iterator().next());
-		AbstractMap map2 = (AbstractMap) map.clone();
-		map2.put("key", "value2");
-		Collection values2 = map2.values();
-		assertTrue("values() is identical", values2 != values);
-		// values() and keySet() on the cloned() map should be different
-		assertEquals("values() was not cloned", 
-				"value2", values2.iterator().next());
-		map2.clear();
-		map2.put("key2", "value3");
-		Set key2 = map2.keySet();
-		assertTrue("keySet() is identical", key2 != keys);
-		assertEquals("keySet() was not cloned", 
-				"key2", key2.iterator().next());
-        
-        // regresion test for HARMONY-4603
-        HashMap hashmap = new HashMap();
-        MockClonable mock = new MockClonable(1);
-        hashmap.put(1, mock);
-        assertEquals(1, ((MockClonable) hashmap.get(1)).i);
-        HashMap hm3 = (HashMap)hashmap.clone();
-        assertEquals(1, ((MockClonable) hm3.get(1)).i);
-        mock.i = 0;
-        assertEquals(0, ((MockClonable) hashmap.get(1)).i);
-        assertEquals(0, ((MockClonable) hm3.get(1)).i);
-	}
-
-	/**
-	 * @tests java.util.HashMap#containsKey(java.lang.Object)
-	 */
-	public void test_containsKeyLjava_lang_Object() {
-		// Test for method boolean
-		// java.util.HashMap.containsKey(java.lang.Object)
-		assertTrue("Returned false for valid key", hm.containsKey(new Integer(
-				876).toString()));
-		assertTrue("Returned true for invalid key", !hm.containsKey("KKDKDKD"));
-
-		HashMap m = new HashMap();
-		m.put(null, "test");
-		assertTrue("Failed with null key", m.containsKey(null));
-		assertTrue("Failed with missing key matching null hash", !m
-				.containsKey(new Integer(0)));
-	}
-
-	/**
-	 * @tests java.util.HashMap#containsValue(java.lang.Object)
-	 */
-	public void test_containsValueLjava_lang_Object() {
-		// Test for method boolean
-		// java.util.HashMap.containsValue(java.lang.Object)
-		assertTrue("Returned false for valid value", hm
-				.containsValue(new Integer(875)));
-		assertTrue("Returned true for invalid valie", !hm
-				.containsValue(new Integer(-9)));
-	}
-
-	/**
-	 * @tests java.util.HashMap#entrySet()
-	 */
-	public void test_entrySet() {
-		// Test for method java.util.Set java.util.HashMap.entrySet()
-		Set s = hm.entrySet();
-		Iterator i = s.iterator();
-		assertTrue("Returned set of incorrect size", hm.size() == s.size());
-		while (i.hasNext()) {
-			Map.Entry m = (Map.Entry) i.next();
-			assertTrue("Returned incorrect entry set", hm.containsKey(m
-					.getKey())
-					&& hm.containsValue(m.getValue()));
-		}
-	}
-
-	/**
-	 * @tests java.util.HashMap#get(java.lang.Object)
-	 */
-	public void test_getLjava_lang_Object() {
-		// Test for method java.lang.Object
-		// java.util.HashMap.get(java.lang.Object)
-		assertNull("Get returned non-null for non existent key",
-				hm.get("T"));
-		hm.put("T", "HELLO");
-		assertEquals("Get returned incorrect value for existing key", "HELLO", hm.get("T")
-				);
-
-		HashMap m = new HashMap();
-		m.put(null, "test");
-		assertEquals("Failed with null key", "test", m.get(null));
-		assertNull("Failed with missing key matching null hash", m
-				.get(new Integer(0)));
-		
-		// Regression for HARMONY-206
-		ReusableKey k = new ReusableKey();
-		HashMap map = new HashMap();
-		k.setKey(1);
-		map.put(k, "value1");
-
-		k.setKey(18);
-		assertNull(map.get(k));
-
-		k.setKey(17);
-		assertNull(map.get(k));
-	}
-
-	/**
-	 * @tests java.util.HashMap#isEmpty()
-	 */
-	public void test_isEmpty() {
-		// Test for method boolean java.util.HashMap.isEmpty()
-		assertTrue("Returned false for new map", new HashMap().isEmpty());
-		assertTrue("Returned true for non-empty", !hm.isEmpty());
-	}
-
-	/**
-	 * @tests java.util.HashMap#keySet()
-	 */
-	public void test_keySet() {
-		// Test for method java.util.Set java.util.HashMap.keySet()
-		Set s = hm.keySet();
-		assertTrue("Returned set of incorrect size()", s.size() == hm.size());
-		for (int i = 0; i < objArray.length; i++)
-			assertTrue("Returned set does not contain all keys", s
-					.contains(objArray[i].toString()));
-
-		HashMap m = new HashMap();
-		m.put(null, "test");
-		assertTrue("Failed with null key", m.keySet().contains(null));
-		assertNull("Failed with null key", m.keySet().iterator().next());
-
-		Map map = new HashMap(101);
-		map.put(new Integer(1), "1");
-		map.put(new Integer(102), "102");
-		map.put(new Integer(203), "203");
-		Iterator it = map.keySet().iterator();
-		Integer remove1 = (Integer) it.next();
-		it.hasNext();
-		it.remove();
-		Integer remove2 = (Integer) it.next();
-		it.remove();
-		ArrayList list = new ArrayList(Arrays.asList(new Integer[] {
-				new Integer(1), new Integer(102), new Integer(203) }));
-		list.remove(remove1);
-		list.remove(remove2);
-		assertTrue("Wrong result", it.next().equals(list.get(0)));
-		assertEquals("Wrong size", 1, map.size());
-		assertTrue("Wrong contents", map.keySet().iterator().next().equals(
-				list.get(0)));
-
-		Map map2 = new HashMap(101);
-		map2.put(new Integer(1), "1");
-		map2.put(new Integer(4), "4");
-		Iterator it2 = map2.keySet().iterator();
-		Integer remove3 = (Integer) it2.next();
-		Integer next;
-		if (remove3.intValue() == 1)
-			next = new Integer(4);
-		else
-			next = new Integer(1);
-		it2.hasNext();
-		it2.remove();
-		assertTrue("Wrong result 2", it2.next().equals(next));
-		assertEquals("Wrong size 2", 1, map2.size());
-		assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
-				next));
-	}
-
-	/**
-	 * @tests java.util.HashMap#put(java.lang.Object, java.lang.Object)
-	 */
-	public void test_putLjava_lang_ObjectLjava_lang_Object() {
-        hm.put("KEY", "VALUE");
-        assertEquals("Failed to install key/value pair", "VALUE", hm.get("KEY"));
-
-        HashMap<Object,Object> m = new HashMap<Object,Object>();
-        m.put(new Short((short) 0), "short");
-        m.put(null, "test");
-        m.put(new Integer(0), "int");
-        assertEquals("Failed adding to bucket containing null", "short", m
-                .get(new Short((short) 0)));
-        assertEquals("Failed adding to bucket containing null2", "int", m
-                .get(new Integer(0)));
-        
-        // Check my actual key instance is returned
-        HashMap<Integer, String> map = new HashMap<Integer, String>();
-        for (int i = -32767; i < 32768; i++) {
-            map.put(i, "foobar");
-        }
-        Integer myKey = new Integer(0);
-        // Put a new value at the old key position
-        map.put(myKey, "myValue");
-        assertTrue(map.containsKey(myKey));
-        assertEquals("myValue", map.get(myKey));
-        boolean found = false;
-        for (Iterator<Integer> itr = map.keySet().iterator(); itr.hasNext();) {
-            Integer key = itr.next();
-            if (found = key == myKey) {
-                break;
-            }
-        }
-        assertFalse("Should not find new key instance in hashmap", found);
-
-        // Add a new key instance and check it is returned
-        assertNotNull(map.remove(myKey));
-        map.put(myKey, "myValue");
-        assertTrue(map.containsKey(myKey));
-        assertEquals("myValue", map.get(myKey));
-        for (Iterator<Integer> itr = map.keySet().iterator(); itr.hasNext();) {
-            Integer key = itr.next();
-            if (found = key == myKey) {
-                break;
-            }
-        }
-        assertTrue("Did not find new key instance in hashmap", found);
-
-        // Ensure keys with identical hashcode are stored separately
-        HashMap<Object,Object> objmap = new HashMap<Object, Object>();
-        for (int i = 0; i < 32768; i++) {
-            objmap.put(i, "foobar");
-        }
-        // Put non-equal object with same hashcode
-        MyKey aKey = new MyKey();
-        assertNull(objmap.put(aKey, "value"));
-        assertNull(objmap.remove(new MyKey()));
-        assertEquals("foobar", objmap.get(0));
-        assertEquals("value", objmap.get(aKey));
-    }
-	
-    static class MyKey {
-        public MyKey() {
-            super();
-        }
-        
-        public int hashCode() {
-            return 0;
-        }
-    }
-	/**
-	 * @tests java.util.HashMap#putAll(java.util.Map)
-	 */
-	public void test_putAllLjava_util_Map() {
-		// Test for method void java.util.HashMap.putAll(java.util.Map)
-		HashMap hm2 = new HashMap();
-		hm2.putAll(hm);
-		for (int i = 0; i < 1000; i++)
-			assertTrue("Failed to clear all elements", hm2.get(
-					new Integer(i).toString()).equals((new Integer(i))));
-        
-        Map mockMap = new MockMap();
-        hm2 = new HashMap();
-        hm2.putAll(mockMap);
-        assertEquals("Size should be 0", 0, hm2.size());
-	}
-    
-    /**
-     * @tests java.util.HashMap#putAll(java.util.Map)
-     */
-    public void test_putAllLjava_util_Map_Null() {
-        HashMap hashMap = new HashMap();
-        try {
-            hashMap.putAll(new MockMapNull());
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected.
-        }
-
-        try {
-            hashMap = new HashMap(new MockMapNull());
-            fail("Should throw NullPointerException");
-        } catch (NullPointerException e) {
-            // expected.
-        }
-    } 
-
-	/**
-	 * @tests java.util.HashMap#remove(java.lang.Object)
-	 */
-	public void test_removeLjava_lang_Object() {
-		int size = hm.size();
-		Integer y = new Integer(9);
-		Integer x = ((Integer) hm.remove(y.toString()));
-		assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
-		assertNull("Failed to remove given key", hm.get(new Integer(9)));
-		assertTrue("Failed to decrement size", hm.size() == (size - 1));
-		assertNull("Remove of non-existent key returned non-null", hm
-				.remove("LCLCLC"));
-
-		HashMap m = new HashMap();
-		m.put(null, "test");
-		assertNull("Failed with same hash as null",
-				m.remove(new Integer(0)));
-		assertEquals("Failed with null key", "test", m.remove(null));
-		
-		HashMap<Integer, Object> map = new HashMap<Integer, Object>();
-        for (int i = 0; i < 32768; i++) {
-            map.put(i, "const");
-        }
-        Object[] values = new Object[32768];
-        for (int i = 0; i < 32768; i++) {
-            values[i] = new Object();
-            map.put(i, values[i]);
-        }
-        for (int i = 32767; i >= 0; i--) {
-            assertEquals("Failed to remove same value", values[i], map.remove(i));
-        }
-
-        // Ensure keys with identical hashcode are removed properly
-        map = new HashMap<Integer, Object>();
-        for (int i = -32767; i < 32768; i++) {
-            map.put(i, "foobar");
-        }
-        // Remove non equal object with same hashcode
-        assertNull(map.remove(new MyKey()));
-        assertEquals("foobar", map.get(0));
-        map.remove(0);
-        assertNull(map.get(0));
-	}
-
-	/**
-	 * @tests java.util.HashMap#size()
-	 */
-	public void test_size() {
-		// Test for method int java.util.HashMap.size()
-		assertTrue("Returned incorrect size",
-				hm.size() == (objArray.length + 2));
-	}
-
-	/**
-	 * @tests java.util.HashMap#values()
-	 */
-	public void test_values() {
-		// Test for method java.util.Collection java.util.HashMap.values()
-		Collection c = hm.values();
-		assertTrue("Returned collection of incorrect size()", c.size() == hm
-				.size());
-		for (int i = 0; i < objArray.length; i++)
-			assertTrue("Returned collection does not contain all keys", c
-					.contains(objArray[i]));
-
-		HashMap myHashMap = new HashMap();
-		for (int i = 0; i < 100; i++)
-			myHashMap.put(objArray2[i], objArray[i]);
-		Collection values = myHashMap.values();
-		new Support_UnmodifiableCollectionTest(
-				"Test Returned Collection From HashMap.values()", values)
-				.runTest();
-		values.remove(new Integer(0));
-		assertTrue(
-				"Removing from the values collection should remove from the original map",
-				!myHashMap.containsValue(new Integer(0)));
-
-	}
-
-	static class ReusableKey {
-		private int key = 0;
-
-		public void setKey(int key) {
-			this.key = key;
-		}
-
-		public int hashCode() {
-			return key;
-		}
-
-		public boolean equals(Object o) {
-			if (o == this) {
-				return true;
-			}
-			if (!(o instanceof ReusableKey)) {
-				return false;
-			}
-			return key == ((ReusableKey) o).key;
-		}
-	}
-    
-	public void test_Map_Entry_hashCode() {
-        //Related to HARMONY-403
-	    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(10);
-	    Integer key = new Integer(1);
-	    Integer val = new Integer(2);
-	    map.put(key, val);
-	    int expected = key.hashCode() ^ val.hashCode();
-	    assertEquals(expected, map.hashCode());
-	    key = new Integer(4);
-	    val = new Integer(8);
-	    map.put(key, val);
-	    expected += key.hashCode() ^ val.hashCode();
-	    assertEquals(expected, map.hashCode());
-	} 
-    
-    class MockClonable implements Cloneable{
-        public int i;
-        
-        public MockClonable(int i) {
-            this.i = i;
-        }
-        
-        @Override
-        protected Object clone() throws CloneNotSupportedException {
-            return new MockClonable(i);
-        }
-    }
-    
-    /*
-     * Regression test for HY-4750
-     */
-    public void test_EntrySet() {
-        HashMap map = new HashMap();
-        map.put(new Integer(1), "ONE");
-
-        Set entrySet = map.entrySet();
-        Iterator e = entrySet.iterator();
-        Object real = e.next();
-        Map.Entry copyEntry = new MockEntry();
-        assertEquals(real, copyEntry);
-        assertTrue(entrySet.contains(copyEntry));
-        
-        entrySet.remove(copyEntry);
-        assertFalse(entrySet.contains(copyEntry));
-    }
-
-    private static class MockEntry implements Map.Entry {
-
-        public Object getKey() {
-            return new Integer(1);
-        }
-
-        public Object getValue() {
-            return "ONE";
-        }
-
-        public Object setValue(Object object) {
-            return null;
-        }
-    }
-	
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-		hm = new HashMap();
-		for (int i = 0; i < objArray.length; i++)
-			hm.put(objArray2[i], objArray[i]);
-		hm.put("test", null);
-		hm.put(null, "test");
-	}
-
-
-    class SubMap<K, V> extends HashMap<K, V> {
-        public SubMap(Map<? extends K, ? extends V> m) {
-            super(m);
-        }
-
-        public V put(K key, V value) {
-            throw new UnsupportedOperationException();
-        }
-    }
-
-    /**
-     * @tests serialization/deserialization.
-     */
-    public void testSerializationSelf() throws Exception {
-        HashMap<String, String> hm = new HashMap<String, String>();
-        hm.put("key", "value");
-
-        SerializationTest.verifySelf(hm);        
-
-        //  regression for HARMONY-1583
-        hm.put(null, "null");
-        SerializationTest.verifySelf(hm);
-    }
-
-    /**
-     * @tests serialization/deserialization compatibility with RI.
-     */
-    public void testSerializationCompatibility() throws Exception {
-        HashMap<String, String> hm = new HashMap<String, String>();
-        hm.put("key", "value");
-
-        SerializationTest.verifyGolden(this, hm);
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.luni.tests.java.util;
+
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
+import tests.support.Support_MapTest2;
+import tests.support.Support_UnmodifiableCollectionTest;
+
+public class HashMapTest extends junit.framework.TestCase {
+    class MockMap extends AbstractMap {
+        public Set entrySet() {
+            return null;
+        }
+        public int size(){
+            return 0;
+        }
+    }
+    
+    private static class MockMapNull extends AbstractMap {
+        public Set entrySet() {
+            return null;
+        }
+
+        public int size() {
+            return 10;
+        }
+    }
+    
+	HashMap hm;
+
+	final static int hmSize = 1000;
+
+	static Object[] objArray;
+
+	static Object[] objArray2;
+	{
+		objArray = new Object[hmSize];
+		objArray2 = new Object[hmSize];
+		for (int i = 0; i < objArray.length; i++) {
+			objArray[i] = new Integer(i);
+			objArray2[i] = objArray[i].toString();
+		}
+	}
+
+	/**
+	 * @tests java.util.HashMap#HashMap()
+	 */
+	public void test_Constructor() {
+		// Test for method java.util.HashMap()
+		new Support_MapTest2(new HashMap()).runTest();
+
+		HashMap hm2 = new HashMap();
+		assertEquals("Created incorrect HashMap", 0, hm2.size());
+	}
+
+	/**
+	 * @tests java.util.HashMap#HashMap(int)
+	 */
+	public void test_ConstructorI() {
+		// Test for method java.util.HashMap(int)
+		HashMap hm2 = new HashMap(5);
+		assertEquals("Created incorrect HashMap", 0, hm2.size());
+		try {
+			new HashMap(-1);
+		} catch (IllegalArgumentException e) {
+			return;
+		}
+		fail(
+				"Failed to throw IllegalArgumentException for initial capacity < 0");
+
+		HashMap empty = new HashMap(0);
+		assertNull("Empty hashmap access", empty.get("nothing"));
+		empty.put("something", "here");
+		assertTrue("cannot get element", empty.get("something") == "here");
+	}
+
+	/**
+	 * @tests java.util.HashMap#HashMap(int, float)
+	 */
+	public void test_ConstructorIF() {
+		// Test for method java.util.HashMap(int, float)
+		HashMap hm2 = new HashMap(5, (float) 0.5);
+		assertEquals("Created incorrect HashMap", 0, hm2.size());
+		try {
+			new HashMap(0, 0);
+		} catch (IllegalArgumentException e) {
+			return;
+		}
+		fail(
+				"Failed to throw IllegalArgumentException for initial load factor <= 0");
+
+		HashMap empty = new HashMap(0, 0.75f);
+		assertNull("Empty hashtable access", empty.get("nothing"));
+		empty.put("something", "here");
+		assertTrue("cannot get element", empty.get("something") == "here");
+	}
+
+	/**
+	 * @tests java.util.HashMap#HashMap(java.util.Map)
+	 */
+	public void test_ConstructorLjava_util_Map() {
+		// Test for method java.util.HashMap(java.util.Map)
+		Map myMap = new TreeMap();
+		for (int counter = 0; counter < hmSize; counter++)
+			myMap.put(objArray2[counter], objArray[counter]);
+		HashMap hm2 = new HashMap(myMap);
+		for (int counter = 0; counter < hmSize; counter++)
+			assertTrue("Failed to construct correct HashMap", hm
+					.get(objArray2[counter]) == hm2.get(objArray2[counter]));
+        
+        try {
+            Map mockMap = new MockMap();
+            hm = new HashMap(mockMap);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            //empty
+        }
+        
+        HashMap map = new HashMap();
+        map.put("a", "a");
+        SubMap map2 = new SubMap(map); 
+        assertTrue(map2.containsKey("a"));
+        assertTrue(map2.containsValue("a"));
+	}
+
+	/**
+	 * @tests java.util.HashMap#clear()
+	 */
+	public void test_clear() {
+		hm.clear();
+		assertEquals("Clear failed to reset size", 0, hm.size());
+		for (int i = 0; i < hmSize; i++)
+			assertNull("Failed to clear all elements",
+					hm.get(objArray2[i]));
+        
+		// Check clear on a large loaded map of Integer keys
+		HashMap<Integer, String> map = new HashMap<Integer, String>();
+        for (int i = -32767; i < 32768; i++) {
+            map.put(i, "foobar");
+        }
+        map.clear();
+        assertEquals("Failed to reset size on large integer map", 0, hm.size());
+        for (int i = -32767; i < 32768; i++) {
+            assertNull("Failed to clear integer map values", map.get(i));
+        }
+	}
+
+	/**
+	 * @tests java.util.HashMap#clone()
+	 */
+	public void test_clone() {
+		// Test for method java.lang.Object java.util.HashMap.clone()
+		HashMap hm2 = (HashMap) hm.clone();
+		assertTrue("Clone answered equivalent HashMap", hm2 != hm);
+		for (int counter = 0; counter < hmSize; counter++)
+			assertTrue("Clone answered unequal HashMap", hm
+					.get(objArray2[counter]) == hm2.get(objArray2[counter]));
+
+		HashMap map = new HashMap();
+		map.put("key", "value");
+		// get the keySet() and values() on the original Map
+		Set keys = map.keySet();
+		Collection values = map.values();
+		assertEquals("values() does not work", 
+				"value", values.iterator().next());
+		assertEquals("keySet() does not work", 
+				"key", keys.iterator().next());
+		AbstractMap map2 = (AbstractMap) map.clone();
+		map2.put("key", "value2");
+		Collection values2 = map2.values();
+		assertTrue("values() is identical", values2 != values);
+		// values() and keySet() on the cloned() map should be different
+		assertEquals("values() was not cloned", 
+				"value2", values2.iterator().next());
+		map2.clear();
+		map2.put("key2", "value3");
+		Set key2 = map2.keySet();
+		assertTrue("keySet() is identical", key2 != keys);
+		assertEquals("keySet() was not cloned", 
+				"key2", key2.iterator().next());
+        
+        // regresion test for HARMONY-4603
+        HashMap hashmap = new HashMap();
+        MockClonable mock = new MockClonable(1);
+        hashmap.put(1, mock);
+        assertEquals(1, ((MockClonable) hashmap.get(1)).i);
+        HashMap hm3 = (HashMap)hashmap.clone();
+        assertEquals(1, ((MockClonable) hm3.get(1)).i);
+        mock.i = 0;
+        assertEquals(0, ((MockClonable) hashmap.get(1)).i);
+        assertEquals(0, ((MockClonable) hm3.get(1)).i);
+	}
+
+	/**
+	 * @tests java.util.HashMap#containsKey(java.lang.Object)
+	 */
+	public void test_containsKeyLjava_lang_Object() {
+		// Test for method boolean
+		// java.util.HashMap.containsKey(java.lang.Object)
+		assertTrue("Returned false for valid key", hm.containsKey(new Integer(
+				876).toString()));
+		assertTrue("Returned true for invalid key", !hm.containsKey("KKDKDKD"));
+
+		HashMap m = new HashMap();
+		m.put(null, "test");
+		assertTrue("Failed with null key", m.containsKey(null));
+		assertTrue("Failed with missing key matching null hash", !m
+				.containsKey(new Integer(0)));
+	}
+
+	/**
+	 * @tests java.util.HashMap#containsValue(java.lang.Object)
+	 */
+	public void test_containsValueLjava_lang_Object() {
+		// Test for method boolean
+		// java.util.HashMap.containsValue(java.lang.Object)
+		assertTrue("Returned false for valid value", hm
+				.containsValue(new Integer(875)));
+		assertTrue("Returned true for invalid valie", !hm
+				.containsValue(new Integer(-9)));
+	}
+
+	/**
+	 * @tests java.util.HashMap#entrySet()
+	 */
+	public void test_entrySet() {
+		// Test for method java.util.Set java.util.HashMap.entrySet()
+		Set s = hm.entrySet();
+		Iterator i = s.iterator();
+		assertTrue("Returned set of incorrect size", hm.size() == s.size());
+		while (i.hasNext()) {
+			Map.Entry m = (Map.Entry) i.next();
+			assertTrue("Returned incorrect entry set", hm.containsKey(m
+					.getKey())
+					&& hm.containsValue(m.getValue()));
+		}
+        
+        Iterator iter = s.iterator(); 
+        s.remove(iter.next());
+        assertEquals(1001, s.size());
+	}
+
+	/**
+	 * @tests java.util.HashMap#get(java.lang.Object)
+	 */
+	public void test_getLjava_lang_Object() {
+		// Test for method java.lang.Object
+		// java.util.HashMap.get(java.lang.Object)
+		assertNull("Get returned non-null for non existent key",
+				hm.get("T"));
+		hm.put("T", "HELLO");
+		assertEquals("Get returned incorrect value for existing key", "HELLO", hm.get("T")
+				);
+
+		HashMap m = new HashMap();
+		m.put(null, "test");
+		assertEquals("Failed with null key", "test", m.get(null));
+		assertNull("Failed with missing key matching null hash", m
+				.get(new Integer(0)));
+		
+		// Regression for HARMONY-206
+		ReusableKey k = new ReusableKey();
+		HashMap map = new HashMap();
+		k.setKey(1);
+		map.put(k, "value1");
+
+		k.setKey(18);
+		assertNull(map.get(k));
+
+		k.setKey(17);
+		assertNull(map.get(k));
+	}
+
+	/**
+	 * @tests java.util.HashMap#isEmpty()
+	 */
+	public void test_isEmpty() {
+		// Test for method boolean java.util.HashMap.isEmpty()
+		assertTrue("Returned false for new map", new HashMap().isEmpty());
+		assertTrue("Returned true for non-empty", !hm.isEmpty());
+	}
+
+	/**
+	 * @tests java.util.HashMap#keySet()
+	 */
+	public void test_keySet() {
+		// Test for method java.util.Set java.util.HashMap.keySet()
+		Set s = hm.keySet();
+		assertTrue("Returned set of incorrect size()", s.size() == hm.size());
+		for (int i = 0; i < objArray.length; i++)
+			assertTrue("Returned set does not contain all keys", s
+					.contains(objArray[i].toString()));
+
+		HashMap m = new HashMap();
+		m.put(null, "test");
+		assertTrue("Failed with null key", m.keySet().contains(null));
+		assertNull("Failed with null key", m.keySet().iterator().next());
+
+		Map map = new HashMap(101);
+		map.put(new Integer(1), "1");
+		map.put(new Integer(102), "102");
+		map.put(new Integer(203), "203");
+		Iterator it = map.keySet().iterator();
+		Integer remove1 = (Integer) it.next();
+		it.hasNext();
+		it.remove();
+		Integer remove2 = (Integer) it.next();
+		it.remove();
+		ArrayList list = new ArrayList(Arrays.asList(new Integer[] {
+				new Integer(1), new Integer(102), new Integer(203) }));
+		list.remove(remove1);
+		list.remove(remove2);
+		assertTrue("Wrong result", it.next().equals(list.get(0)));
+		assertEquals("Wrong size", 1, map.size());
+		assertTrue("Wrong contents", map.keySet().iterator().next().equals(
+				list.get(0)));
+
+		Map map2 = new HashMap(101);
+		map2.put(new Integer(1), "1");
+		map2.put(new Integer(4), "4");
+		Iterator it2 = map2.keySet().iterator();
+		Integer remove3 = (Integer) it2.next();
+		Integer next;
+		if (remove3.intValue() == 1)
+			next = new Integer(4);
+		else
+			next = new Integer(1);
+		it2.hasNext();
+		it2.remove();
+		assertTrue("Wrong result 2", it2.next().equals(next));
+		assertEquals("Wrong size 2", 1, map2.size());
+		assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals(
+				next));
+	}
+
+	/**
+	 * @tests java.util.HashMap#put(java.lang.Object, java.lang.Object)
+	 */
+	public void test_putLjava_lang_ObjectLjava_lang_Object() {
+        hm.put("KEY", "VALUE");
+        assertEquals("Failed to install key/value pair", "VALUE", hm.get("KEY"));
+
+        HashMap<Object,Object> m = new HashMap<Object,Object>();
+        m.put(new Short((short) 0), "short");
+        m.put(null, "test");
+        m.put(new Integer(0), "int");
+        assertEquals("Failed adding to bucket containing null", "short", m
+                .get(new Short((short) 0)));
+        assertEquals("Failed adding to bucket containing null2", "int", m
+                .get(new Integer(0)));
+        
+        // Check my actual key instance is returned
+        HashMap<Integer, String> map = new HashMap<Integer, String>();
+        for (int i = -32767; i < 32768; i++) {
+            map.put(i, "foobar");
+        }
+        Integer myKey = new Integer(0);
+        // Put a new value at the old key position
+        map.put(myKey, "myValue");
+        assertTrue(map.containsKey(myKey));
+        assertEquals("myValue", map.get(myKey));
+        boolean found = false;
+        for (Iterator<Integer> itr = map.keySet().iterator(); itr.hasNext();) {
+            Integer key = itr.next();
+            if (found = key == myKey) {
+                break;
+            }
+        }
+        assertFalse("Should not find new key instance in hashmap", found);
+
+        // Add a new key instance and check it is returned
+        assertNotNull(map.remove(myKey));
+        map.put(myKey, "myValue");
+        assertTrue(map.containsKey(myKey));
+        assertEquals("myValue", map.get(myKey));
+        for (Iterator<Integer> itr = map.keySet().iterator(); itr.hasNext();) {
+            Integer key = itr.next();
+            if (found = key == myKey) {
+                break;
+            }
+        }
+        assertTrue("Did not find new key instance in hashmap", found);
+
+        // Ensure keys with identical hashcode are stored separately
+        HashMap<Object,Object> objmap = new HashMap<Object, Object>();
+        for (int i = 0; i < 32768; i++) {
+            objmap.put(i, "foobar");
+        }
+        // Put non-equal object with same hashcode
+        MyKey aKey = new MyKey();
+        assertNull(objmap.put(aKey, "value"));
+        assertNull(objmap.remove(new MyKey()));
+        assertEquals("foobar", objmap.get(0));
+        assertEquals("value", objmap.get(aKey));
+    }
+	
+    static class MyKey {
+        public MyKey() {
+            super();
+        }
+        
+        public int hashCode() {
+            return 0;
+        }
+    }
+	/**
+	 * @tests java.util.HashMap#putAll(java.util.Map)
+	 */
+	public void test_putAllLjava_util_Map() {
+		// Test for method void java.util.HashMap.putAll(java.util.Map)
+		HashMap hm2 = new HashMap();
+		hm2.putAll(hm);
+		for (int i = 0; i < 1000; i++)
+			assertTrue("Failed to clear all elements", hm2.get(
+					new Integer(i).toString()).equals((new Integer(i))));
+        
+        Map mockMap = new MockMap();
+        hm2 = new HashMap();
+        hm2.putAll(mockMap);
+        assertEquals("Size should be 0", 0, hm2.size());
+	}
+    
+    /**
+     * @tests java.util.HashMap#putAll(java.util.Map)
+     */
+    public void test_putAllLjava_util_Map_Null() {
+        HashMap hashMap = new HashMap();
+        try {
+            hashMap.putAll(new MockMapNull());
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected.
+        }
+
+        try {
+            hashMap = new HashMap(new MockMapNull());
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected.
+        }
+    } 
+
+	/**
+	 * @tests java.util.HashMap#remove(java.lang.Object)
+	 */
+	public void test_removeLjava_lang_Object() {
+		int size = hm.size();
+		Integer y = new Integer(9);
+		Integer x = ((Integer) hm.remove(y.toString()));
+		assertTrue("Remove returned incorrect value", x.equals(new Integer(9)));
+		assertNull("Failed to remove given key", hm.get(new Integer(9)));
+		assertTrue("Failed to decrement size", hm.size() == (size - 1));
+		assertNull("Remove of non-existent key returned non-null", hm
+				.remove("LCLCLC"));
+
+		HashMap m = new HashMap();
+		m.put(null, "test");
+		assertNull("Failed with same hash as null",
+				m.remove(new Integer(0)));
+		assertEquals("Failed with null key", "test", m.remove(null));
+		
+		HashMap<Integer, Object> map = new HashMap<Integer, Object>();
+        for (int i = 0; i < 32768; i++) {
+            map.put(i, "const");
+        }
+        Object[] values = new Object[32768];
+        for (int i = 0; i < 32768; i++) {
+            values[i] = new Object();
+            map.put(i, values[i]);
+        }
+        for (int i = 32767; i >= 0; i--) {
+            assertEquals("Failed to remove same value", values[i], map.remove(i));
+        }
+
+        // Ensure keys with identical hashcode are removed properly
+        map = new HashMap<Integer, Object>();
+        for (int i = -32767; i < 32768; i++) {
+            map.put(i, "foobar");
+        }
+        // Remove non equal object with same hashcode
+        assertNull(map.remove(new MyKey()));
+        assertEquals("foobar", map.get(0));
+        map.remove(0);
+        assertNull(map.get(0));
+	}
+
+	/**
+	 * @tests java.util.HashMap#size()
+	 */
+	public void test_size() {
+		// Test for method int java.util.HashMap.size()
+		assertTrue("Returned incorrect size",
+				hm.size() == (objArray.length + 2));
+	}
+
+	/**
+	 * @tests java.util.HashMap#values()
+	 */
+	public void test_values() {
+		// Test for method java.util.Collection java.util.HashMap.values()
+		Collection c = hm.values();
+		assertTrue("Returned collection of incorrect size()", c.size() == hm
+				.size());
+		for (int i = 0; i < objArray.length; i++)
+			assertTrue("Returned collection does not contain all keys", c
+					.contains(objArray[i]));
+
+		HashMap myHashMap = new HashMap();
+		for (int i = 0; i < 100; i++)
+			myHashMap.put(objArray2[i], objArray[i]);
+		Collection values = myHashMap.values();
+		new Support_UnmodifiableCollectionTest(
+				"Test Returned Collection From HashMap.values()", values)
+				.runTest();
+		values.remove(new Integer(0));
+		assertTrue(
+				"Removing from the values collection should remove from the original map",
+				!myHashMap.containsValue(new Integer(0)));
+
+	}
+
+	static class ReusableKey {
+		private int key = 0;
+
+		public void setKey(int key) {
+			this.key = key;
+		}
+
+		public int hashCode() {
+			return key;
+		}
+
+		public boolean equals(Object o) {
+			if (o == this) {
+				return true;
+			}
+			if (!(o instanceof ReusableKey)) {
+				return false;
+			}
+			return key == ((ReusableKey) o).key;
+		}
+	}
+    
+	public void test_Map_Entry_hashCode() {
+        //Related to HARMONY-403
+	    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(10);
+	    Integer key = new Integer(1);
+	    Integer val = new Integer(2);
+	    map.put(key, val);
+	    int expected = key.hashCode() ^ val.hashCode();
+	    assertEquals(expected, map.hashCode());
+	    key = new Integer(4);
+	    val = new Integer(8);
+	    map.put(key, val);
+	    expected += key.hashCode() ^ val.hashCode();
+	    assertEquals(expected, map.hashCode());
+	} 
+    
+    class MockClonable implements Cloneable{
+        public int i;
+        
+        public MockClonable(int i) {
+            this.i = i;
+        }
+        
+        @Override
+        protected Object clone() throws CloneNotSupportedException {
+            return new MockClonable(i);
+        }
+    }
+    
+    /*
+     * Regression test for HY-4750
+     */
+    public void test_EntrySet() {
+        HashMap map = new HashMap();
+        map.put(new Integer(1), "ONE");
+
+        Set entrySet = map.entrySet();
+        Iterator e = entrySet.iterator();
+        Object real = e.next();
+        Map.Entry copyEntry = new MockEntry();
+        assertEquals(real, copyEntry);
+        assertTrue(entrySet.contains(copyEntry));
+        
+        entrySet.remove(copyEntry);
+        assertFalse(entrySet.contains(copyEntry));
+    }
+
+    private static class MockEntry implements Map.Entry {
+
+        public Object getKey() {
+            return new Integer(1);
+        }
+
+        public Object getValue() {
+            return "ONE";
+        }
+
+        public Object setValue(Object object) {
+            return null;
+        }
+    }
+	
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		hm = new HashMap();
+		for (int i = 0; i < objArray.length; i++)
+			hm.put(objArray2[i], objArray[i]);
+		hm.put("test", null);
+		hm.put(null, "test");
+	}
+
+
+    class SubMap<K, V> extends HashMap<K, V> {
+        public SubMap(Map<? extends K, ? extends V> m) {
+            super(m);
+        }
+
+        public V put(K key, V value) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    /**
+     * @tests serialization/deserialization.
+     */
+    public void testSerializationSelf() throws Exception {
+        HashMap<String, String> hm = new HashMap<String, String>();
+        hm.put("key", "value");
+
+        SerializationTest.verifySelf(hm);        
+
+        //  regression for HARMONY-1583
+        hm.put(null, "null");
+        SerializationTest.verifySelf(hm);
+    }
+
+    /**
+     * @tests serialization/deserialization compatibility with RI.
+     */
+    public void testSerializationCompatibility() throws Exception {
+        HashMap<String, String> hm = new HashMap<String, String>();
+        hm.put("key", "value");
+
+        SerializationTest.verifyGolden(this, hm);
+    }
+
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java Tue Mar  4 00:02:13 2008
@@ -358,9 +358,9 @@
 		
 		// Non-bug difference for HARMONY-5442
 		l = new Locale("", "CA", "var");
-		assertEquals("Wrong representation 2.5", "_CA_VAR", l.toString());
+		assertEquals("Wrong representation 2.5", "_CA_var", l.toString());
 		l = new Locale("en", "", "WIN");
-		assertEquals("Wrong representation 4", "en_WIN", l.toString());
+		assertEquals("Wrong representation 4", "en__WIN", l.toString());
 		l = new Locale("en", "CA");
 		assertEquals("Wrong representation 6", "en_CA", l.toString());
 		l = new Locale("en", "CA", "VAR");

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertiesTest.java Tue Mar  4 00:02:13 2008
@@ -334,6 +334,44 @@
         }
         assertEquals("Failed to load when last line contains a comment", "1",
                 prop.get("fred"));
+
+        // Regression tests for HARMONY-5414
+        prop = new Properties();
+        prop.load(new ByteArrayInputStream("a=\\u1234z".getBytes()));
+
+        prop = new Properties();
+        try {
+            prop.load(new ByteArrayInputStream("a=\\u123".getBytes()));
+            fail("Expected IllegalArgumentException due to invalid Unicode sequence");
+        } catch (IllegalArgumentException e) {
+            // Expected
+        }
+
+        prop = new Properties();
+        try {
+            prop.load(new ByteArrayInputStream("a=\\u123z".getBytes()));
+            fail("Expected IllegalArgumentException due to invalid unicode sequence");
+        } catch (IllegalArgumentException expected) {
+            // Expected
+        }
+
+        prop = new Properties();
+        Properties expected = new Properties();
+        expected.put("a", "\u0000");
+        prop.load(new ByteArrayInputStream("a=\\".getBytes()));
+        assertEquals("Failed to read trailing slash value", expected, prop);
+
+        prop = new Properties();
+        expected = new Properties();
+        expected.put("a", "\u1234\u0000");
+        prop.load(new ByteArrayInputStream("a=\\u1234\\".getBytes()));
+        assertEquals("Failed to read trailing slash value #2", expected, prop);
+
+        prop = new Properties();
+        expected = new Properties();
+        expected.put("a", "q");
+        prop.load(new ByteArrayInputStream("a=\\q".getBytes()));
+        assertEquals("Failed to read slash value #3", expected, prop);
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java Tue Mar  4 00:02:13 2008
@@ -5585,6 +5585,23 @@
         s = new Scanner("test\n ");
         result = s.nextLine();
         assertEquals("test", result);
+
+        // Regression test for Harmony-4774
+        class CountReadable implements Readable {
+            int counter = 0;
+            public int read(CharBuffer charBuffer) throws IOException {
+                counter++;
+                charBuffer.append("hello\n");
+                return 6;
+            }
+        }
+        CountReadable cr = new CountReadable();
+        s = new Scanner(cr);
+        result = s.nextLine();
+        // We expect read() to be called only once, otherwise we see the problem
+        // when reading from System.in described in Harmony-4774
+        assertEquals(1, cr.counter);
+        assertEquals("hello", result);        
     }
     
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/SimpleTimeZoneTest.java Tue Mar  4 00:02:13 2008
@@ -198,6 +198,13 @@
         assertEquals("Incorrect offset returned", -(5 * 60 * 60 * 1000), st1
                 .getOffset(GregorianCalendar.AD, 1998, Calendar.JUNE, 11,
                         Calendar.THURSDAY, 0));
+        
+        // Regression for HARMONY-5459
+        st1 = (TimeZone)TimeZone.getDefault(); 
+        int fourHours = 4*60*60*1000; 
+        st1.setRawOffset(fourHours); 
+        assertEquals(fourHours, st1.getOffset(1, 2099, 01, 1, 5, 0));
+
 	}
 
 	/**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java Tue Mar  4 00:02:13 2008
@@ -18,7 +18,9 @@
 package org.apache.harmony.luni.tests.java.util;
 
 import java.util.Calendar;
+import java.util.Formatter;
 import java.util.GregorianCalendar;
+import java.util.Locale;
 import java.util.SimpleTimeZone;
 import java.util.TimeZone;
 
@@ -161,7 +163,31 @@
 		assertEquals("default not restored",
                              oldDefault, TimeZone.getDefault());
 	}
-
+    
+    /**
+     * @tests java.util.TimeZone#getDisplayName(java.util.Locale)
+     */
+    public void test_getDisplayNameLjava_util_Locale() {
+        TimeZone timezone = TimeZone.getTimeZone("Asia/Shanghai");
+        assertEquals("\u4e2d\u56fd\u6807\u51c6\u65f6\u95f4", timezone
+                .getDisplayName(Locale.CHINA));
+    }
+    
+    /**
+     * @tests java.util.TimeZone#getDisplayName(boolean, int, java.util.Locale)
+     */
+    public void test_getDisplayNameZILjava_util_Locale() {
+        TimeZone timezone = TimeZone.getTimeZone("Asia/Shanghai");
+        assertEquals("GMT+0800", timezone.getDisplayName(false, TimeZone.SHORT,
+                Locale.CHINA));
+        try {
+            timezone.getDisplayName(false, 100, Locale.CHINA);
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+    
 	protected void setUp() {
 	}
 

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/build.xml?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/build.xml Tue Mar  4 00:02:13 2008
@@ -40,17 +40,17 @@
             <present targetdir="${hy.nio.src.main.java}">
                 <mapper type="regexp"
                         from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
+                        to="\1.java" />
             </present>
             <present targetdir="${hy.nio.src.main.java.platform}" />
             <present targetdir="${hy.nio.src.main.java.platform}">
                 <mapper type="regexp"
                         from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
-                        to="\1.java"/>
+                        to="\1.java" />
             </present>
         </or>
     </fileset>
-    
+
     <target name="build" depends="compile-java, copy-resources, build-jar" />
 
     <target name="test" depends="-test-module">
@@ -65,7 +65,8 @@
     </target>
 
     <!-- internal target for local and global test run sequence -->
-    <target name="-test-module" depends="build, compile-tests, prepare-exclude, run-tests" />
+    <target name="-test-module"
+            depends="build, compile-tests, prepare-exclude, run-tests" />
 
     <!-- Build natives.-->
     <target name="build-native">
@@ -74,9 +75,9 @@
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
             <fileset dir="${hy.nio.src.main.native}/nio">
-                <include name="*${shlib.suffix}*"/>
+                <include name="*${shlib.suffix}*" />
                 <include name="*${progdb.suffix}*" if="is.windows" />
-                <exclude name="*${manifest.suffix}"/>
+                <exclude name="*${manifest.suffix}" />
             </fileset>
         </copy>
         <!-- Copy link exports file on z/OS -->
@@ -93,33 +94,32 @@
         <delete includeemptydirs="true" failonerror="false">
             <fileset refid="classes" />
         </delete>
-        <delete failonerror="false" dir="bin"/>
+        <delete failonerror="false" dir="bin" />
     </target>
 
     <!-- Clean natives. -->
     <target name="clean-native">
         <make dir="${hy.nio.src.main.native}/nio/${hy.os.family}"
-                      target="clean" />
+              target="clean" />
     </target>
 
-
     <target name="compile-java">
         <echo message="Compiling NIO classes" />
 
         <mkdir dir="${hy.build}" />
 
         <javac sourcepath=""
-            destdir="${hy.build}"
-            compiler="${hy.javac.compiler}"
-            memoryMaximumSize="${hy.javac.maxmem}"
-            source="${hy.javac.source}" 
-            target="${hy.javac.target}"
-            debug="${hy.javac.debug}">
+               destdir="${hy.build}"
+               compiler="${hy.javac.compiler}"
+               memoryMaximumSize="${hy.javac.maxmem}"
+               source="${hy.javac.source}"
+               target="${hy.javac.target}"
+               debug="${hy.javac.debug}">
 
             <compilerarg line="${build.compilerarg}" />
 
             <src>
-                <pathelement location="${hy.nio.src.main.java}"/>
+                <pathelement location="${hy.nio.src.main.java}" />
                 <pathelement location="${hy.nio.src.main.java.platform}" />
             </src>
 
@@ -142,22 +142,22 @@
 
     <target name="build-jar" depends="svn-info">
         <jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
-            manifest="${hy.nio}/META-INF/MANIFEST.MF">
+             manifest="${hy.nio}/META-INF/MANIFEST.MF">
             <fileset refid="classes" />
             <manifest>
-                <attribute name="Implementation-Version" value="${svn.info}"/> 
+                <attribute name="Implementation-Version" value="${svn.info}" />
             </manifest>
 
-            <metainf refid="hy.required.metainf-files"/>
+            <metainf refid="hy.required.metainf-files" />
         </jar>
 
         <jar destfile="${hy.jdk}/jre/lib/boot/nio-src.jar">
             <fileset dir="${hy.nio.src.main.java}" />
             <manifest>
-                <attribute name="Implementation-Version" value="${svn.info}"/> 
+                <attribute name="Implementation-Version" value="${svn.info}" />
             </manifest>
 
-            <metainf refid="hy.required.metainf-files"/>
+            <metainf refid="hy.required.metainf-files" />
         </jar>
     </target>
 
@@ -170,29 +170,29 @@
                sourcepath=""
                compiler="${hy.javac.compiler}"
                memoryMaximumSize="${hy.javac.maxmem}"
-               source="${hy.javac.source}" 
+               source="${hy.javac.source}"
                target="${hy.javac.target}"
                debug="${hy.javac.debug}">
 
             <compilerarg line="${build.compilerarg}" />
 
-                    <src>
-                        <pathelement location="${hy.nio.src.test.java}"/>
-                        <pathelement
-                             location="${hy.nio.src.test.java.platform}"/>
-                    </src>
+            <src>
+                <pathelement location="${hy.nio.src.test.java}" />
+                <pathelement location="${hy.nio.src.test.java.platform}" />
+            </src>
             <bootclasspath>
-            <fileset dir="${hy.jdk}/jre/lib/boot">
-                <include name="**/*.jar" />
-            </fileset>
+                <fileset dir="${hy.jdk}/jre/lib/boot">
+                    <include name="**/*.jar" />
+                </fileset>
             </bootclasspath>
             <classpath location="${hy.hdk}/build/test/support.jar" />
         </javac>
     </target>
 
     <target name="prepare-exclude">
-       <prepare-exclude-list moduleName="nio" dir="./make"
-                             result="${nio.exclude.file}"/>
+        <prepare-exclude-list moduleName="nio"
+                              dir="./make"
+                              result="${nio.exclude.file}" />
     </target>
 
     <target name="run-tests">
@@ -201,14 +201,14 @@
         <property name="test.jre.home" value="${hy.jdk}/jre" />
 
         <junit fork="yes"
-            forkmode="${hy.test.forkmode}"
-            timeout="${hy.test.timeout}"
-            printsummary="withOutAndErr"
-            errorproperty="test.errors"
-            failureproperty="test.failures"
-            showoutput="on"
-            dir="${basedir}"
-            jvm="${test.jre.home}/bin/java">
+               forkmode="${hy.test.forkmode}"
+               timeout="${hy.test.timeout}"
+               printsummary="withOutAndErr"
+               errorproperty="test.errors"
+               failureproperty="test.failures"
+               showoutput="on"
+               dir="${basedir}"
+               jvm="${test.jre.home}/bin/java">
             <jvmarg line="${hy.test.vmargs}" />
 
             <classpath>
@@ -218,20 +218,22 @@
 
             <formatter type="xml" />
 
-            <batchtest todir="${hy.tests.reports}" haltonfailure="no" >
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no">
                 <fileset dir="${hy.nio.src.test.java}">
                     <!-- if ${test.case}     -->
                     <include name="${converted.tc}" if="test.case" />
                     <!-- unless ${test.case} -->
                     <include name="**/*Test.java" unless="test.case" />
-                    <excludesfile name="${nio.exclude.file}" unless="test.case" />
+                    <excludesfile name="${nio.exclude.file}"
+                                  unless="test.case" />
                 </fileset>
                 <fileset dir="${hy.nio.src.test.java.platform}">
                     <!-- if ${test.case}     -->
                     <include name="${converted.tc}" if="test.case" />
                     <!-- unless ${test.case} -->
                     <include name="**/*Test.java" unless="test.case" />
-                    <excludesfile name="${nio.exclude.file}" unless="test.case" />
+                    <excludesfile name="${nio.exclude.file}"
+                                  unless="test.case" />
                 </fileset>
             </batchtest>
         </junit>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ByteBuffer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ByteBuffer.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ByteBuffer.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/ByteBuffer.java Tue Mar  4 00:02:13 2008
@@ -262,7 +262,7 @@
     /**
      * Returns a readonly buffer that shares content with this buffer.
      * <p>
-     * The returned buffer is guaranteed to be a new instance, even this buffer
+     * The returned buffer is guaranteed to be a new instance, even if this buffer
      * is readonly itself. The new buffer's position, limit, capacity and mark
      * are the same as this buffer.
      * </p>

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Channels.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Channels.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Channels.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Channels.java Tue Mar  4 00:02:13 2008
@@ -487,11 +487,6 @@
 
         private ByteBuffer byteBuf;
 
-        /**
-         * @param outputStream
-         * @param enc
-         * @param minBufferCap
-         */
         public ByteChannelWriter(OutputStream aOutputStream,
                 CharsetEncoder aEncoder, int minBufferCap) {
             super(aOutputStream);

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/DatagramChannel.java Tue Mar  4 00:02:13 2008
@@ -83,6 +83,7 @@
      * @see java.nio.channels.SelectableChannel#validOps()
      * @return Valid operations in bit-set.
      */
+    @Override
     public final int validOps() {
         return (SelectionKey.OP_READ | SelectionKey.OP_WRITE);
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/FileLock.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/FileLock.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/FileLock.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/FileLock.java Tue Mar  4 00:02:13 2008
@@ -191,6 +191,7 @@
      * 
      * @return the display string.
      */
+    @Override
     @SuppressWarnings("nls")
     public final String toString() {
         StringBuffer buffer = new StringBuffer(64); // Guess length of string

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Pipe.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Pipe.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Pipe.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/Pipe.java Tue Mar  4 00:02:13 2008
@@ -24,7 +24,6 @@
  * A pipe contains two channels. One is the writable sink channel and the other is
  * readable source channel. When bytes are written into the writable channel they
  * can be read from readable channel. The order of these bytes remains unchanged. 
- * 
  */
 public abstract class Pipe {
 
@@ -49,6 +48,7 @@
          * 
          * @return a static value of OP_WRITE
          */
+        @Override
         public final int validOps() {
             return SelectionKey.OP_WRITE;
         }
@@ -76,6 +76,7 @@
          * 
          * @return a static value of OP_READ
          */
+        @Override
         public final int validOps() {
             return SelectionKey.OP_READ;
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/ServerSocketChannel.java Tue Mar  4 00:02:13 2008
@@ -70,6 +70,7 @@
      * @see java.nio.channels.SelectableChannel#validOps()
      * @return Valid operations in bit-set.
      */
+    @Override
     public final int validOps() {
         return SelectionKey.OP_ACCEPT;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/SocketChannel.java Tue Mar  4 00:02:13 2008
@@ -135,6 +135,7 @@
      * @see java.nio.channels.SelectableChannel#validOps()
      * @return Valid operations in bit-set.
      */
+    @Override
     public final int validOps() {
         return (SelectionKey.OP_CONNECT | SelectionKey.OP_READ | SelectionKey.OP_WRITE);
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelectionKey.java Tue Mar  4 00:02:13 2008
@@ -41,6 +41,7 @@
     /**
      * @see java.nio.channels.SelectionKey#isValid()
      */
+    @Override
     public final boolean isValid() {
         return isValid;
     }
@@ -50,6 +51,7 @@
      * 
      * @see java.nio.channels.SelectionKey#cancel()
      */
+    @Override
     public final void cancel() {
         if (isValid) {
             isValid = false;

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/java/nio/channels/spi/AbstractSelector.java Tue Mar  4 00:02:13 2008
@@ -57,6 +57,7 @@
      * 
      * @see java.nio.channels.Selector#close()
      */
+    @Override
     public synchronized final void close() throws IOException {
         if (isOpen) {
             isOpen = false;
@@ -75,6 +76,7 @@
     /**
      * @see java.nio.channels.Selector#isOpen()
      */
+    @Override
     public final boolean isOpen() {
         return isOpen;
     }
@@ -84,6 +86,7 @@
      * 
      * @see java.nio.channels.Selector#provider()
      */
+    @Override
     public final SelectorProvider provider() {
         return provider;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/AddressUtil.java Tue Mar  4 00:02:13 2008
@@ -19,6 +19,10 @@
 import java.io.FileDescriptor;
 import java.nio.Buffer;
 import java.nio.channels.Channel;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.FileChannel;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
 
 import org.apache.harmony.luni.platform.FileDescriptorHandler;
 import org.apache.harmony.nio.internal.DirectBuffer;
@@ -49,14 +53,15 @@
     }
 
     /**
-     * Gets the address of native resource held by the given channel, if has
+     * Gets the address of native resource held by the given channel, if it has
      * any.
      * 
-     * For network related channel, including SocketChannel, ServerSocketChannel
-     * and DatagramChannel, this method returns a int of Socket handler in Linux
-     * while returns a SOCKET (UINT_PTR) in windows.
+     * For network related channel, including {@link SocketChannel},
+     * {@link ServerSocketChannel} and {@link DatagramChannel}, this method
+     * returns the Socket handle (long) in Linux, and returns a SOCKET
+     * (UINT_PTR) in windows.
      * 
-     * For FileChannel, this method returns the native file descriptor.
+     * For {@link FileChannel}, this method returns the native file descriptor.
      * 
      * For other channels, this method return 0, which means unsupported
      * operation.

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileLockImpl.java Tue Mar  4 00:02:13 2008
@@ -21,7 +21,7 @@
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 
-/*
+/**
  * The concrete implementation of an NIO file lock object.
  */
 final class FileLockImpl extends FileLock {
@@ -29,35 +29,41 @@
     // Remembers if this lock has been released via the API.
     private boolean isReleased = false;
 
-    /*
+    /**
      * Answers a new file lock object with the given parameters.
      * 
-     * @param channel the file channel hosting the lock. @param position the
-     * start position of the lock, in bytes @param size the length of the lock,
-     * in bytes @param shared whether this lock is shared (true) or exclusive
-     * (false)
+     * @param channel
+     *            the file channel hosting the lock.
+     * @param position
+     *            the start position of the lock, in bytes
+     * @param size
+     *            the length of the lock, in bytes
+     * @param shared
+     *            whether this lock is shared (true) or exclusive (false)
      */
     public FileLockImpl(FileChannel channel, long position, long size,
             boolean shared) {
         super(channel, position, size, shared);
     }
 
-    /*
+    /**
      * Tests to see if the lock is valid. A lock can be invalidated if the
      * channel it is acquired on is closed or if it is released. (non-Javadoc)
      * 
      * @see java.nio.channels.FileLock#isValid()
      */
+    @Override
     public boolean isValid() {
         return !isReleased && channel().isOpen();
     }
 
-    /*
+    /**
      * Releases the file lock on the channel that acquired it. Releasing an
      * invalid lock has no effect.
      * 
      * @see java.nio.channels.FileLock#release()
      */
+    @Override
     public void release() throws IOException {
         if (!channel().isOpen()) {
             throw new ClosedChannelException();

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/IOUtil.java Tue Mar  4 00:02:13 2008
@@ -29,7 +29,7 @@
 import org.apache.harmony.nio.Util;
 import org.apache.harmony.nio.internal.nls.Messages;
 
-/*
+/**
  * Static methods for I/O util. Used by io package and nio package.
  */
 public final class IOUtil {

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/PipeImpl.java Tue Mar  4 00:02:13 2008
@@ -108,7 +108,7 @@
             super(provider);
             sourceServer = provider.openServerSocketChannel();
             sourceServer.socket().bind(
-                    new InetSocketAddress(InetAddress.getLocalHost(), 0));
+                new InetSocketAddress(InetAddress.getByName(null), 0));
             serverPort = sourceServer.socket().getLocalPort();
         }
 
@@ -161,8 +161,8 @@
         }
 
         public boolean finishConnect() throws IOException {
-            return sinkSocket.connect(new InetSocketAddress(InetAddress
-                    .getLocalHost(), serverPort));
+            return sinkSocket.connect(
+                new InetSocketAddress(InetAddress.getByName(null), serverPort));
         }
 
         protected void implCloseSelectableChannel() throws IOException {

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java Tue Mar  4 00:02:13 2008
@@ -449,7 +449,7 @@
                 int length = target.remaining();
                 if (target.isDirect()) {
                     long address = AddressUtil.getDirectBufferAddress(target);
-                    readCount = networkSystem.readDirect(fd, address, offset,
+                    readCount = networkSystem.readDirect(fd, address + offset,
                             length, (isBlocking() ? TIMEOUT_BLOCK
                                     : TIMEOUT_NONBLOCK));
                 } else {
@@ -546,7 +546,7 @@
                 }
                 if (source.isDirect()) {
                     long address = AddressUtil.getDirectBufferAddress(source);
-                    writeCount = networkSystem.writeDirect(fd, address, pos,
+                    writeCount = networkSystem.writeDirect(fd, address + pos,
                             length);
                 } else if (source.hasArray()) {
                     pos += source.arrayOffset();

Modified: harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java Tue Mar  4 00:02:13 2008
@@ -22,6 +22,7 @@
 import java.io.OutputStream;
 import java.net.BindException;
 import java.net.ConnectException;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -2028,6 +2029,42 @@
         }
     }
     
+    public void testReadByteBuffer_Direct2() throws IOException {
+        byte[] request = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+        ByteBuffer buffer = ByteBuffer.allocateDirect(128);
+
+        ServerSocketChannel server = ServerSocketChannel.open();
+        server.socket().bind(
+                new InetSocketAddress(InetAddress.getLocalHost(), 0), 5);
+        Socket client = new Socket(InetAddress.getLocalHost(), server.socket()
+                .getLocalPort());
+        client.setTcpNoDelay(false);
+        Socket worker = server.socket().accept();
+        SocketChannel workerChannel = worker.getChannel();
+
+        OutputStream out = client.getOutputStream();
+        out.write(request);
+        out.close();
+
+        buffer.limit(5);
+        int bytesRead = workerChannel.read(buffer);
+        assertEquals(5, bytesRead);
+        assertEquals(5, buffer.position());
+
+        buffer.limit(request.length);
+        bytesRead = workerChannel.read(buffer);
+        assertEquals(6, bytesRead);
+
+        buffer.flip();
+        assertEquals(request.length, buffer.limit());
+
+        assertEquals(ByteBuffer.wrap(request), buffer);
+
+        client.close();
+        worker.close();
+        server.close();
+    }
+
     public void testReadByteBuffer_BufNull() throws Exception {
         assertTrue(this.server1.isBound());
         java.nio.ByteBuffer readBuf = java.nio.ByteBuffer.allocate(0);



Mime
View raw message