You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/04/25 09:51:37 UTC
svn commit: r532240 - in
/harmony/enhanced/classlib/trunk/modules/luni/src/test:
java/tests/api/java/util/ resources/serialization/tests/api/java/util/
Author: pyang
Date: Wed Apr 25 00:51:36 2007
New Revision: 532240
URL: http://svn.apache.org/viewvc?view=rev&rev=532240
Log:
Apply patch for HARMONY-3735([classlib][luni] Add more test cases for some classes in luni module)
Added:
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java (with props)
harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/HashSetTest.golden.ser (with props)
harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/IdentityHashMapTest.golden.ser (with props)
harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/PropertyPermissionTest.golden.ser (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CalendarTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java Wed Apr 25 00:51:36 2007
@@ -16,10 +16,11 @@
*/
package tests.api.java.util;
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Comparator;
-import java.util.List;
import java.util.LinkedList;
+import java.util.List;
import tests.support.Support_UnmodifiableCollectionTest;
@@ -1757,6 +1758,18 @@
booleanArray[counter + 1] = true;
}
}
+
+ /**
+ * @tests java.util.Arrays#swap(int, int, Object[])
+ */
+ public void test_swap_I_I_$Ljava_lang_Object() throws Exception {
+ Method m = Arrays.class.getDeclaredMethod("swap", int.class, int.class, Object[].class);
+ m.setAccessible(true);
+ Integer[] arr = {new Integer(0), new Integer(1), new Integer(2)};
+ m.invoke(null,0, 1, arr);
+ assertEquals("should be equal to 1",1, arr[0].intValue());
+ assertEquals("should be equal to 0",0, arr[1].intValue());
+ }
/**
* Tears down the fixture, for example, close a network connection. This
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CalendarTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CalendarTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CalendarTest.java Wed Apr 25 00:51:36 2007
@@ -461,6 +461,67 @@
assertEquals(6017546357372606464L, cal.getTimeInMillis());
}
+ /**
+ * @tests {@link java.util.Calendar#getActualMaximum(int)}
+ */
+ public void test_getActualMaximum_I() {
+ Calendar c = new MockCalendar();
+ assertEquals("should be equal to 0", 0, c.getActualMaximum(0));
+ }
+
+ /**
+ * @tests {@link java.util.Calendar#getActualMinimum(int)}
+ */
+ public void test_getActualMinimum_I() {
+ Calendar c = new MockCalendar();
+ assertEquals("should be equal to 0", 0, c.getActualMinimum(0));
+ }
+
+
+ private class MockCalendar extends Calendar {
+
+ public MockCalendar() {
+ super();
+ }
+
+ @Override
+ public void add(int field, int value) {
+ }
+
+ @Override
+ protected void computeFields() {
+ }
+
+ @Override
+ protected void computeTime() {
+ }
+
+ @Override
+ public int getGreatestMinimum(int field) {
+ return 0;
+ }
+
+ @Override
+ public int getLeastMaximum(int field) {
+ return 0;
+ }
+
+ @Override
+ public int getMaximum(int field) {
+ return 0;
+ }
+
+ @Override
+ public int getMinimum(int field) {
+ return 0;
+ }
+
+ @Override
+ public void roll(int field, boolean increment) {
+ }
+ }
+
+
protected void setUp() {
defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java Wed Apr 25 00:51:36 2007
@@ -17,6 +17,8 @@
package tests.api.java.util;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -36,6 +38,8 @@
import java.util.TreeMap;
import java.util.TreeSet;
+import org.apache.harmony.luni.internal.nls.Messages;
+
import tests.support.Support_CollectionTest;
import tests.support.Support_ListTest;
import tests.support.Support_SetTest;
@@ -1889,6 +1893,25 @@
Map um = Collections.unmodifiableMap(m);
assertEquals("{one=1, two=2}", um.toString());
}
+
+ /**
+ * @tests java.util.Collections#checkType(Object, Class)
+ */
+ public void test_checkType_Ljava_lang_Object_Ljava_lang_Class() throws Exception {
+ Method m = Collections.class.getDeclaredMethod("checkType", Object.class, Class.class);
+ m.setAccessible(true);
+ m.invoke(null, new Object(), Object.class);
+
+ try {
+ m.invoke(null, new Object(), int.class);
+ fail("should throw InvocationTargetException");
+ } catch (InvocationTargetException e) {
+ String errMsg = Messages.getString(
+ "luni.05", Object.class, int.class);
+ assertEquals(errMsg, e.getCause().getMessage());
+ }
+ }
+
/**
* Sets up the fixture, for example, open a network connection. This method
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/HashSetTest.java Wed Apr 25 00:51:36 2007
@@ -21,6 +21,14 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.harmony.testframework.serialization.SerializationTest;
public class HashSetTest extends junit.framework.TestCase {
@@ -190,6 +198,17 @@
hs.clear();
assertEquals("Cleared set returned non-zero size", 0, hs.size());
}
+
+ /**
+ * @tests java.util.HashSet#SerializationTest
+ */
+ public void test_Serialization() throws Exception{
+ HashSet<String> hs = new HashSet<String>();
+ hs.add("hello");
+ hs.add("world");
+ SerializationTest.verifySelf(hs, comparator);
+ SerializationTest.verifyGolden(this, hs, comparator);
+ }
/**
* Sets up the fixture, for example, open a network connection. This method
@@ -208,4 +227,15 @@
*/
protected void tearDown() {
}
+
+ private static final SerializationTest.SerializableAssert comparator = new
+ SerializationTest.SerializableAssert() {
+ public void assertDeserialized(Serializable initial, Serializable deserialized) {
+ HashSet<String> initialHs = (HashSet<String>) initial;
+ HashSet<String> deseriaHs = (HashSet<String>) deserialized;
+ assertEquals("should be equal", initialHs.size(), deseriaHs.size());
+ assertEquals("should be equal", initialHs, deseriaHs);
+ }
+
+ };
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java Wed Apr 25 00:51:36 2007
@@ -17,6 +17,7 @@
package tests.api.java.util;
+import java.io.Serializable;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,8 +31,12 @@
import tests.support.Support_MapTest2;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
public class IdentityHashMapTest extends junit.framework.TestCase {
- class MockMap extends AbstractMap {
+ private static final String ID = "hello";
+
+ class MockMap extends AbstractMap {
public Set entrySet() {
return null;
}
@@ -424,6 +429,16 @@
!myIdentityHashMap.containsValue(objArray2[0]));
}
+
+ /**
+ * @tests java.util.IdentityHashMap#Serialization()
+ */
+ public void test_Serialization() throws Exception {
+ IdentityHashMap<String, String> map = new IdentityHashMap<String, String>();
+ map.put(ID, "world");
+ SerializationTest.verifySelf(map, comparator);
+ SerializationTest.verifyGolden(this, map, comparator);
+ }
/**
* Sets up the fixture, for example, open a network connection. This method
@@ -443,4 +458,15 @@
*/
protected void tearDown() {
}
+
+ private static final SerializationTest.SerializableAssert comparator = new
+ SerializationTest.SerializableAssert() {
+
+ public void assertDeserialized(Serializable initial, Serializable deserialized) {
+ IdentityHashMap<String, String> initialMap = (IdentityHashMap<String, String>) initial;
+ IdentityHashMap<String, String> deseriaMap = (IdentityHashMap<String, String>) deserialized;
+ assertEquals("should be equal", initialMap.size(), deseriaMap.size());
+ }
+
+ };
}
Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java?view=auto&rev=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java Wed Apr 25 00:51:36 2007
@@ -0,0 +1,39 @@
+/* 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 tests.api.java.util;
+
+import java.io.NotSerializableException;
+import java.util.InvalidPropertiesFormatException;
+
+import org.apache.harmony.testframework.serialization.SerializationTest;
+
+public class InvalidPropertiesFormatExceptionTest extends
+ junit.framework.TestCase {
+
+ /**
+ * @tests java.util.InvalidPropertiesFormatException#SerializationTest()
+ */
+ public void test_Serialization() throws Exception {
+ InvalidPropertiesFormatException ipfe = new InvalidPropertiesFormatException(
+ "Hey, this is InvalidPropertiesFormatException");
+ try {
+ SerializationTest.verifySelf(ipfe);
+ } catch (NotSerializableException e) {
+ // expected
+ }
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/InvalidPropertiesFormatExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java?view=diff&rev=532240&r1=532239&r2=532240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java Wed Apr 25 00:51:36 2007
@@ -17,9 +17,13 @@
package tests.api.java.util;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.PropertyPermission;
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
public class PropertyPermissionTest extends junit.framework.TestCase {
static PropertyPermission javaPP = new PropertyPermission("java.*", "read");
@@ -119,6 +123,16 @@
assertTrue("Invalid PermissionCollection returned", elementEnum
.nextElement().equals(javaPP));
}
+
+ /**
+ * @tests java.util.PropertyPermission#readObject(ObjectInputStream)
+ * @tests java.util.PropertyPermission#writeObject(ObjectOutputStream)
+ */
+ public void test_serialization() throws Exception{
+ PropertyPermission pp = new PropertyPermission("test", "read");
+ SerializationTest.verifySelf(pp, comparator);
+ SerializationTest.verifyGolden(this, pp, comparator);
+ }
/**
* Sets up the fixture, for example, open a network connection. This method
@@ -133,4 +147,14 @@
*/
protected void tearDown() {
}
+
+ private static final SerializableAssert comparator = new SerializableAssert() {
+
+ public void assertDeserialized(Serializable initial, Serializable deserialized) {
+ PropertyPermission initialPP = (PropertyPermission) initial;
+ PropertyPermission deseriaPP = (PropertyPermission) deserialized;
+ assertEquals("should be equal", initialPP, deseriaPP);
+ }
+
+ };
}
Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/HashSetTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/HashSetTest.golden.ser?view=auto&rev=532240
==============================================================================
Binary file - no diff available.
Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/HashSetTest.golden.ser
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/IdentityHashMapTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/IdentityHashMapTest.golden.ser?view=auto&rev=532240
==============================================================================
Binary file - no diff available.
Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/IdentityHashMapTest.golden.ser
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/PropertyPermissionTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/PropertyPermissionTest.golden.ser?view=auto&rev=532240
==============================================================================
Binary file - no diff available.
Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/serialization/tests/api/java/util/PropertyPermissionTest.golden.ser
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream