You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/04/26 09:12:49 UTC
svn commit: r397123 [7/7] - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java:
org/apache/harmony/tests/java/util/ tests/api/java/io/ tests/api/java/lang/
tests/api/java/lang/ref/ tests/api/java/lang/reflect/ tests/api/java/net/ ...
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ObservableTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ObservableTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ObservableTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ObservableTest.java Wed Apr 26 00:12:16 2006
@@ -78,7 +78,7 @@
try {
Observable ov = new Observable();
assertTrue("Wrong initial values.", !ov.hasChanged());
- assertTrue("Wrong initial values.", ov.countObservers() == 0);
+ assertEquals("Wrong initial values.", 0, ov.countObservers());
} catch (Exception e) {
fail("Exception during test : " + e.getMessage());
}
@@ -92,9 +92,9 @@
// java.util.Observable.addObserver(java.util.Observer)
TestObserver test = new TestObserver();
observable.addObserver(test);
- assertTrue("Failed to add observer", observable.countObservers() == 1);
+ assertEquals("Failed to add observer", 1, observable.countObservers());
observable.addObserver(test);
- assertTrue("Duplicate observer", observable.countObservers() == 1);
+ assertEquals("Duplicate observer", 1, observable.countObservers());
Observable o = new Observable();
try {
@@ -113,11 +113,11 @@
*/
public void test_countObservers() {
// Test for method int java.util.Observable.countObservers()
- assertTrue("New observable had > 0 observers", observable
- .countObservers() == 0);
+ assertEquals("New observable had > 0 observers", 0, observable
+ .countObservers());
observable.addObserver(new TestObserver());
- assertTrue("Observable with observer returned other than 1", observable
- .countObservers() == 1);
+ assertEquals("Observable with observer returned other than 1", 1, observable
+ .countObservers());
}
/**
@@ -128,8 +128,8 @@
// java.util.Observable.deleteObserver(java.util.Observer)
observable.addObserver(observer = new TestObserver());
observable.deleteObserver(observer);
- assertTrue("Failed to delete observer",
- observable.countObservers() == 0);
+ assertEquals("Failed to delete observer",
+ 0, observable.countObservers());
}
@@ -147,8 +147,8 @@
observable.addObserver(new TestObserver());
observable.addObserver(new TestObserver());
observable.deleteObservers();
- assertTrue("Failed to delete observers",
- observable.countObservers() == 0);
+ assertEquals("Failed to delete observers",
+ 0, observable.countObservers());
}
/**
@@ -165,12 +165,12 @@
// Test for method void java.util.Observable.notifyObservers()
observable.addObserver(observer = new TestObserver());
observable.notifyObservers();
- assertTrue("Notified when unchnaged", ((TestObserver) observer)
- .updateCount() == 0);
+ assertEquals("Notified when unchnaged", 0, ((TestObserver) observer)
+ .updateCount());
((TestObservable) observable).doChange();
observable.notifyObservers();
- assertTrue("Failed to notify",
- ((TestObserver) observer).updateCount() == 1);
+ assertEquals("Failed to notify",
+ 1, ((TestObserver) observer).updateCount());
DeleteTestObserver observer1, observer2;
observable.deleteObservers();
@@ -180,7 +180,7 @@
observable.notifyObservers();
assertTrue("Failed to notify all", observer1.updateCount() == 1
&& observer2.updateCount() == 1);
- assertTrue("Failed to delete all", observable.countObservers() == 0);
+ assertEquals("Failed to delete all", 0, observable.countObservers());
observable.addObserver(observer1 = new DeleteTestObserver(false));
observable.addObserver(observer2 = new DeleteTestObserver(false));
@@ -188,7 +188,7 @@
observable.notifyObservers();
assertTrue("Failed to notify all 2", observer1.updateCount() == 1
&& observer2.updateCount() == 1);
- assertTrue("Failed to delete all 2", observable.countObservers() == 0);
+ assertEquals("Failed to delete all 2", 0, observable.countObservers());
}
/**
@@ -200,12 +200,12 @@
Object obj;
observable.addObserver(observer = new TestObserver());
observable.notifyObservers();
- assertTrue("Notified when unchanged", ((TestObserver) observer)
- .updateCount() == 0);
+ assertEquals("Notified when unchanged", 0, ((TestObserver) observer)
+ .updateCount());
((TestObservable) observable).doChange();
observable.notifyObservers(obj = new Object());
- assertTrue("Failed to notify",
- ((TestObserver) observer).updateCount() == 1);
+ assertEquals("Failed to notify",
+ 1, ((TestObserver) observer).updateCount());
assertTrue("Failed to pass Object arg", ((TestObserver) observer).objv
.elementAt(0).equals(obj));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java Wed Apr 26 00:12:16 2006
@@ -51,8 +51,8 @@
if (System.getProperty("java.vendor") != null) {
try {
Properties p = new Properties(System.getProperties());
- assertTrue("failed to construct correct properties", p
- .getProperty("java.vendor") != null);
+ assertNotNull("failed to construct correct properties", p
+ .getProperty("java.vendor"));
} catch (Exception e) {
fail("exception occured while creating construcotr" + e);
}
@@ -66,8 +66,8 @@
public void test_getPropertyLjava_lang_String() {
// Test for method java.lang.String
// java.util.Properties.getProperty(java.lang.String)
- assertTrue("Did not retrieve property", ((String) tProps
- .getProperty("test.prop")).equals("this is a test property"));
+ assertEquals("Did not retrieve property", "this is a test property", ((String) tProps
+ .getProperty("test.prop")));
}
/**
@@ -77,10 +77,10 @@
public void test_getPropertyLjava_lang_StringLjava_lang_String() {
// Test for method java.lang.String
// java.util.Properties.getProperty(java.lang.String, java.lang.String)
- assertTrue("Did not retrieve property", ((String) tProps.getProperty(
- "test.prop", "Blarg")).equals("this is a test property"));
- assertTrue("Did not return default value", ((String) tProps
- .getProperty("notInThere.prop", "Gabba")).equals("Gabba"));
+ assertEquals("Did not retrieve property", "this is a test property", ((String) tProps.getProperty(
+ "test.prop", "Blarg")));
+ assertEquals("Did not return default value", "Gabba", ((String) tProps
+ .getProperty("notInThere.prop", "Gabba")));
}
/**
@@ -135,10 +135,10 @@
} catch (Exception e) {
fail("Exception during load test : " + e.getMessage());
}
- assertTrue("Failed to load correct properties", prop.getProperty(
- "test.pkg").equals("harmony.tests"));
- assertTrue("Load failed to parse incorrectly", prop
- .getProperty("commented.entry") == null);
+ assertEquals("Failed to load correct properties", "harmony.tests", prop.getProperty(
+ "test.pkg"));
+ assertNull("Load failed to parse incorrectly", prop
+ .getProperty("commented.entry"));
prop = new Properties();
try {
@@ -159,15 +159,15 @@
prop.load(new ByteArrayInputStream(" a= b".getBytes()));
} catch (IOException e) {
}
- assertTrue("Failed to ignore whitespace", prop.get("a").equals("b"));
+ assertEquals("Failed to ignore whitespace", "b", prop.get("a"));
prop = new Properties();
try {
prop.load(new ByteArrayInputStream(" a b".getBytes()));
} catch (IOException e) {
}
- assertTrue("Failed to interpret whitespace as =", prop.get("a").equals(
- "b"));
+ assertEquals("Failed to interpret whitespace as =",
+ "b", prop.get("a"));
prop = new Properties();
try {
@@ -175,8 +175,8 @@
.getBytes("ISO8859_1")));
} catch (IOException e) {
}
- assertTrue("Failed to parse chars >= 0x80", prop.get("a").equals(
- "\u008d\u00d3"));
+ assertEquals("Failed to parse chars >= 0x80",
+ "\u008d\u00d3", prop.get("a"));
prop = new Properties();
try {
@@ -187,8 +187,8 @@
} catch (IndexOutOfBoundsException e) {
fail("IndexOutOfBoundsException when last line is a comment with no line terminator");
}
- assertTrue("Failed to load when last line contains a comment", prop
- .get("fred").equals("1"));
+ assertEquals("Failed to load when last line contains a comment", "1", prop
+ .get("fred"));
}
/**
@@ -282,11 +282,11 @@
// java.util.Properties.setProperty(java.lang.String, java.lang.String)
Properties myProps = new Properties();
myProps.setProperty("Yoink", "Yabba");
- assertTrue("Failed to set property", myProps.getProperty("Yoink")
- .equals("Yabba"));
+ assertEquals("Failed to set property", "Yabba", myProps.getProperty("Yoink")
+ );
myProps.setProperty("Yoink", "Gab");
- assertTrue("Failed to reset property", myProps.getProperty("Yoink")
- .equals("Gab"));
+ assertEquals("Failed to reset property", "Gab", myProps.getProperty("Yoink")
+ );
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java Wed Apr 26 00:12:16 2006
@@ -63,11 +63,10 @@
public void test_getActions() {
// Test for method java.lang.String
// java.util.PropertyPermission.getActions()
- assertTrue("getActions did not return proper action", javaPP
- .getActions().equals("read"));
- assertTrue(
- "getActions did not return proper canonical representation of actions",
- userPP.getActions().equals("read,write"));
+ assertEquals("getActions did not return proper action", "read", javaPP
+ .getActions());
+ assertEquals("getActions did not return proper canonical representation of actions",
+ "read,write", userPP.getActions());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java Wed Apr 26 00:12:16 2006
@@ -44,7 +44,7 @@
keyCount++;
}
- assertTrue("Returned the wrong number of keys", keyCount == 2);
+ assertEquals("Returned the wrong number of keys", 2, keyCount);
assertTrue("Returned the wrong keys", test.contains("p1")
&& test.contains("p2"));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java Wed Apr 26 00:12:16 2006
@@ -39,27 +39,27 @@
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
- assertTrue("Wrong bundle fr_FR_VAR", bundle.getString("parent4")
- .equals("frFRVARValue4"));
+ assertEquals("Wrong bundle fr_FR_VAR", "frFRVARValue4", bundle.getString("parent4")
+ );
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "v1"));
- assertTrue("Wrong bundle fr_FR_v1", bundle.getString("parent4").equals(
- "frFRValue4"));
+ assertEquals("Wrong bundle fr_FR_v1",
+ "frFRValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "US", "VAR"));
- assertTrue("Wrong bundle fr_US_var", bundle.getString("parent4")
- .equals("frValue4"));
+ assertEquals("Wrong bundle fr_US_var", "frValue4", bundle.getString("parent4")
+ );
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "VAR"));
- assertTrue("Wrong bundle de_FR_var", bundle.getString("parent4")
- .equals("enUSValue4"));
+ assertEquals("Wrong bundle de_FR_var", "enUSValue4", bundle.getString("parent4")
+ );
Locale.setDefault(new Locale("fr", "FR", "VAR"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "v1"));
- assertTrue("Wrong bundle de_FR_var 2", bundle.getString("parent4")
- .equals("frFRVARValue4"));
+ assertEquals("Wrong bundle de_FR_var 2", "frFRVARValue4", bundle.getString("parent4")
+ );
Locale.setDefault(new Locale("de", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "var"));
- assertTrue("Wrong bundle de_FR_var 2", bundle.getString("parent4")
- .equals("parentValue4"));
+ assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4")
+ );
// Test with a security manager
Locale.setDefault(new Locale("en", "US"));
@@ -67,16 +67,16 @@
try {
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR",
"VAR"));
- assertTrue("Security: Wrong bundle fr_FR_VAR", bundle.getString(
- "parent4").equals("frFRVARValue4"));
+ assertEquals("Security: Wrong bundle fr_FR_VAR", "frFRVARValue4", bundle.getString(
+ "parent4"));
bundle = ResourceBundle.getBundle(name,
new Locale("fr", "FR", "v1"));
- assertTrue("Security: Wrong bundle fr_FR_v1", bundle.getString(
- "parent4").equals("frFRValue4"));
+ assertEquals("Security: Wrong bundle fr_FR_v1", "frFRValue4", bundle.getString(
+ "parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "US",
"VAR"));
- assertTrue("Security: Wrong bundle fr_US_var", bundle.getString(
- "parent4").equals("frValue4"));
+ assertEquals("Security: Wrong bundle fr_US_var", "frValue4", bundle.getString(
+ "parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR",
"VAR"));
assertTrue("Security: Wrong bundle de_FR_var: "
@@ -120,8 +120,8 @@
ResourceBundle bundle = ResourceBundle.getBundle(name, Locale
.getDefault());
bundle = ResourceBundle.getBundle(name, Locale.getDefault(), loader);
- assertTrue("Wrong cached value", bundle.getString("property").equals(
- "resource"));
+ assertEquals("Wrong cached value",
+ "resource", bundle.getString("property"));
}
/**
@@ -132,20 +132,20 @@
String name = "tests.support.Support_TestResource";
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
- assertTrue("Wrong value parent4", bundle.getString("parent4").equals(
- "frFRVARValue4"));
- assertTrue("Wrong value parent3", bundle.getString("parent3").equals(
- "frFRValue3"));
- assertTrue("Wrong value parent2", bundle.getString("parent2").equals(
- "frValue2"));
- assertTrue("Wrong value parent1", bundle.getString("parent1").equals(
- "parentValue1"));
- assertTrue("Wrong value child3", bundle.getString("child3").equals(
- "frFRVARChildValue3"));
- assertTrue("Wrong value child2", bundle.getString("child2").equals(
- "frFRVARChildValue2"));
- assertTrue("Wrong value child1", bundle.getString("child1").equals(
- "frFRVARChildValue1"));
+ assertEquals("Wrong value parent4",
+ "frFRVARValue4", bundle.getString("parent4"));
+ assertEquals("Wrong value parent3",
+ "frFRValue3", bundle.getString("parent3"));
+ assertEquals("Wrong value parent2",
+ "frValue2", bundle.getString("parent2"));
+ assertEquals("Wrong value parent1",
+ "parentValue1", bundle.getString("parent1"));
+ assertEquals("Wrong value child3",
+ "frFRVARChildValue3", bundle.getString("child3"));
+ assertEquals("Wrong value child2",
+ "frFRVARChildValue2", bundle.getString("child2"));
+ assertEquals("Wrong value child1",
+ "frFRVARChildValue1", bundle.getString("child1"));
}
protected void setUp() {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java Wed Apr 26 00:12:16 2006
@@ -34,7 +34,7 @@
// Test for method java.util.SimpleTimeZone(int, java.lang.String)
SimpleTimeZone st = new SimpleTimeZone(1000, "TEST");
- assertTrue("Incorrect TZ constructed", st.getID().equals("TEST"));
+ assertEquals("Incorrect TZ constructed", "TEST", st.getID());
assertTrue("Incorrect TZ constructed: " + "returned wrong offset", st
.getRawOffset() == 1000);
assertTrue("Incorrect TZ constructed" + "using daylight savings", !st
@@ -57,8 +57,8 @@
assertTrue("Incorrect TZ constructed", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
- assertTrue("Incorrect TZ constructed", st.getID().equals("TEST"));
- assertTrue("Incorrect TZ constructed", st.getRawOffset() == 1000);
+ assertEquals("Incorrect TZ constructed", "TEST", st.getID());
+ assertEquals("Incorrect TZ constructed", 1000, st.getRawOffset());
assertTrue("Incorrect TZ constructed", st.useDaylightTime());
}
@@ -78,8 +78,8 @@
assertTrue("Incorrect TZ constructed", !(st
.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER,
13).getTime())));
- assertTrue("Incorrect TZ constructed", st.getID().equals("TEST"));
- assertTrue("Incorrect TZ constructed", st.getRawOffset() == 1000);
+ assertEquals("Incorrect TZ constructed", "TEST", st.getID());
+ assertEquals("Incorrect TZ constructed", 1000, st.getRawOffset());
assertTrue("Incorrect TZ constructed", st.useDaylightTime());
assertTrue("Incorrect TZ constructed",
st.getDSTSavings() == 1000 * 60 * 60);
@@ -135,18 +135,18 @@
// Test for method int java.util.SimpleTimeZone.getDSTSavings()
st1 = new SimpleTimeZone(0, "TEST");
- assertTrue("Non-zero default daylight savings",
- st1.getDSTSavings() == 0);
+ assertEquals("Non-zero default daylight savings",
+ 0, st1.getDSTSavings());
st1.setStartRule(0, 1, 1, 1);
st1.setEndRule(11, 1, 1, 1);
- assertTrue("Incorrect default daylight savings",
- st1.getDSTSavings() == 3600000);
+ assertEquals("Incorrect default daylight savings",
+ 3600000, st1.getDSTSavings());
st1 = new SimpleTimeZone(-5 * 3600000, "EST", Calendar.APRIL, 1,
-Calendar.SUNDAY, 2 * 3600000, Calendar.OCTOBER, -1,
Calendar.SUNDAY, 2 * 3600000, 7200000);
- assertTrue("Incorrect daylight savings from constructor", st1
- .getDSTSavings() == 7200000);
+ assertEquals("Incorrect daylight savings from constructor", 7200000, st1
+ .getDSTSavings());
}
@@ -258,7 +258,7 @@
st.setStartRule(0, 1, 1, 1);
st.setEndRule(11, 1, 1, 1);
st.setDSTSavings(1);
- assertTrue("Daylight savings amount not set", st.getDSTSavings() == 1);
+ assertEquals("Daylight savings amount not set", 1, st.getDSTSavings());
}
/**
@@ -423,7 +423,7 @@
public void test_toString() {
// Test for method java.lang.String java.util.SimpleTimeZone.toString()
String string = TimeZone.getTimeZone("EST").toString();
- assertTrue("toString() returned null", string != null);
+ assertNotNull("toString() returned null", string);
assertTrue("toString() is empty", string.length() != 0);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StackTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StackTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StackTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StackTest.java Wed Apr 26 00:12:16 2006
@@ -27,7 +27,7 @@
*/
public void test_Constructor() {
// Test for method java.util.Stack()
- assertTrue("Stack creation failed", s.size() == 0);
+ assertEquals("Stack creation failed", 0, s.size());
}
/**
@@ -63,8 +63,8 @@
s.pop();
assertTrue("Peek did not return top item after a pop", s.pop() == item2);
s.push(null);
- assertTrue("Peek did not return top item (wanted: null)",
- s.peek() == null);
+ assertNull("Peek did not return top item (wanted: null)",
+ s.peek());
}
/**
@@ -97,7 +97,7 @@
s.push(null);
try {
lastPopped = s.pop();
- assertTrue("c) Pop did not return top item", lastPopped == null);
+ assertNull("c) Pop did not return top item", lastPopped);
} catch (EmptyStackException e) {
fail(
"c) Pop threw EmptyStackException when stack should not have been empty");
@@ -133,29 +133,25 @@
s.push(item1);
s.push(item2);
s.push(item3);
- assertTrue("Search returned incorrect value for equivalent object", s
- .search(item1) == 3);
- assertTrue("Search returned incorrect value for equal object", s
- .search("Ichi") == 3);
+ assertEquals("Search returned incorrect value for equivalent object", 3, s
+ .search(item1));
+ assertEquals("Search returned incorrect value for equal object", 3, s
+ .search("Ichi"));
s.pop();
- assertTrue(
- "Search returned incorrect value for equivalent object at top of stack",
- s.search(item2) == 1);
- assertTrue(
- "Search returned incorrect value for equal object at top of stack",
- s.search("Ni") == 1);
+ assertEquals("Search returned incorrect value for equivalent object at top of stack",
+ 1, s.search(item2));
+ assertEquals("Search returned incorrect value for equal object at top of stack",
+ 1, s.search("Ni"));
s.push(null);
- assertTrue(
- "Search returned incorrect value for search for null at top of stack",
- s.search(null) == 1);
+ assertEquals("Search returned incorrect value for search for null at top of stack",
+ 1, s.search(null));
s.push("Shi");
- assertTrue("Search returned incorrect value for search for null", s
- .search(null) == 2);
+ assertEquals("Search returned incorrect value for search for null", 2, s
+ .search(null));
s.pop();
s.pop();
- assertTrue(
- "Search returned incorrect value for search for null--wanted -1",
- s.search(null) == -1);
+ assertEquals("Search returned incorrect value for search for null--wanted -1",
+ -1, s.search(null));
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java Wed Apr 26 00:12:16 2006
@@ -61,7 +61,7 @@
// Test for method int java.util.StringTokenizer.countTokens()
StringTokenizer st = new StringTokenizer("This is a test String");
- assertTrue("Incorrect token count returned", st.countTokens() == 5);
+ assertEquals("Incorrect token count returned", 5, st.countTokens());
}
/**
@@ -105,16 +105,16 @@
// Test for method java.lang.Object
// java.util.StringTokenizer.nextElement()
StringTokenizer st = new StringTokenizer("This is a test String");
- assertTrue("nextElement returned incorrect value", ((String) st
- .nextElement()).equals("This"));
- assertTrue("nextElement returned incorrect value", ((String) st
- .nextElement()).equals("is"));
- assertTrue("nextElement returned incorrect value", ((String) st
- .nextElement()).equals("a"));
- assertTrue("nextElement returned incorrect value", ((String) st
- .nextElement()).equals("test"));
- assertTrue("nextElement returned incorrect value", ((String) st
- .nextElement()).equals("String"));
+ assertEquals("nextElement returned incorrect value", "This", ((String) st
+ .nextElement()));
+ assertEquals("nextElement returned incorrect value", "is", ((String) st
+ .nextElement()));
+ assertEquals("nextElement returned incorrect value", "a", ((String) st
+ .nextElement()));
+ assertEquals("nextElement returned incorrect value", "test", ((String) st
+ .nextElement()));
+ assertEquals("nextElement returned incorrect value", "String", ((String) st
+ .nextElement()));
try {
st.nextElement();
fail(
@@ -131,16 +131,16 @@
// Test for method java.lang.String
// java.util.StringTokenizer.nextToken()
StringTokenizer st = new StringTokenizer("This is a test String");
- assertTrue("nextToken returned incorrect value", st.nextToken().equals(
- "This"));
- assertTrue("nextToken returned incorrect value", st.nextToken().equals(
- "is"));
- assertTrue("nextToken returned incorrect value", st.nextToken().equals(
- "a"));
- assertTrue("nextToken returned incorrect value", st.nextToken().equals(
- "test"));
- assertTrue("nextToken returned incorrect value", st.nextToken().equals(
- "String"));
+ assertEquals("nextToken returned incorrect value",
+ "This", st.nextToken());
+ assertEquals("nextToken returned incorrect value",
+ "is", st.nextToken());
+ assertEquals("nextToken returned incorrect value",
+ "a", st.nextToken());
+ assertEquals("nextToken returned incorrect value",
+ "test", st.nextToken());
+ assertEquals("nextToken returned incorrect value",
+ "String", st.nextToken());
try {
st.nextToken();
fail(
@@ -157,15 +157,12 @@
// Test for method java.lang.String
// java.util.StringTokenizer.nextToken(java.lang.String)
StringTokenizer st = new StringTokenizer("This is a test String");
- assertTrue(
- "nextToken(String) returned incorrect value with normal token String",
- st.nextToken(" ").equals("This"));
- assertTrue(
- "nextToken(String) returned incorrect value with custom token String",
- st.nextToken("tr").equals(" is a "));
- assertTrue(
- "calling nextToken() did not use the new default delimiter list",
- st.nextToken().equals("es"));
+ assertEquals("nextToken(String) returned incorrect value with normal token String",
+ "This", st.nextToken(" "));
+ assertEquals("nextToken(String) returned incorrect value with custom token String",
+ " is a ", st.nextToken("tr"));
+ assertEquals("calling nextToken() did not use the new default delimiter list",
+ "es", st.nextToken());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java Wed Apr 26 00:12:16 2006
@@ -103,9 +103,8 @@
Thread.sleep(500);
} catch (InterruptedException e) {
}
- assertTrue(
- "TimerTask.run() method should not be called after cancel()",
- testTask.wasRun() == 0);
+ assertEquals("TimerTask.run() method should not be called after cancel()",
+ 0, testTask.wasRun());
t.cancel();
// Ensure cancelling a task which has already run returns true
@@ -274,8 +273,8 @@
Thread.sleep(200);
} catch (InterruptedException e) {
}
- assertTrue("TimerTask.run() method should not have been called",
- testTask.wasRun() == 0);
+ assertEquals("TimerTask.run() method should not have been called",
+ 0, testTask.wasRun());
// Ensure a task is run
t = new Timer();
@@ -285,8 +284,8 @@
Thread.sleep(400);
} catch (InterruptedException e) {
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
// Ensure a repeated execution task does just that
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TimerTest.java Wed Apr 26 00:12:16 2006
@@ -103,8 +103,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
} finally {
if (t != null)
@@ -129,8 +129,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
} finally {
if (t != null)
@@ -169,8 +169,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
synchronized (sync) {
try {
@@ -178,9 +178,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue(
- "TimerTask.run() method should not have been called after cancel",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method should not have been called after cancel",
+ 1, testTask.wasRun());
// Ensure you can call cancel more than once
t = new Timer();
@@ -192,8 +191,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
t.cancel();
t.cancel();
@@ -203,9 +202,8 @@
} catch (InterruptedException e) {
}
}
- assertTrue(
- "TimerTask.run() method should not have been called after cancel",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method should not have been called after cancel",
+ 1, testTask.wasRun());
// Ensure that a call to cancel from within a timer ensures no more
// run
@@ -345,8 +343,8 @@
Thread.sleep(400);
} catch (InterruptedException e) {
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
// Ensure multiple tasks are run
@@ -467,8 +465,8 @@
Thread.sleep(400);
} catch (InterruptedException e) {
}
- assertTrue("TimerTask.run() method not called after 200ms",
- testTask.wasRun() == 1);
+ assertEquals("TimerTask.run() method not called after 200ms",
+ 1, testTask.wasRun());
t.cancel();
// Ensure multiple tasks are run
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java Wed Apr 26 00:12:16 2006
@@ -27,9 +27,9 @@
try {
throw new TooManyListenersException();
} catch (TooManyListenersException e) {
- assertTrue(
+ assertNull(
"Message thrown with exception constructed with no message",
- e.getMessage() == null);
+ e.getMessage());
}
}
@@ -41,8 +41,8 @@
try {
throw new TooManyListenersException("Gah");
} catch (TooManyListenersException e) {
- assertTrue("Incorrect message thrown with exception", e
- .getMessage().equals("Gah"));
+ assertEquals("Incorrect message thrown with exception", "Gah", e
+ .getMessage());
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java Wed Apr 26 00:12:16 2006
@@ -109,7 +109,7 @@
public void test_clear() {
// Test for method void java.util.TreeMap.clear()
tm.clear();
- assertTrue("Cleared map returned non-zero size", tm.size() == 0);
+ assertEquals("Cleared map returned non-zero size", 0, tm.size());
}
/**
@@ -132,23 +132,23 @@
// get the keySet() and values() on the original Map
Set keys = map.keySet();
Collection values = map.values();
- assertTrue("values() does not work", values.iterator().next().equals(
- "value"));
- assertTrue("keySet() does not work", keys.iterator().next().equals(
- "key"));
+ 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
- assertTrue("values() was not cloned", values2.iterator().next().equals(
- "value2"));
+ 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);
- assertTrue("keySet() was not cloned", key2.iterator().next().equals(
- "key2"));
+ assertEquals("keySet() was not cloned",
+ "key2", key2.iterator().next());
}
/**
@@ -212,7 +212,7 @@
*/
public void test_firstKey() {
// Test for method java.lang.Object java.util.TreeMap.firstKey()
- assertTrue("Returned incorrect first key", tm.firstKey().equals("0"));
+ assertEquals("Returned incorrect first key", "0", tm.firstKey());
}
/**
@@ -234,7 +234,7 @@
// Test for method java.util.SortedMap
// java.util.TreeMap.headMap(java.lang.Object)
Map head = tm.headMap("100");
- assertTrue("Returned map of incorrect size", head.size() == 3);
+ assertEquals("Returned map of incorrect size", 3, head.size());
assertTrue("Returned incorrect elements", head.containsKey("0")
&& head.containsValue(new Integer("1"))
&& head.containsKey("10"));
@@ -303,7 +303,7 @@
*/
public void test_size() {
// Test for method int java.util.TreeMap.size()
- assertTrue("Returned incorrect size", tm.size() == 1000);
+ assertEquals("Returned incorrect size", 1000, tm.size());
}
/**
@@ -314,7 +314,7 @@
// java.util.TreeMap.subMap(java.lang.Object, java.lang.Object)
SortedMap subMap = tm.subMap(objArray[100].toString(), objArray[109]
.toString());
- assertTrue("subMap is of incorrect size", subMap.size() == 9);
+ assertEquals("subMap is of incorrect size", 9, subMap.size());
for (int counter = 100; counter < 109; counter++)
assertTrue("SubMap contains incorrect elements", subMap.get(
objArray[counter].toString()).equals(objArray[counter]));
@@ -326,9 +326,8 @@
} catch (IllegalArgumentException e) {
result = 1;
}
- assertTrue(
- "end key less than start key should throw IllegalArgumentException",
- result == 1);
+ assertEquals("end key less than start key should throw IllegalArgumentException",
+ 1, result);
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java Wed Apr 26 00:12:16 2006
@@ -131,7 +131,7 @@
public void test_clear() {
// Test for method void java.util.TreeSet.clear()
ts.clear();
- assertTrue("Returned non-zero size after clear", ts.size() == 0);
+ assertEquals("Returned non-zero size after clear", 0, ts.size());
assertTrue("Found element in cleared set", !ts.contains(objArray[0]));
}
@@ -193,7 +193,7 @@
// Test for method java.util.SortedSet
// java.util.TreeSet.headSet(java.lang.Object)
Set s = ts.headSet(new Integer(100));
- assertTrue("Returned set of incorrect size", s.size() == 100);
+ assertEquals("Returned set of incorrect size", 100, s.size());
for (int i = 0; i < 100; i++)
assertTrue("Returned incorrect set", s.contains(objArray[i]));
}
@@ -218,7 +218,7 @@
Set as = new HashSet(Arrays.asList(objArray));
while (i.hasNext())
as.remove(i.next());
- assertTrue("Returned incorrect iterator", as.size() == 0);
+ assertEquals("Returned incorrect iterator", 0, as.size());
}
@@ -279,7 +279,7 @@
} catch (IllegalArgumentException e) {
result = 1;
}
- assertTrue("end less than start should throw", result == 1);
+ assertEquals("end less than start should throw", 1, result);
}
/**
@@ -289,7 +289,7 @@
// Test for method java.util.SortedSet
// java.util.TreeSet.tailSet(java.lang.Object)
Set s = ts.tailSet(new Integer(900));
- assertTrue("Returned set of incorrect size", s.size() == 100);
+ assertEquals("Returned set of incorrect size", 100, s.size());
for (int i = 900; i < objArray.length; i++)
assertTrue("Returned incorrect set", s.contains(objArray[i]));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/VectorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/VectorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/VectorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/VectorTest.java Wed Apr 26 00:12:16 2006
@@ -51,8 +51,8 @@
new Support_ListTest("", tv.subList(50, 150)).runTest();
Vector v = new Vector();
- assertTrue("Vector creation failed", v.size() == 0);
- assertTrue("Wrong capacity", v.capacity() == 10);
+ assertEquals("Vector creation failed", 0, v.size());
+ assertEquals("Wrong capacity", 10, v.capacity());
}
/**
@@ -62,8 +62,8 @@
// Test for method java.util.Vector(int)
Vector v = new Vector(100);
- assertTrue("Vector creation failed", v.size() == 0);
- assertTrue("Wrong capacity", v.capacity() == 100);
+ assertEquals("Vector creation failed", 0, v.size());
+ assertEquals("Wrong capacity", 100, v.capacity());
}
/**
@@ -77,16 +77,16 @@
v.addElement(new Object());
v.addElement(new Object());
- assertTrue("Failed to inc capacity by proper amount",
- v.capacity() == 12);
+ assertEquals("Failed to inc capacity by proper amount",
+ 12, v.capacity());
Vector grow = new Vector(3, -1);
grow.addElement("one");
grow.addElement("two");
grow.addElement("three");
grow.addElement("four");
- assertTrue("Wrong size", grow.size() == 4);
- assertTrue("Wrong capacity", grow.capacity() == 6);
+ assertEquals("Wrong size", 4, grow.size());
+ assertEquals("Wrong capacity", 6, grow.capacity());
}
/**
@@ -115,14 +115,14 @@
tVector.add(45, o);
assertTrue("Failed to add Object", tVector.get(45) == o);
assertTrue("Failed to fix-up existing indices", tVector.get(46) == prev);
- assertTrue("Wrong size after add", tVector.size() == 101);
+ assertEquals("Wrong size after add", 101, tVector.size());
prev = tVector.get(50);
tVector.add(50, null);
- assertTrue("Failed to add null", tVector.get(50) == null);
+ assertNull("Failed to add null", tVector.get(50));
assertTrue("Failed to fix-up existing indices after adding null",
tVector.get(51) == prev);
- assertTrue("Wrong size after add", tVector.size() == 102);
+ assertEquals("Wrong size after add", 102, tVector.size());
}
/**
@@ -133,11 +133,11 @@
Object o = new Object();
tVector.add(o);
assertTrue("Failed to add Object", tVector.lastElement() == o);
- assertTrue("Wrong size after add", tVector.size() == 101);
+ assertEquals("Wrong size after add", 101, tVector.size());
tVector.add(null);
- assertTrue("Failed to add null", tVector.lastElement() == null);
- assertTrue("Wrong size after add", tVector.size() == 102);
+ assertNull("Failed to add null", tVector.lastElement());
+ assertEquals("Wrong size after add", 102, tVector.size());
}
/**
@@ -170,12 +170,12 @@
l.add("gah");
l.add(null);
tVector.addAll(50, l);
- assertTrue("Wrong element at position 50--wanted null",
- tVector.get(50) == null);
- assertTrue("Wrong element at position 51--wanted 'gah'", tVector
- .get(51).equals("gah"));
- assertTrue("Wrong element at position 52--wanted null",
- tVector.get(52) == null);
+ assertNull("Wrong element at position 50--wanted null",
+ tVector.get(50));
+ assertEquals("Wrong element at position 51--wanted 'gah'", "gah", tVector
+ .get(51));
+ assertNull("Wrong element at position 52--wanted null",
+ tVector.get(52));
}
/**
@@ -201,12 +201,12 @@
l.add("gah");
l.add(null);
tVector.addAll(l);
- assertTrue("Wrong element at 3rd last position--wanted null", tVector
- .get(vSize) == null);
- assertTrue("Wrong element at 2nd last position--wanted 'gah'", tVector
- .get(vSize + 1).equals("gah"));
- assertTrue("Wrong element at last position--wanted null", tVector
- .get(vSize + 2) == null);
+ assertNull("Wrong element at 3rd last position--wanted null", tVector
+ .get(vSize));
+ assertEquals("Wrong element at 2nd last position--wanted 'gah'", "gah", tVector
+ .get(vSize + 1));
+ assertNull("Wrong element at last position--wanted null", tVector
+ .get(vSize + 2));
}
/**
@@ -217,11 +217,11 @@
Vector v = vectorClone(tVector);
v.addElement("Added Element");
assertTrue("Failed to add element", v.contains("Added Element"));
- assertTrue("Added Element to wrong slot", ((String) v.elementAt(100))
- .equals("Added Element"));
+ assertEquals("Added Element to wrong slot", "Added Element", ((String) v.elementAt(100))
+ );
v.addElement(null);
assertTrue("Failed to add null", v.contains(null));
- assertTrue("Added null to wrong slot", v.elementAt(101) == null);
+ assertNull("Added null to wrong slot", v.elementAt(101));
}
/**
@@ -232,11 +232,11 @@
Vector v = vectorClone(tVector);
v.addElement("Added Element");
assertTrue("Failed to add element", v.contains("Added Element"));
- assertTrue("Added Element to wrong slot", ((String) v.elementAt(100))
- .equals("Added Element"));
+ assertEquals("Added Element to wrong slot", "Added Element", ((String) v.elementAt(100))
+ );
v.addElement(null);
assertTrue("Failed to add null", v.contains(null));
- assertTrue("Added null to wrong slot", v.elementAt(101) == null);
+ assertNull("Added null to wrong slot", v.elementAt(101));
}
/**
@@ -246,7 +246,7 @@
// Test for method int java.util.Vector.capacity()
Vector v = new Vector(9);
- assertTrue("Incorrect capacity returned", v.capacity() == 9);
+ assertEquals("Incorrect capacity returned", 9, v.capacity());
}
/**
@@ -256,7 +256,7 @@
// Test for method void java.util.Vector.clear()
Vector orgVector = vectorClone(tVector);
tVector.clear();
- assertTrue("a) Cleared Vector has non-zero size", tVector.size() == 0);
+ assertEquals("a) Cleared Vector has non-zero size", 0, tVector.size());
Enumeration e = orgVector.elements();
while (e.hasMoreElements())
assertTrue("a) Cleared vector contained elements", !tVector
@@ -264,7 +264,7 @@
tVector.add(null);
tVector.clear();
- assertTrue("b) Cleared Vector has non-zero size", tVector.size() == 0);
+ assertEquals("b) Cleared Vector has non-zero size", 0, tVector.size());
e = orgVector.elements();
while (e.hasMoreElements())
assertTrue("b) Cleared vector contained elements", !tVector
@@ -350,11 +350,11 @@
*/
public void test_elementAtI() {
// Test for method java.lang.Object java.util.Vector.elementAt(int)
- assertTrue("Incorrect element returned", ((String) tVector
- .elementAt(18)).equals("Test 18"));
+ assertEquals("Incorrect element returned", "Test 18", ((String) tVector
+ .elementAt(18)));
tVector.setElementAt(null, 20);
- assertTrue("Incorrect element returned--wanted null", tVector
- .elementAt(20) == null);
+ assertNull("Incorrect element returned--wanted null", tVector
+ .elementAt(20));
}
@@ -413,10 +413,10 @@
Vector v = new Vector(9);
v.ensureCapacity(20);
- assertTrue("ensureCapacity failed to set correct capacity", v
- .capacity() == 20);
+ assertEquals("ensureCapacity failed to set correct capacity", 20, v
+ .capacity());
v = new Vector(100);
- assertTrue("ensureCapacity reduced capacity", v.capacity() == 100);
+ assertEquals("ensureCapacity reduced capacity", 100, v.capacity());
}
/**
@@ -441,11 +441,11 @@
*/
public void test_firstElement() {
// Test for method java.lang.Object java.util.Vector.firstElement()
- assertTrue("Returned incorrect firstElement", tVector.firstElement()
- .equals("Test 0"));
+ assertEquals("Returned incorrect firstElement", "Test 0", tVector.firstElement()
+ );
tVector.insertElementAt(null, 0);
- assertTrue("Returned incorrect firstElement--wanted null", tVector
- .firstElement() == null);
+ assertNull("Returned incorrect firstElement--wanted null", tVector
+ .firstElement());
}
/**
@@ -453,11 +453,11 @@
*/
public void test_getI() {
// Test for method java.lang.Object java.util.Vector.get(int)
- assertTrue("Get returned incorrect object", tVector.get(80).equals(
- "Test 80"));
+ assertEquals("Get returned incorrect object",
+ "Test 80", tVector.get(80));
tVector.add(25, null);
- assertTrue("Returned incorrect element--wanted null",
- tVector.get(25) == null);
+ assertNull("Returned incorrect element--wanted null",
+ tVector.get(25));
}
/**
@@ -480,9 +480,9 @@
*/
public void test_indexOfLjava_lang_Object() {
// Test for method int java.util.Vector.indexOf(java.lang.Object)
- assertTrue("Incorrect index returned", tVector.indexOf("Test 10") == 10);
- assertTrue("Index returned for invalid Object", tVector
- .indexOf("XXXXXXXXXXX") == -1);
+ assertEquals("Incorrect index returned", 10, tVector.indexOf("Test 10"));
+ assertEquals("Index returned for invalid Object", -1, tVector
+ .indexOf("XXXXXXXXXXX"));
tVector.setElementAt(null, 20);
tVector.setElementAt(null, 40);
assertTrue("Incorrect indexOf returned for null: "
@@ -516,12 +516,12 @@
Vector v = vectorClone(tVector);
String prevElement = (String) v.elementAt(99);
v.insertElementAt("Inserted Element", 99);
- assertTrue("Element not inserted", ((String) v.elementAt(99))
- .equals("Inserted Element"));
+ assertEquals("Element not inserted", "Inserted Element", ((String) v.elementAt(99))
+ );
assertTrue("Elements shifted incorrectly", ((String) v.elementAt(100))
.equals(prevElement));
v.insertElementAt(null, 20);
- assertTrue("null not inserted", v.elementAt(20) == null);
+ assertNull("null not inserted", v.elementAt(20));
}
/**
@@ -571,11 +571,11 @@
*/
public void test_lastElement() {
// Test for method java.lang.Object java.util.Vector.lastElement()
- assertTrue("Incorrect last element returned", tVector.lastElement()
- .equals("Test 99"));
+ assertEquals("Incorrect last element returned", "Test 99", tVector.lastElement()
+ );
tVector.addElement(null);
- assertTrue("Incorrect last element returned--wanted null", tVector
- .lastElement() == null);
+ assertNull("Incorrect last element returned--wanted null", tVector
+ .lastElement());
}
/**
@@ -587,7 +587,7 @@
for (int i = 0; i < 9; i++)
v.addElement("Test");
v.addElement("z");
- assertTrue("Failed to return correct index", v.lastIndexOf("Test") == 8);
+ assertEquals("Failed to return correct index", 8, v.lastIndexOf("Test"));
tVector.setElementAt(null, 20);
tVector.setElementAt(null, 40);
assertTrue("Incorrect lastIndexOf returned for null: "
@@ -600,8 +600,8 @@
public void test_lastIndexOfLjava_lang_ObjectI() {
// Test for method int java.util.Vector.lastIndexOf(java.lang.Object,
// int)
- assertTrue("Failed to find object",
- tVector.lastIndexOf("Test 0", 0) == 0);
+ assertEquals("Failed to find object",
+ 0, tVector.lastIndexOf("Test 0", 0));
assertTrue("Found Object outside of index", (tVector.lastIndexOf(
"Test 0", 10) > -1));
tVector.setElementAt(null, 20);
@@ -623,15 +623,15 @@
tVector.remove(36);
assertTrue("Contained element after remove", !tVector
.contains("Test 36"));
- assertTrue("Failed to decrement size after remove",
- tVector.size() == 99);
+ assertEquals("Failed to decrement size after remove",
+ 99, tVector.size());
tVector.add(20, null);
tVector.remove(19);
- assertTrue("Didn't move null element over", tVector.get(19) == null);
+ assertNull("Didn't move null element over", tVector.get(19));
tVector.remove(19);
- assertTrue("Didn't remove null element", tVector.get(19) != null);
- assertTrue("Failed to decrement size after removing null", tVector
- .size() == 98);
+ assertNotNull("Didn't remove null element", tVector.get(19));
+ assertEquals("Failed to decrement size after removing null", 98, tVector
+ .size());
}
/**
@@ -642,13 +642,13 @@
tVector.remove("Test 0");
assertTrue("Contained element after remove", !tVector
.contains("Test 0"));
- assertTrue("Failed to decrement size after remove",
- tVector.size() == 99);
+ assertEquals("Failed to decrement size after remove",
+ 99, tVector.size());
tVector.add(null);
tVector.remove(null);
assertTrue("Contained null after remove", !tVector.contains(null));
- assertTrue("Failed to decrement size after removing null", tVector
- .size() == 99);
+ assertEquals("Failed to decrement size after removing null", 99, tVector
+ .size());
}
/**
@@ -675,12 +675,12 @@
v.add(null);
v.add("Boom");
v.removeAll(s);
- assertTrue("Should not have removed any elements", v.size() == 3);
+ assertEquals("Should not have removed any elements", 3, v.size());
l = new LinkedList();
l.add(null);
v.removeAll(l);
- assertTrue("Should only have one element", v.size() == 1);
- assertTrue("Element should be 'Boom'", v.firstElement().equals("Boom"));
+ assertEquals("Should only have one element", 1, v.size());
+ assertEquals("Element should be 'Boom'", "Boom", v.firstElement());
}
/**
@@ -690,7 +690,7 @@
// Test for method void java.util.Vector.removeAllElements()
Vector v = vectorClone(tVector);
v.removeAllElements();
- assertTrue("Failed to remove all elements", v.size() == 0);
+ assertEquals("Failed to remove all elements", 0, v.size());
}
/**
@@ -701,8 +701,8 @@
// java.util.Vector.removeElement(java.lang.Object)
Vector v = vectorClone(tVector);
v.removeElement("Test 98");
- assertTrue("Element not removed", ((String) v.elementAt(98))
- .equals("Test 99"));
+ assertEquals("Element not removed", "Test 99", ((String) v.elementAt(98))
+ );
assertTrue("Vector is wrong size after removal: " + v.size(),
v.size() == 99);
tVector.addElement(null);
@@ -718,11 +718,11 @@
// Test for method void java.util.Vector.removeElementAt(int)
Vector v = vectorClone(tVector);
v.removeElementAt(50);
- assertTrue("Failed to remove element", v.indexOf("Test 50", 0) == -1);
+ assertEquals("Failed to remove element", -1, v.indexOf("Test 50", 0));
tVector.insertElementAt(null, 60);
tVector.removeElementAt(60);
- assertTrue("Element at 60 should not be null after removal", tVector
- .elementAt(60) != null);
+ assertNotNull("Element at 60 should not be null after removal", tVector
+ .elementAt(60));
}
/**
@@ -760,8 +760,8 @@
// int)
Vector v = vectorClone(tVector);
v.setElementAt("Inserted Element", 99);
- assertTrue("Element not set", ((String) v.elementAt(99))
- .equals("Inserted Element"));
+ assertEquals("Element not set", "Inserted Element", ((String) v.elementAt(99))
+ );
}
/**
@@ -771,7 +771,7 @@
// Test for method void java.util.Vector.setSize(int)
Vector v = vectorClone(tVector);
v.setSize(10);
- assertTrue("Failed to set size", v.size() == 10);
+ assertEquals("Failed to set size", 10, v.size());
}
/**
@@ -779,7 +779,7 @@
*/
public void test_size() {
// Test for method int java.util.Vector.size()
- assertTrue("Returned incorrect size", tVector.size() == 100);
+ assertEquals("Returned incorrect size", 100, tVector.size());
final Vector v = new Vector();
v.addElement("initial");
@@ -814,13 +814,13 @@
public void test_subListII() {
// Test for method java.util.List java.util.Vector.subList(int, int)
List sl = tVector.subList(10, 25);
- assertTrue("Returned sublist of incorrect size", sl.size() == 15);
+ assertEquals("Returned sublist of incorrect size", 15, sl.size());
for (int i = 10; i < 25; i++)
assertTrue("Returned incorrect sublist", sl
.contains(tVector.get(i)));
- assertTrue("Not synchronized random access", sl.getClass().getName()
- .equals("java.util.Collections$SynchronizedRandomAccessList"));
+ assertEquals("Not synchronized random access", "java.util.Collections$SynchronizedRandomAccessList", sl.getClass().getName()
+ );
}
@@ -844,7 +844,7 @@
for (int i = 0; i < o.length; i++)
o[i] = f;
tVector.toArray(o);
- assertTrue("Failed to set slot to null", o[100] == null);
+ assertNull("Failed to set slot to null", o[100]);
for (int i = 0; i < tVector.size(); i++)
assertTrue("Returned incorrect array", tVector.elementAt(i) == o[i]);
}
@@ -875,7 +875,7 @@
Vector v = new Vector(10);
v.addElement(new Object());
v.trimToSize();
- assertTrue("Failed to trim capacity", v.capacity() == 1);
+ assertEquals("Failed to trim capacity", 1, v.capacity());
}
protected Vector vectorClone(Vector s) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java Wed Apr 26 00:12:16 2006
@@ -62,7 +62,7 @@
whm.get(keyArray[i]) == valueArray[i]);
WeakHashMap empty = new WeakHashMap(0);
- assertTrue("Empty weakhashmap access", empty.get("nothing") == null);
+ assertNull("Empty weakhashmap access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -80,7 +80,7 @@
whm.get(keyArray[i]) == valueArray[i]);
WeakHashMap empty = new WeakHashMap(0, 0.75f);
- assertTrue("Empty hashtable access", empty.get("nothing") == null);
+ assertNull("Empty hashtable access", empty.get("nothing"));
empty.put("something", "here");
assertTrue("cannot get element", empty.get("something") == "here");
}
@@ -96,8 +96,8 @@
whm.clear();
assertTrue("Cleared map should be empty", whm.isEmpty());
for (int i = 0; i < 100; i++)
- assertTrue("Cleared map should only return null", whm
- .get(keyArray[i]) == null);
+ assertNull("Cleared map should only return null", whm
+ .get(keyArray[i]));
}
@@ -203,7 +203,7 @@
System.gc();
System.runFinalization();
map.remove("nothing"); // Cause objects in queue to be removed
- assertTrue("null key was removed", map.size() == 1);
+ assertEquals("null key was removed", 1, map.size());
}
/**
@@ -218,9 +218,9 @@
assertTrue("Remove returned incorrect value",
whm.remove(keyArray[25]) == valueArray[25]);
- assertTrue("Remove returned incorrect value",
- whm.remove(keyArray[25]) == null);
- assertTrue("Size should be 99 after remove", whm.size() == 99);
+ assertNull("Remove returned incorrect value",
+ whm.remove(keyArray[25]));
+ assertEquals("Size should be 99 after remove", 99, whm.size());
}
/**