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 [4/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/lang/StringBufferTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java Wed Apr 26 00:12:16 2006
@@ -34,8 +34,8 @@
public void test_ConstructorI() {
// Test for method java.lang.StringBuffer(int)
StringBuffer sb = new StringBuffer(8);
- assertTrue("Newly constructed buffer is of incorrect length", sb
- .length() == 0);
+ assertEquals("Newly constructed buffer is of incorrect length", 0, sb
+ .length());
}
/**
@@ -67,8 +67,8 @@
char buf[] = new char[4];
"char".getChars(0, 4, buf, 0);
testBuffer.append(buf);
- assertTrue("Append of char[] failed", testBuffer.toString().equals(
- "This is a test bufferchar"));
+ assertEquals("Append of char[] failed",
+ "This is a test bufferchar", testBuffer.toString());
}
/**
@@ -81,9 +81,9 @@
char[] buf1 = { 'H', 'e', 'l', 'l', 'o' };
char[] buf2 = { 'W', 'o', 'r', 'l', 'd' };
sb.append(buf1, 0, buf1.length);
- assertTrue("Buffer is invalid length after append", sb.length() == 5);
+ assertEquals("Buffer is invalid length after append", 5, sb.length());
sb.append(buf2, 0, buf2.length);
- assertTrue("Buffer is invalid length after append", sb.length() == 10);
+ assertEquals("Buffer is invalid length after append", 10, sb.length());
assertTrue("Buffer contains invalid chars", (sb.toString()
.equals("HelloWorld")));
}
@@ -98,9 +98,9 @@
char buf1 = 'H';
char buf2 = 'W';
sb.append(buf1);
- assertTrue("Buffer is invalid length after append", sb.length() == 1);
+ assertEquals("Buffer is invalid length after append", 1, sb.length());
sb.append(buf2);
- assertTrue("Buffer is invalid length after append", sb.length() == 2);
+ assertEquals("Buffer is invalid length after append", 2, sb.length());
assertTrue("Buffer contains invalid chars",
(sb.toString().equals("HW")));
}
@@ -113,9 +113,9 @@
// java.lang.StringBuffer.append(double)
StringBuffer sb = new StringBuffer();
sb.append(Double.MAX_VALUE);
- assertTrue("Buffer is invalid length after append", sb.length() == 22);
- assertTrue("Buffer contains invalid characters", sb.toString().equals(
- "1.7976931348623157E308"));
+ assertEquals("Buffer is invalid length after append", 22, sb.length());
+ assertEquals("Buffer contains invalid characters",
+ "1.7976931348623157E308", sb.toString());
}
/**
@@ -141,11 +141,11 @@
// java.lang.StringBuffer.append(int)
StringBuffer sb = new StringBuffer();
sb.append(9000);
- assertTrue("Buffer is invalid length after append", sb.length() == 4);
+ assertEquals("Buffer is invalid length after append", 4, sb.length());
sb.append(1000);
- assertTrue("Buffer is invalid length after append", sb.length() == 8);
- assertTrue("Buffer contains invalid characters", sb.toString().equals(
- "90001000"));
+ assertEquals("Buffer is invalid length after append", 8, sb.length());
+ assertEquals("Buffer contains invalid characters",
+ "90001000", sb.toString());
}
/**
@@ -158,9 +158,9 @@
StringBuffer sb = new StringBuffer();
long t = 927654321098L;
sb.append(t);
- assertTrue("Buffer is of invlaid length", sb.length() == 12);
- assertTrue("Buffer contains invalid characters", sb.toString().equals(
- "927654321098"));
+ assertEquals("Buffer is of invlaid length", 12, sb.length());
+ assertEquals("Buffer contains invalid characters",
+ "927654321098", sb.toString());
}
/**
@@ -188,9 +188,9 @@
String buf1 = "Hello";
String buf2 = "World";
sb.append(buf1);
- assertTrue("Buffer is invalid length after append", sb.length() == 5);
+ assertEquals("Buffer is invalid length after append", 5, sb.length());
sb.append(buf2);
- assertTrue("Buffer is invalid length after append", sb.length() == 10);
+ assertEquals("Buffer is invalid length after append", 10, sb.length());
assertTrue("Buffer contains invalid chars", (sb.toString()
.equals("HelloWorld")));
}
@@ -203,9 +203,9 @@
// java.lang.StringBuffer.append(boolean)
StringBuffer sb = new StringBuffer();
sb.append(false);
- assertTrue("Buffer is invalid length after append", sb.length() == 5);
+ assertEquals("Buffer is invalid length after append", 5, sb.length());
sb.append(true);
- assertTrue("Buffer is invalid length after append", sb.length() == 9);
+ assertEquals("Buffer is invalid length after append", 9, sb.length());
assertTrue("Buffer is invalid length after append", (sb.toString()
.equals("falsetrue")));
}
@@ -216,7 +216,7 @@
public void test_capacity() {
// Test for method int java.lang.StringBuffer.capacity()
StringBuffer sb = new StringBuffer(10);
- assertTrue("Returned incorrect capacity", sb.capacity() == 10);
+ assertEquals("Returned incorrect capacity", 10, sb.capacity());
sb.ensureCapacity(100);
assertTrue("Returned incorrect capacity", sb.capacity() >= 100);
}
@@ -226,7 +226,7 @@
*/
public void test_charAtI() {
// Test for method char java.lang.StringBuffer.charAt(int)
- assertTrue("Returned incorrect char", testBuffer.charAt(3) == 's');
+ assertEquals("Returned incorrect char", 's', testBuffer.charAt(3));
// Test for StringIndexOutOfBoundsException
boolean exception = false;
@@ -246,28 +246,28 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.delete(int, int)
testBuffer.delete(7, 7);
- assertTrue("Deleted chars when start == end", testBuffer.toString()
- .equals("This is a test buffer"));
+ assertEquals("Deleted chars when start == end", "This is a test buffer", testBuffer.toString()
+ );
testBuffer.delete(4, 14);
- assertTrue("Deleted incorrect chars", testBuffer.toString().equals(
- "This buffer"));
+ assertEquals("Deleted incorrect chars",
+ "This buffer", testBuffer.toString());
testBuffer = new StringBuffer("This is a test buffer");
String sharedStr = testBuffer.toString();
testBuffer.delete(0, testBuffer.length());
- assertTrue("Didn't clone shared buffer", sharedStr
- .equals("This is a test buffer"));
+ assertEquals("Didn't clone shared buffer", "This is a test buffer", sharedStr
+ );
assertTrue("Deleted incorrect chars", testBuffer.toString().equals(""));
testBuffer.append("more stuff");
- assertTrue("Didn't clone shared buffer 2", sharedStr
- .equals("This is a test buffer"));
- assertTrue("Wrong contents", testBuffer.toString().equals("more stuff"));
+ assertEquals("Didn't clone shared buffer 2", "This is a test buffer", sharedStr
+ );
+ assertEquals("Wrong contents", "more stuff", testBuffer.toString());
try {
testBuffer.delete(-5, 2);
} catch (IndexOutOfBoundsException e) {
}
- assertTrue("Wrong contents 2", testBuffer.toString().equals(
- "more stuff"));
+ assertEquals("Wrong contents 2",
+ "more stuff", testBuffer.toString());
}
/**
@@ -277,8 +277,8 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.deleteCharAt(int)
testBuffer.deleteCharAt(3);
- assertTrue("Deleted incorrect char", testBuffer.toString().equals(
- "Thi is a test buffer"));
+ assertEquals("Deleted incorrect char",
+ "Thi is a test buffer", testBuffer.toString());
}
/**
@@ -323,8 +323,8 @@
char buf[] = new char[4];
"char".getChars(0, 4, buf, 0);
testBuffer.insert(15, buf);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test charbuffer"));
+ assertEquals("Insert test failed",
+ "This is a test charbuffer", testBuffer.toString());
boolean exception = false;
StringBuffer buf1 = new StringBuffer("abcd");
@@ -366,8 +366,8 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.insert(int, char)
testBuffer.insert(15, 'T');
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test Tbuffer"));
+ assertEquals("Insert test failed",
+ "This is a test Tbuffer", testBuffer.toString());
}
/**
@@ -403,8 +403,8 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.insert(int, int)
testBuffer.insert(15, 100);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test 100buffer"));
+ assertEquals("Insert test failed",
+ "This is a test 100buffer", testBuffer.toString());
}
/**
@@ -414,8 +414,8 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.insert(int, long)
testBuffer.insert(15, 88888888888888888L);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test 88888888888888888buffer"));
+ assertEquals("Insert test failed",
+ "This is a test 88888888888888888buffer", testBuffer.toString());
}
/**
@@ -438,8 +438,8 @@
// java.lang.StringBuffer.insert(int, java.lang.String)
testBuffer.insert(15, "STRING ");
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test STRING buffer"));
+ assertEquals("Insert test failed",
+ "This is a test STRING buffer", testBuffer.toString());
}
/**
@@ -449,8 +449,8 @@
// Test for method java.lang.StringBuffer
// java.lang.StringBuffer.insert(int, boolean)
testBuffer.insert(15, true);
- assertTrue("Insert test failed", testBuffer.toString().equals(
- "This is a test truebuffer"));
+ assertEquals("Insert test failed",
+ "This is a test truebuffer", testBuffer.toString());
}
/**
@@ -458,7 +458,7 @@
*/
public void test_length() {
// Test for method int java.lang.StringBuffer.length()
- assertTrue("Incorrect length returned", testBuffer.length() == 21);
+ assertEquals("Incorrect length returned", 21, testBuffer.length());
}
/**
@@ -472,12 +472,12 @@
+ "This is a replaced test buffer" + "\'" + " but got: " + "\'"
+ testBuffer.toString() + "\'", testBuffer.toString().equals(
"This is a replaced test buffer"));
- assertTrue("insert1", new StringBuffer().replace(0, 0, "text")
- .toString().equals("text"));
- assertTrue("insert2", new StringBuffer("123").replace(3, 3, "text")
- .toString().equals("123text"));
- assertTrue("insert2", new StringBuffer("123").replace(1, 1, "text")
- .toString().equals("1text23"));
+ assertEquals("insert1", "text", new StringBuffer().replace(0, 0, "text")
+ .toString());
+ assertEquals("insert2", "123text", new StringBuffer("123").replace(3, 3, "text")
+ .toString());
+ assertEquals("insert2", "1text23", new StringBuffer("123").replace(1, 1, "text")
+ .toString());
}
private String writeString(String in) {
@@ -550,7 +550,7 @@
// Test for method void java.lang.StringBuffer.setCharAt(int, char)
StringBuffer s = new StringBuffer("HelloWorld");
s.setCharAt(4, 'Z');
- assertTrue("Returned incorrect char", s.charAt(4) == 'Z');
+ assertEquals("Returned incorrect char", 'Z', s.charAt(4));
}
/**
@@ -559,13 +559,13 @@
public void test_setLengthI() {
// Test for method void java.lang.StringBuffer.setLength(int)
testBuffer.setLength(1000);
- assertTrue("Failed to increase length", testBuffer.length() == 1000);
+ assertEquals("Failed to increase length", 1000, testBuffer.length());
assertTrue("Increase in length trashed buffer", testBuffer.toString()
.startsWith("This is a test buffer"));
testBuffer.setLength(2);
- assertTrue("Failed to decrease length", testBuffer.length() == 2);
- assertTrue("Decrease in length failed", testBuffer.toString().equals(
- "Th"));
+ assertEquals("Failed to decrease length", 2, testBuffer.length());
+ assertEquals("Decrease in length failed",
+ "Th", testBuffer.toString());
}
/**
@@ -574,8 +574,8 @@
public void test_substringI() {
// Test for method java.lang.String
// java.lang.StringBuffer.substring(int)
- assertTrue("Returned incorrect substring", testBuffer.substring(5)
- .equals("is a test buffer"));
+ assertEquals("Returned incorrect substring", "is a test buffer", testBuffer.substring(5)
+ );
}
/**
@@ -584,8 +584,8 @@
public void test_substringII() {
// Test for method java.lang.String
// java.lang.StringBuffer.substring(int, int)
- assertTrue("Returned incorrect substring", testBuffer.substring(5, 7)
- .equals("is"));
+ assertEquals("Returned incorrect substring", "is", testBuffer.substring(5, 7)
+ );
}
/**
@@ -593,8 +593,8 @@
*/
public void test_toString() {
// Test for method java.lang.String java.lang.StringBuffer.toString()
- assertTrue("Incorrect string value returned", testBuffer.toString()
- .equals("This is a test buffer"));
+ assertEquals("Incorrect string value returned", "This is a test buffer", testBuffer.toString()
+ );
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/StringTest.java Wed Apr 26 00:12:16 2006
@@ -129,7 +129,7 @@
*/
public void test_Constructor$C() {
// Test for method java.lang.String(char [])
- assertTrue("Failed Constructor test", new String(buf).equals("World"));
+ assertEquals("Failed Constructor test", "World", new String(buf));
}
/**
@@ -156,8 +156,8 @@
public void test_ConstructorLjava_lang_String() {
// Test for method java.lang.String(java.lang.String)
String s = new String("Hello World");
- assertTrue("Failed to construct correct string", s
- .equals("Hello World"));
+ assertEquals("Failed to construct correct string", "Hello World", s
+ );
}
/**
@@ -167,8 +167,8 @@
// Test for method java.lang.String(java.lang.StringBuffer)
StringBuffer sb = new StringBuffer();
sb.append("HelloWorld");
- assertTrue("Created incorrect string", new String(sb)
- .equals("HelloWorld"));
+ assertEquals("Created incorrect string", "HelloWorld", new String(sb)
+ );
}
/**
@@ -187,8 +187,8 @@
// Test for method int java.lang.String.compareTo(java.lang.String)
assertTrue("Returned incorrect value for first < second", "aaaaab"
.compareTo("aaaaac") < 0);
- assertTrue("Returned incorrect value for first = second", "aaaaac"
- .compareTo("aaaaac") == 0);
+ assertEquals("Returned incorrect value for first = second", 0, "aaaaac"
+ .compareTo("aaaaac"));
assertTrue("Returned incorrect value for first > second", "aaaaac"
.compareTo("aaaaab") > 0);
assertTrue("Considered case to not be of importance", !("A"
@@ -209,27 +209,27 @@
// java.lang.String.compareToIgnoreCase(java.lang.String)
assertTrue("Returned incorrect value for first < second", "aaaaab"
.compareToIgnoreCase("aaaaac") < 0);
- assertTrue("Returned incorrect value for first = second", "aaaaac"
- .compareToIgnoreCase("aaaaac") == 0);
+ assertEquals("Returned incorrect value for first = second", 0, "aaaaac"
+ .compareToIgnoreCase("aaaaac"));
assertTrue("Returned incorrect value for first > second", "aaaaac"
.compareToIgnoreCase("aaaaab") > 0);
- assertTrue("Considered case to not be of importance", "A"
- .compareToIgnoreCase("a") == 0);
+ assertEquals("Considered case to not be of importance", 0, "A"
+ .compareToIgnoreCase("a"));
assertTrue("0xbf should not compare = to 'ss'", "\u00df"
.compareToIgnoreCase("ss") != 0);
- assertTrue("0x130 should compare = to 'i'", "\u0130"
- .compareToIgnoreCase("i") == 0);
- assertTrue("0x131 should compare = to 'i'", "\u0131"
- .compareToIgnoreCase("i") == 0);
+ assertEquals("0x130 should compare = to 'i'", 0, "\u0130"
+ .compareToIgnoreCase("i"));
+ assertEquals("0x131 should compare = to 'i'", 0, "\u0131"
+ .compareToIgnoreCase("i"));
Locale defLocale = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr", ""));
- assertTrue("Locale tr: 0x130 should compare = to 'i'", "\u0130"
- .compareToIgnoreCase("i") == 0);
- assertTrue("Locale tr: 0x131 should compare = to 'i'", "\u0131"
- .compareToIgnoreCase("i") == 0);
+ assertEquals("Locale tr: 0x130 should compare = to 'i'", 0, "\u0130"
+ .compareToIgnoreCase("i"));
+ assertEquals("Locale tr: 0x131 should compare = to 'i'", 0, "\u0131"
+ .compareToIgnoreCase("i"));
} finally {
Locale.setDefault(defLocale);
}
@@ -281,8 +281,8 @@
// Test for method java.lang.String java.lang.String.copyValueOf(char
// [])
char[] t = { 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' };
- assertTrue("copyValueOf returned incorrect String", String.copyValueOf(
- t).equals("HelloWorld"));
+ assertEquals("copyValueOf returned incorrect String", "HelloWorld", String.copyValueOf(
+ t));
}
/**
@@ -292,8 +292,8 @@
// Test for method java.lang.String java.lang.String.copyValueOf(char
// [], int, int)
char[] t = { 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' };
- assertTrue("copyValueOf returned incorrect String", String.copyValueOf(
- t, 5, 5).equals("World"));
+ assertEquals("copyValueOf returned incorrect String", "World", String.copyValueOf(
+ t, 5, 5));
}
/**
@@ -389,7 +389,7 @@
String result = null;
try {
result = new String(bytes, "8859_1");
- assertTrue("Wrong char length", result.length() == 1);
+ assertEquals("Wrong char length", 1, result.length());
assertTrue("Wrong char value", result.charAt(0) == (char) i);
} catch (java.io.UnsupportedEncodingException e) {
}
@@ -427,7 +427,7 @@
// int)
byte[] buf = new byte[5];
"Hello World".getBytes(6, 11, buf, 0);
- assertTrue("Returned incorrect bytes", new String(buf).equals("World"));
+ assertEquals("Returned incorrect bytes", "World", new String(buf));
Exception exception = null;
try {
@@ -445,8 +445,8 @@
public void test_getBytesLjava_lang_String() {
// Test for method byte [] java.lang.String.getBytes(java.lang.String)
byte[] buf = "Hello World".getBytes();
- assertTrue("Returned incorrect bytes", new String(buf)
- .equals("Hello World"));
+ assertEquals("Returned incorrect bytes", "Hello World", new String(buf)
+ );
boolean exception = false;
try {
@@ -503,7 +503,7 @@
*/
public void test_indexOfI() {
// Test for method int java.lang.String.indexOf(int)
- assertTrue("Invalid index returned", 1 == hw1.indexOf('e'));
+ assertEquals("Invalid index returned", 1, hw1.indexOf('e'));
}
@@ -512,7 +512,7 @@
*/
public void test_indexOfII() {
// Test for method int java.lang.String.indexOf(int, int)
- assertTrue("Invalid character index returned", 5 == hw1.indexOf('W', 2));
+ assertEquals("Invalid character index returned", 5, hw1.indexOf('W', 2));
}
@@ -532,10 +532,10 @@
// Test for method int java.lang.String.indexOf(java.lang.String, int)
assertTrue("Failed to find string", hw1.indexOf("World", 0) > 0);
assertTrue("Found string outside index", !(hw1.indexOf("Hello", 6) > 0));
- assertTrue("Did not accept valid negative starting position", hello1
- .indexOf("", -5) == 0);
- assertTrue("Reported wrong error code", hello1.indexOf("", 5) == 5);
- assertTrue("Wrong for empty in empty", "".indexOf("", 0) == 0);
+ assertEquals("Did not accept valid negative starting position", 0, hello1
+ .indexOf("", -5));
+ assertEquals("Reported wrong error code", 5, hello1.indexOf("", 5));
+ assertEquals("Wrong for empty in empty", 0, "".indexOf("", 0));
}
/**
@@ -552,9 +552,9 @@
*/
public void test_lastIndexOfI() {
// Test for method int java.lang.String.lastIndexOf(int)
- assertTrue("Failed to return correct index", hw1.lastIndexOf('W') == 5);
- assertTrue("Returned index for non-existent char",
- hw1.lastIndexOf('Z') == -1);
+ assertEquals("Failed to return correct index", 5, hw1.lastIndexOf('W'));
+ assertEquals("Returned index for non-existent char",
+ -1, hw1.lastIndexOf('Z'));
}
@@ -563,12 +563,12 @@
*/
public void test_lastIndexOfII() {
// Test for method int java.lang.String.lastIndexOf(int, int)
- assertTrue("Failed to return correct index",
- hw1.lastIndexOf('W', 6) == 5);
- assertTrue("Returned index for char out of specified range", hw1
- .lastIndexOf('W', 4) == -1);
- assertTrue("Returned index for non-existent char", hw1.lastIndexOf('Z',
- 9) == -1);
+ assertEquals("Failed to return correct index",
+ 5, hw1.lastIndexOf('W', 6));
+ assertEquals("Returned index for char out of specified range", -1, hw1
+ .lastIndexOf('W', 4));
+ assertEquals("Returned index for non-existent char", -1, hw1.lastIndexOf('Z',
+ 9));
}
@@ -577,9 +577,9 @@
*/
public void test_lastIndexOfLjava_lang_String() {
// Test for method int java.lang.String.lastIndexOf(java.lang.String)
- assertTrue("Returned incorrect index", hw1.lastIndexOf("World") == 5);
- assertTrue("Found String outside of index", hw1
- .lastIndexOf("HeKKKKKKKK") == -1);
+ assertEquals("Returned incorrect index", 5, hw1.lastIndexOf("World"));
+ assertEquals("Found String outside of index", -1, hw1
+ .lastIndexOf("HeKKKKKKKK"));
}
/**
@@ -588,13 +588,13 @@
public void test_lastIndexOfLjava_lang_StringI() {
// Test for method int java.lang.String.lastIndexOf(java.lang.String,
// int)
- assertTrue("Returned incorrect index", hw1.lastIndexOf("World", 9) == 5);
+ assertEquals("Returned incorrect index", 5, hw1.lastIndexOf("World", 9));
int result = hw1.lastIndexOf("Hello", 2);
assertTrue("Found String outside of index: " + result, result == 0);
- assertTrue("Reported wrong error code",
- hello1.lastIndexOf("", -5) == -1);
- assertTrue("Did not accept valid large starting position", hello1
- .lastIndexOf("", 5) == 5);
+ assertEquals("Reported wrong error code",
+ -1, hello1.lastIndexOf("", -5));
+ assertEquals("Did not accept valid large starting position", 5, hello1
+ .lastIndexOf("", 5));
}
/**
@@ -602,7 +602,7 @@
*/
public void test_length() {
// Test for method int java.lang.String.length()
- assertTrue("Invalid length returned", comp11.length() == 11);
+ assertEquals("Invalid length returned", 11, comp11.length());
}
/**
@@ -644,7 +644,7 @@
*/
public void test_replaceCC() {
// Test for method java.lang.String java.lang.String.replace(char, char)
- assertTrue("Failed replace", hw1.replace('l', 'z').equals("HezzoWorzd"));
+ assertEquals("Failed replace", "HezzoWorzd", hw1.replace('l', 'z'));
}
/**
@@ -671,8 +671,8 @@
*/
public void test_substringI() {
// Test for method java.lang.String java.lang.String.substring(int)
- assertTrue("Incorrect substring returned", hw1.substring(5).equals(
- "World"));
+ assertEquals("Incorrect substring returned",
+ "World", hw1.substring(5));
assertTrue("not identical", hw1.substring(0) == hw1);
}
@@ -707,12 +707,10 @@
assertTrue("toLowerCase case conversion did not succeed", hwuc
.toLowerCase().equals(hwlc));
- assertTrue(
- "a) Sigma has same lower case value at end of word with Unicode 3.0",
- "\u03a3\u03a3".toLowerCase().equals("\u03c3\u03c3"));
- assertTrue(
- "b) Sigma has same lower case value at end of word with Unicode 3.0",
- "a\u03a3".toLowerCase().equals("a\u03c3"));
+ assertEquals("a) Sigma has same lower case value at end of word with Unicode 3.0",
+ "\u03c3\u03c3", "\u03a3\u03a3".toLowerCase());
+ assertEquals("b) Sigma has same lower case value at end of word with Unicode 3.0",
+ "a\u03c3", "a\u03a3".toLowerCase());
}
/**
@@ -723,10 +721,10 @@
// java.lang.String.toLowerCase(java.util.Locale)
assertTrue("toLowerCase case conversion did not succeed", hwuc
.toLowerCase(java.util.Locale.getDefault()).equals(hwlc));
- assertTrue("Invalid \\u0049 for English", "\u0049".toLowerCase(
- Locale.ENGLISH).equals("\u0069"));
- assertTrue("Invalid \\u0049 for Turkish", "\u0049".toLowerCase(
- new Locale("tr", "")).equals("\u0131"));
+ assertEquals("Invalid \\u0049 for English", "\u0069", "\u0049".toLowerCase(
+ Locale.ENGLISH));
+ assertEquals("Invalid \\u0049 for Turkish", "\u0131", "\u0049".toLowerCase(
+ new Locale("tr", "")));
}
private static String writeString(String in) {
@@ -763,7 +761,7 @@
assertTrue("Returned string is not UpperCase", hwlc.toUpperCase()
.equals(hwuc));
- assertTrue("Wrong conversion", "\u00df".toUpperCase().equals("SS"));
+ assertEquals("Wrong conversion", "SS", "\u00df".toUpperCase());
String s = "a\u00df\u1f56";
assertTrue("Invalid conversion", !s.toUpperCase().equals(s));
@@ -778,10 +776,10 @@
// java.lang.String.toUpperCase(java.util.Locale)
assertTrue("Returned string is not UpperCase", hwlc.toUpperCase()
.equals(hwuc));
- assertTrue("Invalid \\u0069 for English", "\u0069".toUpperCase(
- Locale.ENGLISH).equals("\u0049"));
- assertTrue("Invalid \\u0069 for Turkish", "\u0069".toUpperCase(
- new Locale("tr", "")).equals("\u0130"));
+ assertEquals("Invalid \\u0069 for English", "\u0049", "\u0069".toUpperCase(
+ Locale.ENGLISH));
+ assertEquals("Invalid \\u0069 for Turkish", "\u0130", "\u0069".toUpperCase(
+ new Locale("tr", "")));
}
/**
@@ -806,8 +804,8 @@
*/
public void test_valueOf$C() {
// Test for method java.lang.String java.lang.String.valueOf(char [])
- assertTrue("Returned incorrect String", String.valueOf(buf).equals(
- "World"));
+ assertEquals("Returned incorrect String",
+ "World", String.valueOf(buf));
}
/**
@@ -817,8 +815,8 @@
// Test for method java.lang.String java.lang.String.valueOf(char [],
// int, int)
char[] t = { 'H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd' };
- assertTrue("copyValueOf returned incorrect String", String.valueOf(t,
- 5, 5).equals("World"));
+ assertEquals("copyValueOf returned incorrect String", "World", String.valueOf(t,
+ 5, 5));
}
/**
@@ -836,8 +834,8 @@
*/
public void test_valueOfD() {
// Test for method java.lang.String java.lang.String.valueOf(double)
- assertTrue("Incorrect double string returned", String.valueOf(
- Double.MAX_VALUE).equals("1.7976931348623157E308"));
+ assertEquals("Incorrect double string returned", "1.7976931348623157E308", String.valueOf(
+ Double.MAX_VALUE));
}
/**
@@ -861,7 +859,7 @@
*/
public void test_valueOfI() {
// Test for method java.lang.String java.lang.String.valueOf(int)
- assertTrue("returned invalid int string", String.valueOf(1).equals("1"));
+ assertEquals("returned invalid int string", "1", String.valueOf(1));
}
/**
@@ -869,8 +867,8 @@
*/
public void test_valueOfJ() {
// Test for method java.lang.String java.lang.String.valueOf(long)
- assertTrue("returned incorrect long string", String.valueOf(
- 927654321098L).equals("927654321098"));
+ assertEquals("returned incorrect long string", "927654321098", String.valueOf(
+ 927654321098L));
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/SystemTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/SystemTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/SystemTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/SystemTest.java Wed Apr 26 00:12:16 2006
@@ -140,7 +140,7 @@
"os.version", "file.separator", "path.separator",
"line.separator", "user.name", "user.home", "user.dir", };
for (int i = 0; i < props.length; i++) {
- assertTrue(props[i], System.getProperty(props[i]) != null);
+ assertNotNull(props[i], System.getProperty(props[i]));
}
}
@@ -193,8 +193,8 @@
assertTrue("Failed to return correct property value: "
+ System.getProperty("java.version", "99999"), System
.getProperty("java.version", "99999").indexOf("1.", 0) >= 0);
- assertTrue("Failed to return correct property value", System
- .getProperty("bogus.prop", "bogus").equals("bogus"));
+ assertEquals("Failed to return correct property value", "bogus", System
+ .getProperty("bogus.prop", "bogus"));
}
/**
@@ -204,8 +204,8 @@
// Test for method java.lang.String
// java.lang.System.setProperty(java.lang.String, java.lang.String)
- assertTrue("Failed to return null", System.setProperty("testing",
- "value1") == null);
+ assertNull("Failed to return null", System.setProperty("testing",
+ "value1"));
assertTrue("Failed to return old value", System.setProperty("testing",
"value2") == "value1");
assertTrue("Failed to find value",
@@ -226,8 +226,8 @@
public void test_getSecurityManager() {
// Test for method java.lang.SecurityManager
// java.lang.System.getSecurityManager()
- assertTrue("Returned incorrect SecurityManager", System
- .getSecurityManager() == null);
+ assertNull("Returned incorrect SecurityManager", System
+ .getSecurityManager());
}
/**
@@ -238,8 +238,8 @@
// java.lang.System.identityHashCode(java.lang.Object)
Object o = new Object();
String s = "Gabba";
- assertTrue("Nonzero returned for null",
- System.identityHashCode(null) == 0);
+ assertEquals("Nonzero returned for null",
+ 0, System.identityHashCode(null));
assertTrue("Nonequal has returned for Object", System
.identityHashCode(o) == o.hashCode());
assertTrue("Same as usual hash returned for String", System
@@ -291,8 +291,8 @@
tProps.put("bogus.prop", "bogus");
System.setProperties(tProps);
try {
- assertTrue("Failed to set properties", System.getProperties()
- .getProperty("test.prop").equals("this is a test property"));
+ assertEquals("Failed to set properties", "this is a test property", System.getProperties()
+ .getProperty("test.prop"));
} finally {
// restore the original properties
System.setProperties(orgProps);
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java Wed Apr 26 00:12:16 2006
@@ -100,8 +100,8 @@
newGroup = new ThreadGroup(null, null);
} catch (NullPointerException e) {
}
- assertTrue("Can't create a ThreadGroup with a null parent",
- newGroup == null);
+ assertNull("Can't create a ThreadGroup with a null parent",
+ newGroup);
newGroup = new ThreadGroup(getInitialThreadGroup(), null);
assertTrue("Has to be possible to create a subgroup of current group",
@@ -123,8 +123,8 @@
newGroup = null;
}
;
- assertTrue("Can't create a subgroup of a destroyed group",
- newGroup == null);
+ assertNull("Can't create a subgroup of a destroyed group",
+ newGroup);
}
/**
@@ -195,8 +195,8 @@
for (int i = 0; i < subgroups.size(); i++) {
ThreadGroup child = (ThreadGroup) subgroups.elementAt(i);
- assertTrue("Destroyed child can't have children", child
- .activeCount() == 0);
+ assertEquals("Destroyed child can't have children", 0, child
+ .activeCount());
boolean passed = false;
try {
child.destroy();
@@ -597,8 +597,8 @@
+ " was not running when it was killed", isResumed[i]);
}
- assertTrue("Method destroy must have problems",
- testRoot.activeCount() == 0);
+ assertEquals("Method destroy must have problems",
+ 0, testRoot.activeCount());
}
@@ -674,7 +674,7 @@
parentMaxPrio = current.getParent().getMaxPriority();
ThreadGroup[] children = groups(current);
- assertTrue("Can only have 1 subgroup", children.length == 1);
+ assertEquals("Can only have 1 subgroup", 1, children.length);
current = children[0];
assertTrue(
"Had to be 1 unit smaller than parent's priority in iteration="
@@ -795,8 +795,8 @@
assertTrue("Thread should be dead by now", passed);
- assertTrue("Method destroy (or wipeAllThreads) must have problems",
- testRoot.activeCount() == 0);
+ assertEquals("Method destroy (or wipeAllThreads) must have problems",
+ 0, testRoot.activeCount());
}
@@ -848,8 +848,8 @@
}
assertTrue("All threads should be suspended", passed);
- assertTrue("Method destroy (or wipeAllThreads) must have problems",
- testRoot.activeCount() == 0);
+ assertEquals("Method destroy (or wipeAllThreads) must have problems",
+ 0, testRoot.activeCount());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java Wed Apr 26 00:12:16 2006
@@ -34,7 +34,7 @@
public void test_get() {
// Test for method java.lang.Object java.lang.ThreadLocal.get()
ThreadLocal l = new ThreadLocal();
- assertTrue("ThreadLocal's initial value is null", l.get() == null);
+ assertNull("ThreadLocal's initial value is null", l.get());
// The ThreadLocal has to run once for each thread that touches the
// ThreadLocal
@@ -112,8 +112,8 @@
// ThreadLocal is not inherited, so the other Thread should see it as
// null
- assertTrue("ThreadLocal's value in other Thread should be null",
- THREADVALUE.result == null);
+ assertNull("ThreadLocal's value in other Thread should be null",
+ THREADVALUE.result);
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java Wed Apr 26 00:12:16 2006
@@ -159,8 +159,8 @@
// Test for method java.lang.Thread(java.lang.Runnable,
// java.lang.String)
Thread st1 = new Thread(new SimpleThread(1), "SimpleThread1");
- assertTrue("Constructed thread with incorrect thread name", st1
- .getName().equals("SimpleThread1"));
+ assertEquals("Constructed thread with incorrect thread name", "SimpleThread1", st1
+ .getName());
st1.start();
}
@@ -170,8 +170,8 @@
public void test_ConstructorLjava_lang_String() {
// Test for method java.lang.Thread(java.lang.String)
Thread t = new Thread("Testing");
- assertTrue("Created tread with incorrect name", t.getName().equals(
- "Testing"));
+ assertEquals("Created tread with incorrect name",
+ "Testing", t.getName());
t.start();
}
@@ -234,8 +234,8 @@
// Test for method java.lang.Thread(java.lang.ThreadGroup,
// java.lang.String)
st = new Thread(new SimpleThread(1), "SimpleThread4");
- assertTrue("Returned incorrect thread name", st.getName().equals(
- "SimpleThread4"));
+ assertEquals("Returned incorrect thread name",
+ "SimpleThread4", st.getName());
st.start();
}
@@ -281,8 +281,8 @@
public void test_countStackFrames() {
// Test for method int java.lang.Thread.countStackFrames()
// SM.
- assertTrue("Test failed.",
- Thread.currentThread().countStackFrames() == 0);
+ assertEquals("Test failed.",
+ 0, Thread.currentThread().countStackFrames());
}
/**
@@ -373,8 +373,8 @@
public void test_getName() {
// Test for method java.lang.String java.lang.Thread.getName()
st = new Thread(new SimpleThread(1), "SimpleThread6");
- assertTrue("Returned incorrect thread name", st.getName().equals(
- "SimpleThread6"));
+ assertEquals("Returned incorrect thread name",
+ "SimpleThread6", st.getName());
st.start();
}
@@ -404,8 +404,8 @@
st.join();
} catch (InterruptedException e) {
}
- assertTrue("group should be null", st.getThreadGroup() == null);
- assertTrue("toString() should not be null", st.toString() != null);
+ assertNull("group should be null", st.getThreadGroup());
+ assertNotNull("toString() should not be null", st.toString());
tg.destroy();
final Object lock = new Object();
@@ -427,7 +427,7 @@
while (t.isAlive())
running++;
ThreadGroup group = t.getThreadGroup();
- assertTrue("ThreadGroup is not null", group == null);
+ assertNull("ThreadGroup is not null", group);
}
/**
@@ -806,8 +806,8 @@
// Test for method void java.lang.Thread.setName(java.lang.String)
st = new Thread(new SimpleThread(1), "SimpleThread15");
st.setName("Bogus Name");
- assertTrue("Failed to set thread name", st.getName().equals(
- "Bogus Name"));
+ assertEquals("Failed to set thread name",
+ "Bogus Name", st.getName());
try {
st.setName(null);
fail("Null should not be accepted as a valid name");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java Wed Apr 26 00:12:16 2006
@@ -43,8 +43,8 @@
if (true)
throw new Throwable("Throw");
} catch (Throwable e) {
- assertTrue("Threw Throwable with incorrect message", e.getMessage()
- .equals("Throw"));
+ assertEquals("Threw Throwable with incorrect message", "Throw", e.getMessage()
+ );
return;
}
fail("Failed to throw Throwable");
@@ -135,8 +135,8 @@
// Test for method java.lang.String java.lang.Throwable.getMessage()
Throwable x = new ClassNotFoundException("A Message");
- assertTrue("Returned incorrect messasge string", x.getMessage().equals(
- "A Message"));
+ assertEquals("Returned incorrect messasge string",
+ "A Message", x.getMessage());
}
/**
@@ -199,8 +199,8 @@
if (true)
throw new Throwable("Throw");
} catch (Throwable e) {
- assertTrue("Threw Throwable with incorrect string", e.toString()
- .equals("java.lang.Throwable: Throw"));
+ assertEquals("Threw Throwable with incorrect string", "java.lang.Throwable: Throw", e.toString()
+ );
return;
}
fail("Failed to throw Throwable");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java Wed Apr 26 00:12:16 2006
@@ -40,8 +40,8 @@
if (true)
throw new UnknownError("Unknown");
} catch (UnknownError e) {
- assertTrue(" Incorrect msg string ", e.getMessage().equals(
- "Unknown"));
+ assertEquals(" Incorrect msg string ",
+ "Unknown", e.getMessage());
return;
}
fail("Failed to generate error");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java Wed Apr 26 00:12:16 2006
@@ -26,9 +26,9 @@
if (true)
throw new UnsatisfiedLinkError();
} catch (UnsatisfiedLinkError e) {
- assertTrue("Initializer failed.", e.getMessage() == null);
- assertTrue("To string failed.", e.toString().equals(
- "java.lang.UnsatisfiedLinkError"));
+ assertNull("Initializer failed.", e.getMessage());
+ assertEquals("To string failed.",
+ "java.lang.UnsatisfiedLinkError", e.toString());
}
}
@@ -41,13 +41,13 @@
try {
Runtime.getRuntime().loadLibrary("Hello World89797");
} catch (UnsatisfiedLinkError e) {
- assertTrue("Does not set message", e.getMessage() != null);
+ assertNotNull("Does not set message", e.getMessage());
exception = true;
}
assertTrue("Does not throw UnsatisfiedLinkError", exception);
UnsatisfiedLinkError err = new UnsatisfiedLinkError("my message");
- assertTrue("Incorrect message", "my message".equals(err.getMessage()));
+ assertEquals("Incorrect message", "my message", err.getMessage());
}
protected void setUp() {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java Wed Apr 26 00:12:16 2006
@@ -59,8 +59,8 @@
try {
throw new UnsupportedOperationException("HelloWorld");
} catch (UnsupportedOperationException e) {
- assertTrue("Wrong message given.", e.getMessage().equals(
- "HelloWorld"));
+ assertEquals("Wrong message given.",
+ "HelloWorld", e.getMessage());
return;
} catch (Exception e) {
fail("Exception during Constructor : " + e.getMessage());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java Wed Apr 26 00:12:16 2006
@@ -38,8 +38,8 @@
if (true)
throw new VerifyError("HelloWorld");
} catch (VerifyError e) {
- assertTrue("VerifyError(String) failed.", e.getMessage().equals(
- "HelloWorld"));
+ assertEquals("VerifyError(String) failed.",
+ "HelloWorld", e.getMessage());
return;
}
fail("Constructor failed");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java Wed Apr 26 00:12:16 2006
@@ -51,8 +51,8 @@
if (true)
throw new TestVirtualMachineError("HelloWorld");
} catch (VirtualMachineError e) {
- assertTrue("VerifyError(String) failed.", e.getMessage().equals(
- "HelloWorld"));
+ assertEquals("VerifyError(String) failed.",
+ "HelloWorld", e.getMessage());
return;
}
fail("Constructor failed");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java Wed Apr 26 00:12:16 2006
@@ -32,7 +32,7 @@
ReferenceQueue rq = new ReferenceQueue();
bool = new Boolean(false);
PhantomReference pr = new PhantomReference(bool, rq);
- assertTrue("Same object returned.", pr.get() == null);
+ assertNull("Same object returned.", pr.get());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java Wed Apr 26 00:12:16 2006
@@ -90,12 +90,12 @@
*/
public void test_removeJ() {
try {
- assertTrue("Queue is empty.", rq.poll() == null);
- assertTrue("Queue is empty.", rq.remove((long) 1) == null);
+ assertNull("Queue is empty.", rq.poll());
+ assertNull("Queue is empty.", rq.remove((long) 1));
Thread ct = new Thread(new ChildThread());
ct.start();
Reference ret = rq.remove(0L);
- assertTrue("Delayed remove failed.", ret != null);
+ assertNotNull("Delayed remove failed.", ret);
} catch (InterruptedException e) {
fail("InterruptedExeException during test : " + e.getMessage());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java Wed Apr 26 00:12:16 2006
@@ -113,8 +113,8 @@
System.runFinalization();
ref = rq.remove();
assertTrue("Unexpected ref1", ref == wr);
- assertTrue("Object not garbage collected1.", ref != null);
- assertTrue("Object could not be reclaimed1.", wr.get() == null);
+ assertNotNull("Object not garbage collected1.", ref);
+ assertNull("Object could not be reclaimed1.", wr.get());
} catch (InterruptedException e) {
fail("InterruptedException : " + e.getMessage());
}
@@ -127,10 +127,10 @@
System.runFinalization();
ref = rq.poll();
assertTrue("Unexpected ref2", ref == wr);
- assertTrue("Object not garbage collected.", ref != null);
- assertTrue("Object could not be reclaimed.", ref.get() == null);
+ assertNotNull("Object not garbage collected.", ref);
+ assertNull("Object could not be reclaimed.", ref.get());
// Reference wr so it does not get collected
- assertTrue("Object could not be reclaimed.", wr.get() == null);
+ assertNull("Object could not be reclaimed.", wr.get());
} catch (Exception e) {
fail("Exception : " + e.getMessage());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java Wed Apr 26 00:12:16 2006
@@ -34,8 +34,8 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value",
- ((Integer) ret).intValue() == 1);
+ assertEquals("Get returned incorrect value",
+ 1, ((Integer) ret).intValue());
try {
ret = Array.get(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -107,7 +107,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getByte(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -143,7 +143,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getChar(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -179,7 +179,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret, 0.0);
try {
ret = Array.getDouble(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -216,7 +216,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret, 0.0);
try {
ret = Array.getFloat(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -252,7 +252,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getInt(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -282,9 +282,9 @@
// java.lang.reflect.Array.getLength(java.lang.Object)
long[] x = { 1 };
- assertTrue("Returned incorrect length", Array.getLength(x) == 1);
- assertTrue("Returned incorrect length", Array
- .getLength(new Object[10000]) == 10000);
+ assertEquals("Returned incorrect length", 1, Array.getLength(x));
+ assertEquals("Returned incorrect length", 10000, Array
+ .getLength(new Object[10000]));
try {
Array.getLength(new Object());
} catch (IllegalArgumentException e) {
@@ -308,7 +308,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getLong(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -344,7 +344,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ret == 1);
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getShort(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -376,7 +376,7 @@
int[] y = { 2 };
x = (int[][]) Array.newInstance(int[].class, y);
- assertTrue("Failed to instantiate array properly", x.length == 2);
+ assertEquals("Failed to instantiate array properly", 2, x.length);
}
@@ -389,7 +389,7 @@
int[] x;
x = (int[]) Array.newInstance(int.class, 100);
- assertTrue("Failed to instantiate array properly", x.length == 100);
+ assertEquals("Failed to instantiate array properly", 100, x.length);
}
/**
@@ -406,8 +406,8 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", ((Integer) Array.get(x, 0))
- .intValue() == 1);
+ assertEquals("Get returned incorrect value", 1, ((Integer) Array.get(x, 0))
+ .intValue());
try {
Array.set(new Object(), 0, new Object());
} catch (IllegalArgumentException e) {
@@ -487,7 +487,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getByte(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getByte(x, 0));
try {
Array.setByte(new Object(), 0, (byte) 9);
} catch (IllegalArgumentException e) {
@@ -522,7 +522,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getChar(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getChar(x, 0));
try {
Array.setChar(new Object(), 0, (char) 9);
} catch (IllegalArgumentException e) {
@@ -557,7 +557,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getDouble(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getDouble(x, 0), 0.0);
try {
Array.setDouble(new Object(), 0, (double) 9);
} catch (IllegalArgumentException e) {
@@ -592,7 +592,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getFloat(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getFloat(x, 0), 0.0);
try {
Array.setFloat(new Object(), 0, (float) 9);
} catch (IllegalArgumentException e) {
@@ -627,7 +627,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getInt(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getInt(x, 0));
try {
Array.setInt(new Object(), 0, (int) 9);
} catch (IllegalArgumentException e) {
@@ -662,7 +662,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getLong(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getLong(x, 0));
try {
Array.setLong(new Object(), 0, (long) 9);
} catch (IllegalArgumentException e) {
@@ -697,7 +697,7 @@
} catch (Exception e) {
fail("Exception during get test : " + e.getMessage());
}
- assertTrue("Get returned incorrect value", Array.getShort(x, 0) == 1);
+ assertEquals("Get returned incorrect value", 1, Array.getShort(x, 0));
try {
Array.setShort(new Object(), 0, (short) 9);
} catch (IllegalArgumentException e) {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java Wed Apr 26 00:12:16 2006
@@ -97,8 +97,8 @@
} catch (Exception e) {
fail("Exception during test : " + e.getMessage());
}
- assertTrue("Returned exception list of incorrect length",
- exceptions.length == 1);
+ assertEquals("Returned exception list of incorrect length",
+ 1, exceptions.length);
assertTrue("Returned incorrect exception", exceptions[0].equals(ex));
}
@@ -177,7 +177,7 @@
fail("Exception during getParameterTypes test:"
+ e.toString());
}
- assertTrue("Incorrect parameter returned", types.length == 0);
+ assertEquals("Incorrect parameter returned", 0, types.length);
Class[] parms = null;
try {
@@ -208,7 +208,7 @@
} catch (Exception e) {
fail("Failed to create instance : " + e.getMessage());
}
- assertTrue("improper instance created", test.check() == 99);
+ assertEquals("improper instance created", 99, test.check());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java Wed Apr 26 00:12:16 2006
@@ -188,14 +188,14 @@
try {
Method mth = TestMethod.class.getMethod("voidMethod", new Class[0]);
Class[] ex = mth.getExceptionTypes();
- assertTrue("Returned incorrect number of exceptions",
- ex.length == 1);
+ assertEquals("Returned incorrect number of exceptions",
+ 1, ex.length);
assertTrue("Returned incorrect exception type", ex[0]
.equals(IllegalArgumentException.class));
mth = TestMethod.class.getMethod("intMethod", new Class[0]);
ex = mth.getExceptionTypes();
- assertTrue("Returned incorrect number of exceptions",
- ex.length == 0);
+ assertEquals("Returned incorrect number of exceptions",
+ 0, ex.length);
} catch (Exception e) {
fail("Exception during getExceptionTypes: " + e.toString());
}
@@ -267,8 +267,8 @@
} catch (Exception e) {
fail("Exception during getMethodName(): " + e.toString());
}
- assertTrue("Returned incorrect method name", mth.getName().equals(
- "voidMethod"));
+ assertEquals("Returned incorrect method name",
+ "voidMethod", mth.getName());
}
/**
@@ -291,7 +291,7 @@
fail("Exception during getParameterTypes test: "
+ e.toString());
}
- assertTrue("Returned incorrect parameterTypes", parms.length == 0);
+ assertEquals("Returned incorrect parameterTypes", 0, parms.length);
try {
mth = cl.getMethod("parmTest", plist);
parms = mth.getParameterTypes();
@@ -425,8 +425,8 @@
} catch (Exception e) {
fail("Exception during invoke test : " + e.getMessage());
}
- assertTrue("Invoke returned incorrect value", ((Integer) ret)
- .intValue() == 1);
+ assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
+ .intValue());
// Get and invoke an instance method
try {
@@ -440,8 +440,8 @@
} catch (Exception e) {
fail("Exception during invoke test : " + e.getMessage());
}
- assertTrue("Invoke returned incorrect value", ((Integer) ret)
- .intValue() == 1);
+ assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
+ .intValue());
// Get and attempt to invoke a private method
try {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java Wed Apr 26 00:12:16 2006
@@ -112,7 +112,7 @@
assertTrue("Failed identity test ", proxy.equals(proxy));
assertTrue("Failed not equals test ", !proxy.equals(""));
int[] result = (int[]) proxy.array(new long[] { 100L, -200L });
- assertTrue("Failed base type conversion test ", result[0] == -200);
+ assertEquals("Failed base type conversion test ", -200, result[0]);
boolean worked = false;
try {
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java Wed Apr 26 00:12:16 2006
@@ -39,9 +39,9 @@
// Test for method java.net.DatagramPacket(byte [], int)
try {
dp = new DatagramPacket("Hello".getBytes(), 5);
- assertTrue("Created incorrect packet", new String(dp.getData(), 0,
- dp.getData().length).equals("Hello"));
- assertTrue("Wrong length", dp.getLength() == 5);
+ assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
+ dp.getData().length));
+ assertEquals("Wrong length", 5, dp.getLength());
} catch (Exception e) {
fail("Exception during Constructor test: " + e.toString());
}
@@ -53,10 +53,10 @@
public void test_Constructor$BII() {
try {
dp = new DatagramPacket("Hello".getBytes(), 2, 3);
- assertTrue("Created incorrect packet", new String(dp.getData(), 0,
- dp.getData().length).equals("Hello"));
- assertTrue("Wrong length", dp.getLength() == 3);
- assertTrue("Wrong offset", dp.getOffset() == 2);
+ assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
+ dp.getData().length));
+ assertEquals("Wrong length", 3, dp.getLength());
+ assertEquals("Wrong offset", 2, dp.getOffset());
} catch (Exception e) {
fail("Exception during Constructor test: " + e.toString());
}
@@ -73,8 +73,8 @@
assertTrue("Created incorrect packet", dp.getAddress().equals(
InetAddress.getLocalHost())
&& dp.getPort() == 0);
- assertTrue("Wrong length", dp.getLength() == 3);
- assertTrue("Wrong offset", dp.getOffset() == 2);
+ assertEquals("Wrong length", 3, dp.getLength());
+ assertEquals("Wrong offset", 2, dp.getOffset());
} catch (Exception e) {
fail("Exception during Constructor test: " + e.toString());
}
@@ -93,7 +93,7 @@
assertTrue("Created incorrect packet", dp.getAddress().equals(
InetAddress.getLocalHost())
&& dp.getPort() == 0);
- assertTrue("Wrong length", dp.getLength() == 5);
+ assertEquals("Wrong length", 5, dp.getLength());
} catch (Exception e) {
fail("Exception during Constructor test: " + e.toString());
}
@@ -122,8 +122,8 @@
// Test for method byte [] java.net.DatagramPacket.getData()
dp = new DatagramPacket("Hello".getBytes(), 5);
- assertTrue("Incorrect length returned", new String(dp.getData(), 0, dp
- .getData().length).equals("Hello"));
+ assertEquals("Incorrect length returned", "Hello", new String(dp.getData(), 0, dp
+ .getData().length));
}
/**
@@ -133,7 +133,7 @@
// Test for method int java.net.DatagramPacket.getLength()
dp = new DatagramPacket("Hello".getBytes(), 5);
- assertTrue("Incorrect length returned", dp.getLength() == 5);
+ assertEquals("Incorrect length returned", 5, dp.getLength());
}
/**
@@ -141,7 +141,7 @@
*/
public void test_getOffset() {
dp = new DatagramPacket("Hello".getBytes(), 3, 2);
- assertTrue("Incorrect length returned", dp.getOffset() == 3);
+ assertEquals("Incorrect length returned", 3, dp.getOffset());
}
/**
@@ -152,7 +152,7 @@
try {
dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
.getLocalHost(), 1000);
- assertTrue("Incorrect port returned", dp.getPort() == 1000);
+ assertEquals("Incorrect port returned", 1000, dp.getPort());
} catch (Exception e) {
fail("Exception during getPort test : " + e.getMessage());
}
@@ -243,8 +243,8 @@
public void test_setData$BII() {
dp = new DatagramPacket("Hello".getBytes(), 5);
dp.setData("Wagga Wagga".getBytes(), 2, 3);
- assertTrue("Incorrect data set", new String(dp.getData())
- .equals("Wagga Wagga"));
+ assertEquals("Incorrect data set", "Wagga Wagga", new String(dp.getData())
+ );
}
/**
@@ -254,8 +254,8 @@
// Test for method void java.net.DatagramPacket.setData(byte [])
dp = new DatagramPacket("Hello".getBytes(), 5);
dp.setData("Ralph".getBytes());
- assertTrue("Incorrect data set", new String(dp.getData(), 0, dp
- .getData().length).equals("Ralph"));
+ assertEquals("Incorrect data set", "Ralph", new String(dp.getData(), 0, dp
+ .getData().length));
}
/**
@@ -265,7 +265,7 @@
// Test for method void java.net.DatagramPacket.setLength(int)
dp = new DatagramPacket("Hello".getBytes(), 5);
dp.setLength(1);
- assertTrue("Failed to set packet length", dp.getLength() == 1);
+ assertEquals("Failed to set packet length", 1, dp.getLength());
}
/**
@@ -277,7 +277,7 @@
dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
.getLocalHost(), 1000);
dp.setPort(2000);
- assertTrue("Port not set", dp.getPort() == 2000);
+ assertEquals("Port not set", 2000, dp.getPort());
} catch (Exception e) {
fail("Exception during setPort test : " + e.getMessage());
}
@@ -374,7 +374,7 @@
assertTrue("Socket address not set correctly (2)", theAddress
.equals(new InetSocketAddress(thePacket.getAddress(),
thePacket.getPort())));
- assertTrue("Offset not set correctly", thePacket.getOffset() == 1);
+ assertEquals("Offset not set correctly", 1, thePacket.getOffset());
} catch (Exception e) {
fail("Exception during constructor test(2):" + e.toString());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java Wed Apr 26 00:12:16 2006
@@ -557,8 +557,8 @@
int portNumber = Support_PortManager.getNextPort();
ds.connect(inetAddress, portNumber);
ds.disconnect();
- assertTrue("Incorrect InetAddress", ds.getInetAddress() == null);
- assertTrue("Incorrect Port", ds.getPort() == -1);
+ assertNull("Incorrect InetAddress", ds.getInetAddress());
+ assertEquals("Incorrect Port", -1, ds.getPort());
} catch (Exception e) {
fail("Exception during test : " + e.getMessage());
}
@@ -574,8 +574,8 @@
int portNumber = Support_PortManager.getNextPort();
ds.connect(inetAddress, portNumber);
ds.disconnect();
- assertTrue("Incorrect InetAddress", ds.getInetAddress() == null);
- assertTrue("Incorrect Port", ds.getPort() == -1);
+ assertNull("Incorrect InetAddress", ds.getInetAddress());
+ assertEquals("Incorrect Port", -1, ds.getPort());
} catch (Exception e) {
fail("Exception during test : " + e.getMessage());
}
@@ -658,8 +658,8 @@
try {
int portNumber = Support_PortManager.getNextPort();
DatagramSocket theSocket = new DatagramSocket(portNumber);
- assertTrue("Expected -1 for remote port as not connected",
- theSocket.getPort() == -1);
+ assertEquals("Expected -1 for remote port as not connected",
+ -1, theSocket.getPort());
// now connect the socket and validate that we get the right port
theSocket.connect(InetAddress.getLocalHost(), portNumber);
@@ -711,7 +711,7 @@
int portNumber = Support_PortManager.getNextPort();
ds = new java.net.DatagramSocket(portNumber);
ds.setSoTimeout(100);
- assertTrue("Returned incorrect timeout", ds.getSoTimeout() == 100);
+ assertEquals("Returned incorrect timeout", 100, ds.getSoTimeout());
ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_TIMEOUT);
} catch (Exception e) {
handleException(e, SO_TIMEOUT);
@@ -1073,8 +1073,8 @@
// all is ok
theSocket = new DatagramSocket(null);
theSocket.bind(null);
- assertTrue("Bind with null did not work", theSocket
- .getLocalSocketAddress() != null);
+ assertNotNull("Bind with null did not work", theSocket
+ .getLocalSocketAddress());
theSocket.close();
// now check the error conditions
@@ -1527,10 +1527,10 @@
portNumber = Support_PortManager.getNextPort();
theSocket.bind(new InetSocketAddress(InetAddress.getLocalHost(),
portNumber));
- assertTrue(
+ assertNull(
"Returned incorrect InetSocketAddress -unconnected socket:"
+ "Expected: NULL", theSocket
- .getRemoteSocketAddress() == null);
+ .getRemoteSocketAddress());
// now connect and validate we get the right answer
theSocket.connect(new InetSocketAddress(InetAddress.getLocalHost(),
@@ -1572,9 +1572,9 @@
// now create a socket that is not bound and validate we get the
// right answer
DatagramSocket theSocket = new DatagramSocket(null);
- assertTrue(
+ assertNull(
"Returned incorrect InetSocketAddress -unbound socket- Expected null",
- theSocket.getLocalSocketAddress() == null);
+ theSocket.getLocalSocketAddress());
// now bind the socket and make sure we get the right answer
portNumber = Support_PortManager.getNextPort();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java Wed Apr 26 00:12:16 2006
@@ -40,7 +40,7 @@
*/
public void test_getResponseCode() {
try {
- assertTrue("Wrong response", uc.getResponseCode() == 200);
+ assertEquals("Wrong response", 200, uc.getResponseCode());
} catch (IOException e) {
fail("Unexpected exception : " + e.getMessage());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java Wed Apr 26 00:12:16 2006
@@ -43,9 +43,9 @@
+ Support_Resources.getResourceURL("/JUC/lf.jar!/swt.dll"));
juc = (JarURLConnection) u.openConnection();
java.util.jar.Attributes a = juc.getJarEntry().getAttributes();
- assertTrue("Returned incorrect Attributes", a.get(
+ assertEquals("Returned incorrect Attributes", "SHA MD5", a.get(
new java.util.jar.Attributes.Name("Digest-Algorithms"))
- .equals("SHA MD5"));
+ );
} catch (java.io.IOException e) {
fail("Exception during test : " + e.getMessage());
}
@@ -59,13 +59,13 @@
URL u = new URL("jar:"
+ Support_Resources.getResourceURL("/JUC/lf.jar!/plus.bmp"));
juc = (JarURLConnection) u.openConnection();
- assertTrue("Returned incorrect entryName", juc.getEntryName()
- .equals("plus.bmp"));
+ assertEquals("Returned incorrect entryName", "plus.bmp", juc.getEntryName()
+ );
u = new URL("jar:"
+ Support_Resources.getResourceURL("/JUC/lf.jar!/"));
juc = (JarURLConnection) u.openConnection();
- assertTrue("Returned incorrect entryName",
- juc.getEntryName() == null);
+ assertNull("Returned incorrect entryName",
+ juc.getEntryName());
} catch (java.io.IOException e) {
fail("IOException during test : " + e.getMessage());
}
@@ -79,12 +79,12 @@
URL u = new URL("jar:"
+ Support_Resources.getResourceURL("/JUC/lf.jar!/plus.bmp"));
juc = (JarURLConnection) u.openConnection();
- assertTrue("Returned incorrect JarEntry", juc.getJarEntry()
- .getName().equals("plus.bmp"));
+ assertEquals("Returned incorrect JarEntry", "plus.bmp", juc.getJarEntry()
+ .getName());
u = new URL("jar:"
+ Support_Resources.getResourceURL("/JUC/lf.jar!/"));
juc = (JarURLConnection) u.openConnection();
- assertTrue("Returned incorrect JarEntry", juc.getJarEntry() == null);
+ assertNull("Returned incorrect JarEntry", juc.getJarEntry());
} catch (java.io.IOException e) {
fail("IOException during test : " + e.getMessage());
}
@@ -115,14 +115,14 @@
} catch (IOException e) {
exception = 1;
}
- assertTrue("Did not throw exception on connect", exception == 1);
+ assertEquals("Did not throw exception on connect", 1, exception);
exception = 0;
try {
connection.getJarFile();
} catch (IOException e) {
exception = 1;
}
- assertTrue("Did not throw exception after connect", exception == 1);
+ assertEquals("Did not throw exception after connect", 1, exception);
File resources = Support_Resources.createTempFolder();
try {
Support_Resources.copyFile(resources, null, "hyts_att.jar");
@@ -191,9 +191,9 @@
+ Support_Resources.getResourceURL("/JUC/lf.jar!/swt.dll"));
juc = (JarURLConnection) u.openConnection();
java.util.jar.Attributes a = juc.getMainAttributes();
- assertTrue("Returned incorrect Attributes", a.get(
- java.util.jar.Attributes.Name.MANIFEST_VERSION).equals(
- "1.0"));
+ assertEquals("Returned incorrect Attributes",
+ "1.0", a.get(
+ java.util.jar.Attributes.Name.MANIFEST_VERSION));
} catch (java.io.IOException e) {
fail("IOException during test : " + e.getMessage());
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java Wed Apr 26 00:12:16 2006
@@ -212,10 +212,10 @@
// set
mss = new MulticastSocket(groupPort);
NetworkInterface theInterface = mss.getNetworkInterface();
- assertTrue(
+ assertNotNull(
"network interface returned wrong network interface when not set:"
+ theInterface,
- theInterface.getInetAddresses() != null);
+ theInterface.getInetAddresses());
InetAddress firstAddress = (InetAddress) theInterface
.getInetAddresses().nextElement();
// validate we the first address in the network interface is the
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java Wed Apr 26 00:12:16 2006
@@ -25,8 +25,8 @@
public void test_ConstructorLjava_lang_String() {
// Test for method java.net.NetPermission(java.lang.String)
NetPermission n = new NetPermission("requestPasswordAuthentication");
- assertTrue("Returned incorrect name", n.getName().equals(
- "requestPasswordAuthentication"));
+ assertEquals("Returned incorrect name",
+ "requestPasswordAuthentication", n.getName());
}
/**
@@ -38,8 +38,8 @@
// java.lang.String)
NetPermission n = new NetPermission("requestPasswordAuthentication",
null);
- assertTrue("Returned incorrect name", n.getName().equals(
- "requestPasswordAuthentication"));
+ assertEquals("Returned incorrect name",
+ "requestPasswordAuthentication", n.getName());
}
/**
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java Wed Apr 26 00:12:16 2006
@@ -39,8 +39,8 @@
*/
public void test_getName() {
if (atLeastOneInterface) {
- assertTrue("validate that non null name is returned",
- networkInterface1.getName() != null);
+ assertNotNull("validate that non null name is returned",
+ networkInterface1.getName());
assertFalse("validate that non-zero length name is generated",
networkInterface1.getName().equals(""));
}
@@ -214,11 +214,11 @@
// This is to be compatible
for (int i = 0; i < notOkAddresses.size(); i++) {
try {
- assertTrue(
+ assertNotNull(
"validate we cannot get the NetworkInterface with an address for which we have no privs",
NetworkInterface
.getByInetAddress((InetAddress) notOkAddresses
- .get(i)) != null);
+ .get(i)));
} catch (Exception e) {
fail("get NetworkInterface for address with no perm - exception");
}
@@ -228,11 +228,11 @@
// addresses
try {
for (int i = 0; i < okAddresses.size(); i++) {
- assertTrue(
+ assertNotNull(
"validate we cannot get the NetworkInterface with an address fro which we have no privs",
NetworkInterface
.getByInetAddress((InetAddress) okAddresses
- .get(i)) != null);
+ .get(i)));
}
} catch (Exception e) {
fail("get NetworkInterface for address with perm - exception");
@@ -247,8 +247,8 @@
*/
public void test_getDisplayName() {
if (atLeastOneInterface) {
- assertTrue("validate that non null display name is returned",
- networkInterface1.getDisplayName() != null);
+ assertNotNull("validate that non null display name is returned",
+ networkInterface1.getDisplayName());
assertFalse(
"validate that non-zero lengtj display name is generated",
networkInterface1.getDisplayName().equals(""));
@@ -446,8 +446,8 @@
*/
public void test_toString() {
if (atLeastOneInterface) {
- assertTrue("validate that non null string is generated",
- networkInterface1.toString() != null);
+ assertNotNull("validate that non null string is generated",
+ networkInterface1.toString());
assertFalse("validate that non-zero length string is generated",
networkInterface1.toString().equals(""));
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java Wed Apr 26 00:12:16 2006
@@ -45,8 +45,8 @@
if (true)
throw new NoRouteToHostException("test");
} catch (NoRouteToHostException e) {
- assertTrue("Threw exception with incorrect message", e.getMessage()
- .equals("test"));
+ assertEquals("Threw exception with incorrect message", "test", e.getMessage()
+ );
return;
}
fail("Failed to generate expected exception");
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java Wed Apr 26 00:12:16 2006
@@ -292,7 +292,7 @@
int portNumber = Support_PortManager.getNextPort();
s = new ServerSocket(portNumber);
s.setSoTimeout(100);
- assertTrue("Returned incorrect sotimeout", s.getSoTimeout() == 100);
+ assertEquals("Returned incorrect sotimeout", 100, s.getSoTimeout());
} catch (Exception e) {
fail("Exception during getSoTimeout test : " + e.getMessage());
}
@@ -321,7 +321,7 @@
s.accept();
} catch (java.io.InterruptedIOException e) {
try {
- assertTrue("Set incorrect sotimeout", s.getSoTimeout() == 100);
+ assertEquals("Set incorrect sotimeout", 100, s.getSoTimeout());
return;
} catch (Exception x) {
fail("Exception during setSOTimeout: " + e.toString());
@@ -599,9 +599,9 @@
// now create a socket that is not bound and validate we get the
// right answer
theSocket = new ServerSocket();
- assertTrue(
+ assertNull(
"Returned incorrect InetSocketAddress -unbound socket- Expected null",
- theSocket.getLocalSocketAddress() == null);
+ theSocket.getLocalSocketAddress());
// now bind the socket and make sure we get the right answer
portNumber = Support_PortManager.getNextPort();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java?rev=397123&r1=397122&r2=397123&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java Wed Apr 26 00:12:16 2006
@@ -47,13 +47,13 @@
// Test for method java.net.SocketPermission(java.lang.String,
// java.lang.String)
assertTrue("Incorrect name", star_Resolve.getName().equals(starName));
- assertTrue("Incorrect actions", star_Resolve.getActions().equals(
- "resolve"));
+ assertEquals("Incorrect actions",
+ "resolve", star_Resolve.getActions());
SocketPermission sp1 = new SocketPermission("", "connect");
- assertTrue("Wrong name1", sp1.getName().equals("localhost"));
+ assertEquals("Wrong name1", "localhost", sp1.getName());
SocketPermission sp2 = new SocketPermission(":80", "connect");
- assertTrue("Wrong name2", sp2.getName().equals(":80"));
+ assertEquals("Wrong name2", ":80", sp2.getName());
}
/**
@@ -95,10 +95,10 @@
public void test_getActions() {
// Test for method java.lang.String
// java.net.SocketPermission.getActions()
- assertTrue("Incorrect actions", star_Resolve.getActions().equals(
- "resolve"));
- assertTrue("Incorrect actions/not in canonical form", star_All
- .getActions().equals("connect,listen,accept,resolve"));
+ assertEquals("Incorrect actions",
+ "resolve", star_Resolve.getActions());
+ assertEquals("Incorrect actions/not in canonical form", "connect,listen,accept,resolve", star_All
+ .getActions());
}
/**