harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r647063 - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util: AbstractMapTest.java AbstractSequentialListTest.java CalendarTest.java
Date Fri, 11 Apr 2008 06:09:07 GMT
Author: tonywu
Date: Thu Apr 10 23:09:04 2008
New Revision: 647063

URL: http://svn.apache.org/viewvc?rev=647063&view=rev
Log:
Refine Testcase for HARMONY-5699

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractSequentialListTest.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CalendarTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java?rev=647063&r1=647062&r2=647063&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractMapTest.java
Thu Apr 10 23:09:04 2008
@@ -35,104 +35,103 @@
 
 public class AbstractMapTest extends junit.framework.TestCase {
 
-	static final String specialKey = "specialKey".intern();
+    static final String specialKey = "specialKey".intern();
 
-	static final String specialValue = "specialValue".intern();
+    static final String specialValue = "specialValue".intern();
 
-	// The impl of MyMap is not realistic, but serves to create a type
-	// that uses the default remove behavior.
-	class MyMap extends AbstractMap {
-		final Set mySet = new HashSet(1);
-
-		MyMap() {
-			mySet.add(new Map.Entry() {
-				public Object getKey() {
-					return specialKey;
-				}
-
-				public Object getValue() {
-					return specialValue;
-				}
-
-				public Object setValue(Object object) {
-					return null;
-				}
-			});
-		}
-
-		public Object put(Object key, Object value) {
-			return null;
-		}
-
-		public Set entrySet() {
-			return mySet;
-		}
-	}
-
-	/**
-	 * @tests java.util.AbstractMap#keySet()
-	 */
-	public void test_keySet() {
-		AbstractMap map1 = new HashMap(0);
-		assertSame("HashMap(0)", map1.keySet(), map1.keySet());
-
-		AbstractMap map2 = new HashMap(10);
-		assertSame("HashMap(10)", map2.keySet(), map2.keySet());
-
-		Map map3 = Collections.EMPTY_MAP;
-		assertSame("EMPTY_MAP", map3.keySet(), map3.keySet());
-
-		AbstractMap map4 = new IdentityHashMap(1);
-		assertSame("IdentityHashMap", map4.keySet(), map4.keySet());
-
-		AbstractMap map5 = new LinkedHashMap(122);
-		assertSame("LinkedHashMap", map5.keySet(), map5.keySet());
-
-		AbstractMap map6 = new TreeMap();
-		assertSame("TreeMap", map6.keySet(), map6.keySet());
-
-		AbstractMap map7 = new WeakHashMap();
-		assertSame("WeakHashMap", map7.keySet(), map7.keySet());
-	}
-
-	/**
-	 * @tests java.util.AbstractMap#remove(java.lang.Object)
-	 */
-	public void test_removeLjava_lang_Object() {
-		Object key = new Object();
-		Object value = new Object();
-
-		AbstractMap map1 = new HashMap(0);
-		map1.put("key", value);
-		assertSame("HashMap(0)", map1.remove("key"), value);
-
-		AbstractMap map4 = new IdentityHashMap(1);
-		map4.put(key, value);
-		assertSame("IdentityHashMap", map4.remove(key), value);
-
-		AbstractMap map5 = new LinkedHashMap(122);
-		map5.put(key, value);
-		assertSame("LinkedHashMap", map5.remove(key), value);
-
-		AbstractMap map6 = new TreeMap(new Comparator() {
-			// Bogus comparator
-			public int compare(Object object1, Object object2) {
-				return 0;
-			}
-		});
-		map6.put(key, value);
-		assertSame("TreeMap", map6.remove(key), value);
-
-		AbstractMap map7 = new WeakHashMap();
-		map7.put(key, value);
-		assertSame("WeakHashMap", map7.remove(key), value);
-
-		AbstractMap aSpecialMap = new MyMap();
-		aSpecialMap.put(specialKey, specialValue);
-		Object valueOut = aSpecialMap.remove(specialKey);
-		assertSame("MyMap", valueOut, specialValue);
-	}
-    
+    // The impl of MyMap is not realistic, but serves to create a type
+    // that uses the default remove behavior.
+    class MyMap extends AbstractMap {
+        final Set mySet = new HashSet(1);
+
+        MyMap() {
+            mySet.add(new Map.Entry() {
+                public Object getKey() {
+                    return specialKey;
+                }
+
+                public Object getValue() {
+                    return specialValue;
+                }
+
+                public Object setValue(Object object) {
+                    return null;
+                }
+            });
+        }
+
+        public Object put(Object key, Object value) {
+            return null;
+        }
+
+        public Set entrySet() {
+            return mySet;
+        }
+    }
+
+    /**
+     * @tests java.util.AbstractMap#keySet()
+     */
+    public void test_keySet() {
+        AbstractMap map1 = new HashMap(0);
+        assertSame("HashMap(0)", map1.keySet(), map1.keySet());
+
+        AbstractMap map2 = new HashMap(10);
+        assertSame("HashMap(10)", map2.keySet(), map2.keySet());
+
+        Map map3 = Collections.EMPTY_MAP;
+        assertSame("EMPTY_MAP", map3.keySet(), map3.keySet());
+
+        AbstractMap map4 = new IdentityHashMap(1);
+        assertSame("IdentityHashMap", map4.keySet(), map4.keySet());
+
+        AbstractMap map5 = new LinkedHashMap(122);
+        assertSame("LinkedHashMap", map5.keySet(), map5.keySet());
+
+        AbstractMap map6 = new TreeMap();
+        assertSame("TreeMap", map6.keySet(), map6.keySet());
+
+        AbstractMap map7 = new WeakHashMap();
+        assertSame("WeakHashMap", map7.keySet(), map7.keySet());
+    }
+
+    /**
+     * @tests java.util.AbstractMap#remove(java.lang.Object)
+     */
+    public void test_removeLjava_lang_Object() {
+        Object key = new Object();
+        Object value = new Object();
+
+        AbstractMap map1 = new HashMap(0);
+        map1.put("key", value);
+        assertSame("HashMap(0)", map1.remove("key"), value);
+
+        AbstractMap map4 = new IdentityHashMap(1);
+        map4.put(key, value);
+        assertSame("IdentityHashMap", map4.remove(key), value);
+
+        AbstractMap map5 = new LinkedHashMap(122);
+        map5.put(key, value);
+        assertSame("LinkedHashMap", map5.remove(key), value);
+
+        AbstractMap map6 = new TreeMap(new Comparator() {
+            // Bogus comparator
+            public int compare(Object object1, Object object2) {
+                return 0;
+            }
+        });
+        map6.put(key, value);
+        assertSame("TreeMap", map6.remove(key), value);
+
+        AbstractMap map7 = new WeakHashMap();
+        map7.put(key, value);
+        assertSame("WeakHashMap", map7.remove(key), value);
+
+        AbstractMap aSpecialMap = new MyMap();
+        aSpecialMap.put(specialKey, specialValue);
+        Object valueOut = aSpecialMap.remove(specialKey);
+        assertSame("MyMap", valueOut, specialValue);
+    }
 
     /**
      * @tests java.util.AbstractMap#clear()
@@ -142,15 +141,15 @@
         AbstractMap map = new HashMap();
         map.put(1, 1);
         map.clear();
-        assertEquals("Should equal to be empty.", true, map.isEmpty());
+        assertTrue(map.isEmpty());
 
         // Special entrySet return a Set with no clear method.
         AbstractMap myMap = new MocAbstractMap();
         try {
             myMap.clear();
-            fail("Should throw an unsupportedoprationexception");
+            fail("Should throw UnsupportedOprationException");
         } catch (UnsupportedOperationException e) {
-
+            // expected
         }
     }
 
@@ -162,7 +161,6 @@
         }
 
         class MySet extends HashSet {
-
             public void clear() {
                 throw new UnsupportedOperationException();
             }
@@ -175,17 +173,17 @@
     public void test_containsKey() {
         AbstractMap map = new AMT();
 
-        assertEquals("Shoule equal to be false.", false, map.containsKey("k"));
-        assertEquals("Shoule equal to be false.", false, map.containsKey(null));
+        assertFalse(map.containsKey("k"));
+        assertFalse(map.containsKey(null));
 
         map.put("k", "v");
         map.put("key", null);
         map.put(null, "value");
         map.put(null, null);
 
-        assertEquals("Shoule equal to be true.", true, map.containsKey("k"));
-        assertEquals("Shoule equal to be true.", true, map.containsKey("key"));
-        assertEquals("Shoule equal to be true.", true, map.containsKey(null));
+        assertTrue(map.containsKey("k"));
+        assertTrue(map.containsKey("key"));
+        assertTrue(map.containsKey(null));
     }
 
     /**
@@ -194,20 +192,16 @@
     public void test_containValue() {
         AbstractMap map = new AMT();
 
-        assertEquals("Shoule equal to be false.", false, map.containsValue("v"));
-        assertEquals("Shoule equal to be false.", false, map
-                .containsValue(null));
-        
+        assertFalse(map.containsValue("v"));
+        assertFalse(map.containsValue(null));
+
         map.put("k", "v");
         map.put("key", null);
         map.put(null, "value");
-        
-        System.out.println(map);
-        
-        assertEquals("Shoule equal to be true.", true, map.containsValue("v"));
-        assertEquals("Shoule equal to be true.", true, map
-                .containsValue("value"));
-        assertEquals("Shoule equal to be true.", true, map.containsValue(null));
+
+        assertTrue(map.containsValue("v"));
+        assertTrue(map.containsValue("value"));
+        assertTrue(map.containsValue(null));
     }
 
     /**
@@ -215,82 +209,82 @@
      */
     public void test_get() {
         AbstractMap map = new AMT();
-        assertEquals("Shoule equal to be null.", null, map.get("key"));
-        assertEquals("Shoule equal to be null.", null, map.get(null));
+        assertNull(map.get("key"));
+        assertNull(map.get(null));
 
         map.put("k", "v");
         map.put("key", null);
         map.put(null, "value");
 
-        assertEquals("Shoule equal to be v.", "v", map.get("k"));
-        assertEquals("Shoule equal to be null.", null, map.get("key"));
-        assertEquals("Shoule equal to be value.", "value", map.get(null));
+        assertEquals("v", map.get("k"));
+        assertNull(map.get("key"));
+        assertEquals("value", map.get(null));
     }
 
-	/**
+    /**
      * @tests java.util.AbstractMap#values()
      */
-	public void test_values() {
-		AbstractMap map1 = new HashMap(0);
-		assertSame("HashMap(0)", map1.values(), map1.values());
-
-		AbstractMap map2 = new HashMap(10);
-		assertSame("HashMap(10)", map2.values(), map2.values());
-
-		Map map3 = Collections.EMPTY_MAP;
-		assertSame("EMPTY_MAP", map3.values(), map3.values());
-
-		AbstractMap map4 = new IdentityHashMap(1);
-		assertSame("IdentityHashMap", map4.values(), map4.values());
-
-		AbstractMap map5 = new LinkedHashMap(122);
-		assertSame("IdentityHashMap", map5.values(), map5.values());
-
-		AbstractMap map6 = new TreeMap();
-		assertSame("TreeMap", map6.values(), map6.values());
-
-		AbstractMap map7 = new WeakHashMap();
-		assertSame("WeakHashMap", map7.values(), map7.values());
-	}
-
-	/**
-	 * @tests java.util.AbstractMap#clone()
-	 */
-	public void test_clone() {
-		class MyMap extends AbstractMap implements Cloneable {
-			private Map map = new HashMap();
-
-			public Set entrySet() {
-				return map.entrySet();
-			}
-
-			public Object put(Object key, Object value) {
-				return map.put(key, value);
-			}
-
-			public Map getMap() {
-				return map;
-			}
-
-			public Object clone() {
-				try {
-					return super.clone();
-				} catch (CloneNotSupportedException e) {
-					return null;
-				}
-			}
-		}
-		;
-		MyMap map = new MyMap();
-		map.put("one", "1");
-		Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
-		assertTrue("entry not added", entry.getKey() == "one"
-				&& entry.getValue() == "1");
-		MyMap mapClone = (MyMap) map.clone();
-		assertTrue("clone not shallow", map.getMap() == mapClone.getMap());
-	}
-	
-	public class AMT extends AbstractMap {
+    public void test_values() {
+        AbstractMap map1 = new HashMap(0);
+        assertSame("HashMap(0)", map1.values(), map1.values());
+
+        AbstractMap map2 = new HashMap(10);
+        assertSame("HashMap(10)", map2.values(), map2.values());
+
+        Map map3 = Collections.EMPTY_MAP;
+        assertSame("EMPTY_MAP", map3.values(), map3.values());
+
+        AbstractMap map4 = new IdentityHashMap(1);
+        assertSame("IdentityHashMap", map4.values(), map4.values());
+
+        AbstractMap map5 = new LinkedHashMap(122);
+        assertSame("IdentityHashMap", map5.values(), map5.values());
+
+        AbstractMap map6 = new TreeMap();
+        assertSame("TreeMap", map6.values(), map6.values());
+
+        AbstractMap map7 = new WeakHashMap();
+        assertSame("WeakHashMap", map7.values(), map7.values());
+    }
+
+    /**
+     * @tests java.util.AbstractMap#clone()
+     */
+    public void test_clone() {
+        class MyMap extends AbstractMap implements Cloneable {
+            private Map map = new HashMap();
+
+            public Set entrySet() {
+                return map.entrySet();
+            }
+
+            public Object put(Object key, Object value) {
+                return map.put(key, value);
+            }
+
+            public Map getMap() {
+                return map;
+            }
+
+            public Object clone() {
+                try {
+                    return super.clone();
+                } catch (CloneNotSupportedException e) {
+                    return null;
+                }
+            }
+        }
+        ;
+        MyMap map = new MyMap();
+        map.put("one", "1");
+        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
+        assertTrue("entry not added", entry.getKey() == "one"
+                && entry.getValue() == "1");
+        MyMap mapClone = (MyMap) map.clone();
+        assertTrue("clone not shallow", map.getMap() == mapClone.getMap());
+    }
+
+    public class AMT extends AbstractMap {
 
         // Very crude AbstractMap implementation
         Vector values = new Vector();
@@ -361,9 +355,9 @@
         assertEquals("Should be equal", amt, ht);
     }
 
-	protected void setUp() {
-	}
+    protected void setUp() {
+    }
 
-	protected void tearDown() {
-	}
+    protected void tearDown() {
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractSequentialListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractSequentialListTest.java?rev=647063&r1=647062&r2=647063&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractSequentialListTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractSequentialListTest.java
Thu Apr 10 23:09:04 2008
@@ -73,8 +73,8 @@
         AbstractSequentialList list = new MyAbstractSequentialList();
         list.add(1);
         list.add("value");
-        assertEquals("Should be equal to \"1\".", 1, list.get(0));
-        assertEquals("Should be equal to \"value\".", "value", list.get(1));
+        assertEquals(1, list.get(0));
+        assertEquals("value", list.get(1));
 
         // get value by index which is out of bounds
         try {
@@ -100,10 +100,10 @@
         list.add(1);
 
         // normal test
-        assertEquals("Should be equal to \"1\".", 1, list.remove(0));
+        assertEquals(1, list.remove(0));
 
         list.add("value");
-        assertEquals("Should be equal to \"value\".", "value", list.remove(0));
+        assertEquals("value", list.remove(0));
 
         // remove index is out of bounds
         try {
@@ -139,7 +139,7 @@
 		}
 	}
 
-	public static class MyAbstractSequentialList extends AbstractSequentialList {
+	static class MyAbstractSequentialList extends AbstractSequentialList {
 
 		private LinkedList list = new LinkedList();
 
@@ -154,21 +154,55 @@
 		}
 	}
     
-    class MockAbstractSequentialList<E> extends AbstractSequentialList {
-        private LinkedList list = new LinkedList();
+    static class MockAbstractSequentialList<E> extends AbstractSequentialList {
 
         public ListIterator listIterator(int index) {
-            ListIterator iter = list.listIterator(index);
-            return iter;
+            return new MockListIterator();
         }
 
         @Override
         public int size() {
-            return list.size();
+            return 0;
+        }
+    }
+    
+    static class MockListIterator implements ListIterator{
+
+        public void add(Object object) {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean hasNext() {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean hasPrevious() {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object next() {
+            throw new UnsupportedOperationException();
+        }
+
+        public int nextIndex() {
+            throw new UnsupportedOperationException();
+        }
+
+        public Object previous() {
+            throw new UnsupportedOperationException();
+        }
+
+        public int previousIndex() {
+            throw new UnsupportedOperationException();
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
         }
 
-        public E remove(int location) {
+        public void set(Object object) {
             throw new UnsupportedOperationException();
         }
+        
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CalendarTest.java?rev=647063&r1=647062&r2=647063&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CalendarTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CalendarTest.java
Thu Apr 10 23:09:04 2008
@@ -500,73 +500,73 @@
         early.set(2008, 3, 20, 17, 28, 12);
         late.set(2008, 3, 20, 17, 28, 22);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
 
         // test by minute
         early.set(2008, 3, 20, 17, 18, 12);
         late.set(2008, 3, 20, 17, 28, 12);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
 
         // test by hour
         early.set(2008, 3, 20, 17, 28, 12);
         late.set(2008, 3, 20, 27, 28, 12);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
 
         // test by day
         early.set(2008, 3, 10, 17, 28, 12);
         late.set(2008, 3, 20, 17, 28, 12);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
 
         // test by month
         early.set(2008, 2, 20, 17, 28, 12);
         late.set(2008, 3, 20, 17, 28, 12);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
 
         // test by year
         early.set(2007, 3, 20, 17, 28, 12);
         late.set(2008, 3, 20, 17, 28, 12);
         // test before()
-        assertEquals("Should be equal to true.", true, early.before(late));
-        assertEquals("Should be equal to false.", false, early.before(early));
-        assertEquals("Should be equal to false.", false, late.before(early));
-        // test after();
-        assertEquals("Should be equal to true.", true, late.after(early));
-        assertEquals("Should be equal to false.", false, late.after(late));
-        assertEquals("Should be equal to false.", false, early.after(late));
+        assertTrue(early.before(late));
+        assertFalse(early.before(early));
+        assertFalse(late.before(early));
+        // test after();
+        assertTrue(late.after(early));
+        assertFalse(late.after(late));
+        assertFalse(early.after(late));
     }
 
     /**
@@ -601,16 +601,16 @@
             int index = fields[i];
             calendar.clear(index);
             if (5 == index) {
-                // RI also don't change the value of DATE
-                assertEquals("Field " + index + " Should be equal to 20.", 20,
+                // RI also doesn't change the value of DATE
+                assertEquals("Field " + index + " Should equal to 20.", 20,
                         calendar.get(index));
             } else if (11 == index) {
-                // RI also don't change the value of HOUR
-                assertEquals("Field " + index + " Should be equal to 17.", 17,
+                // RI also doesn't change the value of HOUR
+                assertEquals("Field " + index + " Should equal to 17.", 17,
                         calendar.get(index));
             } else {
                 // Other have been set to default values
-                assertEquals("Field " + index + " Should be equal to "
+                assertEquals("Field " + index + " Should equal to "
                         + defaults[i] + ".", defaults[i], calendar.get(index));
             }
         }
@@ -622,7 +622,7 @@
 
         for (int i = 0; i < fields.length; i++) {
             int index = fields[i];
-            assertEquals("Field " + index + " Should be equal to "
+            assertEquals("Field " + index + " Should equal to "
                     + defaults[i] + ".", defaults[i], calendar.get(index));
         }
     }
@@ -634,7 +634,7 @@
         Calendar calendar = Calendar.getInstance();
         calendar.clear();
         for (int i = 0; i < Calendar.FIELD_COUNT; i++) {
-            assertEquals("Should equal to be false.", false, calendar.isSet(i));
+            assertFalse(calendar.isSet(i));
         }
     }
 
@@ -651,7 +651,7 @@
                 break;
             }
         }
-        assertEquals("Should at least contain Locale.US.", true, exist);
+        assertTrue(exist);
     }
 
     /**
@@ -662,19 +662,19 @@
         // test getInstance(Locale)
         Calendar us_calendar = Calendar.getInstance(Locale.US);
         Calendar ch_calendar = Calendar.getInstance(Locale.CHINESE);
-        assertEquals("Should equal to be Sunday.", Calendar.SUNDAY, us_calendar
+        assertEquals(Calendar.SUNDAY, us_calendar
                 .getFirstDayOfWeek());
-        assertEquals("Should equal to be Monday.", Calendar.MONDAY, ch_calendar
+        assertEquals(Calendar.MONDAY, ch_calendar
                 .getFirstDayOfWeek());
 
         // test getInstance(Locale, TimeZone)
         Calendar gmt_calendar = Calendar.getInstance(TimeZone
                 .getTimeZone("GMT"), Locale.US);
-        assertEquals("Should equal to \"GMT\"", TimeZone.getTimeZone("GMT"),
+        assertEquals(TimeZone.getTimeZone("GMT"),
                 gmt_calendar.getTimeZone());
         Calendar est_calendar = Calendar.getInstance(TimeZone
                 .getTimeZone("EST"), Locale.US);
-        assertEquals("Should equal to \"EST\"", TimeZone.getTimeZone("EST")
+        assertEquals(TimeZone.getTimeZone("EST")
                 .getID(), est_calendar.getTimeZone().getID());
     }
 
@@ -684,8 +684,7 @@
     public void test_internalGet() {
         MockGregorianCalendar c = new MockGregorianCalendar();
         c.clear(Calendar.YEAR);
-        assertEquals("Should not be equal to 1970.", 0, c
-                .internal_get(Calendar.YEAR));
+        assertEquals(0, c.internal_get(Calendar.YEAR));
     }
 
     /**
@@ -693,11 +692,7 @@
      */
     public void test_hashcode() {
         Calendar calendar = Calendar.getInstance(Locale.JAPAN);
-        assertEquals("Should equal to true.", true,
-                calendar.hashCode() == calendar.hashCode());
-        Calendar en_calendar = Calendar.getInstance(Locale.ENGLISH);
-        assertEquals("Should equal to false.", false,
-                en_calendar.hashCode() == calendar.hashCode());
+        assertTrue(calendar.hashCode() == calendar.hashCode());
     }
 
     /**
@@ -709,20 +704,20 @@
 
         // roll up
         calendar.roll(Calendar.DATE, 5);
-        assertEquals("Shoule be equal to 25", 25, calendar.get(Calendar.DATE));
+        assertEquals(25, calendar.get(Calendar.DATE));
 
         // roll down
         calendar.roll(Calendar.DATE, -5);
-        assertEquals("Shoule be equal to 20", 20, calendar.get(Calendar.DATE));
+        assertEquals(20, calendar.get(Calendar.DATE));
 
         // roll 0
         calendar.roll(Calendar.DATE, 0);
-        assertEquals("Shoule be equal to 20", 20, calendar.get(Calendar.DATE));
+        assertEquals(20, calendar.get(Calendar.DATE));
 
         // roll overweight
         calendar.set(2008, 1, 31, 17, 28, 12);
         calendar.roll(Calendar.MONTH, 1);
-        assertEquals("Shoule be equal to 2", 2, calendar.get(Calendar.DATE));
+        assertEquals(2, calendar.get(Calendar.DATE));
 
     }
 
@@ -731,16 +726,12 @@
      */
     public void test_toString() {
         Calendar calendar = Calendar.getInstance();
-        assertEquals("Should be the current time with no '?' in the string.",
-                true, (calendar.toString() != null)
-                        && (calendar.toString() instanceof String)
-                        && (calendar.toString().indexOf("?") == -1));
+        //Should be the current time with no interrogation in the string.
+        assertTrue(calendar.toString() instanceof String);
+        assertEquals(-1, calendar.toString().indexOf("?"));
         calendar.clear();
-        assertEquals(
-                "Should be the empty but not null. With several '?'s in the string.",
-                true, (calendar.toString() != null)
-                        && (calendar.toString() instanceof String)
-                        && (calendar.toString().indexOf("?") != -1));
+        assertTrue(calendar.toString() instanceof String);
+        assertTrue(0 <= calendar.toString().indexOf("?"));
     }
 
     /**



Mime
View raw message