Index: modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java =================================================================== --- modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java (revision 396457) +++ modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java (working copy) @@ -157,7 +157,7 @@ final String algorithm = "DESede/CBC/PKCS5Padding"; try { Cipher cipher = Cipher.getInstance(algorithm); - assertTrue("Block size does not match", cipher.getBlockSize() == 8); + assertEquals("Block size does not match", 8, cipher.getBlockSize()); } catch (Exception e) { fail("Unexpected Exception"); } Index: modules/crypto/src/test/java/javax/crypto/spec/PSourceTest.java =================================================================== --- modules/crypto/src/test/java/javax/crypto/spec/PSourceTest.java (revision 396457) +++ modules/crypto/src/test/java/javax/crypto/spec/PSourceTest.java (working copy) @@ -47,8 +47,8 @@ } catch (NullPointerException e) { } - assertTrue("The PSource.PSpecified DEFAULT value should be byte[0]", - PSource.PSpecified.DEFAULT.getValue().length == 0); + assertEquals("The PSource.PSpecified DEFAULT value should be byte[0]", + 0, PSource.PSpecified.DEFAULT.getValue().length); byte[] p = new byte[] {1, 2, 3, 4, 5}; PSource.PSpecified ps = new PSource.PSpecified(p); Index: modules/crypto/src/test/java/javax/crypto/spec/RC2ParameterSpecTest.java =================================================================== --- modules/crypto/src/test/java/javax/crypto/spec/RC2ParameterSpecTest.java (revision 396457) +++ modules/crypto/src/test/java/javax/crypto/spec/RC2ParameterSpecTest.java (working copy) @@ -131,8 +131,8 @@ + "should not cause the change of internal array.", result[0] == ps.getIV()[0]); ps = new RC2ParameterSpec(effectiveKeyBits); - assertTrue("The getIV() method should return null if the parameter " - + "set does not contain iv.", ps.getIV() == null); + assertNull("The getIV() method should return null if the parameter " + + "set does not contain iv.", ps.getIV()); } /** Index: modules/crypto/src/test/java/javax/crypto/spec/RC5ParameterSpecTest.java =================================================================== --- modules/crypto/src/test/java/javax/crypto/spec/RC5ParameterSpecTest.java (revision 396457) +++ modules/crypto/src/test/java/javax/crypto/spec/RC5ParameterSpecTest.java (working copy) @@ -192,8 +192,8 @@ + "should not cause the change of internal array.", result[0] == ps.getIV()[0]); ps = new RC5ParameterSpec(version, rounds, wordSize); - assertTrue("The getIV() method should return null if the parameter " - + "set does not contain IV.", ps.getIV() == null); + assertNull("The getIV() method should return null if the parameter " + + "set does not contain IV.", ps.getIV()); } /** Index: modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java =================================================================== --- modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java (revision 396457) +++ modules/crypto/src/test/java/javax/crypto/spec/PBEKeySpecTest.java (working copy) @@ -253,8 +253,8 @@ + "should not cause the change of internal array.", result[0] == pbeks.getSalt()[0]); pbeks = new PBEKeySpec(password); - assertTrue("The getSalt() method should return null if the salt " - + "is not specified.", pbeks.getSalt() == null); + assertNull("The getSalt() method should return null if the salt " + + "is not specified.", pbeks.getSalt()); } /** Index: modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/ZipOutputStreamTest.java (working copy) @@ -91,7 +91,7 @@ zos.putNextEntry(ze); zos.write("Hello World".getBytes()); zos.finish(); - assertTrue("Finish failed to closeCurrentEntry", ze.getSize() == 11); + assertEquals("Finish failed to closeCurrentEntry", 11, ze.getSize()); } catch (IOException e) { fail("Exception during finish test: " + e.toString()); } Index: modules/archive/src/test/java/tests/api/java/util/zip/InflaterInputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/InflaterInputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/InflaterInputStreamTest.java (working copy) @@ -194,8 +194,8 @@ * InflaterInputStream(infile, inflate); * * inflatIP.read(byteArray, 0, 4);// ony suppose to read in 4 bytes - * inflatIP.close(); assertTrue( "the fifth element of byteArray - * contained a non zero value", byteArray[4] == 0); } catch + * inflatIP.close(); assertEquals("the fifth element of byteArray + * contained a non zero value", 0, byteArray[4]); } catch * (FileNotFoundException e) { fail( "input file to test * InflaterInputStream constructor is not found"); } catch * (ZipException e) { fail( "read() threw an zip exception while @@ -257,27 +257,27 @@ fail("IllegalArgumentException not thrown"); } catch (IllegalArgumentException e) { } - assertTrue("Incorrect Byte Returned.", iis.read() == 5); + assertEquals("Incorrect Byte Returned.", 5, iis.read()); try { iis.skip(Integer.MIN_VALUE); fail("IllegalArgumentException not thrown"); } catch (IllegalArgumentException e) { } - assertTrue("Incorrect Byte Returned.", iis.read() == 4); + assertEquals("Incorrect Byte Returned.", 4, iis.read()); // Test to make sure the correct number of bytes were skipped - assertTrue("Incorrect Number Of Bytes Skipped.", iis.skip(3) == 3); + assertEquals("Incorrect Number Of Bytes Skipped.", 3, iis.skip(3)); // Test to see if the number of bytes skipped returned is true. - assertTrue("Incorrect Byte Returned.", iis.read() == 7); + assertEquals("Incorrect Byte Returned.", 7, iis.read()); - assertTrue("Incorrect Number Of Bytes Skipped.", iis.skip(0) == 0); - assertTrue("Incorrect Byte Returned.", iis.read() == 0); + assertEquals("Incorrect Number Of Bytes Skipped.", 0, iis.skip(0)); + assertEquals("Incorrect Byte Returned.", 0, iis.read()); // Test for skipping more bytes than available in the stream - assertTrue("Incorrect Number Of Bytes Skipped.", iis.skip(4) == 2); - assertTrue("Incorrect Byte Returned.", iis.read() == -1); + assertEquals("Incorrect Number Of Bytes Skipped.", 2, iis.skip(4)); + assertEquals("Incorrect Byte Returned.", -1, iis.read()); iis.close(); } catch (IOException e) { fail("Unexpected IOException during test"); @@ -317,17 +317,16 @@ skip = inflatIP2.skip(Integer.MAX_VALUE); // System.out.println(skip); - assertTrue("method skip() returned wrong number of bytes skiped", - skip == 5); + assertEquals("method skip() returned wrong number of bytes skiped", + 5, skip); // test for skiping of 2 bytes InputStream infile3 = Support_Resources .getStream("hyts_constru(OD).txt"); InflaterInputStream inflatIP3 = new InflaterInputStream(infile3); skip = inflatIP3.skip(2); - assertTrue( - "the number of bytes returned by skip did not correspond with its input parameters", - skip == 2); + assertEquals("the number of bytes returned by skip did not correspond with its input parameters", + 2, skip); int i = 0; result = 0; while ((result = inflatIP3.read()) != -1) { @@ -369,11 +368,11 @@ read = iis.read(); available = iis.available(); if (read == -1) - assertTrue("Bytes Available Should Return 0 ", - available == 0); + assertEquals("Bytes Available Should Return 0 ", + 0, available); else - assertTrue("Bytes Available Should Return 1.", - available == 1); + assertEquals("Bytes Available Should Return 1.", + 1, available); } iis.close(); Index: modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/ZipFileTest.java (working copy) @@ -100,12 +100,12 @@ out.close(); /* * ZipFile zip = new ZipFile(file); ZipEntry entry1 = - * zip.getEntry("File1.txt"); assertTrue("Did not find entry", - * entry1 != null); entry1 = null; zip = null; + * zip.getEntry("File1.txt"); assertNotNull("Did not find entry", + * entry1); entry1 = null; zip = null; */ - assertTrue("Did not find entry", - test_finalize1(test_finalize2(file)) != null); + assertNotNull("Did not find entry", + test_finalize1(test_finalize2(file))); System.gc(); System.gc(); System.runFinalization(); @@ -166,40 +166,40 @@ // Test for method java.util.zip.ZipEntry // java.util.zip.ZipFile.getEntry(java.lang.String) java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt"); - assertTrue("Could not obtain ZipEntry", zentry != null); + assertNotNull("Could not obtain ZipEntry", zentry); zentry = zfile.getEntry("testdir1/File1.txt"); - assertTrue("Could not obtain ZipEntry: testdir1/File1.txt", - zentry != null); + assertNotNull("Could not obtain ZipEntry: testdir1/File1.txt", + zentry); try { int r; InputStream in; zentry = zfile.getEntry("testdir1/"); - assertTrue("Could not obtain ZipEntry: testdir1/", zentry != null); + assertNotNull("Could not obtain ZipEntry: testdir1/", zentry); in = zfile.getInputStream(zentry); - assertTrue("testdir1/ should not have null input stream", - in != null); + assertNotNull("testdir1/ should not have null input stream", + in); r = in.read(); in.close(); - assertTrue("testdir1/ should not contain data", r == -1); + assertEquals("testdir1/ should not contain data", -1, r); zentry = zfile.getEntry("testdir1"); - assertTrue("Could not obtain ZipEntry: testdir1", zentry != null); + assertNotNull("Could not obtain ZipEntry: testdir1", zentry); in = zfile.getInputStream(zentry); - assertTrue("testdir1 should not have null input stream", in != null); + assertNotNull("testdir1 should not have null input stream", in); r = in.read(); in.close(); - assertTrue("testdir1 should not contain data", r == -1); + assertEquals("testdir1 should not contain data", -1, r); zentry = zfile.getEntry("testdir1/testdir1"); - assertTrue("Could not obtain ZipEntry: testdir1/testdir1", - zentry != null); + assertNotNull("Could not obtain ZipEntry: testdir1/testdir1", + zentry); in = zfile.getInputStream(zentry); byte[] buf = new byte[256]; r = in.read(buf); in.close(); - assertTrue("incorrect contents", new String(buf, 0, r) - .equals("This is also text")); + assertEquals("incorrect contents", "This is also text", new String(buf, 0, r) + ); } catch (IOException e) { fail("Unexpected: " + e); } @@ -218,8 +218,8 @@ byte[] rbuf = new byte[1000]; int r; is.read(rbuf, 0, r = (int) zentry.getSize()); - assertTrue("getInputStream read incorrect data", new String(rbuf, - 0, r).equals("This is text")); + assertEquals("getInputStream read incorrect data", "This is text", new String(rbuf, + 0, r)); } catch (java.io.IOException e) { fail("IOException during getInputStream"); } finally { Index: modules/archive/src/test/java/tests/api/java/util/zip/InflaterTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/InflaterTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/InflaterTest.java (working copy) @@ -49,7 +49,7 @@ } catch (NullPointerException e) { r = 1; } - assertTrue("inflate can still be used after end is called", r == 1); + assertEquals("inflate can still be used after end is called", 1, r); Inflater i = new Inflater(); i.end(); @@ -84,9 +84,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - finished()", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - finished()", + 0, outPutInf[byteArray.length]); } /** @@ -116,9 +115,8 @@ // test method of java.util.zip.inflater.getRemaining() byte byteArray[] = { 1, 3, 5, 6, 7 }; Inflater inflate = new Inflater(); - assertTrue( - "upon creating an instance of inflate, getRemaining returned a non zero value", - inflate.getRemaining() == 0); + assertEquals("upon creating an instance of inflate, getRemaining returned a non zero value", + 0, inflate.getRemaining()); inflate.setInput(byteArray); assertTrue( "getRemaining returned zero when there is input in the input buffer", @@ -272,9 +270,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - inflateB", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - inflateB", + 0, outPutInf[byteArray.length]); // testing for an empty input array byte outPutBuf[] = new byte[500]; byte emptyArray[] = new byte[11]; @@ -309,12 +306,11 @@ assertTrue( "Final decompressed data does not equal the original data", emptyArray[i] == outPutInf[i]); - assertTrue("Final decompressed data does not equal zero", - outPutInf[i] == 0); + assertEquals("Final decompressed data does not equal zero", + 0, outPutInf[i]); } - assertTrue( - "Final decompressed data contains more element than original data", - outPutInf[emptyArray.length] == 0); + assertEquals("Final decompressed data contains more element than original data", + 0, outPutInf[emptyArray.length]); } /** @@ -342,9 +338,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - inflateB", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - inflateB", + 0, outPutInf[byteArray.length]); // test boundary checks inflate.reset(); @@ -362,7 +357,7 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue("out of bounds error did not get caught", r == 1); + assertEquals("out of bounds error did not get caught", 1, r); } /** @@ -372,8 +367,8 @@ // test method of java.util.zip.inflater.Inflater() try { Inflater inflate = new Inflater(); - assertTrue("failed to create the instance of inflater", - inflate != null); + assertNotNull("failed to create the instance of inflater", + inflate); } catch (Exception e) { @@ -390,7 +385,7 @@ // doesn't or vice versa. byte byteArray[] = { 1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5' }; Inflater inflate = new Inflater(true); - assertTrue("failed to create the instance of inflater", inflate != null); + assertNotNull("failed to create the instance of inflater", inflate); byte outPutInf[] = new byte[500]; int r = 0; try { @@ -402,16 +397,14 @@ inflate.inflate(outPutInf); } for (int i = 0; i < byteArray.length; i++) { - assertTrue( - "the output array from inflate should contain 0 because the header of inflate and deflate did not match, but this faled", - outPutBuff1[i] == 0); + assertEquals("the output array from inflate should contain 0 because the header of inflate and deflate did not match, but this faled", + 0, outPutBuff1[i]); } } catch (DataFormatException e) { r = 1; } - assertTrue( - "Error: exception should be thrown becuase of header inconsistancy", - r == 1); + assertEquals("Error: exception should be thrown becuase of header inconsistancy", + 1, r); } @@ -429,8 +422,8 @@ inflateDiction.setInput(outPutDiction); } try { - assertTrue("should return 0 because needs dictionary", - inflateDiction.inflate(outPutInf) == 0); + assertEquals("should return 0 because needs dictionary", + 0, inflateDiction.inflate(outPutInf)); } catch (DataFormatException e) { fail("Should not cause exception"); } @@ -501,9 +494,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - reset", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - reset", + 0, outPutInf[byteArray.length]); // testing that resetting the inflater will also return the correct // decompressed data @@ -524,9 +516,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - reset", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - reset", + 0, outPutInf[byteArray.length]); } @@ -556,9 +547,8 @@ } catch (DataFormatException e) { r = 1; } - assertTrue( - "invalid input to be decompressed due to dictionary not set", - r == 1); + assertEquals("invalid input to be decompressed due to dictionary not set", + 1, r); // now setting the dictionary in inflater Inflater inflate = new Inflater(); try { @@ -579,9 +569,8 @@ "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); } - assertTrue( - "final decompressed data contained more bytes than original - deflateB", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - deflateB", + 0, outPutInf[byteArray.length]); } /** @@ -617,7 +606,7 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue("boundary check is not present for setInput", r == 1); + assertEquals("boundary check is not present for setInput", 1, r); } protected void setUp() { Index: modules/archive/src/test/java/tests/api/java/util/zip/GZIPInputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/GZIPInputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/GZIPInputStreamTest.java (working copy) @@ -61,10 +61,10 @@ + "/GZIPInputStream/hyts_gInput.txt").toURL(); TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput .openConnection().getInputStream()); - assertTrue("the constructor for GZIPInputStream is null", - inGZIP != null); - assertTrue("the CRC value of the inputStream is not zero", inGZIP - .getChecksum().getValue() == 0); + assertNotNull("the constructor for GZIPInputStream is null", + inGZIP); + assertEquals("the CRC value of the inputStream is not zero", 0, inGZIP + .getChecksum().getValue()); inGZIP.close(); } catch (IOException e) { fail( @@ -85,10 +85,10 @@ + "/GZIPInputStream/hyts_gInput.txt").toURL(); TestGZIPInputStream inGZIP = new TestGZIPInputStream(gInput .openConnection().getInputStream(), 200); - assertTrue("the constructor for GZIPInputStream is null", - inGZIP != null); - assertTrue("the CRC value of the inputStream is not zero", inGZIP - .getChecksum().getValue() == 0); + assertNotNull("the constructor for GZIPInputStream is null", + inGZIP); + assertEquals("the CRC value of the inputStream is not zero", 0, inGZIP + .getChecksum().getValue()); inGZIP.close(); } catch (IOException e) { fail( @@ -117,9 +117,8 @@ while (!(inGZIP.endofInput())) { result += inGZIP.read(outBuf, result, outBuf.length - result); } - assertTrue( - "the checkSum value of the compressed and decompressed data does not equal", - inGZIP.getChecksum().getValue() == 3097700292L); + assertEquals("the checkSum value of the compressed and decompressed data does not equal", + 3097700292L, inGZIP.getChecksum().getValue()); for (int i = 0; i < orgBuf.length; i++) { assertTrue( "the decompressed data does not equal the orginal data decompressed", @@ -133,7 +132,7 @@ r = 1; } inGZIP.close(); - assertTrue("Boundary Check was not present", r == 1); + assertEquals("Boundary Check was not present", 1, r); } catch (IOException e) { e.printStackTrace(); fail("unexpected: " + e); @@ -158,7 +157,7 @@ int result, total = 0; while ((result = gin2.read(test)) != -1) total += result; - assertTrue("Should return -1", gin2.read() == -1); + assertEquals("Should return -1", -1, gin2.read()); gin2.close(); assertTrue("Incorrectly decompressed", total == test.length); @@ -167,7 +166,7 @@ while ((result = gin2.read(new byte[200])) != -1) { total += result; } - assertTrue("Should return -1", gin2.read() == -1); + assertEquals("Should return -1", -1, gin2.read()); gin2.close(); assertTrue("Incorrectly decompressed", total == test.length); @@ -176,7 +175,7 @@ while ((result = gin2.read(new byte[200])) != -1) { total += result; } - assertTrue("Should return -1", gin2.read() == -1); + assertEquals("Should return -1", -1, gin2.read()); gin2.close(); assertTrue("Incorrectly decompressed", total == test.length); @@ -215,9 +214,8 @@ while (!(inGZIP.endofInput())) { result += inGZIP.read(outBuf, result, outBuf.length - result); } - assertTrue( - "the checkSum value of the compressed and decompressed data does not equal", - inGZIP.getChecksum().getValue() == 3097700292L); + assertEquals("the checkSum value of the compressed and decompressed data does not equal", + 3097700292L, inGZIP.getChecksum().getValue()); inGZIP.close(); int r = 0; try { @@ -225,9 +223,8 @@ } catch (IOException e) { r = 1; } - assertTrue( - "GZIPInputStream can still be used after close is called", - r == 1); + assertEquals("GZIPInputStream can still be used after close is called", + 1, r); } catch (IOException e) { e.printStackTrace(); fail("unexpected: " + e); Index: modules/archive/src/test/java/tests/api/java/util/zip/GZIPOutputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/GZIPOutputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/GZIPOutputStreamTest.java (working copy) @@ -46,10 +46,10 @@ try { FileOutputStream outFile = new FileOutputStream("GZIPOutCon.txt"); TestGZIPOutputStream outGZIP = new TestGZIPOutputStream(outFile); - assertTrue("the constructor for GZIPOutputStream is null", - outGZIP != null); - assertTrue("the CRC value of the outputStream is not zero", outGZIP - .getChecksum().getValue() == 0); + assertNotNull("the constructor for GZIPOutputStream is null", + outGZIP); + assertEquals("the CRC value of the outputStream is not zero", 0, outGZIP + .getChecksum().getValue()); outGZIP.close(); } catch (IOException e) { fail( @@ -66,10 +66,10 @@ FileOutputStream outFile = new FileOutputStream("GZIPOutCon.txt"); TestGZIPOutputStream outGZIP = new TestGZIPOutputStream(outFile, 100); - assertTrue("the constructor for GZIPOutputStream is null", - outGZIP != null); - assertTrue("the CRC value of the outputStream is not zero", outGZIP - .getChecksum().getValue() == 0); + assertNotNull("the constructor for GZIPOutputStream is null", + outGZIP); + assertEquals("the CRC value of the outputStream is not zero", 0, outGZIP + .getChecksum().getValue()); outGZIP.close(); } catch (IOException e) { fail( @@ -95,9 +95,8 @@ r = 1; } - assertTrue( - "GZIP instance can still be used after finish is called", - r == 1); + assertEquals("GZIP instance can still be used after finish is called", + 1, r); outGZIP.close(); } catch (IOException e) { fail( @@ -121,8 +120,8 @@ } catch (IOException e) { r = 1; } - assertTrue("GZIP instance can still be used after close is called", - r == 1); + assertEquals("GZIP instance can still be used after close is called", + 1, r); } catch (IOException e) { fail( "an IO error occured while trying to find the output file or creating GZIP constructor"); @@ -141,9 +140,8 @@ outGZIP.write(byteArray, 0, 10); // ran JDK and found this CRC32 value is 3097700292 // System.out.print(outGZIP.getChecksum().getValue()); - assertTrue( - "the checksum value was incorrect result of write from GZIP", - outGZIP.getChecksum().getValue() == 3097700292L); + assertEquals("the checksum value was incorrect result of write from GZIP", + 3097700292L, outGZIP.getChecksum().getValue()); // test for boundary check int r = 0; @@ -152,7 +150,7 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue("out of bounds exception is not present", r == 1); + assertEquals("out of bounds exception is not present", 1, r); outGZIP.close(); } catch (IOException e) { fail( Index: modules/archive/src/test/java/tests/api/java/util/zip/CRC32Test.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/CRC32Test.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/CRC32Test.java (working copy) @@ -26,7 +26,7 @@ public void test_Constructor() { // test methods of java.util.zip.CRC32() CRC32 crc = new CRC32(); - assertTrue("Constructor of CRC32 failed", crc.getValue() == 0); + assertEquals("Constructor of CRC32 failed", 0, crc.getValue()); } /** @@ -35,18 +35,16 @@ public void test_getValue() { // test methods of java.util.zip.crc32.getValue() CRC32 crc = new CRC32(); - assertTrue( - "getValue() should return a zero as a result of constructing a CRC32 instance", - crc.getValue() == 0); + assertEquals("getValue() should return a zero as a result of constructing a CRC32 instance", + 0, crc.getValue()); crc.reset(); crc.update(Integer.MAX_VALUE); // System.out.print("value of crc " + crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 4278190080 - assertTrue( - "update(max) failed to update the checksum to the correct value ", - crc.getValue() == 4278190080L); + assertEquals("update(max) failed to update the checksum to the correct value ", + 4278190080L, crc.getValue()); crc.reset(); byte byteEmpty[] = new byte[10000]; @@ -54,20 +52,19 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 1295764014 - assertTrue( - "update(byte[]) failed to update the checksum to the correct value ", - crc.getValue() == 1295764014L); + assertEquals("update(byte[]) failed to update the checksum to the correct value ", + 1295764014L, crc.getValue()); crc.reset(); crc.update(1); // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 2768625435 - // assertTrue("update(int) failed to update the checksum to the correct - // value ",crc.getValue() == 2768625435L); + // assertEquals("update(int) failed to update the checksum to the correct + // value ",2768625435L, crc.getValue()); crc.reset(); - assertTrue("reset failed to reset the checksum value to zero", crc - .getValue() == 0); + assertEquals("reset failed to reset the checksum value to zero", 0, crc + .getValue()); } /** @@ -80,12 +77,11 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 2768625435 - assertTrue( - "update(int) failed to update the checksum to the correct value ", - crc.getValue() == 2768625435L); + assertEquals("update(int) failed to update the checksum to the correct value ", + 2768625435L, crc.getValue()); crc.reset(); - assertTrue("reset failed to reset the checksum value to zero", crc - .getValue() == 0); + assertEquals("reset failed to reset the checksum value to zero", 0, crc + .getValue()); } @@ -99,27 +95,24 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 2768625435 - assertTrue( - "update(1) failed to update the checksum to the correct value ", - crc.getValue() == 2768625435L); + assertEquals("update(1) failed to update the checksum to the correct value ", + 2768625435L, crc.getValue()); crc.reset(); crc.update(Integer.MAX_VALUE); // System.out.print("value of crc " + crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 4278190080 - assertTrue( - "update(max) failed to update the checksum to the correct value ", - crc.getValue() == 4278190080L); + assertEquals("update(max) failed to update the checksum to the correct value ", + 4278190080L, crc.getValue()); crc.reset(); crc.update(Integer.MIN_VALUE); // System.out.print("value of crc " + crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 3523407757 - assertTrue( - "update(min) failed to update the checksum to the correct value ", - crc.getValue() == 3523407757L); + assertEquals("update(min) failed to update the checksum to the correct value ", + 3523407757L, crc.getValue()); } /** @@ -133,9 +126,8 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 3066839698 - assertTrue( - "update(byte[]) failed to update the checksum to the correct value ", - crc.getValue() == 3066839698L); + assertEquals("update(byte[]) failed to update the checksum to the correct value ", + 3066839698L, crc.getValue()); crc.reset(); byte byteEmpty[] = new byte[10000]; @@ -143,9 +135,8 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 1295764014 - assertTrue( - "update(byte[]) failed to update the checksum to the correct value ", - crc.getValue() == 1295764014L); + assertEquals("update(byte[]) failed to update the checksum to the correct value ", + 1295764014L, crc.getValue()); } /** @@ -163,26 +154,24 @@ // System.out.print("value of crc"+crc.getValue()); // Ran JDK and discovered that the value of the CRC should be // 1259060791 - assertTrue( - "update(byte[],int,int) failed to update the checksum to the correct value ", - crc.getValue() == 1259060791L); + assertEquals("update(byte[],int,int) failed to update the checksum to the correct value ", + 1259060791L, crc.getValue()); int r = 0; try { crc.update(byteArray, off, lenError); } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue( - "update(byte[],int,int) failed b/c lenError>byte[].length-off", - r == 1); + assertEquals("update(byte[],int,int) failed b/c lenError>byte[].length-off", + 1, r); try { crc.update(byteArray, offError, len); } catch (ArrayIndexOutOfBoundsException e) { r = 2; } - assertTrue("update(byte[],int,int) failed b/c offError>byte[].length", - r == 2); + assertEquals("update(byte[],int,int) failed b/c offError>byte[].length", + 2, r); } protected void setUp() { Index: modules/archive/src/test/java/tests/api/java/util/zip/CheckedInputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/CheckedInputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/CheckedInputStreamTest.java (working copy) @@ -40,8 +40,8 @@ checkInput = Support_Resources.getStream("hyts_checkInput.txt"); CheckedInputStream checkIn = new CheckedInputStream(checkInput, new CRC32()); - assertTrue("constructor of checkedInputStream has failed", checkIn - .getChecksum().getValue() == 0); + assertEquals("constructor of checkedInputStream has failed", 0, checkIn + .getChecksum().getValue()); checkInput.close(); } catch (FileNotFoundException e) { fail("File for checkInputStream is not found"); @@ -65,8 +65,8 @@ new CRC32()); while (checkEmpty.read() >= 0) { } - assertTrue("the checkSum value of an empty file is not zero", - checkEmpty.getChecksum().getValue() == 0); + assertEquals("the checkSum value of an empty file is not zero", + 0, checkEmpty.getChecksum().getValue()); inEmp.close(); // testing getChecksum for the file checkInput @@ -77,8 +77,8 @@ } // ran JDK and found that the checkSum value of this is 2036203193 // System.out.print(" " + checkIn.getChecksum().getValue()); - assertTrue("the checksum value is incorrect", checkIn.getChecksum() - .getValue() == 2036203193); + assertEquals("the checksum value is incorrect", 2036203193, checkIn.getChecksum() + .getValue()); checkInput.close(); // testing getChecksum for file checkInput checkInput = Support_Resources.getStream("hyts_checkInput.txt"); @@ -87,8 +87,8 @@ checkIn2.read(outBuf, 0, 10); // ran JDK and found that the checkSum value of this is 2235765342 // System.out.print(" " + checkIn2.getChecksum().getValue()); - assertTrue("the checksum value is incorrect", checkIn2 - .getChecksum().getValue() == 2235765342L); + assertEquals("the checksum value is incorrect", 2235765342L, checkIn2 + .getChecksum().getValue()); checkInput.close(); } catch (FileNotFoundException e) { fail("File for checkInputStream is not found"); @@ -114,8 +114,8 @@ checkIn.skip(skipValue); // ran JDK and found the checkSum value is 2235765342 // System.out.print(checkIn.getChecksum().getValue()); - assertTrue("checkSum value is not correct", checkIn.getChecksum() - .getValue() == 2235765342L); + assertEquals("checkSum value is not correct", 2235765342L, checkIn.getChecksum() + .getValue()); checkInput.close(); } catch (FileNotFoundException e) { fail("File for checkInputStream is not found"); Index: modules/archive/src/test/java/tests/api/java/util/zip/CheckedOutputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/CheckedOutputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/CheckedOutputStreamTest.java (working copy) @@ -35,8 +35,8 @@ FileOutputStream outFile = new FileOutputStream("chkOut.txt"); CheckedOutputStream chkOut = new CheckedOutputStream(outFile, new CRC32()); - assertTrue("the checkSum value of the constructor is not 0", chkOut - .getChecksum().getValue() == 0); + assertEquals("the checkSum value of the constructor is not 0", 0, chkOut + .getChecksum().getValue()); outFile.close(); } catch (IOException e) { fail("Unable to find file"); @@ -60,15 +60,15 @@ // ran JDK and found that checkSum value is 7536755 // System.out.print(chkOut.getChecksum().getValue()); - assertTrue("the checkSum value for writeI is incorrect", chkOut - .getChecksum().getValue() == 7536755); + assertEquals("the checkSum value for writeI is incorrect", 7536755, chkOut + .getChecksum().getValue()); chkOut.getChecksum().reset(); chkOut.write(byteArray, 5, 4); // ran JDK and found that checkSum value is 51708133 // System.out.print(" " +chkOut.getChecksum().getValue()); - assertTrue("the checkSum value for writeBII is incorrect ", chkOut - .getChecksum().getValue() == 51708133); + assertEquals("the checkSum value for writeBII is incorrect ", 51708133, chkOut + .getChecksum().getValue()); outFile.close(); } catch (IOException e) { fail("Unable to find file"); @@ -122,7 +122,7 @@ } catch (IndexOutOfBoundsException e) { r = 1; } - assertTrue("boundary check is not performed", r == 1); + assertEquals("boundary check is not performed", 1, r); outFile.close(); } catch (IOException e) { fail("Unable to find file"); Index: modules/archive/src/test/java/tests/api/java/util/zip/DeflaterOutputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/DeflaterOutputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/DeflaterOutputStreamTest.java (working copy) @@ -76,8 +76,8 @@ // Test to see if DflaterOutputStream was created with the correct // buffer. - assertTrue("Incorrect Buffer Size", - dos.getProtectedBuf().length == 512); + assertEquals("Incorrect Buffer Size", + 512, dos.getProtectedBuf().length); dos.write(byteArray); dos.close(); @@ -103,8 +103,8 @@ // Test to see if DflaterOutputStream was created with the correct // buffer. - assertTrue("Incorrect Buffer Size", - dos.getProtectedBuf().length == 512); + assertEquals("Incorrect Buffer Size", + 512, dos.getProtectedBuf().length); dos.write(outPutBuf); dos.close(); @@ -160,8 +160,8 @@ // Test to see if DflaterOutputStream was created with the correct // buffer. dos = new MyDeflaterOutputStream(fos, defl, buf); - assertTrue("Incorrect Buffer Size", - dos.getProtectedBuf().length == 5); + assertEquals("Incorrect Buffer Size", + 5, dos.getProtectedBuf().length); dos.write(byteArray); dos.close(); @@ -196,12 +196,12 @@ dos.close(); // Test to see if the finish method wrote the bytes to the file. - assertTrue("Incorrect Byte Returned.", iis.read() == 1); - assertTrue("Incorrect Byte Returned.", iis.read() == 3); - assertTrue("Incorrect Byte Returned.", iis.read() == 4); - assertTrue("Incorrect Byte Returned.", iis.read() == 6); - assertTrue("Incorrect Byte Returned.", iis.read() == -1); - assertTrue("Incorrect Byte Returned.", iis.read() == -1); + assertEquals("Incorrect Byte Returned.", 1, iis.read()); + assertEquals("Incorrect Byte Returned.", 3, iis.read()); + assertEquals("Incorrect Byte Returned.", 4, iis.read()); + assertEquals("Incorrect Byte Returned.", 6, iis.read()); + assertEquals("Incorrect Byte Returned.", -1, iis.read()); + assertEquals("Incorrect Byte Returned.", -1, iis.read()); iis.close(); // Not sure if this test will stay. @@ -330,8 +330,8 @@ InflaterInputStream iis = new InflaterInputStream(fis); for (int i = 0; i < 3; i++) assertTrue("Incorrect Byte Returned.", iis.read() == i); - assertTrue("Incorrect Byte Returned (EOF).", iis.read() == -1); - assertTrue("Incorrect Byte Returned (EOF).", iis.read() == -1); + assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); + assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); iis.close(); // Not sure if this test is that important. @@ -372,11 +372,11 @@ dos1.close(); FileInputStream fis = new FileInputStream(f1); InflaterInputStream iis = new InflaterInputStream(fis); - assertTrue("Incorrect Byte Returned.", iis.read() == 4); - assertTrue("Incorrect Byte Returned.", iis.read() == 7); - assertTrue("Incorrect Byte Returned.", iis.read() == 8); - assertTrue("Incorrect Byte Returned (EOF).", iis.read() == -1); - assertTrue("Incorrect Byte Returned (EOF).", iis.read() == -1); + assertEquals("Incorrect Byte Returned.", 4, iis.read()); + assertEquals("Incorrect Byte Returned.", 7, iis.read()); + assertEquals("Incorrect Byte Returned.", 8, iis.read()); + assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); + assertEquals("Incorrect Byte Returned (EOF).", -1, iis.read()); iis.close(); f1.delete(); Index: modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/ZipEntryTest.java (working copy) @@ -47,7 +47,7 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.util.zip.ZipEntry(java.lang.String) zentry = zfile.getEntry("File3.txt"); - assertTrue("Failed to create ZipEntry", zentry != null); + assertNotNull("Failed to create ZipEntry", zentry); try { zentry = zfile.getEntry(null); fail("NullPointerException not thrown"); @@ -81,10 +81,10 @@ public void test_getComment() { // Test for method java.lang.String java.util.zip.ZipEntry.getComment() ZipEntry zipEntry = new ZipEntry("zippy.zip"); - assertTrue("Incorrect Comment Returned.", zipEntry.getComment() == null); + assertNull("Incorrect Comment Returned.", zipEntry.getComment()); zipEntry.setComment("This Is A Comment"); - assertTrue("Incorrect Comment Returned.", zipEntry.getComment().equals( - "This Is A Comment")); + assertEquals("Incorrect Comment Returned.", + "This Is A Comment", zipEntry.getComment()); } /** @@ -109,8 +109,8 @@ */ public void test_getExtra() { // Test for method byte [] java.util.zip.ZipEntry.getExtra() - assertTrue("Incorrect extra information returned", - zentry.getExtra() == null); + assertNull("Incorrect extra information returned", + zentry.getExtra()); byte[] ba = { 'T', 'E', 'S', 'T' }; zentry = new ZipEntry("test.tst"); zentry.setExtra(ba); @@ -130,7 +130,7 @@ assertTrue("Incorrect compression method returned", zentry.getMethod() == java.util.zip.ZipEntry.DEFLATED); zentry = new ZipEntry("test.tst"); - assertTrue("Incorrect Method Returned.", zentry.getMethod() == -1); + assertEquals("Incorrect Method Returned.", -1, zentry.getMethod()); } /** @@ -138,9 +138,8 @@ */ public void test_getName() { // Test for method java.lang.String java.util.zip.ZipEntry.getName() - assertTrue( - "Incorrect name returned - Note return result somewhat ambiguous in spec", - zentry.getName().equals("File1.txt")); + assertEquals("Incorrect name returned - Note return result somewhat ambiguous in spec", + "File1.txt", zentry.getName()); } /** @@ -179,11 +178,11 @@ // java.util.zip.ZipEntry.setComment(java.lang.String) zentry = zfile.getEntry("File1.txt"); zentry.setComment("Set comment using api"); - assertTrue("Comment not correctly set", zentry.getComment().equals( - "Set comment using api")); + assertEquals("Comment not correctly set", + "Set comment using api", zentry.getComment()); String n = null; zentry.setComment(n); - assertTrue("Comment not correctly set", zentry.getComment() == null); + assertNull("Comment not correctly set", zentry.getComment()); StringBuffer s = new StringBuffer(); for (int i = 0; i < 0xFFFF; i++) s.append('a'); @@ -209,11 +208,11 @@ assertTrue("Set compressed size failed", zentry.getCompressedSize() == (orgCompressedSize + 10)); zentry.setCompressedSize(0); - assertTrue("Set compressed size failed", - zentry.getCompressedSize() == 0); + assertEquals("Set compressed size failed", + 0, zentry.getCompressedSize()); zentry.setCompressedSize(-25); - assertTrue("Set compressed size failed", - zentry.getCompressedSize() == -25); + assertEquals("Set compressed size failed", + -25, zentry.getCompressedSize()); zentry.setCompressedSize(4294967296l); assertTrue("Set compressed size failed", zentry.getCompressedSize() == 4294967296l); @@ -227,7 +226,7 @@ zentry.setCrc(orgCrc + 100); assertTrue("Failed to set Crc", zentry.getCrc() == (orgCrc + 100)); zentry.setCrc(0); - assertTrue("Failed to set Crc", zentry.getCrc() == 0); + assertEquals("Failed to set Crc", 0, zentry.getCrc()); try { zentry.setCrc(-25); fail("IllegalArgumentException not thrown"); @@ -252,9 +251,9 @@ // Test for method void java.util.zip.ZipEntry.setExtra(byte []) zentry = zfile.getEntry("File1.txt"); zentry.setExtra("Test setting extra information".getBytes()); - assertTrue("Extra information not written properly", new String(zentry + assertEquals("Extra information not written properly", "Test setting extra information", new String(zentry .getExtra(), 0, zentry.getExtra().length) - .equals("Test setting extra information")); + ); zentry = new ZipEntry("test.tst"); byte[] ba = new byte[0xFFFF]; try { @@ -314,7 +313,7 @@ zentry.setSize(orgSize + 10); assertTrue("Set size failed", zentry.getSize() == (orgSize + 10)); zentry.setSize(0); - assertTrue("Set size failed", zentry.getSize() == 0); + assertEquals("Set size failed", 0, zentry.getSize()); try { zentry.setSize(-25); fail("IllegalArgumentException not thrown"); @@ -386,12 +385,12 @@ zentry.setCompressedSize(4); zentry.setComment("Testing"); ZipEntry zentry2 = new ZipEntry(zentry); - assertTrue("ZipEntry Created With Incorrect Size.", - zentry2.getSize() == 2); - assertTrue("ZipEntry Created With Incorrect Compressed Size.", zentry2 - .getCompressedSize() == 4); - assertTrue("ZipEntry Created With Incorrect Comment.", zentry2 - .getComment().equals("Testing")); + assertEquals("ZipEntry Created With Incorrect Size.", + 2, zentry2.getSize()); + assertEquals("ZipEntry Created With Incorrect Compressed Size.", 4, zentry2 + .getCompressedSize()); + assertEquals("ZipEntry Created With Incorrect Comment.", "Testing", zentry2 + .getComment()); assertTrue("ZipEntry Created With Incorrect Crc.", zentry2.getCrc() == orgCrc); assertTrue("ZipEntry Created With Incorrect Time.", Index: modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/DeflaterTest.java (working copy) @@ -74,8 +74,8 @@ defl.finish(); while (!defl.finished()) x += defl.deflate(outPutBuf); - assertTrue("Deflater at end of stream, should return 0", defl - .deflate(outPutBuf) == 0); + assertEquals("Deflater at end of stream, should return 0", 0, defl + .deflate(outPutBuf)); int totalOut = defl.getTotalOut(); int totalIn = defl.getTotalIn(); assertTrue( @@ -105,9 +105,8 @@ assertTrue( "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); - assertTrue( - "Final decompressed data contained more bytes than original", - outPutInf[byteArray.length] == 0); + assertEquals("Final decompressed data contained more bytes than original", + 0, outPutInf[byteArray.length]); infl.end(); } @@ -128,8 +127,8 @@ defl.finish(); while (!defl.finished()) x += defl.deflate(outPutBuf, offSet, length); - assertTrue("Deflater at end of stream, should return 0", defl.deflate( - outPutBuf, offSet, length) == 0); + assertEquals("Deflater at end of stream, should return 0", 0, defl.deflate( + outPutBuf, offSet, length)); int totalOut = defl.getTotalOut(); int totalIn = defl.getTotalIn(); assertTrue( @@ -158,9 +157,8 @@ assertTrue( "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); - assertTrue( - "Final decompressed data contained more bytes than original", - outPutInf[byteArray.length] == 0); + assertEquals("Final decompressed data contained more bytes than original", + 0, outPutInf[byteArray.length]); infl.end(); // Set of tests testing the boundaries of the offSet/length @@ -264,9 +262,8 @@ assertTrue( "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); - assertTrue( - "Final decompressed data contained more bytes than original", - outPutInf[byteArray.length] == 0); + assertEquals("Final decompressed data contained more bytes than original", + 0, outPutInf[byteArray.length]); infl.end(); } @@ -499,9 +496,8 @@ Deflater defl = new Deflater(); long deflAdler = defl.getAdler(); - assertTrue( - "No dictionary set, no data deflated, getAdler should return 1", - deflAdler == 1); + assertEquals("No dictionary set, no data deflated, getAdler should return 1", + 1, deflAdler); defl.setDictionary(dictionaryArray); deflAdler = defl.getAdler(); @@ -545,9 +541,8 @@ Deflater defl = new Deflater(); long deflAdler = defl.getAdler(); - assertTrue( - "No dictionary set, no data deflated, getAdler should return 1", - deflAdler == 1); + assertEquals("No dictionary set, no data deflated, getAdler should return 1", + 1, deflAdler); defl.setDictionary(dictionaryArray, offSet, length); deflAdler = defl.getAdler(); @@ -794,22 +789,19 @@ // System.out.println(mdefl.getTotalOut()); // ran JDK and found that getTotalOut() = 86 for this particular // file - assertTrue( - "getTotalOut() for the default strategy did not correspond with JDK", - mdefl.getTotalOut() == 86); + assertEquals("getTotalOut() for the default strategy did not correspond with JDK", + 86, mdefl.getTotalOut()); } else if (i == 1) { // System.out.println(mdefl.getTotalOut()); // ran JDK and found that getTotalOut() = 100 for this // particular file - assertTrue( - "getTotalOut() for the Huffman strategy did not correspond with JDK", - mdefl.getTotalOut() == 100); + assertEquals("getTotalOut() for the Huffman strategy did not correspond with JDK", + 100, mdefl.getTotalOut()); } else { // System.out.println(mdefl.getTotalOut()); // ran JDK and found that totalOut = 93 for this particular file - assertTrue( - "Total Out for the Filtered strategy did not correspond with JDK", - mdefl.getTotalOut() == 93); + assertEquals("Total Out for the Filtered strategy did not correspond with JDK", + 93, mdefl.getTotalOut()); } mdefl.end(); } @@ -929,9 +921,8 @@ assertTrue( "Final decompressed data does not equal the original data", byteArray[i] == outPutInf[i]); - assertTrue( - "final decompressed data contained more bytes than original - construcotrIZ", - outPutInf[byteArray.length] == 0); + assertEquals("final decompressed data contained more bytes than original - construcotrIZ", + 0, outPutInf[byteArray.length]); infl.end(); infl = new Inflater(false); @@ -946,7 +937,7 @@ } catch (DataFormatException e) { r = 1; } - assertTrue("header option did not correspond", r == 1); + assertEquals("header option did not correspond", 1, r); // testing boundaries try { Index: modules/archive/src/test/java/tests/api/java/util/zip/Adler32Test.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/Adler32Test.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/Adler32Test.java (working copy) @@ -26,7 +26,7 @@ public void test_Constructor() { // test method of java.util.zip.Adler32() Adler32 adl = new Adler32(); - assertTrue("Constructor of adl32 failed", adl.getValue() == 1); + assertEquals("Constructor of adl32 failed", 1, adl.getValue()); } /** @@ -35,28 +35,25 @@ public void test_getValue() { // test methods of java.util.zip.getValue() Adler32 adl = new Adler32(); - assertTrue( - "GetValue should return a zero as a result of construction an object of Adler32", - adl.getValue() == 1); + assertEquals("GetValue should return a zero as a result of construction an object of Adler32", + 1, adl.getValue()); adl.reset(); adl.update(1); // System.out.print("value of adl"+adl.getValue()); // The value of the adl should be 131074 - assertTrue( - "update(int) failed to update the checksum to the correct value ", - adl.getValue() == 131074); + assertEquals("update(int) failed to update the checksum to the correct value ", + 131074, adl.getValue()); adl.reset(); - assertTrue("reset failed to reset the checksum value to zero", adl - .getValue() == 1); + assertEquals("reset failed to reset the checksum value to zero", 1, adl + .getValue()); adl.reset(); adl.update(Integer.MIN_VALUE); // System.out.print("value of adl " + adl.getValue()); // The value of the adl should be 65537 - assertTrue( - "update(min) failed to update the checksum to the correct value ", - adl.getValue() == 65537L); + assertEquals("update(min) failed to update the checksum to the correct value ", + 65537L, adl.getValue()); } /** @@ -68,12 +65,11 @@ adl.update(1); // System.out.print("value of adl"+adl.getValue()); // The value of the adl should be 131074 - assertTrue( - "update(int) failed to update the checksum to the correct value ", - adl.getValue() == 131074); + assertEquals("update(int) failed to update the checksum to the correct value ", + 131074, adl.getValue()); adl.reset(); - assertTrue("reset failed to reset the checksum value to zero", adl - .getValue() == 1); + assertEquals("reset failed to reset the checksum value to zero", 1, adl + .getValue()); } /** @@ -84,25 +80,22 @@ Adler32 adl = new Adler32(); adl.update(1); // The value of the adl should be 131074 - assertTrue( - "update(int) failed to update the checksum to the correct value ", - adl.getValue() == 131074); + assertEquals("update(int) failed to update the checksum to the correct value ", + 131074, adl.getValue()); adl.reset(); adl.update(Integer.MAX_VALUE); // System.out.print("value of adl " + adl.getValue()); // The value of the adl should be 16777472 - assertTrue( - "update(max) failed to update the checksum to the correct value ", - adl.getValue() == 16777472L); + assertEquals("update(max) failed to update the checksum to the correct value ", + 16777472L, adl.getValue()); adl.reset(); adl.update(Integer.MIN_VALUE); // System.out.print("value of adl " + adl.getValue()); // The value of the adl should be 65537 - assertTrue( - "update(min) failed to update the checksum to the correct value ", - adl.getValue() == 65537L); + assertEquals("update(min) failed to update the checksum to the correct value ", + 65537L, adl.getValue()); } @@ -116,18 +109,16 @@ adl.update(byteArray); // System.out.print("value of adl"+adl.getValue()); // The value of the adl should be 393220 - assertTrue( - "update(byte[]) failed to update the checksum to the correct value ", - adl.getValue() == 393220); + assertEquals("update(byte[]) failed to update the checksum to the correct value ", + 393220, adl.getValue()); adl.reset(); byte byteEmpty[] = new byte[10000]; adl.update(byteEmpty); // System.out.print("value of adl"+adl.getValue()); // The value of the adl should be 655360001 - assertTrue( - "update(byte[]) failed to update the checksum to the correct value ", - adl.getValue() == 655360001L); + assertEquals("update(byte[]) failed to update the checksum to the correct value ", + 655360001L, adl.getValue()); } @@ -145,9 +136,8 @@ adl.update(byteArray, off, len); // System.out.print("value of adl"+adl.getValue()); // The value of the adl should be 262148 - assertTrue( - "update(byte[],int,int) failed to update the checksum to the correct value ", - adl.getValue() == 262148); + assertEquals("update(byte[],int,int) failed to update the checksum to the correct value ", + 262148, adl.getValue()); int r = 0; try { @@ -155,17 +145,16 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue( - "update(byte[],int,int) failed b/c lenError>byte[].length-off", - r == 1); + assertEquals("update(byte[],int,int) failed b/c lenError>byte[].length-off", + 1, r); try { adl.update(byteArray, offError, len); } catch (ArrayIndexOutOfBoundsException e) { r = 2; } - assertTrue("update(byte[],int,int) failed b/c offError>byte[].length", - r == 2); + assertEquals("update(byte[],int,int) failed b/c offError>byte[].length", + 2, r); } Index: modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/zip/ZipInputStreamTest.java (working copy) @@ -76,7 +76,7 @@ // Test for method java.util.zip.ZipEntry // java.util.zip.ZipInputStream.getNextEntry() try { - assertTrue("getNextEntry failed", zis.getNextEntry() != null); + assertNotNull("getNextEntry failed", zis.getNextEntry()); } catch (java.io.IOException e) { fail("Exception during getNextEntry test"); } @@ -93,7 +93,7 @@ byte[] rbuf = new byte[(int) zentry.getSize()]; int r = zis.read(rbuf, 0, rbuf.length); new String(rbuf, 0, r); - assertTrue("Failed to read entry", r == 12); + assertEquals("Failed to read entry", 12, r); } catch (java.io.IOException e) { fail("Exception during read test"); } @@ -109,7 +109,7 @@ byte[] rbuf = new byte[(int) zentry.getSize()]; zis.skip(2); int r = zis.read(rbuf, 0, rbuf.length); - assertTrue("Failed to skip data", r == 10); + assertEquals("Failed to skip data", 10, r); } catch (java.io.IOException e) { fail("Unexpected1: " + e); } Index: modules/archive/src/test/java/tests/api/java/util/jar/AttributesTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/jar/AttributesTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/jar/AttributesTest.java (working copy) @@ -49,14 +49,14 @@ public void test_clear() { // Test for method void java.util.jar.Attributes.clear() a.clear(); - assertTrue("a) All entries should be null after clear", - a.get("1") == null); - assertTrue("b) All entries should be null after clear", - a.get("2") == null); - assertTrue("c) All entries should be null after clear", - a.get("3") == null); - assertTrue("d) All entries should be null after clear", - a.get("4") == null); + assertNull("a) All entries should be null after clear", + a.get("1")); + assertNull("b) All entries should be null after clear", + a.get("2")); + assertNull("c) All entries should be null after clear", + a.get("3")); + assertNull("d) All entries should be null after clear", + a.get("4")); assertTrue("Should not contain any keys", !a.containsKey("1")); } @@ -124,8 +124,8 @@ public void test_getLjava_lang_Object() { // Test for method java.lang.Object // java.util.jar.Attributes.get(java.lang.Object) - assertTrue("a) Incorrect value returned", a.getValue("1").equals("one")); - assertTrue("b) Incorrect value returned", a.getValue("0") == null); + assertEquals("a) Incorrect value returned", "one", a.getValue("1")); + assertNull("b) Incorrect value returned", a.getValue("0")); } /** @@ -177,10 +177,10 @@ b.putValue("5", "go"); b.putValue("6", "roku"); a.putAll(b); - assertTrue("Should not have been replaced", a.getValue("1").equals( - "one")); - assertTrue("Should have been replaced", a.getValue("3").equals("san")); - assertTrue("Should have been added", a.getValue("5").equals("go")); + assertEquals("Should not have been replaced", + "one", a.getValue("1")); + assertEquals("Should have been replaced", "san", a.getValue("3")); + assertEquals("Should have been added", "go", a.getValue("5")); } @@ -192,9 +192,9 @@ // java.util.jar.Attributes.remove(java.lang.Object) a.remove(new Attributes.Name("1")); a.remove(new Attributes.Name("3")); - assertTrue("Should have been removed", a.getValue("1") == null); - assertTrue("Should not have been removed", a.getValue("4").equals( - "four")); + assertNull("Should have been removed", a.getValue("1")); + assertEquals("Should not have been removed", + "four", a.getValue("4")); } /** @@ -202,7 +202,7 @@ */ public void test_size() { // Test for method int java.util.jar.Attributes.size() - assertTrue("Incorrect size returned", a.size() == 4); + assertEquals("Incorrect size returned", 4, a.size()); a.clear(); assertTrue("Should have returned 0 size, but got: " + a.size(), a .size() == 0); Index: modules/archive/src/test/java/tests/api/java/util/jar/ManifestTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/jar/ManifestTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/jar/ManifestTest.java (working copy) @@ -71,45 +71,40 @@ fail("IOException"); } Attributes main = manifest.getMainAttributes(); - assertTrue("Bundle-Name not correct", main.getValue("Bundle-Name") - .equals("ClientSupport")); - assertTrue( - "Bundle-Description not correct", - main + assertEquals("Bundle-Name not correct", "ClientSupport", main.getValue("Bundle-Name") + ); + assertEquals("Bundle-Description not correct", + + "Provides SessionService, AuthenticationService. Extends RegistryService.", main .getValue("Bundle-Description") - .equals( - "Provides SessionService, AuthenticationService. Extends RegistryService.")); - assertTrue("Bundle-Activator not correct", main.getValue( - "Bundle-Activator").equals( - "com.ibm.ive.eccomm.client.support.ClientSupportActivator")); - assertTrue( - "Import-Package not correct", - main + ); + assertEquals("Bundle-Activator not correct", + "com.ibm.ive.eccomm.client.support.ClientSupportActivator", main.getValue( + "Bundle-Activator")); + assertEquals("Import-Package not correct", + + "com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client", main .getValue("Import-Package") - .equals( - "com.ibm.ive.eccomm.client.services.log,com.ibm.ive.eccomm.client.services.registry,com.ibm.ive.eccomm.service.registry; specification-version=1.0.0,com.ibm.ive.eccomm.service.session; specification-version=1.0.0,com.ibm.ive.eccomm.service.framework; specification-version=1.2.0,org.osgi.framework; specification-version=1.0.0,org.osgi.service.log; specification-version=1.0.0,com.ibm.ive.eccomm.flash; specification-version=1.2.0,com.ibm.ive.eccomm.client.xml,com.ibm.ive.eccomm.client.http.common,com.ibm.ive.eccomm.client.http.client")); - assertTrue( - "Import-Service not correct", - main + ); + assertEquals("Import-Service not correct", + + "org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService", main .getValue("Import-Service") - .equals( - "org.osgi.service.log.LogReaderServiceorg.osgi.service.log.LogService,com.ibm.ive.eccomm.service.registry.RegistryService")); - assertTrue( - "Export-Package not correct", - main + ); + assertEquals("Export-Package not correct", + + "com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0", main .getValue("Export-Package") - .equals( - "com.ibm.ive.eccomm.client.services.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.service.authentication; specification-version=1.0.0,com.ibm.ive.eccomm.common; specification-version=1.0.0,com.ibm.ive.eccomm.client.services.registry.store; specification-version=1.0.0")); - assertTrue( - "Export-Service not correct", - main + ); + assertEquals("Export-Service not correct", + + "com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService", main .getValue("Export-Service") - .equals( - "com.ibm.ive.eccomm.service.authentication.AuthenticationService,com.ibm.ive.eccomm.service.session.SessionService")); - assertTrue("Bundle-Vendor not correct", main.getValue("Bundle-Vendor") - .equals("IBM")); - assertTrue("Bundle-Version not correct", main - .getValue("Bundle-Version").equals("1.2.0")); + ); + assertEquals("Bundle-Vendor not correct", "IBM", main.getValue("Bundle-Vendor") + ); + assertEquals("Bundle-Version not correct", "1.2.0", main + .getValue("Bundle-Version")); } /** @@ -129,10 +124,10 @@ public void test_getAttributesLjava_lang_String() { // Test for method java.util.jar.Attributes // java.util.jar.Manifest.getAttributes(java.lang.String) - assertTrue("Should not exist", - m2.getAttributes("Doesn't Exist") == null); - assertTrue("Should exist", m2.getAttributes("HasAttributes.txt").get( - new Attributes.Name("MyAttribute")).equals("OK")); + assertNull("Should not exist", + m2.getAttributes("Doesn't Exist")); + assertEquals("Should exist", "OK", m2.getAttributes("HasAttributes.txt").get( + new Attributes.Name("MyAttribute"))); } /** @@ -141,10 +136,10 @@ public void test_getEntries() { // Test for method java.util.Map java.util.jar.Manifest.getEntries() Map myMap = m2.getEntries(); - assertTrue("Shouldn't exist", myMap.get("Doesn't exist") == null); - assertTrue("Should exist", - ((Attributes) myMap.get("HasAttributes.txt")).get( - new Attributes.Name("MyAttribute")).equals("OK")); + assertNull("Shouldn't exist", myMap.get("Doesn't exist")); + assertEquals("Should exist", + "OK", ((Attributes) myMap.get("HasAttributes.txt")).get( + new Attributes.Name("MyAttribute"))); } @@ -155,8 +150,8 @@ // Test for method java.util.jar.Attributes // java.util.jar.Manifest.getMainAttributes() Attributes a = m.getMainAttributes(); - assertTrue("Manifest_Version should return 1.0", a.get( - Attributes.Name.MANIFEST_VERSION).equals("1.0")); + assertEquals("Manifest_Version should return 1.0", "1.0", a.get( + Attributes.Name.MANIFEST_VERSION)); } /** Index: modules/archive/src/test/java/tests/api/java/util/jar/JarInputStreamTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/jar/JarInputStreamTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/jar/JarInputStreamTest.java (working copy) @@ -54,8 +54,8 @@ .getInputStream(); boolean hasCorrectEntry = false; JarInputStream jis = new JarInputStream(is); - assertTrue("The jar input stream should have a manifest", jis - .getManifest() != null); + assertNotNull("The jar input stream should have a manifest", jis + .getManifest()); JarEntry je = jis.getNextJarEntry(); while (je != null) { if (je.getName().equals(entryName)) @@ -84,13 +84,13 @@ .getInputStream(); JarInputStream jis = new JarInputStream(is); m = jis.getManifest(); - assertTrue("The jar input stream should not have a manifest", - m == null); + assertNull("The jar input stream should not have a manifest", + m); is = new URL(jarName).openConnection().getInputStream(); jis = new JarInputStream(is); m = jis.getManifest(); - assertTrue("The jar input stream should have a manifest", m != null); + assertNotNull("The jar input stream should have a manifest", m); } catch (Exception e) { fail("Exception during test: " + e.toString()); } Index: modules/archive/src/test/java/tests/api/java/util/jar/JarFileTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/jar/JarFileTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/jar/JarFileTest.java (working copy) @@ -149,8 +149,8 @@ try { Support_Resources.copyFile(resources, null, jarName); JarFile jarFile = new JarFile(new File(resources, jarName)); - assertTrue("Error in returned entry", jarFile.getEntry(entryName) - .getSize() == 311); + assertEquals("Error in returned entry", 311, jarFile.getEntry(entryName) + .getSize()); jarFile.close(); } catch (Exception e) { fail("Exception during test: " + e.toString()); @@ -234,8 +234,8 @@ try { Support_Resources.copyFile(resources, null, jarName); JarFile jarFile = new JarFile(new File(resources, jarName)); - assertTrue("Error--Manifest not returned", - jarFile.getManifest() != null); + assertNotNull("Error--Manifest not returned", + jarFile.getManifest()); jarFile.close(); } catch (Exception e) { fail("Exception during 1st test: " + e.toString()); @@ -243,8 +243,8 @@ try { Support_Resources.copyFile(resources, null, jarName2); JarFile jarFile = new JarFile(new File(resources, jarName2)); - assertTrue("Error--should have returned null", jarFile - .getManifest() == null); + assertNull("Error--should have returned null", jarFile + .getManifest()); jarFile.close(); } catch (Exception e) { fail("Exception during 2nd test: " + e.toString()); @@ -254,8 +254,8 @@ // jarName3 was created using the following test Support_Resources.copyFile(resources, null, jarName3); JarFile jarFile = new JarFile(new File(resources, jarName3)); - assertTrue("Should find manifest without verifying", jarFile - .getManifest() != null); + assertNotNull("Should find manifest without verifying", jarFile + .getManifest()); jarFile.close(); } catch (Exception e) { fail("Exception during 3rd test: " + e.toString()); @@ -286,8 +286,8 @@ jarOut.write(65); jarOut.close(); JarFile jar = new JarFile(file.getAbsolutePath(), false); - assertTrue("Should find manifest without verifying", jar - .getManifest() != null); + assertNotNull("Should find manifest without verifying", jar + .getManifest()); jar.close(); file.delete(); } catch (IOException e) { @@ -328,7 +328,7 @@ try { JarFile jf = new JarFile(localFile); InputStream in = jf.getInputStream(new JarEntry("invalid")); - assertTrue("Got stream for non-existent entry", in == null); + assertNull("Got stream for non-existent entry", in); } catch (Exception e) { fail("Exception during test 2: " + e); } @@ -360,7 +360,7 @@ JarEntry entry = new JarEntry(entryName3); InputStream in = jar.getInputStream(entry); in.read(new byte[1077]); - assertTrue("found certificates", entry.getCertificates() == null); + assertNull("found certificates", entry.getCertificates()); } catch (Exception e) { fail("Exception during test 4: " + e); } Index: modules/archive/src/test/java/tests/api/java/util/jar/JarEntryTest.java =================================================================== --- modules/archive/src/test/java/tests/api/java/util/jar/JarEntryTest.java (revision 396457) +++ modules/archive/src/test/java/tests/api/java/util/jar/JarEntryTest.java (working copy) @@ -49,15 +49,15 @@ */ public void test_ConstructorLjava_util_zip_ZipEntry() { // Test for method java.util.jar.JarEntry(java.util.zip.ZipEntry) - assertTrue("Jar file is null", jarFile != null); + assertNotNull("Jar file is null", jarFile); zipEntry = jarFile.getEntry(entryName); - assertTrue("Zip entry is null", zipEntry != null); + assertNotNull("Zip entry is null", zipEntry); jarEntry = new JarEntry(zipEntry); - assertTrue("Jar entry is null", jarEntry != null); + assertNotNull("Jar entry is null", jarEntry); assertTrue("Wrong entry constucted--wrong name", jarEntry.getName() .equals(entryName)); - assertTrue("Wrong entry constucted--wrong size", - jarEntry.getSize() == 311); + assertEquals("Wrong entry constucted--wrong size", + 311, jarEntry.getSize()); } /** @@ -79,16 +79,16 @@ try { jarEntry = attrJar.getJarEntry(attEntryName); - assertTrue("Should have Manifest attributes", jarEntry - .getAttributes() != null); + assertNotNull("Should have Manifest attributes", jarEntry + .getAttributes()); } catch (Exception e) { fail("Exception during 2nd test: " + e.toString()); } try { jarEntry = attrJar.getJarEntry(attEntryName2); - assertTrue("Shouldn't have any Manifest attributes", jarEntry - .getAttributes() == null); + assertNull("Shouldn't have any Manifest attributes", jarEntry + .getAttributes()); attrJar.close(); } catch (Exception e) { fail("Exception during 1st test: " + e.toString()); @@ -103,8 +103,8 @@ // java.util.jar.JarEntry.getCertificates() zipEntry = jarFile.getEntry(entryName2); jarEntry = new JarEntry(zipEntry); - assertTrue("Shouldn't have any Certificates", jarEntry - .getCertificates() == null); + assertNull("Shouldn't have any Certificates", jarEntry + .getCertificates()); } /** Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetDecoderTest.java (working copy) @@ -122,8 +122,8 @@ // FIXME: give up this tests // public void testDefaultCharsPerByte() { - // // assertTrue(decoder.averageCharsPerByte() == 1); - // // assertTrue(decoder.maxCharsPerByte() == 1); + // // assertEquals(1, decoder.averageCharsPerByte()); + // // assertEquals(1, decoder.maxCharsPerByte()); // assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetEncoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetEncoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetEncoderTest.java (working copy) @@ -86,8 +86,8 @@ } public void testSpecificDefaultValue() { - assertTrue(encoder.averageBytesPerChar() == 2); - assertTrue(encoder.maxBytesPerChar() == 2); + assertEquals(2, encoder.averageBytesPerChar()); + assertEquals(2, encoder.maxBytesPerChar()); } CharBuffer getMalformedCharBuffer() { Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/GBCharsetDecoderTest.java (working copy) @@ -38,8 +38,8 @@ // // FIXME: give up this tests // public void testDefaultCharsPerByte(){ - // //assertTrue(decoder.averageCharsPerByte() == 1); - // //assertTrue(decoder.maxCharsPerByte() == 1); + // //assertEquals(1, decoder.averageCharsPerByte()); + // //assertEquals(1, decoder.maxCharsPerByte()); // assertEquals(decoder.averageCharsPerByte(), 0.25, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTFCharsetDecoderTest.java (working copy) @@ -40,8 +40,8 @@ // public void testDefaultCharsPerByte(){ // assertEquals(decoder.averageCharsPerByte(), 0.333, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); - // // assertTrue(decoder.averageCharsPerByte() == 1); - // // assertTrue(decoder.maxCharsPerByte() == 1); + // // assertEquals(1, decoder.averageCharsPerByte()); + // // assertEquals(1, decoder.maxCharsPerByte()); // } ByteBuffer getUnmappedByteBuffer() throws UnsupportedEncodingException { Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetEncoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetEncoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetEncoderTest.java (working copy) @@ -86,8 +86,8 @@ } public void testSpecificDefaultValue() { - assertTrue(encoder.averageBytesPerChar() == 2); - assertTrue(encoder.maxBytesPerChar() == 2); + assertEquals(2, encoder.averageBytesPerChar()); + assertEquals(2, encoder.maxBytesPerChar()); } public void testIsLegalReplacementEmptyArray() { Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetEncoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetEncoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetEncoderTest.java (working copy) @@ -68,8 +68,8 @@ } public void testSpecificDefaultValue() { - assertTrue(encoder.averageBytesPerChar() == 1); - assertTrue(encoder.maxBytesPerChar() == 1); + assertEquals(1, encoder.averageBytesPerChar()); + assertEquals(1, encoder.maxBytesPerChar()); } CharBuffer getMalformedCharBuffer() { Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/ASCCharsetDecoderTest.java (working copy) @@ -35,8 +35,8 @@ // FIXME: give up this tests // public void testDefaultCharsPerByte(){ - // // assertTrue(decoder.averageCharsPerByte() == 1); - // // assertTrue(decoder.maxCharsPerByte() == 1); + // // assertEquals(1, decoder.averageCharsPerByte()); + // // assertEquals(1, decoder.maxCharsPerByte()); // assertEquals(decoder.averageCharsPerByte(), 1, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16BECharsetDecoderTest.java (working copy) @@ -40,8 +40,8 @@ // FIXME: give up this tests // public void testDefaultCharsPerByte() { - // // assertTrue(decoder.averageCharsPerByte() == 1); - // // assertTrue(decoder.maxCharsPerByte() == 1); + // // assertEquals(1, decoder.averageCharsPerByte()); + // // assertEquals(1, decoder.maxCharsPerByte()); // assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetEncoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetEncoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16CharsetEncoderTest.java (working copy) @@ -91,7 +91,7 @@ public void testSpecificDefaultValue() { assertEquals(encoder.averageBytesPerChar(), 2, 0.001); - // assertTrue(encoder.maxBytesPerChar() == 4); + // assertEquals(4, encoder.maxBytesPerChar()); // FIXME: different here! assertEquals(encoder.maxBytesPerChar(), 2, 0.001); } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/UTF16LECharsetDecoderTest.java (working copy) @@ -40,8 +40,8 @@ // // FIXME: give up this tests // public void testDefaultCharsPerByte(){ - // // assertTrue(decoder.averageCharsPerByte() == 1); - // // assertTrue(decoder.maxCharsPerByte() == 1); + // // assertEquals(1, decoder.averageCharsPerByte()); + // // assertEquals(1, decoder.maxCharsPerByte()); // assertEquals(decoder.averageCharsPerByte(), 0.5, 0.001); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetTest.java (working copy) @@ -440,10 +440,10 @@ */ public void testCompareTo_Normal() { MockCharset c1 = new MockCharset("mock", null); - assertTrue(c1.compareTo(c1) == 0); + assertEquals(0, c1.compareTo(c1)); MockCharset c2 = new MockCharset("Mock", null); - assertTrue(c1.compareTo(c2) == 0); + assertEquals(0, c1.compareTo(c2)); c2 = new MockCharset("mock2", null); assertTrue(c1.compareTo(c2) < 0); Index: modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetDecoderTest.java =================================================================== --- modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetDecoderTest.java (revision 396457) +++ modules/nio_char/src/test/java/tests/api/java/nio/charset/ISOCharsetDecoderTest.java (working copy) @@ -38,7 +38,7 @@ // FIXME: give up this tests // public void testDefaultCharsPerByte(){ - // assertTrue(decoder.averageCharsPerByte() == 1); + // assertEquals(1, decoder.averageCharsPerByte()); // assertEquals(decoder.maxCharsPerByte(), 2, 0.001); // } Index: modules/jndi/src/test/java/tests/api/javax/naming/directory/TestSearchControls.java =================================================================== --- modules/jndi/src/test/java/tests/api/javax/naming/directory/TestSearchControls.java (revision 396457) +++ modules/jndi/src/test/java/tests/api/javax/naming/directory/TestSearchControls.java (working copy) @@ -140,7 +140,7 @@ SearchControls ctrl; ctrl = new SearchControls(); - assertTrue(ctrl.toString() != null); + assertNotNull(ctrl.toString()); } } Index: modules/text/src/test/java/tests/api/java/text/ParsePositionTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/ParsePositionTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/ParsePositionTest.java (working copy) @@ -29,7 +29,7 @@ ParsePosition pp1 = new ParsePosition(Integer.MIN_VALUE); assertTrue("Initialization failed.", pp1.getIndex() == Integer.MIN_VALUE); - assertTrue("Initialization failed.", pp1.getErrorIndex() == -1); + assertEquals("Initialization failed.", -1, pp1.getErrorIndex()); } catch (Exception e) { fail("Constructor failed."); } @@ -56,7 +56,7 @@ public void test_getErrorIndex() { // Test for method int java.text.ParsePosition.getErrorIndex() pp.setErrorIndex(56); - assertTrue("getErrorIndex failed.", pp.getErrorIndex() == 56); + assertEquals("getErrorIndex failed.", 56, pp.getErrorIndex()); } /** @@ -82,7 +82,7 @@ public void test_setErrorIndexI() { // Test for method void java.text.ParsePosition.setErrorIndex(int) pp.setErrorIndex(4564); - assertTrue("setErrorIndex failed.", pp.getErrorIndex() == 4564); + assertEquals("setErrorIndex failed.", 4564, pp.getErrorIndex()); } /** @@ -91,7 +91,7 @@ public void test_setIndexI() { // Test for method void java.text.ParsePosition.setIndex(int) pp.setIndex(4564); - assertTrue("setErrorIndex failed.", pp.getIndex() == 4564); + assertEquals("setErrorIndex failed.", 4564, pp.getIndex()); } /** @@ -99,8 +99,8 @@ */ public void test_toString() { // Test for method java.lang.String java.text.ParsePosition.toString() - assertTrue("toString failed.", pp.toString().equals( - "java.text.ParsePosition[index=2147483647, errorIndex=-1]")); + assertEquals("toString failed.", + "java.text.ParsePosition[index=2147483647, errorIndex=-1]", pp.toString()); } /** Index: modules/text/src/test/java/tests/api/java/text/SimpleDateFormatTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/SimpleDateFormatTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/SimpleDateFormatTest.java (working copy) @@ -124,7 +124,7 @@ // Test for method java.text.SimpleDateFormat(java.lang.String) SimpleDateFormat f2 = new SimpleDateFormat("yyyy"); assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class); - assertTrue("Wrong pattern", f2.toPattern().equals("yyyy")); + assertEquals("Wrong pattern", "yyyy", f2.toPattern()); assertTrue("Wrong locale", f2.equals(new SimpleDateFormat("yyyy", Locale.getDefault()))); assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals( @@ -168,7 +168,7 @@ symbols.setEras(new String[] { "Before", "After" }); SimpleDateFormat f2 = new SimpleDateFormat("y'y'yy", symbols); assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class); - assertTrue("Wrong pattern", f2.toPattern().equals("y'y'yy")); + assertEquals("Wrong pattern", "y'y'yy", f2.toPattern()); assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(symbols)); assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class); @@ -184,7 +184,7 @@ SimpleDateFormat f2 = new SimpleDateFormat("'yyyy' MM yy", Locale.GERMAN); assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class); - assertTrue("Wrong pattern", f2.toPattern().equals("'yyyy' MM yy")); + assertEquals("Wrong pattern", "'yyyy' MM yy", f2.toPattern()); assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals( new DateFormatSymbols(Locale.GERMAN))); assertTrue("Doesn't work", @@ -243,7 +243,7 @@ // java.text.SimpleDateFormat.applyPattern(java.lang.String) SimpleDateFormat f2 = new SimpleDateFormat("y", new Locale("de", "CH")); f2.applyPattern("GyMdkHmsSEDFwWahKz"); - assertTrue("Wrong pattern", f2.toPattern().equals("GyMdkHmsSEDFwWahKz")); + assertEquals("Wrong pattern", "GyMdkHmsSEDFwWahKz", f2.toPattern()); // test invalid patterns try { @@ -483,7 +483,7 @@ test.test(" z", cal, " GMT-01:30", DateFormat.TIMEZONE_FIELD); format.applyPattern("'Mkz''':.@5"); - assertTrue("Wrong output", format.format(new Date()).equals("Mkz':.@5")); + assertEquals("Wrong output", "Mkz':.@5", format.format(new Date())); assertTrue("Tests failed", !test.testsFailed()); @@ -785,16 +785,16 @@ Calendar cal = new GregorianCalendar(); try { cal.setTime(f1.parse("49")); - assertTrue("Incorrect year 2049", cal.get(Calendar.YEAR) == 2049); + assertEquals("Incorrect year 2049", 2049, cal.get(Calendar.YEAR)); cal.setTime(f1.parse("50")); int year = cal.get(Calendar.YEAR); assertTrue("Incorrect year 1950: " + year, year == 1950); f1.applyPattern("y"); cal.setTime(f1.parse("00")); - assertTrue("Incorrect year 2000", cal.get(Calendar.YEAR) == 2000); + assertEquals("Incorrect year 2000", 2000, cal.get(Calendar.YEAR)); f1.applyPattern("yyy"); cal.setTime(f1.parse("50")); - assertTrue("Incorrect year 50", cal.get(Calendar.YEAR) == 50); + assertEquals("Incorrect year 50", 50, cal.get(Calendar.YEAR)); } catch (ParseException e) { fail("ParseException"); } @@ -815,7 +815,7 @@ assertTrue("Not a clone", f1.getDateFormatSymbols() != symbols); String result = f1.format(new GregorianCalendar(1999, Calendar.JUNE, 12, 3, 0).getTime()); - assertTrue("Incorrect symbols used", result.equals("morning")); + assertEquals("Incorrect symbols used", "morning", result); symbols.setEras(new String[] { "before", "after" }); assertTrue("Identical symbols", !f1.getDateFormatSymbols().equals( symbols)); Index: modules/text/src/test/java/tests/api/java/text/NumberFormatTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/NumberFormatTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/NumberFormatTest.java (working copy) @@ -200,7 +200,7 @@ public void test_getMaximumIntegerDigits() { NumberFormat format = NumberFormat.getInstance(); format.setMaximumIntegerDigits(2); - assertTrue("Wrong result", format.format(123).equals("23")); + assertEquals("Wrong result", "23", format.format(123)); } /** Index: modules/text/src/test/java/tests/api/java/text/ChoiceFormatTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/ChoiceFormatTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/ChoiceFormatTest.java (working copy) @@ -203,19 +203,19 @@ FieldPosition field = new FieldPosition(0); StringBuffer buf = new StringBuffer(); String r = f1.format(-1, buf, field).toString(); - assertTrue("Wrong choice for -1", r.equals("Less than one")); + assertEquals("Wrong choice for -1", "Less than one", r); buf.setLength(0); r = f1.format(0, buf, field).toString(); - assertTrue("Wrong choice for 0", r.equals("Less than one")); + assertEquals("Wrong choice for 0", "Less than one", r); buf.setLength(0); r = f1.format(1, buf, field).toString(); - assertTrue("Wrong choice for 1", r.equals("one")); + assertEquals("Wrong choice for 1", "one", r); buf.setLength(0); r = f1.format(2, buf, field).toString(); - assertTrue("Wrong choice for 2", r.equals("Between one and two")); + assertEquals("Wrong choice for 2", "Between one and two", r); buf.setLength(0); r = f1.format(3, buf, field).toString(); - assertTrue("Wrong choice for 3", r.equals("Greater than two")); + assertEquals("Wrong choice for 3", "Greater than two", r); } /** @@ -229,13 +229,13 @@ FieldPosition field = new FieldPosition(0); StringBuffer buf = new StringBuffer(); String r = f1.format(0.5, buf, field).toString(); - assertTrue("Wrong choice for 0.5", r.equals("Less than one")); + assertEquals("Wrong choice for 0.5", "Less than one", r); buf.setLength(0); r = f1.format(1.5, buf, field).toString(); - assertTrue("Wrong choice for 1.5", r.equals("Between one and two")); + assertEquals("Wrong choice for 1.5", "Between one and two", r); buf.setLength(0); r = f1.format(2.5, buf, field).toString(); - assertTrue("Wrong choice for 2.5", r.equals("Greater than two")); + assertEquals("Wrong choice for 2.5", "Greater than two", r); } /** @@ -303,24 +303,24 @@ // java.text.ChoiceFormat.parse(java.lang.String, // java.text.ParsePosition) ChoiceFormat format = new ChoiceFormat("1#one|2#two|3#three"); - assertTrue("Case insensitive", format - .parse("One", new ParsePosition(0)).intValue() == 0); + assertEquals("Case insensitive", 0, format + .parse("One", new ParsePosition(0)).intValue()); ParsePosition pos = new ParsePosition(0); Number result = f1.parse("Greater than two", pos); assertTrue("Not a Double1", result instanceof Double); assertTrue("Wrong value ~>2", result.doubleValue() == ChoiceFormat .nextDouble(2)); - assertTrue("Wrong position ~16", pos.getIndex() == 16); + assertEquals("Wrong position ~16", 16, pos.getIndex()); pos = new ParsePosition(0); assertTrue("Incorrect result", Double.isNaN(f1.parse("12one", pos) .doubleValue())); - assertTrue("Wrong position ~0", pos.getIndex() == 0); + assertEquals("Wrong position ~0", 0, pos.getIndex()); pos = new ParsePosition(2); result = f1.parse("12one and two", pos); assertTrue("Not a Double2", result instanceof Double); - assertTrue("Ignored parse position", result.doubleValue() == 1.0); - assertTrue("Wrong position ~5", pos.getIndex() == 5); + assertEquals("Ignored parse position", 1.0, result.doubleValue()); + assertEquals("Wrong position ~5", 5, pos.getIndex()); } /** @@ -357,8 +357,8 @@ MessageFormat mf = new MessageFormat("CHOICE {1,choice}"); String ptrn = mf.toPattern(); - assertTrue("Unused message format returning incorrect pattern", ptrn - .equals("CHOICE {1,choice,}")); + assertEquals("Unused message format returning incorrect pattern", "CHOICE {1,choice,}", ptrn + ); String pattern = f1.toPattern(); assertTrue( @@ -371,8 +371,8 @@ String str = "org.apache.harmony.tests.java.lang.share.MyResources2"; cf.applyPattern(str); ptrn = cf.toPattern(); - assertTrue("Return value should be empty string for invalid pattern", - ptrn.length() == 0); + assertEquals("Return value should be empty string for invalid pattern", + 0, ptrn.length()); } /** Index: modules/text/src/test/java/tests/api/java/text/DecimalFormatTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/DecimalFormatTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/DecimalFormatTest.java (working copy) @@ -47,13 +47,13 @@ */ public void test_applyPatternLjava_lang_String() { DecimalFormat format = new DecimalFormat("#.#"); - assertTrue("Wrong pattern 1", format.toPattern().equals("#0.#")); + assertEquals("Wrong pattern 1", "#0.#", format.toPattern()); format = new DecimalFormat("#."); - assertTrue("Wrong pattern 2", format.toPattern().equals("#0.")); + assertEquals("Wrong pattern 2", "#0.", format.toPattern()); format = new DecimalFormat("#"); - assertTrue("Wrong pattern 3", format.toPattern().equals("#")); + assertEquals("Wrong pattern 3", "#", format.toPattern()); format = new DecimalFormat(".#"); - assertTrue("Wrong pattern 4", format.toPattern().equals("#.0")); + assertEquals("Wrong pattern 4", "#.0", format.toPattern()); } /** @@ -323,64 +323,64 @@ Support_BitSet failures = new Support_BitSet(); DecimalFormat df = new DecimalFormat("00.0#E0"); - assertTrue("00.0#E0: 0", df.format(0).equals("00.0E0")); - assertTrue("00.0#E0: 1", df.format(1).equals("10.0E-1")); - assertTrue("00.0#E0: 12", df.format(12).equals("12.0E0")); - assertTrue("00.0#E0: 123", df.format(123).equals("12.3E1")); - assertTrue("00.0#E0: 1234", df.format(1234).equals("12.34E2")); - assertTrue("00.0#E0: 12346", df.format(12346).equals("12.35E3")); - assertTrue("00.0#E0: 99999", df.format(99999).equals("10.0E4")); - assertTrue("00.0#E0: -1", df.format(-1).equals("-10.0E-1")); - assertTrue("00.0#E0: -12", df.format(-12).equals("-12.0E0")); - assertTrue("00.0#E0: -123", df.format(-123).equals("-12.3E1")); - assertTrue("00.0#E0: -1234", df.format(-1234).equals("-12.34E2")); - assertTrue("00.0#E0: -12346", df.format(-12346).equals("-12.35E3")); - assertTrue("00.0#E0: -99999", df.format(-99999).equals("-10.0E4")); + assertEquals("00.0#E0: 0", "00.0E0", df.format(0)); + assertEquals("00.0#E0: 1", "10.0E-1", df.format(1)); + assertEquals("00.0#E0: 12", "12.0E0", df.format(12)); + assertEquals("00.0#E0: 123", "12.3E1", df.format(123)); + assertEquals("00.0#E0: 1234", "12.34E2", df.format(1234)); + assertEquals("00.0#E0: 12346", "12.35E3", df.format(12346)); + assertEquals("00.0#E0: 99999", "10.0E4", df.format(99999)); + assertEquals("00.0#E0: -1", "-10.0E-1", df.format(-1)); + assertEquals("00.0#E0: -12", "-12.0E0", df.format(-12)); + assertEquals("00.0#E0: -123", "-12.3E1", df.format(-123)); + assertEquals("00.0#E0: -1234", "-12.34E2", df.format(-1234)); + assertEquals("00.0#E0: -12346", "-12.35E3", df.format(-12346)); + assertEquals("00.0#E0: -99999", "-10.0E4", df.format(-99999)); df = new DecimalFormat("##0.0E0"); - assertTrue("##0.0E0: 0", df.format(0).equals("0.0E0")); - assertTrue("##0.0E0: 1", df.format(1).equals("1.0E0")); - assertTrue("##0.0E0: 12", df.format(12).equals("12E0")); - assertTrue("##0.0E0: 123", df.format(123).equals("123E0")); - assertTrue("##0.0E0: 1234", df.format(1234).equals("1.234E3")); - assertTrue("##0.0E0: 12346", df.format(12346).equals("12.35E3")); + assertEquals("##0.0E0: 0", "0.0E0", df.format(0)); + assertEquals("##0.0E0: 1", "1.0E0", df.format(1)); + assertEquals("##0.0E0: 12", "12E0", df.format(12)); + assertEquals("##0.0E0: 123", "123E0", df.format(123)); + assertEquals("##0.0E0: 1234", "1.234E3", df.format(1234)); + assertEquals("##0.0E0: 12346", "12.35E3", df.format(12346)); // Fails in JDK 1.2.2 if (!df.format(99999).equals("100E3")) failures.set(failCount); failCount++; - assertTrue("##0.0E0: 999999", df.format(999999).equals("1.0E6")); + assertEquals("##0.0E0: 999999", "1.0E6", df.format(999999)); df = new DecimalFormat("#00.0##E0"); // Fails in JDK 1.2.2 if (!df.format(0).equals("0.00E0")) failures.set(failCount); failCount++; - assertTrue("#00.0##E0: 1", df.format(1).equals("1.00E0")); - assertTrue("#00.0##E0: 12", df.format(12).equals("12.0E0")); - assertTrue("#00.0##E0: 123", df.format(123).equals("123E0")); - assertTrue("#00.0##E0: 1234", df.format(1234).equals("1.234E3")); - assertTrue("#00.0##E0: 12345", df.format(12345).equals("12.345E3")); - assertTrue("#00.0##E0: 123456", df.format(123456).equals("123.456E3")); - assertTrue("#00.0##E0: 1234567", df.format(1234567).equals("1.23457E6")); - assertTrue("#00.0##E0: 12345678", df.format(12345678).equals( - "12.3457E6")); - assertTrue("#00.0##E0: 99999999", df.format(99999999).equals("100E6")); + assertEquals("#00.0##E0: 1", "1.00E0", df.format(1)); + assertEquals("#00.0##E0: 12", "12.0E0", df.format(12)); + assertEquals("#00.0##E0: 123", "123E0", df.format(123)); + assertEquals("#00.0##E0: 1234", "1.234E3", df.format(1234)); + assertEquals("#00.0##E0: 12345", "12.345E3", df.format(12345)); + assertEquals("#00.0##E0: 123456", "123.456E3", df.format(123456)); + assertEquals("#00.0##E0: 1234567", "1.23457E6", df.format(1234567)); + assertEquals("#00.0##E0: 12345678", + "12.3457E6", df.format(12345678)); + assertEquals("#00.0##E0: 99999999", "100E6", df.format(99999999)); df = new DecimalFormat("#.0E0"); - assertTrue("#.0E0: 0", df.format(0).equals(".0E0")); - assertTrue("#.0E0: 1", df.format(1).equals(".1E1")); - assertTrue("#.0E0: 12", df.format(12).equals(".12E2")); - assertTrue("#.0E0: 123", df.format(123).equals(".12E3")); - assertTrue("#.0E0: 1234", df.format(1234).equals(".12E4")); - assertTrue("#.0E0: 9999", df.format(9999).equals(".1E5")); + assertEquals("#.0E0: 0", ".0E0", df.format(0)); + assertEquals("#.0E0: 1", ".1E1", df.format(1)); + assertEquals("#.0E0: 12", ".12E2", df.format(12)); + assertEquals("#.0E0: 123", ".12E3", df.format(123)); + assertEquals("#.0E0: 1234", ".12E4", df.format(1234)); + assertEquals("#.0E0: 9999", ".1E5", df.format(9999)); df = new DecimalFormat("0.#E0"); - assertTrue("0.#E0: 0", df.format(0).equals("0E0")); - assertTrue("0.#E0: 1", df.format(1).equals("1E0")); - assertTrue("0.#E0: 12", df.format(12).equals("1.2E1")); - assertTrue("0.#E0: 123", df.format(123).equals("1.2E2")); - assertTrue("0.#E0: 1234", df.format(1234).equals("1.2E3")); - assertTrue("0.#E0: 9999", df.format(9999).equals("1E4")); + assertEquals("0.#E0: 0", "0E0", df.format(0)); + assertEquals("0.#E0: 1", "1E0", df.format(1)); + assertEquals("0.#E0: 12", "1.2E1", df.format(12)); + assertEquals("0.#E0: 123", "1.2E2", df.format(123)); + assertEquals("0.#E0: 1234", "1.2E3", df.format(1234)); + assertEquals("0.#E0: 9999", "1E4", df.format(9999)); assertTrue("Failed " + failures + " of " + failCount, failures.length() == 0); @@ -495,11 +495,11 @@ */ public void test_getGroupingSize() { DecimalFormat df = new DecimalFormat("###0.##"); - assertTrue("Wrong unset size", df.getGroupingSize() == 0); + assertEquals("Wrong unset size", 0, df.getGroupingSize()); df = new DecimalFormat("#,##0.##"); - assertTrue("Wrong set size", df.getGroupingSize() == 3); + assertEquals("Wrong set size", 3, df.getGroupingSize()); df = new DecimalFormat("#,###,###0.##"); - assertTrue("Wrong multiple set size", df.getGroupingSize() == 4); + assertEquals("Wrong multiple set size", 4, df.getGroupingSize()); } /** @@ -507,11 +507,11 @@ */ public void test_getMultiplier() { DecimalFormat df = new DecimalFormat("###0.##"); - assertTrue("Wrong unset multiplier", df.getMultiplier() == 1); + assertEquals("Wrong unset multiplier", 1, df.getMultiplier()); df = new DecimalFormat("###0.##%"); - assertTrue("Wrong percent multiplier", df.getMultiplier() == 100); + assertEquals("Wrong percent multiplier", 100, df.getMultiplier()); df = new DecimalFormat("###0.##\u2030"); - assertTrue("Wrong mille multiplier", df.getMultiplier() == 1000); + assertEquals("Wrong mille multiplier", 1000, df.getMultiplier()); } /** @@ -629,7 +629,7 @@ dfs.setDecimalSeparator('@'); df.setDecimalFormatSymbols(dfs); assertTrue("Not set", df.getDecimalFormatSymbols().equals(dfs)); - assertTrue("Symbols not used", df.format(1.2).equals("1@2")); + assertEquals("Symbols not used", "1@2", df.format(1.2)); } /** @@ -637,10 +637,10 @@ */ public void test_setDecimalSeparatorAlwaysShownZ() { DecimalFormat df = new DecimalFormat("###0.##"); - assertTrue("Wrong default result", df.format(5).equals("5")); + assertEquals("Wrong default result", "5", df.format(5)); df.setDecimalSeparatorAlwaysShown(true); assertTrue("Not set", df.isDecimalSeparatorAlwaysShown()); - assertTrue("Wrong set result", df.format(7).equals("7.")); + assertEquals("Wrong set result", "7.", df.format(7)); } /** @@ -677,7 +677,7 @@ new DecimalFormatSymbols(Locale.ENGLISH)); df.setGroupingUsed(true); df.setGroupingSize(2); - assertTrue("Value not set", df.getGroupingSize() == 2); + assertEquals("Value not set", 2, df.getGroupingSize()); String result = df.format(123); assertTrue("Invalid format:" + result, result.equals("1,23")); } @@ -688,11 +688,11 @@ public void test_setMaximumFractionDigitsI() { DecimalFormat df = new DecimalFormat("###0.##"); df.setMaximumFractionDigits(3); - assertTrue("Not set", df.getMaximumFractionDigits() == 3); - assertTrue("Wrong maximum", df.format(1.23456).equals("1.235")); + assertEquals("Not set", 3, df.getMaximumFractionDigits()); + assertEquals("Wrong maximum", "1.235", df.format(1.23456)); df.setMinimumFractionDigits(4); - assertTrue("Not changed", df.getMaximumFractionDigits() == 4); - assertTrue("Incorrect fraction", df.format(456).equals("456.0000")); + assertEquals("Not changed", 4, df.getMaximumFractionDigits()); + assertEquals("Incorrect fraction", "456.0000", df.format(456)); } /** @@ -701,11 +701,11 @@ public void test_setMaximumIntegerDigitsI() { DecimalFormat df = new DecimalFormat("###0.##"); df.setMaximumIntegerDigits(2); - assertTrue("Not set", df.getMaximumIntegerDigits() == 2); - assertTrue("Wrong maximum", df.format(1234).equals("34")); + assertEquals("Not set", 2, df.getMaximumIntegerDigits()); + assertEquals("Wrong maximum", "34", df.format(1234)); df.setMinimumIntegerDigits(4); - assertTrue("Not changed", df.getMaximumIntegerDigits() == 4); - assertTrue("Incorrect integer", df.format(26).equals("0026")); + assertEquals("Not changed", 4, df.getMaximumIntegerDigits()); + assertEquals("Incorrect integer", "0026", df.format(26)); } /** @@ -714,11 +714,11 @@ public void test_setMinimumFractionDigitsI() { DecimalFormat df = new DecimalFormat("###0.##"); df.setMinimumFractionDigits(4); - assertTrue("Not set", df.getMinimumFractionDigits() == 4); - assertTrue("Wrong minimum", df.format(1.23).equals("1.2300")); + assertEquals("Not set", 4, df.getMinimumFractionDigits()); + assertEquals("Wrong minimum", "1.2300", df.format(1.23)); df.setMaximumFractionDigits(2); - assertTrue("Not changed", df.getMinimumFractionDigits() == 2); - assertTrue("Incorrect fraction", df.format(456).equals("456.00")); + assertEquals("Not changed", 2, df.getMinimumFractionDigits()); + assertEquals("Incorrect fraction", "456.00", df.format(456)); } /** @@ -727,11 +727,11 @@ public void test_setMinimumIntegerDigitsI() { DecimalFormat df = new DecimalFormat("###0.##"); df.setMinimumIntegerDigits(3); - assertTrue("Not set", df.getMinimumIntegerDigits() == 3); - assertTrue("Wrong minimum", df.format(12).equals("012")); + assertEquals("Not set", 3, df.getMinimumIntegerDigits()); + assertEquals("Wrong minimum", "012", df.format(12)); df.setMaximumIntegerDigits(2); - assertTrue("Not changed", df.getMinimumIntegerDigits() == 2); - assertTrue("Incorrect integer", df.format(0.7).equals("00.7")); + assertEquals("Not changed", 2, df.getMinimumIntegerDigits()); + assertEquals("Incorrect integer", "00.7", df.format(0.7)); } /** @@ -740,9 +740,9 @@ public void test_setMultiplierI() { DecimalFormat df = new DecimalFormat("###0.##"); df.setMultiplier(10); - assertTrue("Wrong multiplier", df.getMultiplier() == 10); - assertTrue("Wrong format", df.format(5).equals("50")); - assertTrue("Wrong parse", df.parse("50", new ParsePosition(0)) - .intValue() == 5); + assertEquals("Wrong multiplier", 10, df.getMultiplier()); + assertEquals("Wrong format", "50", df.format(5)); + assertEquals("Wrong parse", 5, df.parse("50", new ParsePosition(0)) + .intValue()); } } Index: modules/text/src/test/java/tests/api/java/text/FieldPositionTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/FieldPositionTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/FieldPositionTest.java (working copy) @@ -110,8 +110,8 @@ FieldPosition fpos = new FieldPosition(1); fpos.setEndIndex(3); fpos.setBeginIndex(2); - assertTrue("getBeginIndex should have returned 2", - fpos.getBeginIndex() == 2); + assertEquals("getBeginIndex should have returned 2", + 2, fpos.getBeginIndex()); } /** @@ -122,8 +122,8 @@ FieldPosition fpos = new FieldPosition(1); fpos.setBeginIndex(2); fpos.setEndIndex(3); - assertTrue("getEndIndex should have returned 3", - fpos.getEndIndex() == 3); + assertEquals("getEndIndex should have returned 3", + 3, fpos.getEndIndex()); } /** @@ -132,13 +132,11 @@ public void test_getField() { // Test for method int java.text.FieldPosition.getField() FieldPosition fpos = new FieldPosition(65); - assertTrue( - "FieldPosition(65) should have caused getField to return 65", - fpos.getField() == 65); + assertEquals("FieldPosition(65) should have caused getField to return 65", + 65, fpos.getField()); FieldPosition fpos2 = new FieldPosition(DateFormat.Field.MINUTE); - assertTrue( - "FieldPosition(DateFormat.Field.MINUTE) should have caused getField to return -1", - fpos2.getField() == -1); + assertEquals("FieldPosition(DateFormat.Field.MINUTE) should have caused getField to return -1", + -1, fpos2.getField()); } /** @@ -152,9 +150,9 @@ fpos.getFieldAttribute() == DateFormat.Field.TIME_ZONE); FieldPosition fpos2 = new FieldPosition(DateFormat.TIMEZONE_FIELD); - assertTrue( + assertNull( "FieldPosition(DateFormat.TIMEZONE_FIELD) should have caused getFieldAttribute to return null", - fpos2.getFieldAttribute() == null); + fpos2.getFieldAttribute()); } /** @@ -183,8 +181,8 @@ FieldPosition fpos = new FieldPosition(1); fpos.setBeginIndex(2); fpos.setEndIndex(3); - assertTrue("beginIndex should have been set to 2", - fpos.getBeginIndex() == 2); + assertEquals("beginIndex should have been set to 2", + 2, fpos.getBeginIndex()); } /** @@ -195,8 +193,8 @@ FieldPosition fpos = new FieldPosition(1); fpos.setEndIndex(3); fpos.setBeginIndex(2); - assertTrue("EndIndex should have been set to 3", - fpos.getEndIndex() == 3); + assertEquals("EndIndex should have been set to 3", + 3, fpos.getEndIndex()); } /** Index: modules/text/src/test/java/tests/api/java/text/AnnotationTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/AnnotationTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/AnnotationTest.java (working copy) @@ -61,8 +61,8 @@ */ public void test_toString() { ant = new Annotation("HelloWorld"); - assertTrue("toString error.", ant.toString().equals( - "java.text.Annotation[value=HelloWorld]")); + assertEquals("toString error.", + "java.text.Annotation[value=HelloWorld]", ant.toString()); } protected void setUp() { Index: modules/text/src/test/java/tests/api/java/text/CollatorTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/CollatorTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/CollatorTest.java (working copy) @@ -53,7 +53,7 @@ assertTrue("a) Failed on identical", c.compare(o, o2) < 0); o = "e"; o2 = "e"; - assertTrue("a) Failed on equivalence", c.compare(o, o2) == 0); + assertEquals("a) Failed on equivalence", 0, c.compare(o, o2)); assertTrue("a) Failed on primary expansion", c.compare("\u01db", "v") < 0); @@ -69,10 +69,10 @@ assertTrue("b) Failed on tertiary difference", c.compare(o, o2) < 0); o = "\u0001"; o2 = "\u0002"; - assertTrue("b) Failed on identical", c.compare(o, o2) == 0); + assertEquals("b) Failed on identical", 0, c.compare(o, o2)); o = "e"; o2 = "e"; - assertTrue("b) Failed on equivalence", c.compare(o, o2) == 0); + assertEquals("b) Failed on equivalence", 0, c.compare(o, o2)); c.setStrength(Collator.SECONDARY); o = "E"; @@ -83,13 +83,13 @@ assertTrue("c) Failed on secondary difference", c.compare(o, o2) < 0); o = "e"; o2 = "E"; - assertTrue("c) Failed on tertiary difference", c.compare(o, o2) == 0); + assertEquals("c) Failed on tertiary difference", 0, c.compare(o, o2)); o = "\u0001"; o2 = "\u0002"; - assertTrue("c) Failed on identical", c.compare(o, o2) == 0); + assertEquals("c) Failed on identical", 0, c.compare(o, o2)); o = "e"; o2 = "e"; - assertTrue("c) Failed on equivalence", c.compare(o, o2) == 0); + assertEquals("c) Failed on equivalence", 0, c.compare(o, o2)); c.setStrength(Collator.PRIMARY); o = "E"; @@ -97,16 +97,16 @@ assertTrue("d) Failed on primary difference", c.compare(o, o2) < 0); o = "e"; o2 = "\u00e9"; - assertTrue("d) Failed on secondary difference", c.compare(o, o2) == 0); + assertEquals("d) Failed on secondary difference", 0, c.compare(o, o2)); o = "e"; o2 = "E"; - assertTrue("d) Failed on tertiary difference", c.compare(o, o2) == 0); + assertEquals("d) Failed on tertiary difference", 0, c.compare(o, o2)); o = "\u0001"; o2 = "\u0002"; - assertTrue("d) Failed on identical", c.compare(o, o2) == 0); + assertEquals("d) Failed on identical", 0, c.compare(o, o2)); o = "e"; o2 = "e"; - assertTrue("d) Failed on equivalence", c.compare(o, o2) == 0); + assertEquals("d) Failed on equivalence", 0, c.compare(o, o2)); try { c.compare("e", new StringBuffer("Blah")); Index: modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java (working copy) @@ -48,7 +48,7 @@ public void test_ConstructorLjava_util_Locale() { DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale("en", "us")); - assertTrue("Returned incorrect symbols", dfs.getPercent() == '%'); + assertEquals("Returned incorrect symbols", '%', dfs.getPercent()); } /** @@ -79,34 +79,34 @@ "KR")); assertTrue("Test1: Returned incorrect currency", dfs1.getCurrency() == currK); - assertTrue("Test1: Returned incorrect currencySymbol", dfs1 - .getCurrencySymbol().equals("\uffe6")); - assertTrue("Test1: Returned incorrect intlCurrencySymbol", dfs1 - .getInternationalCurrencySymbol().equals("KRW")); + assertEquals("Test1: Returned incorrect currencySymbol", "\uffe6", dfs1 + .getCurrencySymbol()); + assertEquals("Test1: Returned incorrect intlCurrencySymbol", "KRW", dfs1 + .getInternationalCurrencySymbol()); dfs1 = new DecimalFormatSymbols(new Locale("", "KR")); assertTrue("Test2: Returned incorrect currency", dfs1.getCurrency() == currK); - assertTrue("Test2: Returned incorrect currencySymbol", dfs1 - .getCurrencySymbol().equals("KRW")); - assertTrue("Test2: Returned incorrect intlCurrencySymbol", dfs1 - .getInternationalCurrencySymbol().equals("KRW")); + assertEquals("Test2: Returned incorrect currencySymbol", "KRW", dfs1 + .getCurrencySymbol()); + assertEquals("Test2: Returned incorrect intlCurrencySymbol", "KRW", dfs1 + .getInternationalCurrencySymbol()); dfs1 = new DecimalFormatSymbols(new Locale("ko", "")); assertTrue("Test3: Returned incorrect currency", dfs1.getCurrency() == currX); - assertTrue("Test3: Returned incorrect currencySymbol", dfs1 - .getCurrencySymbol().equals("\u00a4")); - assertTrue("Test3: Returned incorrect intlCurrencySymbol", dfs1 - .getInternationalCurrencySymbol().equals("XXX")); + assertEquals("Test3: Returned incorrect currencySymbol", "\u00a4", dfs1 + .getCurrencySymbol()); + assertEquals("Test3: Returned incorrect intlCurrencySymbol", "XXX", dfs1 + .getInternationalCurrencySymbol()); dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR")); assertTrue("Test4: Returned incorrect currency", dfs1.getCurrency() == currE); - assertTrue("Test4: Returned incorrect currencySymbol", dfs1 - .getCurrencySymbol().equals("\u20ac")); - assertTrue("Test4: Returned incorrect intlCurrencySymbol", dfs1 - .getInternationalCurrencySymbol().equals("EUR")); + assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1 + .getCurrencySymbol()); + assertEquals("Test4: Returned incorrect intlCurrencySymbol", "EUR", dfs1 + .getInternationalCurrencySymbol()); // RI fails these tests since it doesn't have the PREEURO variant // dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR","PREEURO")); @@ -122,8 +122,8 @@ * @tests java.text.DecimalFormatSymbols#getCurrencySymbol() */ public void test_getCurrencySymbol() { - assertTrue("Returned incorrect currencySymbol", dfsUS - .getCurrencySymbol().equals("$")); + assertEquals("Returned incorrect currencySymbol", "$", dfsUS + .getCurrencySymbol()); } /** @@ -131,8 +131,8 @@ */ public void test_getDecimalSeparator() { dfs.setDecimalSeparator('*'); - assertTrue("Returned incorrect DecimalSeparator symbol", dfs - .getDecimalSeparator() == '*'); + assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs + .getDecimalSeparator()); } /** @@ -140,7 +140,7 @@ */ public void test_getDigit() { dfs.setDigit('*'); - assertTrue("Returned incorrect Digit symbol", dfs.getDigit() == '*'); + assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit()); } /** @@ -148,8 +148,8 @@ */ public void test_getGroupingSeparator() { dfs.setGroupingSeparator('*'); - assertTrue("Returned incorrect GroupingSeparator symbol", dfs - .getGroupingSeparator() == '*'); + assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs + .getGroupingSeparator()); } /** @@ -165,8 +165,8 @@ * @tests java.text.DecimalFormatSymbols#getInternationalCurrencySymbol() */ public void test_getInternationalCurrencySymbol() { - assertTrue("Returned incorrect InternationalCurrencySymbol", dfsUS - .getInternationalCurrencySymbol().equals("USD")); + assertEquals("Returned incorrect InternationalCurrencySymbol", "USD", dfsUS + .getInternationalCurrencySymbol()); } /** @@ -174,8 +174,8 @@ */ public void test_getMinusSign() { dfs.setMinusSign('&'); - assertTrue("Returned incorrect MinusSign symbol", - dfs.getMinusSign() == '&'); + assertEquals("Returned incorrect MinusSign symbol", + '&', dfs.getMinusSign()); } /** @@ -183,8 +183,8 @@ */ public void test_getNaN() { dfs.setNaN("NAN!!"); - assertTrue("Returned incorrect nan symbol", dfs.getNaN() - .equals("NAN!!")); + assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN() + ); } /** @@ -192,8 +192,8 @@ */ public void test_getPatternSeparator() { dfs.setPatternSeparator('X'); - assertTrue("Returned incorrect PatternSeparator symbol", dfs - .getPatternSeparator() == 'X'); + assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs + .getPatternSeparator()); } /** @@ -201,7 +201,7 @@ */ public void test_getPercent() { dfs.setPercent('*'); - assertTrue("Returned incorrect Percent symbol", dfs.getPercent() == '*'); + assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent()); } /** @@ -209,7 +209,7 @@ */ public void test_getPerMill() { dfs.setPerMill('#'); - assertTrue("Returned incorrect PerMill symbol", dfs.getPerMill() == '#'); + assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill()); } /** @@ -217,8 +217,8 @@ */ public void test_getZeroDigit() { dfs.setZeroDigit('*'); - assertTrue("Returned incorrect ZeroDigit symbol", - dfs.getZeroDigit() == '*'); + assertEquals("Returned incorrect ZeroDigit symbol", + '*', dfs.getZeroDigit()); } /** @@ -250,8 +250,8 @@ */ public void test_setDecimalSeparatorC() { dfs.setDecimalSeparator('*'); - assertTrue("Returned incorrect DecimalSeparator symbol", dfs - .getDecimalSeparator() == '*'); + assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs + .getDecimalSeparator()); } /** @@ -259,7 +259,7 @@ */ public void test_setDigitC() { dfs.setDigit('*'); - assertTrue("Returned incorrect Digit symbol", dfs.getDigit() == '*'); + assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit()); } /** @@ -267,8 +267,8 @@ */ public void test_setGroupingSeparatorC() { dfs.setGroupingSeparator('*'); - assertTrue("Returned incorrect GroupingSeparator symbol", dfs - .getGroupingSeparator() == '*'); + assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs + .getGroupingSeparator()); } /** @@ -300,12 +300,12 @@ String symbol = dfs.getCurrencySymbol(); dfs.setInternationalCurrencySymbol("bogus"); - assertTrue("Test2: Returned incorrect currency", - dfs.getCurrency() == null); + assertNull("Test2: Returned incorrect currency", + dfs.getCurrency()); assertTrue("Test2: Returned incorrect currency symbol", dfs .getCurrencySymbol().equals(symbol)); - assertTrue("Test2: Returned incorrect international currency symbol", - dfs.getInternationalCurrencySymbol().equals("bogus")); + assertEquals("Test2: Returned incorrect international currency symbol", + "bogus", dfs.getInternationalCurrencySymbol()); } /** @@ -313,8 +313,8 @@ */ public void test_setMinusSignC() { dfs.setMinusSign('&'); - assertTrue("Returned incorrect MinusSign symbol", - dfs.getMinusSign() == '&'); + assertEquals("Returned incorrect MinusSign symbol", + '&', dfs.getMinusSign()); } /** @@ -322,8 +322,8 @@ */ public void test_setNaNLjava_lang_String() { dfs.setNaN("NAN!!"); - assertTrue("Returned incorrect nan symbol", dfs.getNaN() - .equals("NAN!!")); + assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN() + ); } /** @@ -331,8 +331,8 @@ */ public void test_setPatternSeparatorC() { dfs.setPatternSeparator('X'); - assertTrue("Returned incorrect PatternSeparator symbol", dfs - .getPatternSeparator() == 'X'); + assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs + .getPatternSeparator()); } /** @@ -340,7 +340,7 @@ */ public void test_setPercentC() { dfs.setPercent('*'); - assertTrue("Returned incorrect Percent symbol", dfs.getPercent() == '*'); + assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent()); } /** @@ -348,7 +348,7 @@ */ public void test_setPerMillC() { dfs.setPerMill('#'); - assertTrue("Returned incorrect PerMill symbol", dfs.getPerMill() == '#'); + assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill()); } /** @@ -356,7 +356,7 @@ */ public void test_setZeroDigitC() { dfs.setZeroDigit('*'); - assertTrue("Set incorrect ZeroDigit symbol", dfs.getZeroDigit() == '*'); + assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit()); } /** Index: modules/text/src/test/java/tests/api/java/text/ParseExceptionTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/ParseExceptionTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/ParseExceptionTest.java (working copy) @@ -44,7 +44,7 @@ DateFormat df = DateFormat.getInstance(); df.parse("1999HelloWorld"); } catch (ParseException e) { - assertTrue("getErrorOffsetFailed.", e.getErrorOffset() == 4); + assertEquals("getErrorOffsetFailed.", 4, e.getErrorOffset()); } } Index: modules/text/src/test/java/tests/api/java/text/CollationKeyTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/CollationKeyTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/CollationKeyTest.java (working copy) @@ -30,7 +30,7 @@ collator.setStrength(Collator.PRIMARY); CollationKey key1 = collator.getCollationKey("abc"); CollationKey key2 = collator.getCollationKey("ABC"); - assertTrue("Should be equal", key1.compareTo(key2) == 0); + assertEquals("Should be equal", 0, key1.compareTo(key2)); } /** @@ -43,7 +43,7 @@ collator.setStrength(Collator.PRIMARY); CollationKey key1 = collator.getCollationKey("abc"); CollationKey key2 = collator.getCollationKey("ABC"); - assertTrue("Should be equal", key1.compareTo(key2) == 0); + assertEquals("Should be equal", 0, key1.compareTo(key2)); } /** Index: modules/text/src/test/java/tests/api/java/text/MessageFormatTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/MessageFormatTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/MessageFormatTest.java (working copy) @@ -89,7 +89,7 @@ assertTrue("Not a MessageFormat", format.getClass() == MessageFormat.class); Format[] formats = format.getFormats(); - assertTrue("null formats", formats != null); + assertNotNull("null formats", formats); assertTrue("Wrong format count: " + formats.length, formats.length >= 5); assertTrue("Wrong time format", formats[0].equals(DateFormat .getTimeInstance())); @@ -99,7 +99,7 @@ .getInstance())); assertTrue("Wrong choice format", formats[3].equals(new ChoiceFormat( "0.0#low|1.0#high"))); - assertTrue("Wrong string format", formats[4] == null); + assertNull("Wrong string format", formats[4]); Date date = new Date(); FieldPosition pos = new FieldPosition(-1); @@ -118,8 +118,8 @@ assertTrue("Wrong answer:\n" + result + "\n" + buffer, result .equals(buffer.toString())); - assertTrue("Simple string", new MessageFormat("Test message").format( - new Object[0]).equals("Test message")); + assertEquals("Simple string", "Test message", new MessageFormat("Test message").format( + new Object[0])); try { result = new MessageFormat("Don't").format(new Object[0]); @@ -166,8 +166,8 @@ // java.text.MessageFormat.applyPattern(java.lang.String) MessageFormat format = new MessageFormat("test"); format.applyPattern("xx {0}"); - assertTrue("Invalid number", format.format( - new Object[] { new Integer(46) }).equals("xx 46")); + assertEquals("Invalid number", "xx 46", format.format( + new Object[] { new Integer(46) })); Date date = new Date(); String result = format.format(new Object[] { date }); String expected = "xx " + DateFormat.getInstance().format(date); @@ -175,110 +175,110 @@ .equals(expected)); format = new MessageFormat("{0,date}{1,time}{2,number,integer}"); format.applyPattern("nothing"); - assertTrue("Found formats", format.toPattern().equals("nothing")); + assertEquals("Found formats", "nothing", format.toPattern()); format.applyPattern("{0}"); - assertTrue("Wrong format", format.getFormats()[0] == null); - assertTrue("Wrong pattern", format.toPattern().equals("{0}")); + assertNull("Wrong format", format.getFormats()[0]); + assertEquals("Wrong pattern", "{0}", format.toPattern()); format.applyPattern("{0, \t\u001ftime }"); assertTrue("Wrong time format", format.getFormats()[0] .equals(DateFormat.getTimeInstance())); - assertTrue("Wrong time pattern", format.toPattern().equals("{0,time}")); + assertEquals("Wrong time pattern", "{0,time}", format.toPattern()); format.applyPattern("{0,Time, Short\n}"); assertTrue("Wrong short time format", format.getFormats()[0] .equals(DateFormat.getTimeInstance(DateFormat.SHORT))); - assertTrue("Wrong short time pattern", format.toPattern().equals( - "{0,time,short}")); + assertEquals("Wrong short time pattern", + "{0,time,short}", format.toPattern()); format.applyPattern("{0,TIME,\nmedium }"); assertTrue("Wrong medium time format", format.getFormats()[0] .equals(DateFormat.getTimeInstance(DateFormat.MEDIUM))); - assertTrue("Wrong medium time pattern", format.toPattern().equals( - "{0,time}")); + assertEquals("Wrong medium time pattern", + "{0,time}", format.toPattern()); format.applyPattern("{0,time,LONG}"); assertTrue("Wrong long time format", format.getFormats()[0] .equals(DateFormat.getTimeInstance(DateFormat.LONG))); - assertTrue("Wrong long time pattern", format.toPattern().equals( - "{0,time,long}")); + assertEquals("Wrong long time pattern", + "{0,time,long}", format.toPattern()); format.setLocale(Locale.FRENCH); // use French since English has the // same LONG and FULL time patterns format.applyPattern("{0,time, Full}"); assertTrue("Wrong full time format", format.getFormats()[0] .equals(DateFormat.getTimeInstance(DateFormat.FULL, Locale.FRENCH))); - assertTrue("Wrong full time pattern", format.toPattern().equals( - "{0,time,full}")); + assertEquals("Wrong full time pattern", + "{0,time,full}", format.toPattern()); format.setLocale(Locale.getDefault()); format.applyPattern("{0, date}"); assertTrue("Wrong date format", format.getFormats()[0] .equals(DateFormat.getDateInstance())); - assertTrue("Wrong date pattern", format.toPattern().equals("{0,date}")); + assertEquals("Wrong date pattern", "{0,date}", format.toPattern()); format.applyPattern("{0, date, short}"); assertTrue("Wrong short date format", format.getFormats()[0] .equals(DateFormat.getDateInstance(DateFormat.SHORT))); - assertTrue("Wrong short date pattern", format.toPattern().equals( - "{0,date,short}")); + assertEquals("Wrong short date pattern", + "{0,date,short}", format.toPattern()); format.applyPattern("{0, date, medium}"); assertTrue("Wrong medium date format", format.getFormats()[0] .equals(DateFormat.getDateInstance(DateFormat.MEDIUM))); - assertTrue("Wrong medium date pattern", format.toPattern().equals( - "{0,date}")); + assertEquals("Wrong medium date pattern", + "{0,date}", format.toPattern()); format.applyPattern("{0, date, long}"); assertTrue("Wrong long date format", format.getFormats()[0] .equals(DateFormat.getDateInstance(DateFormat.LONG))); - assertTrue("Wrong long date pattern", format.toPattern().equals( - "{0,date,long}")); + assertEquals("Wrong long date pattern", + "{0,date,long}", format.toPattern()); format.applyPattern("{0, date, full}"); assertTrue("Wrong full date format", format.getFormats()[0] .equals(DateFormat.getDateInstance(DateFormat.FULL))); - assertTrue("Wrong full date pattern", format.toPattern().equals( - "{0,date,full}")); + assertEquals("Wrong full date pattern", + "{0,date,full}", format.toPattern()); format.applyPattern("{0, date, MMM d {hh:mm:ss}}"); - assertTrue("Wrong time/date format", ((SimpleDateFormat) (format - .getFormats()[0])).toPattern().equals(" MMM d {hh:mm:ss}")); - assertTrue("Wrong time/date pattern", format.toPattern().equals( - "{0,date, MMM d {hh:mm:ss}}")); + assertEquals("Wrong time/date format", " MMM d {hh:mm:ss}", ((SimpleDateFormat) (format + .getFormats()[0])).toPattern()); + assertEquals("Wrong time/date pattern", + "{0,date, MMM d {hh:mm:ss}}", format.toPattern()); format.applyPattern("{0, number}"); assertTrue("Wrong number format", format.getFormats()[0] .equals(NumberFormat.getNumberInstance())); - assertTrue("Wrong number pattern", format.toPattern().equals( - "{0,number}")); + assertEquals("Wrong number pattern", + "{0,number}", format.toPattern()); format.applyPattern("{0, number, currency}"); assertTrue("Wrong currency number format", format.getFormats()[0] .equals(NumberFormat.getCurrencyInstance())); - assertTrue("Wrong currency number pattern", format.toPattern().equals( - "{0,number,currency}")); + assertEquals("Wrong currency number pattern", + "{0,number,currency}", format.toPattern()); format.applyPattern("{0, number, percent}"); assertTrue("Wrong percent number format", format.getFormats()[0] .equals(NumberFormat.getPercentInstance())); - assertTrue("Wrong percent number pattern", format.toPattern().equals( - "{0,number,percent}")); + assertEquals("Wrong percent number pattern", + "{0,number,percent}", format.toPattern()); format.applyPattern("{0, number, integer}"); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(0); nf.setParseIntegerOnly(true); assertTrue("Wrong integer number format", format.getFormats()[0] .equals(nf)); - assertTrue("Wrong integer number pattern", format.toPattern().equals( - "{0,number,integer}")); + assertEquals("Wrong integer number pattern", + "{0,number,integer}", format.toPattern()); format.applyPattern("{0, number, {'#'}##0.0E0}"); - assertTrue("Wrong pattern number format", ((DecimalFormat) (format - .getFormats()[0])).toPattern().equals("' {#}'##0.0E0")); - assertTrue("Wrong pattern number pattern", format.toPattern().equals( - "{0,number,' {#}'##0.0E0}")); + assertEquals("Wrong pattern number format", "' {#}'##0.0E0", ((DecimalFormat) (format + .getFormats()[0])).toPattern()); + assertEquals("Wrong pattern number pattern", + "{0,number,' {#}'##0.0E0}", format.toPattern()); format.applyPattern("{0, choice,0#no|1#one|2#{1,number}}"); - assertTrue("Wrong choice format", - ((ChoiceFormat) format.getFormats()[0]).toPattern().equals( - "0.0#no|1.0#one|2.0#{1,number}")); - assertTrue("Wrong choice pattern", format.toPattern().equals( - "{0,choice,0.0#no|1.0#one|2.0#{1,number}}")); - assertTrue("Wrong formatted choice", format.format( - new Object[] { new Integer(2), new Float(3.6) }).equals("3.6")); + assertEquals("Wrong choice format", + + "0.0#no|1.0#one|2.0#{1,number}", ((ChoiceFormat) format.getFormats()[0]).toPattern()); + assertEquals("Wrong choice pattern", + "{0,choice,0.0#no|1.0#one|2.0#{1,number}}", format.toPattern()); + assertEquals("Wrong formatted choice", "3.6", format.format( + new Object[] { new Integer(2), new Float(3.6) })); try { format.applyPattern("WRONG MESSAGE FORMAT {0,number,{}"); @@ -295,8 +295,8 @@ MessageFormat format = new MessageFormat("'{'choice'}'{0}"); MessageFormat clone = (MessageFormat) format.clone(); assertTrue("Clone not equal", format.equals(clone)); - assertTrue("Wrong answer", format.format(new Object[] {}).equals( - "{choice}{0}")); + assertEquals("Wrong answer", + "{choice}{0}", format.format(new Object[] {})); clone.setFormat(0, DateFormat.getInstance()); assertTrue("Clone shares format data", !format.equals(clone)); format = (MessageFormat) clone.clone(); @@ -344,7 +344,7 @@ StringBuffer buffer = new StringBuffer(); format.format(new Object[] { "0", new Double(53.863) }, buffer, new FieldPosition(0)); - assertTrue("Wrong result", buffer.toString().equals("54")); + assertEquals("Wrong result", "54", buffer.toString()); format .applyPattern("{0,choice,0#zero|1#one '{1,choice,2#two {2,time}}'}"); Date date = new Date(); @@ -643,7 +643,7 @@ mf = new MessageFormat("{0}; {0}; {0}"); String parse = "a; b; c"; result = mf.parse(parse, new ParsePosition(0)); - assertTrue("Wrong variable result", result[0].equals("c")); + assertEquals("Wrong variable result", "c", result[0]); } /** Index: modules/text/src/test/java/tests/api/java/text/StringCharacterIteratorTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/StringCharacterIteratorTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/StringCharacterIteratorTest.java (working copy) @@ -24,11 +24,11 @@ */ public void test_ConstructorLjava_lang_String() { StringCharacterIterator it = new StringCharacterIterator("testing"); - assertTrue("Wrong begin index", it.getBeginIndex() == 0); - assertTrue("Wrong end index", it.getEndIndex() == 7); - assertTrue("Wrong current index", it.getIndex() == 0); - assertTrue("Wrong current char", it.current() == 't'); - assertTrue("Wrong next char", it.next() == 'e'); + assertEquals("Wrong begin index", 0, it.getBeginIndex()); + assertEquals("Wrong end index", 7, it.getEndIndex()); + assertEquals("Wrong current index", 0, it.getIndex()); + assertEquals("Wrong current char", 't', it.current()); + assertEquals("Wrong next char", 'e', it.next()); } /** @@ -37,11 +37,11 @@ */ public void test_ConstructorLjava_lang_StringI() { StringCharacterIterator it = new StringCharacterIterator("testing", 3); - assertTrue("Wrong begin index", it.getBeginIndex() == 0); - assertTrue("Wrong end index", it.getEndIndex() == 7); - assertTrue("Wrong current index", it.getIndex() == 3); - assertTrue("Wrong current char", it.current() == 't'); - assertTrue("Wrong next char", it.next() == 'i'); + assertEquals("Wrong begin index", 0, it.getBeginIndex()); + assertEquals("Wrong end index", 7, it.getEndIndex()); + assertEquals("Wrong current index", 3, it.getIndex()); + assertEquals("Wrong current char", 't', it.current()); + assertEquals("Wrong next char", 'i', it.next()); } /** @@ -51,11 +51,11 @@ public void test_ConstructorLjava_lang_StringIII() { StringCharacterIterator it = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong begin index", it.getBeginIndex() == 2); - assertTrue("Wrong end index", it.getEndIndex() == 6); - assertTrue("Wrong current index", it.getIndex() == 4); - assertTrue("Wrong current char", it.current() == 'i'); - assertTrue("Wrong next char", it.next() == 'n'); + assertEquals("Wrong begin index", 2, it.getBeginIndex()); + assertEquals("Wrong end index", 6, it.getEndIndex()); + assertEquals("Wrong current index", 4, it.getIndex()); + assertEquals("Wrong current char", 'i', it.current()); + assertEquals("Wrong next char", 'n', it.next()); } /** @@ -74,7 +74,7 @@ public void test_current() { StringCharacterIterator it = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong current char", it.current() == 'i'); + assertEquals("Wrong current char", 'i', it.current()); } /** @@ -98,8 +98,8 @@ public void test_first() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong first char", it1.first() == 's'); - assertTrue("Wrong next char", it1.next() == 't'); + assertEquals("Wrong first char", 's', it1.first()); + assertEquals("Wrong next char", 't', it1.next()); it1 = new StringCharacterIterator("testing", 2, 2, 2); assertTrue("Not DONE", it1.first() == CharacterIterator.DONE); } @@ -110,7 +110,7 @@ public void test_getBeginIndex() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong begin index 2", it1.getBeginIndex() == 2); + assertEquals("Wrong begin index 2", 2, it1.getBeginIndex()); } /** @@ -119,7 +119,7 @@ public void test_getEndIndex() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong end index 6", it1.getEndIndex() == 6); + assertEquals("Wrong end index 6", 6, it1.getEndIndex()); } /** @@ -128,11 +128,11 @@ public void test_getIndex() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong index 4", it1.getIndex() == 4); + assertEquals("Wrong index 4", 4, it1.getIndex()); it1.next(); - assertTrue("Wrong index 5", it1.getIndex() == 5); + assertEquals("Wrong index 5", 5, it1.getIndex()); it1.last(); - assertTrue("Wrong index 4/2", it1.getIndex() == 5); + assertEquals("Wrong index 4/2", 5, it1.getIndex()); } /** @@ -161,8 +161,8 @@ public void test_last() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 3); - assertTrue("Wrong last char", it1.last() == 'n'); - assertTrue("Wrong previous char", it1.previous() == 'i'); + assertEquals("Wrong last char", 'n', it1.last()); + assertEquals("Wrong previous char", 'i', it1.previous()); it1 = new StringCharacterIterator("testing", 2, 2, 2); assertTrue("Not DONE", it1.last() == CharacterIterator.DONE); } @@ -175,7 +175,7 @@ 6, 3); char result = it1.next(); assertTrue("Wrong next char1: " + result, result == 'i'); - assertTrue("Wrong next char2", it1.next() == 'n'); + assertEquals("Wrong next char2", 'n', it1.next()); assertTrue("Wrong next char3", it1.next() == CharacterIterator.DONE); assertTrue("Wrong next char4", it1.next() == CharacterIterator.DONE); int index = it1.getIndex(); @@ -190,14 +190,14 @@ public void test_previous() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong previous char1", it1.previous() == 't'); - assertTrue("Wrong previous char2", it1.previous() == 's'); + assertEquals("Wrong previous char1", 't', it1.previous()); + assertEquals("Wrong previous char2", 's', it1.previous()); assertTrue("Wrong previous char3", it1.previous() == CharacterIterator.DONE); assertTrue("Wrong previous char4", it1.previous() == CharacterIterator.DONE); - assertTrue("Wrong index", it1.getIndex() == 2); - assertTrue("Wrong current char", it1.current() == 's'); + assertEquals("Wrong index", 2, it1.getIndex()); + assertEquals("Wrong current char", 's', it1.current()); } /** @@ -206,11 +206,11 @@ public void test_setIndexI() { StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); - assertTrue("Wrong result1", it1.setIndex(2) == 's'); + assertEquals("Wrong result1", 's', it1.setIndex(2)); char result = it1.next(); assertTrue("Wrong next char: " + result, result == 't'); assertTrue("Wrong result2", it1.setIndex(6) == CharacterIterator.DONE); - assertTrue("Wrong previous char", it1.previous() == 'n'); + assertEquals("Wrong previous char", 'n', it1.previous()); } /** @@ -220,9 +220,9 @@ StringCharacterIterator it1 = new StringCharacterIterator("testing", 2, 6, 4); it1.setText("frog"); - assertTrue("Wrong begin index", it1.getBeginIndex() == 0); - assertTrue("Wrong end index", it1.getEndIndex() == 4); - assertTrue("Wrong current index", it1.getIndex() == 0); + assertEquals("Wrong begin index", 0, it1.getBeginIndex()); + assertEquals("Wrong end index", 4, it1.getEndIndex()); + assertEquals("Wrong current index", 0, it1.getIndex()); } protected void setUp() { Index: modules/text/src/test/java/tests/api/java/text/AttributedCharacterIteratorTest.java =================================================================== --- modules/text/src/test/java/tests/api/java/text/AttributedCharacterIteratorTest.java (revision 396457) +++ modules/text/src/test/java/tests/api/java/text/AttributedCharacterIteratorTest.java (working copy) @@ -27,17 +27,17 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); - assertTrue("Wrong first", it.current() == 'T'); + assertEquals("Wrong first", 'T', it.current()); it.next(); - assertTrue("Wrong second", it.current() == 'e'); + assertEquals("Wrong second", 'e', it.current()); for (int i = 0; i < 9; i++) it.next(); - assertTrue("Wrong last", it.current() == 'g'); + assertEquals("Wrong last", 'g', it.current()); it.next(); assertTrue("Wrong final", it.current() == CharacterIterator.DONE); it = attrString.getIterator(null, 2, 8); - assertTrue("Wrong first2", it.current() == 's'); + assertEquals("Wrong first2", 's', it.current()); } /** @@ -47,11 +47,11 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); - assertTrue("Wrong first1", it.first() == 'T'); + assertEquals("Wrong first1", 'T', it.first()); it = attrString.getIterator(null, 0, 3); - assertTrue("Wrong first2", it.first() == 'T'); + assertEquals("Wrong first2", 'T', it.first()); it = attrString.getIterator(null, 2, 8); - assertTrue("Wrong first3", it.first() == 's'); + assertEquals("Wrong first3", 's', it.first()); it = attrString.getIterator(null, 11, 11); assertTrue("Wrong first4", it.first() == CharacterIterator.DONE); } @@ -63,7 +63,7 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(null, 2, 6); - assertTrue("Wrong begin index", it.getBeginIndex() == 2); + assertEquals("Wrong begin index", 2, it.getBeginIndex()); } /** @@ -73,7 +73,7 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(null, 2, 6); - assertTrue("Wrong begin index", it.getEndIndex() == 6); + assertEquals("Wrong begin index", 6, it.getEndIndex()); } /** @@ -83,14 +83,14 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); - assertTrue("Wrong first", it.getIndex() == 0); + assertEquals("Wrong first", 0, it.getIndex()); it.next(); - assertTrue("Wrong second", it.getIndex() == 1); + assertEquals("Wrong second", 1, it.getIndex()); for (int i = 0; i < 9; i++) it.next(); - assertTrue("Wrong last", it.getIndex() == 10); + assertEquals("Wrong last", 10, it.getIndex()); it.next(); - assertTrue("Wrong final", it.getIndex() == 11); + assertEquals("Wrong final", 11, it.getIndex()); } /** @@ -100,11 +100,11 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); - assertTrue("Wrong last1", it.last() == 'g'); + assertEquals("Wrong last1", 'g', it.last()); it = attrString.getIterator(null, 0, 3); - assertTrue("Wrong last2", it.last() == 's'); + assertEquals("Wrong last2", 's', it.last()); it = attrString.getIterator(null, 2, 8); - assertTrue("Wrong last3", it.last() == 'r'); + assertEquals("Wrong last3", 'r', it.last()); it = attrString.getIterator(null, 0, 0); assertTrue("Wrong last4", it.last() == CharacterIterator.DONE); } @@ -116,14 +116,14 @@ String test = "Test 23ring"; AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); - assertTrue("Wrong first", it.next() == 'e'); + assertEquals("Wrong first", 'e', it.next()); for (int i = 0; i < 8; i++) it.next(); - assertTrue("Wrong last", it.next() == 'g'); + assertEquals("Wrong last", 'g', it.next()); assertTrue("Wrong final", it.next() == CharacterIterator.DONE); it = attrString.getIterator(null, 2, 8); - assertTrue("Wrong first2", it.next() == 't'); + assertEquals("Wrong first2", 't', it.next()); } /** @@ -134,7 +134,7 @@ AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); it.setIndex(11); - assertTrue("Wrong first", it.previous() == 'g'); + assertEquals("Wrong first", 'g', it.previous()); } /** @@ -145,7 +145,7 @@ AttributedString attrString = new AttributedString(test); AttributedCharacterIterator it = attrString.getIterator(); it.setIndex(5); - assertTrue("Wrong first", it.current() == '2'); + assertEquals("Wrong first", '2', it.current()); } /** @@ -156,17 +156,15 @@ as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "a", 2, 3); AttributedCharacterIterator it = as.getIterator(); - assertTrue( - "non-null value limit", - it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 2); + assertEquals("non-null value limit", + 2, it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE)); as = new AttributedString("test"); as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, null, 2, 3); it = as.getIterator(); - assertTrue( - "null value limit", - it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 4); + assertEquals("null value limit", + 4, it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE)); } protected void setUp() { Index: modules/logging/src/test/java/tests/api/java/util/logging/StreamHandlerTest.java =================================================================== --- modules/logging/src/test/java/tests/api/java/util/logging/StreamHandlerTest.java (revision 396457) +++ modules/logging/src/test/java/tests/api/java/util/logging/StreamHandlerTest.java (working copy) @@ -381,8 +381,8 @@ assertEquals("flush", CallVerificationStack.getInstance() .getCurrentSourceMethod()); CallVerificationStack.getInstance().clear(); - assertTrue(aos.toString() - .equals("MockFormatter_HeadMockFormatter_Tail")); + assertEquals("MockFormatter_HeadMockFormatter_Tail", aos.toString() + ); } /* Index: modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java =================================================================== --- modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java (revision 396457) +++ modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java (working copy) @@ -231,7 +231,7 @@ public void test_compareToLjava_math_BigInteger() { assertTrue("Smaller number returned >= 0", one.compareTo(two) < 0); assertTrue("Larger number returned >= 0", two.compareTo(one) > 0); - assertTrue("Equal numbers did not return 0", one.compareTo(one) == 0); + assertEquals("Equal numbers did not return 0", 0, one.compareTo(one)); assertTrue("Neg number messed things up", two.negate().compareTo(one) < 0); } @@ -240,18 +240,18 @@ * @tests java.math.BigInteger#intValue() */ public void test_intValue() { - assertTrue("Incorrect intValue for 2**70", - twoToTheSeventy.intValue() == 0); - assertTrue("Incorrect intValue for 2", two.intValue() == 2); + assertEquals("Incorrect intValue for 2**70", + 0, twoToTheSeventy.intValue()); + assertEquals("Incorrect intValue for 2", 2, two.intValue()); } /** * @tests java.math.BigInteger#longValue() */ public void test_longValue() { - assertTrue("Incorrect longValue for 2**70", - twoToTheSeventy.longValue() == 0); - assertTrue("Incorrect longValue for 2", two.longValue() == 2); + assertEquals("Incorrect longValue for 2**70", + 0, twoToTheSeventy.longValue()); + assertEquals("Incorrect longValue for 2", 2, two.longValue()); } /** @@ -330,10 +330,10 @@ * @tests java.math.BigInteger#signum() */ public void test_signum() { - assertTrue("Wrong positive signum", two.signum() == 1); - assertTrue("Wrong zero signum", zero.signum() == 0); - assertTrue("Wrong neg zero signum", zero.negate().signum() == 0); - assertTrue("Wrong neg signum", two.negate().signum() == -1); + assertEquals("Wrong positive signum", 1, two.signum()); + assertEquals("Wrong zero signum", 0, zero.signum()); + assertEquals("Wrong neg zero signum", 0, zero.negate().signum()); + assertEquals("Wrong neg signum", -1, two.negate().signum()); } /** @@ -457,7 +457,7 @@ assertTrue("e==f", e.equals(f)); e = e.shiftRight(1); assertTrue(">>1 == /2", f.subtract(one).divide(two).equals(e)); - assertTrue("e negative", e.signum() == -1); + assertEquals("e negative", -1, e.signum()); assertTrue("b >> i", b.shiftRight(i).equals(one)); assertTrue("b >> i+1", b.shiftRight(i + 1).equals(zero)); @@ -501,7 +501,7 @@ assertTrue("c==d", c.equals(d)); c = c.shiftLeft(1); assertTrue("<<1 == *2 negative", d.multiply(two).equals(c)); - assertTrue("c negative", c.signum() == -1); + assertEquals("c negative", -1, c.signum()); assertTrue("d >> i == minusOne", d.shiftRight(i).equals(minusOne)); } } @@ -738,8 +738,8 @@ * @tests java.math.BigInteger#toString() */ public void test_toString() { - assertTrue("0.toString", "0".equals(BigInteger.valueOf(0).toString())); - assertTrue("1.toString", "1".equals(BigInteger.valueOf(1).toString())); + assertEquals("0.toString", "0", BigInteger.valueOf(0).toString()); + assertEquals("1.toString", "1", BigInteger.valueOf(1).toString()); assertTrue("12345678901234.toString", "12345678901234" .equals(BigInteger.valueOf(12345678901234L).toString())); assertTrue("-1.toString", "-1" @@ -752,18 +752,18 @@ * @tests java.math.BigInteger#toString(int) */ public void test_toStringI() { - assertTrue("0.toString(16)", "0".equals(BigInteger.valueOf(0).toString( - 16))); - assertTrue("1.toString(16)", "1".equals(BigInteger.valueOf(1).toString( - 16))); + assertEquals("0.toString(16)", "0", BigInteger.valueOf(0).toString( + 16)); + assertEquals("1.toString(16)", "1", BigInteger.valueOf(1).toString( + 16)); assertTrue("ABF345678901234.toString(16)", "abf345678901234" .equals(BigInteger.valueOf(0xABF345678901234L).toString(16))); - assertTrue("-1.toString(16)", "-1".equals(BigInteger.valueOf(-1) - .toString(16))); + assertEquals("-1.toString(16)", "-1", BigInteger.valueOf(-1) + .toString(16)); assertTrue("-ABF345678901234.toString(16)", "-abf345678901234" .equals(BigInteger.valueOf(-0xABF345678901234L).toString(16))); - assertTrue("-101010101.toString(2)", "-101010101".equals(BigInteger - .valueOf(-341).toString(2))); + assertEquals("-101010101.toString(2)", "-101010101", BigInteger + .valueOf(-341).toString(2)); } /** Index: modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java =================================================================== --- modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java (revision 396457) +++ modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java (working copy) @@ -41,8 +41,8 @@ assertTrue("the BigDecimal value is not initialized properly", big .unscaledValue().equals(value2) && big.scale() == 5); - assertTrue("the BigDecimal value is not represented properly", big - .toString().equals("123345.60000")); + assertEquals("the BigDecimal value is not represented properly", "123345.60000", big + .toString()); } /** @@ -50,29 +50,26 @@ */ public void test_ConstructorD() { BigDecimal big = new BigDecimal(123E04); - assertTrue( - "the BigDecimal value taking a double argument is not initialized properly", - big.toString().equals("1230000")); + assertEquals("the BigDecimal value taking a double argument is not initialized properly", + "1230000", big.toString()); big = new BigDecimal(1.2345E-12); assertTrue("the double representation is not correct", big .doubleValue() == 1.2345E-12); assertTrue("the string representation of this value is not correct: " + big, big.toString().equals("0.0000000000012345")); big = new BigDecimal(-12345E-3); - assertTrue("the double representation is not correct", big - .doubleValue() == -12.345); + assertEquals("the double representation is not correct", -12.345, big + .doubleValue()); big = new BigDecimal(5.1234567897654321e138); assertTrue("the double representation is not correct", big .doubleValue() == 5.1234567897654321E138 && big.scale() == 0); big = new BigDecimal(0.1); - assertTrue( - "the double representation of 0.1 bigDecimal is not correct", - big.doubleValue() == 0.1); + assertEquals("the double representation of 0.1 bigDecimal is not correct", + 0.1, big.doubleValue()); big = new BigDecimal(0.00345); - assertTrue( - "the double representation of 0.00345 bigDecimal is not correct", - big.doubleValue() == 0.00345); + assertEquals("the double representation of 0.00345 bigDecimal is not correct", + 0.00345, big.doubleValue()); } @@ -98,9 +95,8 @@ } catch (NumberFormatException e) { r = 1; } - assertTrue( - "constructor failed to catch invalid character in BigDecimal(string)", - r == 0); + assertEquals("constructor failed to catch invalid character in BigDecimal(string)", + 0, r); } /** @@ -152,12 +148,12 @@ public void test_abs() { BigDecimal big = new BigDecimal("-1234"); BigDecimal bigabs = big.abs(); - assertTrue("the absolute value of -1234 is not 1234", bigabs.toString() - .equals("1234")); + assertEquals("the absolute value of -1234 is not 1234", "1234", bigabs.toString() + ); big = new BigDecimal(new BigInteger("2345"), 2); bigabs = big.abs(); - assertTrue("the absolute value of 23.45 is not 23.45", bigabs - .toString().equals("23.45")); + assertEquals("the absolute value of 23.45 is not 23.45", "23.45", bigabs + .toString()); } /** @@ -170,11 +166,11 @@ assertTrue("the sum of 23.456 + 3849.235 is wrong", sum.unscaledValue() .toString().equals("3872691") && sum.scale() == 3); - assertTrue("the sum of 23.456 + 3849.235 is not printed correctly", sum - .toString().equals("3872.691")); + assertEquals("the sum of 23.456 + 3849.235 is not printed correctly", "3872.691", sum + .toString()); BigDecimal add3 = new BigDecimal(12.34E02D); - assertTrue("the sum of 23.456 + 12.34E02 is not printed correctly", - (add1.add(add3)).toString().equals("1257.456")); + assertEquals("the sum of 23.456 + 12.34E02 is not printed correctly", + "1257.456", (add1.add(add3)).toString()); } /** @@ -183,14 +179,14 @@ public void test_compareToLjava_math_BigDecimal() { BigDecimal comp1 = new BigDecimal("1.00"); BigDecimal comp2 = new BigDecimal(1.000000D); - assertTrue("1.00 and 1.000000 should be equal", - comp1.compareTo(comp2) == 0); + assertEquals("1.00 and 1.000000 should be equal", + 0, comp1.compareTo(comp2)); BigDecimal comp3 = new BigDecimal("1.02"); - assertTrue("1.02 should be bigger than 1.00", - comp3.compareTo(comp1) == 1); + assertEquals("1.02 should be bigger than 1.00", + 1, comp3.compareTo(comp1)); BigDecimal comp4 = new BigDecimal(0.98D); - assertTrue("0.98 should be less than 1.00", - comp4.compareTo(comp1) == -1); + assertEquals("0.98 should be less than 1.00", + -1, comp4.compareTo(comp1)); } /** @@ -203,9 +199,8 @@ assertTrue("123459.08/2.335 is not correct", divd3.toString().equals( "52873.27") && divd3.scale() == divd1.scale()); - assertTrue( - "the unscaledValue representation of 123459.08/2.335 is not correct", - divd3.unscaledValue().toString().equals("5287327")); + assertEquals("the unscaledValue representation of 123459.08/2.335 is not correct", + "5287327", divd3.unscaledValue().toString()); divd2 = new BigDecimal(123.4D); divd3 = divd1.divide(divd2, BigDecimal.ROUND_DOWN); assertTrue("123459.08/123.4 is not correct", divd3.toString().equals( @@ -243,7 +238,7 @@ } catch (ArithmeticException e) { r = 1; } - assertTrue("divide by zero is not caught", r == 1); + assertEquals("divide by zero is not caught", 1, r); } /** @@ -363,17 +358,17 @@ */ public void test_intValue() { BigDecimal int1 = new BigDecimal(value, 3); - assertTrue("the int value of 12345.908 is not 12345", - int1.intValue() == 12345); + assertEquals("the int value of 12345.908 is not 12345", + 12345, int1.intValue()); int1 = new BigDecimal("1.99"); - assertTrue("the int value of 1.99 is not 1", int1.intValue() == 1); + assertEquals("the int value of 1.99 is not 1", 1, int1.intValue()); int1 = new BigDecimal("23423419083091823091283933"); // ran JDK and found representation for the above was -249268259 - assertTrue("the int value of 23423419083091823091283933 is wrong", int1 - .intValue() == -249268259); + assertEquals("the int value of 23423419083091823091283933 is wrong", -249268259, int1 + .intValue()); int1 = new BigDecimal(-1235D); - assertTrue("the int value of -1235 is not -1235", - int1.intValue() == -1235); + assertEquals("the int value of -1235 is not -1235", + -1235, int1.intValue()); } /** @@ -381,17 +376,16 @@ */ public void test_longValue() { BigDecimal long1 = new BigDecimal(value2.negate(), 0); - assertTrue("the long value of 12334560000 is not 12334560000", long1 - .longValue() == -12334560000L); + assertEquals("the long value of 12334560000 is not 12334560000", -12334560000L, long1 + .longValue()); long1 = new BigDecimal(-1345.348E-123D); - assertTrue("the long value of -1345.348E-123D is not zero", long1 - .longValue() == 0); + assertEquals("the long value of -1345.348E-123D is not zero", 0, long1 + .longValue()); long1 = new BigDecimal("31323423423419083091823091283933"); // ran JDK and found representation for the above was // -5251313250005125155 - assertTrue( - "the long value of 31323423423419083091823091283933 is wrong", - long1.longValue() == -5251313250005125155L); + assertEquals("the long value of 31323423423419083091823091283933 is wrong", + -5251313250005125155L, long1.longValue()); } /** @@ -528,11 +522,11 @@ */ public void test_negate() { BigDecimal negate1 = new BigDecimal(value2, 7); - assertTrue("the negate of 1233.4560000 is not -1233.4560000", negate1 - .negate().toString().equals("-1233.4560000")); + assertEquals("the negate of 1233.4560000 is not -1233.4560000", "-1233.4560000", negate1 + .negate().toString()); negate1 = new BigDecimal("-23465839"); - assertTrue("the negate of -23465839 is not 23465839", negate1.negate() - .toString().equals("23465839")); + assertEquals("the negate of -23465839 is not 23465839", "23465839", negate1.negate() + .toString()); negate1 = new BigDecimal(-3.456E6); assertTrue("the negate of -3.456E6 is not 3.456E6", negate1.negate() .negate().equals(negate1)); @@ -578,9 +572,8 @@ } catch (ArithmeticException e) { r = 1; } - assertTrue( - "arithmetic Exception not caught as a result of loosing precision", - r == 1); + assertEquals("arithmetic Exception not caught as a result of loosing precision", + 1, r); } /** @@ -696,8 +689,8 @@ } catch (ArithmeticException e) { r = 1; } - assertTrue("arithmetic Exception not caught for round unnecessary", - r == 1); + assertEquals("arithmetic Exception not caught for round unnecessary", + 1, r); // testing rounding Mode ROUND_UP setScale1 = new BigDecimal("100000.374"); @@ -719,9 +712,8 @@ } catch (IllegalArgumentException e) { r = 1; } - assertTrue( - "IllegalArgumentException is not caught for wrong rounding mode", - r == 1); + assertEquals("IllegalArgumentException is not caught for wrong rounding mode", + 1, r); } /** @@ -729,12 +721,12 @@ */ public void test_signum() { BigDecimal sign = new BigDecimal(123E-104); - assertTrue("123E-104 is not positive in signum()", sign.signum() == 1); + assertEquals("123E-104 is not positive in signum()", 1, sign.signum()); sign = new BigDecimal("-1234.3959"); - assertTrue("-1234.3959 is not negative in signum()", - sign.signum() == -1); + assertEquals("-1234.3959 is not negative in signum()", + -1, sign.signum()); sign = new BigDecimal(000D); - assertTrue("000D is not zero in signum()", sign.signum() == 0); + assertEquals("000D is not zero in signum()", 0, sign.signum()); } /** @@ -776,8 +768,8 @@ BigDecimal sub1 = new BigDecimal("-29830.989"); BigInteger result = sub1.toBigInteger(); - assertTrue("the bigInteger equivalent of -29830.989 is wrong", result - .toString().equals("-29830")); + assertEquals("the bigInteger equivalent of -29830.989 is wrong", "-29830", result + .toString()); sub1 = new BigDecimal(-2837E10); result = sub1.toBigInteger(); assertTrue("the bigInteger equivalent of -2837E10 is wrong", result @@ -788,8 +780,8 @@ .equals(BigInteger.ZERO)); sub1 = new BigDecimal(value2, 6); result = sub1.toBigInteger(); - assertTrue("the bigInteger equivalent of 12334.560000 is wrong", result - .toString().equals("12334")); + assertEquals("the bigInteger equivalent of 12334.560000 is wrong", "12334", result + .toString()); } /** @@ -839,9 +831,8 @@ valueOfL.unscaledValue().toString().equals( "9223372036854775806") && valueOfL.scale() == 0); - assertTrue( - "the toString representation of 9223372036854775806 is wrong", - valueOfL.toString().equals("9223372036854775806")); + assertEquals("the toString representation of 9223372036854775806 is wrong", + "9223372036854775806", valueOfL.toString()); valueOfL = BigDecimal.valueOf(0L); assertTrue("the bigDecimal equivalent of 0 is wrong", valueOfL .unscaledValue().toString().equals("0") @@ -858,25 +849,22 @@ valueOfJI.unscaledValue().toString().equals( "9223372036854775806") && valueOfJI.scale() == 5); - assertTrue( - "the toString representation of 9223372036854775806 is wrong", - valueOfJI.toString().equals("92233720368547.75806")); + assertEquals("the toString representation of 9223372036854775806 is wrong", + "92233720368547.75806", valueOfJI.toString()); valueOfJI = BigDecimal.valueOf(1234L, 8); assertTrue( "the bigDecimal equivalent of 92233720368547.75806 is wrong", valueOfJI.unscaledValue().toString().equals("1234") && valueOfJI.scale() == 8); - assertTrue( - "the toString representation of 9223372036854775806 is wrong", - valueOfJI.toString().equals("0.00001234")); + assertEquals("the toString representation of 9223372036854775806 is wrong", + "0.00001234", valueOfJI.toString()); valueOfJI = BigDecimal.valueOf(0, 3); assertTrue( "the bigDecimal equivalent of 92233720368547.75806 is wrong", valueOfJI.unscaledValue().toString().equals("0") && valueOfJI.scale() == 3); - assertTrue( - "the toString representation of 9223372036854775806 is wrong", - valueOfJI.toString().equals("0.000")); + assertEquals("the toString representation of 9223372036854775806 is wrong", + "0.000", valueOfJI.toString()); } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerNotTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerNotTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerNotTest.java (working copy) @@ -45,7 +45,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -65,7 +65,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -85,7 +85,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -105,7 +105,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -120,7 +120,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -135,7 +135,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -152,7 +152,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -169,7 +169,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -187,6 +187,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } } \ No newline at end of file Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAndTest.java (working copy) @@ -45,7 +45,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -65,7 +65,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -85,7 +85,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -105,7 +105,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -125,7 +125,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -136,7 +136,7 @@ BigInteger bNumber = BigInteger.ONE; BigInteger result = aNumber.and(bNumber); assertTrue(result.equals(BigInteger.ZERO)); - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -147,7 +147,7 @@ BigInteger bNumber = BigInteger.ONE; BigInteger result = aNumber.and(bNumber); assertTrue(result.equals(BigInteger.ONE)); - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -167,7 +167,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -187,7 +187,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -207,7 +207,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -227,7 +227,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -247,7 +247,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -267,7 +267,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -287,7 +287,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -307,7 +307,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -327,7 +327,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -347,7 +347,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -367,7 +367,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -387,7 +387,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -407,7 +407,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -427,6 +427,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java (working copy) @@ -42,7 +42,7 @@ BigInteger result = aNumber.divide(bNumber); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("division by zero")); + assertEquals("Improper exception message", "division by zero", e.getMessage()); } } @@ -58,7 +58,7 @@ BigInteger result = aNumber.divide(bNumber); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("division by zero")); + assertEquals("Improper exception message", "division by zero", e.getMessage()); } } @@ -79,7 +79,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -99,7 +99,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -120,7 +120,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -141,7 +141,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -161,7 +161,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -181,7 +181,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -201,7 +201,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -221,7 +221,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -241,7 +241,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -259,7 +259,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -277,7 +277,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -293,7 +293,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -313,7 +313,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -333,7 +333,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -354,7 +354,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -374,7 +374,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -394,7 +394,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -411,7 +411,7 @@ BigInteger result = aNumber.remainder(bNumber); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("division by zero")); + assertEquals("Improper exception message", "division by zero", e.getMessage()); } } @@ -432,7 +432,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -452,7 +452,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -472,7 +472,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -493,7 +493,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -514,7 +514,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -534,7 +534,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -554,7 +554,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -574,7 +574,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -600,13 +600,13 @@ fail("Incorrect quotation"); } } - assertTrue(result[0].signum() == -1); + assertEquals(-1, result[0].signum()); resBytes = result[1].toByteArray(); for(int i = 0; i < resBytes.length; i++) { if (resBytes[i] != rBytes[1][i]) { fail("Incorrect remainder"); } - assertTrue(result[1].signum() == -1); + assertEquals(-1, result[1].signum()); } } @@ -624,7 +624,7 @@ BigInteger result = aNumber.mod(bNumber); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("modulus is non-positive")); + assertEquals("Improper exception message", "modulus is non-positive", e.getMessage()); } } @@ -645,7 +645,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -665,6 +665,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerModPowTest.java (working copy) @@ -45,7 +45,7 @@ BigInteger result = aNumber.modPow(exp, modulus); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("non-positive modulus")); + assertEquals("Improper exception message", "non-positive modulus", e.getMessage()); } } @@ -69,7 +69,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -92,7 +92,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -109,7 +109,7 @@ BigInteger result = aNumber.modInverse(modulus); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("non-positive modulus")); + assertEquals("Improper exception message", "non-positive modulus", e.getMessage()); } } @@ -127,7 +127,7 @@ BigInteger result = aNumber.modInverse(modulus); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("non-invertible BigInteger")); + assertEquals("Improper exception message", "non-invertible BigInteger", e.getMessage()); } } @@ -148,7 +148,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -168,7 +168,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -188,7 +188,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -206,7 +206,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -226,7 +226,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -246,7 +246,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -264,7 +264,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -279,7 +279,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -299,7 +299,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -319,6 +319,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConstructorsTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConstructorsTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConstructorsTest.java (working copy) @@ -40,7 +40,7 @@ BigInteger aNumber = new BigInteger(aBytes); fail("NumberFormatException has not been caught"); } catch (NumberFormatException e) { - assertTrue("Improper exception message", e.getMessage().equals("zero length array")); + assertEquals("Improper exception message", "zero length array", e.getMessage()); } } @@ -57,7 +57,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -73,7 +73,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -89,7 +89,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -105,7 +105,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -121,7 +121,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -137,7 +137,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -153,7 +153,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -169,7 +169,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -184,7 +184,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -198,7 +198,7 @@ BigInteger aNumber = new BigInteger(aSign, aBytes); fail("NumberFormatException has not been caught"); } catch (NumberFormatException e) { - assertTrue("Improper exception message", e.getMessage().equals("sign must be -1, 0, or 1")); + assertEquals("Improper exception message", "sign must be -1, 0, or 1", e.getMessage()); } } @@ -213,7 +213,7 @@ BigInteger aNumber = new BigInteger(aSign, aBytes); fail("NumberFormatException has not been caught"); } catch (NumberFormatException e) { - assertTrue("Improper exception message", e.getMessage().equals("zero sign with non-zero magnitude")); + assertEquals("Improper exception message", "zero sign with non-zero magnitude", e.getMessage()); } } @@ -232,7 +232,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -250,7 +250,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -267,7 +267,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -285,7 +285,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -303,7 +303,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -321,7 +321,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -339,7 +339,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -357,7 +357,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -375,7 +375,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -392,7 +392,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -410,7 +410,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -428,7 +428,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -446,7 +446,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -464,7 +464,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -481,7 +481,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -498,7 +498,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -515,7 +515,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -532,7 +532,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -549,7 +549,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -566,7 +566,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** @@ -580,7 +580,7 @@ BigInteger aNumber = new BigInteger(value, radix); fail("NumberFormatException has not been caught"); } catch (NumberFormatException e) { - assertTrue("Improper exception message", e.getMessage().equals("radix is out of range")); + assertEquals("Improper exception message", "radix is out of range", e.getMessage()); } } @@ -639,7 +639,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -655,7 +655,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -671,7 +671,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -687,7 +687,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -703,7 +703,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -719,7 +719,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -735,7 +735,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } /** Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerMultiplyTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerMultiplyTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerMultiplyTest.java (working copy) @@ -45,7 +45,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -66,7 +66,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -88,7 +88,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -110,7 +110,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -133,7 +133,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -156,7 +156,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -176,7 +176,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -194,7 +194,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -212,7 +212,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -230,7 +230,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -250,7 +250,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -270,7 +270,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -285,7 +285,7 @@ BigInteger result = aNumber.pow(exp); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("exponent is negative")); + assertEquals("Improper exception message", "exponent is negative", e.getMessage()); } } @@ -307,7 +307,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -327,7 +327,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -345,7 +345,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -366,7 +366,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -384,6 +384,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConvertTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConvertTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerConvertTest.java (working copy) @@ -666,7 +666,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -681,7 +681,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -696,7 +696,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -711,7 +711,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -726,7 +726,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -742,7 +742,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -757,7 +757,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -773,7 +773,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** * valueOf (long val): convert a zero long value to a BigInteger. @@ -787,6 +787,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOrTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOrTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOrTest.java (working copy) @@ -45,7 +45,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -65,7 +65,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -85,7 +85,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -105,7 +105,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -125,7 +125,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -145,7 +145,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -165,7 +165,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -185,7 +185,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -205,7 +205,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -225,7 +225,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -245,7 +245,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -265,7 +265,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -285,7 +285,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -305,7 +305,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -325,7 +325,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -345,7 +345,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -365,7 +365,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -385,7 +385,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -405,6 +405,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOperateBitsTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOperateBitsTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerOperateBitsTest.java (working copy) @@ -34,7 +34,7 @@ */ public void testBitCountZero() { BigInteger aNumber = new BigInteger("0"); - assertTrue(aNumber.bitCount() == 0); + assertEquals(0, aNumber.bitCount()); } /** @@ -42,7 +42,7 @@ */ public void testBitCountNeg() { BigInteger aNumber = new BigInteger("-12378634756382937873487638746283767238657872368748726875"); - assertTrue(aNumber.bitCount() == 87); + assertEquals(87, aNumber.bitCount()); } /** @@ -50,7 +50,7 @@ */ public void testBitCountPos() { BigInteger aNumber = new BigInteger("12378634756343564757582937873487638746283767238657872368748726875"); - assertTrue(aNumber.bitCount() == 107); + assertEquals(107, aNumber.bitCount()); } /** @@ -58,7 +58,7 @@ */ public void testBitLengthZero() { BigInteger aNumber = new BigInteger("0"); - assertTrue(aNumber.bitLength() == 0); + assertEquals(0, aNumber.bitLength()); } /** @@ -68,7 +68,7 @@ byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91}; int aSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 108); + assertEquals(108, aNumber.bitLength()); } /** @@ -78,7 +78,7 @@ byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26}; int aSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 96); + assertEquals(96, aNumber.bitLength()); } /** @@ -88,7 +88,7 @@ byte aBytes[] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int aSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 81); + assertEquals(81, aNumber.bitLength()); } /** @@ -98,7 +98,7 @@ byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91}; int aSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 108); + assertEquals(108, aNumber.bitLength()); } /** @@ -108,7 +108,7 @@ byte aBytes[] = {-128, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26}; int aSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 96); + assertEquals(96, aNumber.bitLength()); } /** @@ -118,7 +118,7 @@ byte aBytes[] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int aSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue(aNumber.bitLength() == 80); + assertEquals(80, aNumber.bitLength()); } /** @@ -133,7 +133,7 @@ BigInteger result = aNumber.clearBit(number); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("negative bit number")); + assertEquals("Improper exception message", "negative bit number", e.getMessage()); } } @@ -152,7 +152,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -170,7 +170,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -188,7 +188,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -206,7 +206,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -263,7 +263,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -281,7 +281,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -299,7 +299,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -317,7 +317,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -335,7 +335,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -353,7 +353,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -371,7 +371,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -389,7 +389,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -407,7 +407,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -425,7 +425,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -440,7 +440,7 @@ BigInteger result = aNumber.flipBit(number); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("negative bit number")); + assertEquals("Improper exception message", "negative bit number", e.getMessage()); } } @@ -459,7 +459,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -477,7 +477,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue("incorrect value", resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -495,7 +495,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue("incorrect value", resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -513,7 +513,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -531,7 +531,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -549,7 +549,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -567,7 +567,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -625,7 +625,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -643,7 +643,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -661,7 +661,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -679,7 +679,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -697,7 +697,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -715,7 +715,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -730,7 +730,7 @@ BigInteger result = aNumber.setBit(number); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("negative bit number")); + assertEquals("Improper exception message", "negative bit number", e.getMessage()); } } @@ -749,7 +749,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -767,7 +767,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -785,7 +785,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -803,7 +803,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -821,7 +821,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -839,7 +839,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -857,7 +857,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -875,7 +875,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -893,7 +893,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -911,7 +911,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -929,7 +929,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -947,7 +947,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1003,7 +1003,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1021,7 +1021,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1031,8 +1031,8 @@ */ public void testSetBitBug1331() { BigInteger result = BigInteger.valueOf(0L).setBit(191); - assertTrue("incorrect value", result.toString().equals("3138550867693340381917894711603833208051177722232017256448")); - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect value", "3138550867693340381917894711603833208051177722232017256448", result.toString()); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1050,7 +1050,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1068,7 +1068,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1086,7 +1086,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1104,7 +1104,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1122,7 +1122,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1140,7 +1140,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1158,7 +1158,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1176,7 +1176,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1194,7 +1194,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -1212,7 +1212,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -1232,7 +1232,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1252,7 +1252,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1272,7 +1272,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1292,7 +1292,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -1307,7 +1307,7 @@ boolean result = aNumber.testBit(number); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("negative bit number")); + assertEquals("Improper exception message", "negative bit number", e.getMessage()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerCompareTest.java (working copy) @@ -42,7 +42,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -59,7 +59,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -74,7 +74,7 @@ int bSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 1); + assertEquals(1, aNumber.compareTo(bNumber)); } /** @@ -90,7 +90,7 @@ BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); int result = aNumber.compareTo(bNumber); - assertTrue(aNumber.compareTo(bNumber) == -1); + assertEquals(-1, aNumber.compareTo(bNumber)); } /** @@ -104,7 +104,7 @@ int bSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 0); + assertEquals(0, aNumber.compareTo(bNumber)); } /** @@ -119,7 +119,7 @@ int bSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == -1); + assertEquals(-1, aNumber.compareTo(bNumber)); } /** @@ -134,7 +134,7 @@ int bSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 1); + assertEquals(1, aNumber.compareTo(bNumber)); } /** @@ -148,7 +148,7 @@ int bSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 0); + assertEquals(0, aNumber.compareTo(bNumber)); } /** @@ -163,7 +163,7 @@ int bSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 1); + assertEquals(1, aNumber.compareTo(bNumber)); } /** @@ -178,7 +178,7 @@ int bSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == -1); + assertEquals(-1, aNumber.compareTo(bNumber)); } /** @@ -191,7 +191,7 @@ BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = BigInteger.ZERO; int result = aNumber.compareTo(bNumber); - assertTrue(aNumber.compareTo(bNumber) == 1); + assertEquals(1, aNumber.compareTo(bNumber)); } /** @@ -203,7 +203,7 @@ int bSign = 1; BigInteger aNumber = BigInteger.ZERO; BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == -1); + assertEquals(-1, aNumber.compareTo(bNumber)); } /** @@ -215,7 +215,7 @@ int aSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); BigInteger bNumber = BigInteger.ZERO; - assertTrue(aNumber.compareTo(bNumber) == -1); + assertEquals(-1, aNumber.compareTo(bNumber)); } /** @@ -227,7 +227,7 @@ int bSign = -1; BigInteger aNumber = BigInteger.ZERO; BigInteger bNumber = new BigInteger(bSign, bBytes); - assertTrue(aNumber.compareTo(bNumber) == 1); + assertEquals(1, aNumber.compareTo(bNumber)); } /** @@ -237,7 +237,7 @@ public void testCompareToZeroZero() { BigInteger aNumber = BigInteger.ZERO; BigInteger bNumber = BigInteger.ZERO; - assertTrue(aNumber.compareTo(bNumber) == 0); + assertEquals(0, aNumber.compareTo(bNumber)); } /** @@ -352,7 +352,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -392,7 +392,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -413,7 +413,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -502,7 +502,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -512,7 +512,7 @@ byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91}; int aSign = 1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue("incorrect sign", aNumber.signum() == 1); + assertEquals("incorrect sign", 1, aNumber.signum()); } /** @@ -522,7 +522,7 @@ byte aBytes[] = {12, 56, 100, -2, -76, 89, 45, 91, 3, -15, 35, 26, 3, 91}; int aSign = -1; BigInteger aNumber = new BigInteger(aSign, aBytes); - assertTrue("incorrect sign", aNumber.signum() == -1); + assertEquals("incorrect sign", -1, aNumber.signum()); } /** @@ -530,6 +530,6 @@ */ public void testSignumZero() { BigInteger aNumber = BigInteger.ZERO; - assertTrue("incorrect sign", aNumber.signum() == 0); + assertEquals("incorrect sign", 0, aNumber.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerSubtractTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerSubtractTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerSubtractTest.java (working copy) @@ -46,7 +46,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -67,7 +67,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -89,7 +89,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -111,7 +111,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -132,7 +132,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -153,7 +153,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -175,7 +175,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -197,7 +197,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -218,7 +218,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -239,7 +239,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -261,7 +261,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -283,7 +283,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -305,7 +305,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -327,7 +327,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -348,7 +348,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } /** @@ -369,7 +369,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -389,7 +389,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 0); + assertEquals(0, result.signum()); } /** @@ -410,7 +410,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -431,7 +431,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -451,7 +451,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 0); + assertEquals(0, result.signum()); } /** @@ -470,7 +470,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -489,7 +489,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 1); + assertEquals(1, result.signum()); } /** @@ -505,7 +505,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 0); + assertEquals(0, result.signum()); } /** @@ -521,7 +521,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == 0); + assertEquals(0, result.signum()); } /** @@ -541,7 +541,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue(result.signum() == -1); + assertEquals(-1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAddTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAddTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerAddTest.java (working copy) @@ -45,7 +45,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -65,7 +65,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -87,7 +87,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -109,7 +109,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -131,7 +131,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -153,7 +153,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -174,7 +174,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -195,7 +195,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -216,7 +216,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -237,7 +237,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -259,7 +259,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -281,7 +281,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -303,7 +303,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == -1); + assertEquals("incorrect sign", -1, result.signum()); } /** @@ -325,7 +325,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -344,7 +344,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -364,7 +364,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -384,7 +384,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -404,7 +404,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -422,7 +422,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -440,7 +440,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -456,7 +456,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 0); + assertEquals("incorrect sign", 0, result.signum()); } /** @@ -472,7 +472,7 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } /** @@ -492,6 +492,6 @@ for(int i = 0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } - assertTrue("incorrect sign", result.signum() == 1); + assertEquals("incorrect sign", 1, result.signum()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java (working copy) @@ -489,7 +489,7 @@ aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("division by zero")); + assertEquals("Improper exception message", "division by zero", e.getMessage()); } } @@ -507,7 +507,7 @@ aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("rounding mode is ROUND_UNNECESSARY but the result is not exact")); + assertEquals("Improper exception message", "rounding mode is ROUND_UNNECESSARY but the result is not exact", e.getMessage()); } } @@ -525,7 +525,7 @@ aNumber.divide(bNumber, 100); fail("IllegalArgumentException has not been caught"); } catch (IllegalArgumentException e) { - assertTrue("Improper exception message", e.getMessage().equals("invalid rounding mode")); + assertEquals("Improper exception message", "invalid rounding mode", e.getMessage()); } } Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalScaleOperationsTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalScaleOperationsTest.java (revision 396457) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalScaleOperationsTest.java (working copy) @@ -92,7 +92,7 @@ BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal bNumber = aNumber.setScale(newScale); assertTrue("incorrect scale", bNumber.scale() == newScale); - assertTrue("incorrect value", bNumber.compareTo(aNumber) == 0); + assertEquals("incorrect value", 0, bNumber.compareTo(aNumber)); } /** @@ -104,7 +104,7 @@ BigDecimal aNumber = new BigDecimal(a); BigDecimal bNumber = aNumber.setScale(newScale); assertTrue("incorrect scale", bNumber.scale() == newScale); - assertTrue("incorrect value", bNumber.compareTo(aNumber) == 0); + assertEquals("incorrect value", 0, bNumber.compareTo(aNumber)); } /** @@ -333,7 +333,7 @@ BigDecimal bNumber = aNumber.movePointRight(shift); fail("ArithmeticException has not been caught"); } catch (ArithmeticException e) { - assertTrue("Improper exception message", e.getMessage().equals("scale outside the range of a 32-bit integer")); + assertEquals("Improper exception message", "scale outside the range of a 32-bit integer", e.getMessage()); } } Index: modules/sql/src/test/java/tests/api/java/sql/SQLPermissionTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/SQLPermissionTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/SQLPermissionTest.java (working copy) @@ -39,7 +39,7 @@ SQLPermission thePermission = new SQLPermission(validName, validActions); - assertTrue(thePermission != null); + assertNotNull(thePermission); assertTrue(thePermission.getName().equals(validName)); // System.out.println("The actions: " + thePermission.getActions() + "." // ); @@ -54,7 +54,7 @@ SQLPermission thePermission = new SQLPermission(validName); - assertTrue(thePermission != null); + assertNotNull(thePermission); assertTrue(thePermission.getName().equals(validName)); // Set an invalid name ... @@ -62,7 +62,7 @@ thePermission = new SQLPermission(invalidName); - assertTrue(thePermission != null); + assertNotNull(thePermission); assertTrue(thePermission.getName().equals(invalidName)); assertTrue(thePermission.getActions().equals("")); } // end method testSQLPermissionString Index: modules/sql/src/test/java/tests/api/java/sql/DateTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/DateTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/DateTest.java (working copy) @@ -118,7 +118,7 @@ try { Date theDate = new Date(init1[i], init2[i], init3[i]); - assertTrue(theDate != null); + assertNotNull(theDate); if (theExceptions[i] != null) { fail(i + "Exception expected - none thrown."); } // end if @@ -151,7 +151,7 @@ try { Date theDate = new Date(init1[i]); - assertTrue(theDate != null); + assertNotNull(theDate); if (theExceptions[i] != null) { fail(i + "Exception expected - none thrown."); } // end if @@ -179,7 +179,7 @@ int theHours = theDate.getHours(); // If it worked, it should get the Hours setting - assertTrue(theHours == 23); + assertEquals(23, theHours); assertTrue(false); } catch (IllegalArgumentException ie) { /* @@ -200,7 +200,7 @@ int theMinutes = theDate.getMinutes(); // If it worked, it should get the Hours setting - assertTrue(theMinutes == 59); + assertEquals(59, theMinutes); assertTrue(false); } catch (IllegalArgumentException ie) { /* @@ -221,7 +221,7 @@ int theSeconds = theDate.getSeconds(); // If it worked, it should get the Hours setting - assertTrue(theSeconds == 23); + assertEquals(23, theSeconds); assertTrue(false); } catch (IllegalArgumentException ie) { /* Index: modules/sql/src/test/java/tests/api/java/sql/TimeTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/TimeTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/TimeTest.java (working copy) @@ -74,14 +74,14 @@ Time theTime = new Time(10, 45, 20); // The date should have been created - assertTrue(theTime != null); + assertNotNull(theTime); } // end method testTimeintintint() public void testTime() { Time theTime = new Time(TIME_TEST1); // The date should have been created - assertTrue(theTime != null); + assertNotNull(theTime); } // end method testTime() public void testToString() { Index: modules/sql/src/test/java/tests/api/java/sql/TimestampTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/TimestampTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/TimestampTest.java (working copy) @@ -109,7 +109,7 @@ Timestamp theTimestamp = new Timestamp(TIME_TEST1); // The Timestamp should have been created - assertTrue(theTimestamp != null); + assertNotNull(theTimestamp); } // end method testTimestamplong /* @@ -153,7 +153,7 @@ Timestamp theTimestamp = new Timestamp(initParms[i][0], initParms[i][1], initParms[i][2], initParms[i][3], initParms[i][4], initParms[i][5], initParms[i][6]); - assertTrue("Timestamp not generated: ", theTimestamp != null); + assertNotNull("Timestamp not generated: ", theTimestamp); if (theExceptions[i] != null) fail(i + ": Did not get exception"); } catch (Exception e) { @@ -556,7 +556,7 @@ assertTrue(theTimestamp.compareTo(theTest) > 0); assertTrue(theTimestamp.compareTo(theTest2) < 0); - assertTrue(theTimestamp.compareTo(theTimestamp2) == 0); + assertEquals(0, theTimestamp.compareTo(theTimestamp2)); } // end for } // end method testcompareToTimestamp @@ -574,7 +574,7 @@ assertTrue(theTimestamp.compareTo(theTest) > 0); assertTrue(theTimestamp.compareTo(theTest2) < 0); - assertTrue(theTimestamp.compareTo(theTimestamp2) == 0); + assertEquals(0, theTimestamp.compareTo(theTimestamp2)); } // end for Object nastyTest = new String("Test "); Index: modules/sql/src/test/java/tests/api/java/sql/DriverPropertyInfoTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/DriverPropertyInfoTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/DriverPropertyInfoTest.java (working copy) @@ -41,7 +41,7 @@ DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo( validName, validValue); - assertTrue(aDriverPropertyInfo != null); + assertNotNull(aDriverPropertyInfo); aDriverPropertyInfo = new DriverPropertyInfo(null, null); Index: modules/sql/src/test/java/tests/api/java/sql/DriverManagerTest.java =================================================================== --- modules/sql/src/test/java/tests/api/java/sql/DriverManagerTest.java (revision 396457) +++ modules/sql/src/test/java/tests/api/java/sql/DriverManagerTest.java (working copy) @@ -194,7 +194,7 @@ // validConnection - no user & password required try { theConnection = DriverManager.getConnection(validConnectionURL); - assertTrue(theConnection != null); + assertNotNull(theConnection); } catch (SQLException e) { assertTrue(false); } // end try @@ -207,7 +207,7 @@ .getConnection(invalidConnectionURLs[i]); assertFalse(theConnection != null); } catch (SQLException e) { - assertTrue(theConnection == null); + assertNull(theConnection); // System.out.println("testGetConnectionString: exception // message: " + // e.getMessage() ); @@ -249,7 +249,7 @@ // validConnection - user & password required try { theConnection = DriverManager.getConnection(validURL1, validProps); - assertTrue(theConnection != null); + assertNotNull(theConnection); } catch (SQLException e) { assertTrue(false); } // end try @@ -299,7 +299,7 @@ try { theConnection = DriverManager.getConnection(validURL1, validuser1, validpassword1); - assertTrue(theConnection != null); + assertNotNull(theConnection); } catch (SQLException e) { assertTrue(false); } // end try @@ -389,7 +389,7 @@ } // end method testGetLoginTimeout() public void testGetLogStream() { - assertTrue(DriverManager.getLogStream() == null); + assertNull(DriverManager.getLogStream()); DriverManager.setLogStream(testPrintStream); @@ -399,7 +399,7 @@ } // end method testGetLogStream() public void testGetLogWriter() { - assertTrue(DriverManager.getLogWriter() == null); + assertNull(DriverManager.getLogWriter()); DriverManager.setLogWriter(testPrintWriter); @@ -499,7 +499,7 @@ DriverManager.setLogStream(null); - assertTrue(DriverManager.getLogStream() == null); + assertNull(DriverManager.getLogStream()); // Now let's deal with the case where there is a SecurityManager in // place @@ -549,8 +549,8 @@ DriverManager.setLogWriter(null); - assertTrue("testDriverManager: Log writer not null:", DriverManager - .getLogWriter() == null); + assertNull("testDriverManager: Log writer not null:", DriverManager + .getLogWriter()); // Now let's deal with the case where there is a SecurityManager in // place Index: modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java =================================================================== --- modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java (revision 396457) +++ modules/auth/src/test/java/common/org/apache/harmony/auth/internal/SecurityTest.java (working copy) @@ -210,7 +210,7 @@ assertTrue("IteratorTest: suite MUST be initialized", set != null && element != null); - assertTrue("IteratorTest: set MUST be empty", set.size() == 0); + assertEquals("IteratorTest: set MUST be empty", 0, set.size()); } /** @@ -656,7 +656,7 @@ assertTrue("SetTest: suite MUST be initialized", set != null && element != null); - assertTrue("SetTest: set MUST be empty", set.size() == 0); + assertEquals("SetTest: set MUST be empty", 0, set.size()); hash.add(element); } @@ -708,13 +708,13 @@ // public void testClear_EmptySet() { set.clear(); - assertTrue("Set MUST be empty", set.size() == 0); + assertEquals("Set MUST be empty", 0, set.size()); } public void testClear_NotEmptySet() { set.add(element); set.clear(); - assertTrue("Set MUST be empty", set.size() == 0); + assertEquals("Set MUST be empty", 0, set.size()); } // @@ -933,8 +933,8 @@ assertTrue("UnsupportedNullTest: suite MUST be initialized", set != null && element != null); - assertTrue("UnsupportedNullTest: set MUST be empty", - set.size() == 0); + assertEquals("UnsupportedNullTest: set MUST be empty", + 0, set.size()); hash.add(null); } @@ -1010,7 +1010,7 @@ assertTrue("Retaining NULL element", set.retainAll(hash)); } catch (NullPointerException npe) { } - assertTrue("Set is empty", set.size() == 0); + assertEquals("Set is empty", 0, set.size()); } } @@ -1047,8 +1047,8 @@ assertTrue("IneligibleElementTest: suite MUST be initialized", set != null && element != null && iElement != null); - assertTrue("IneligibleElementTest: set MUST be empty", - set.size() == 0); + assertEquals("IneligibleElementTest: set MUST be empty", + 0, set.size()); hash.add(null); @@ -1161,7 +1161,7 @@ } catch (ClassCastException e) { } catch (IllegalArgumentException e) { } - assertTrue("Now set is empty", set.size() == 0); + assertEquals("Now set is empty", 0, set.size()); } } Index: modules/auth/src/test/java/common/javax/security/auth/SubjectTest.java =================================================================== --- modules/auth/src/test/java/common/javax/security/auth/SubjectTest.java (revision 396457) +++ modules/auth/src/test/java/common/javax/security/auth/SubjectTest.java (working copy) @@ -878,10 +878,10 @@ Subject ss = (Subject) sIn.readObject(); assertTrue(ss.isReadOnly()); - assertTrue(ss.getPrincipals().size() == 1); + assertEquals(1, ss.getPrincipals().size()); assertTrue(ss.getPrincipals().iterator().next() instanceof MyClass1); - assertTrue(ss.getPublicCredentials().size() == 0); - assertTrue(ss.getPrivateCredentials().size() == 0); + assertEquals(0, ss.getPublicCredentials().size()); + assertEquals(0, ss.getPrivateCredentials().size()); try { ss.getPrincipals().add(new MyClass1()); Index: modules/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java =================================================================== --- modules/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java (revision 396457) +++ modules/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java (working copy) @@ -708,7 +708,7 @@ PrivateCredentialPermission p = new PrivateCredentialPermission( "a b \"c c\"", "read"); - assertTrue("Principal name:", "c c".equals(p.getPrincipals()[0][1])); + assertEquals("Principal name:", "c c", p.getPrincipals()[0][1]); } public final void testSerialization_Wildcard() throws Exception { @@ -747,12 +747,12 @@ PrivateCredentialPermission p = (PrivateCredentialPermission) sIn .readObject(); - assertTrue("CredentialClass ", "a".equals(p.getCredentialClass())); + assertEquals("CredentialClass ", "a", p.getCredentialClass()); String[][] principals = p.getPrincipals(); - assertTrue("Size:", principals.length == 1); - assertTrue("PrincipalClass:", "b".equals(principals[0][0])); - assertTrue("PrincipalName:", "c".equals(principals[0][1])); + assertEquals("Size:", 1, principals.length); + assertEquals("PrincipalClass:", "b", principals[0][0]); + assertEquals("PrincipalName:", "c", principals[0][1]); } public final void testSerialization_Self() throws Exception { @@ -763,12 +763,12 @@ PrivateCredentialPermission p = (PrivateCredentialPermission) sIn .readObject(); - assertTrue("CredentialClass ", "a".equals(p.getCredentialClass())); + assertEquals("CredentialClass ", "a", p.getCredentialClass()); String[][] principals = p.getPrincipals(); - assertTrue("Size:", principals.length == 1); - assertTrue("PrincipalClass:", "b".equals(principals[0][0])); - assertTrue("PrincipalName:", "c".equals(principals[0][1])); + assertEquals("Size:", 1, principals.length); + assertEquals("PrincipalClass:", "b", principals[0][0]); + assertEquals("PrincipalName:", "c", principals[0][1]); } // Golden: PrivateCredentialPermission("a b \"c\"","read"); Index: modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest.java =================================================================== --- modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest.java (revision 396457) +++ modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest.java (working copy) @@ -106,8 +106,7 @@ new LoginContext(moduleName); fail("No expected LoginException"); } catch (LoginException e) { - assertTrue("Default module", MyConfig.getLastAppName().equals( - "other")); + assertEquals("Default module", "other", MyConfig.getLastAppName()); } } @@ -210,7 +209,7 @@ context.login(); // only one module must be created - assertTrue("Number of modules", MyLoginModule.list.size() == 1); + assertEquals("Number of modules", 1, MyLoginModule.list.size()); MyLoginModule module = (MyLoginModule) MyLoginModule.list.get(0); @@ -315,8 +314,7 @@ new LoginContext(moduleName, handler); fail("No expected LoginException"); } catch (LoginException e) { - assertTrue("Default module", MyConfig.getLastAppName().equals( - "other")); + assertEquals("Default module", "other", MyConfig.getLastAppName()); } } @@ -371,7 +369,7 @@ context.login(); // only one module must be created - assertTrue("Number of modules", MyLoginModule.list.size() == 1); + assertEquals("Number of modules", 1, MyLoginModule.list.size()); MyLoginModule module = (MyLoginModule) MyLoginModule.list.get(0); @@ -454,8 +452,7 @@ new LoginContext(moduleName, subject); fail("No expected LoginException"); } catch (LoginException e) { - assertTrue("Default module", MyConfig.getLastAppName().equals( - "other")); + assertEquals("Default module", "other", MyConfig.getLastAppName()); } } @@ -535,7 +532,7 @@ context.login(); // only one module must be created - assertTrue("Number of modules", MyLoginModule.list.size() == 1); + assertEquals("Number of modules", 1, MyLoginModule.list.size()); MyLoginModule module = (MyLoginModule) MyLoginModule.list.get(0); @@ -651,8 +648,7 @@ new LoginContext(moduleName, subject, handler); fail("No expected LoginException"); } catch (LoginException e) { - assertTrue("Default module", MyConfig.getLastAppName().equals( - "other")); + assertEquals("Default module", "other", MyConfig.getLastAppName()); } } @@ -682,7 +678,7 @@ context.login(); // only one module must be created - assertTrue("Number of modules", MyLoginModule.list.size() == 1); + assertEquals("Number of modules", 1, MyLoginModule.list.size()); MyLoginModule module = (MyLoginModule) MyLoginModule.list.get(0); @@ -934,4 +930,4 @@ return false; } } -} \ No newline at end of file +} Index: modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest_1.java =================================================================== --- modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest_1.java (revision 396457) +++ modules/auth/src/test/java/common/javax/security/auth/login/LoginContextTest_1.java (working copy) @@ -709,7 +709,7 @@ Security.setProperty(DEFAULT_CBHANDLER_PROPERTY, klassName); // This also shows that the cbHandler is instantiated at the ctor new LoginContext(CONFIG_NAME); - assertTrue(TestCallbackHandler.size() == 1); + assertEquals(1, TestCallbackHandler.size()); // ugh... cant set 'null' here... Security.setProperty(DEFAULT_CBHANDLER_PROPERTY, ""); // additional cleanup to make it PerfTests compatible @@ -887,7 +887,7 @@ TestConfig.addInstalledSufficient("TestLoginModule_Success"); LoginContext lc = new LoginContext(CONFIG_NAME); lc.login(); - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); @@ -899,7 +899,7 @@ lc.login(); - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).loginCalled); assertFalse(TestLoginModule.get(0).initCalled); // additional cleanup to make it PerfTests compatible @@ -922,7 +922,7 @@ //ok } - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).initCalled); assertFalse(TestLoginModule.get(0).loginCalled); assertFalse(TestLoginModule.get(0).commitCalled); @@ -940,7 +940,7 @@ TestLoginModule.staticMask = 0; lc.login(); - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertFalse(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1096,7 +1096,7 @@ */ public void testLogin_04() throws Exception { TestConfig.addInstalledRequired("TestLoginModule"); - assertTrue(TestLoginModule.size() == 0); + assertEquals(0, TestLoginModule.size()); LoginContext lc = new LoginContext(CONFIG_NAME); TestLoginModule.staticMask = TestLoginModule.FAIL_AT_CTOR; try { @@ -1105,11 +1105,11 @@ } catch (LoginException ex) { // ok } - assertTrue(TestLoginModule.size() == 0); + assertEquals(0, TestLoginModule.size()); // fail nowhere TestLoginModule.staticMask = 0; lc.login(); // must be successful now - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1154,14 +1154,14 @@ } catch (LoginException ex) { // ok } - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertFalse(TestLoginModule.get(0).loginCalled); assertFalse(TestLoginModule.get(0).commitCalled); // self check // fail nowhere TestLoginModule.staticMask = 0; lc.login(); // must be successful now // no new module must be created - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); // additional cleanup to make it PerfTests compatible @@ -1183,7 +1183,7 @@ } catch (LoginException ex) { //ok } - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).abortCalled); assertFalse(TestLoginModule.get(0).commitCalled); @@ -1360,7 +1360,7 @@ lc.login(); - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1390,7 +1390,7 @@ assertSame(TestLoginModule.staticLE, le); } - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1421,7 +1421,7 @@ // gut } - assertTrue(TestLoginModule.size() == 3); + assertEquals(3, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1454,7 +1454,7 @@ // gut } - assertTrue(TestLoginModule.size() == 3); + assertEquals(3, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1483,7 +1483,7 @@ lc.login(); - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).loginCalled); assertTrue(TestLoginModule.get(0).commitCalled); @@ -1510,7 +1510,7 @@ lc.login(); - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); @@ -1539,7 +1539,7 @@ lc.login(); - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); @@ -1572,7 +1572,7 @@ // gut } - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); @@ -1609,7 +1609,7 @@ // assertSame( ex, TestLoginModule.staticLE); } - assertTrue(TestLoginModule.size() == 1); + assertEquals(1, TestLoginModule.size()); // assertTrue(TestLoginModule.get(0).initCalled); assertTrue(TestLoginModule.get(0).loginCalled); @@ -1676,7 +1676,7 @@ } catch (LoginException _) { // gut } - assertTrue(TestLoginModule.size() == 0); + assertEquals(0, TestLoginModule.size()); // additional cleanup to make it PerfTests compatible clear(); } @@ -1698,7 +1698,7 @@ } catch (LoginException _) { // gut } - assertTrue(TestLoginModule.size() == 2); + assertEquals(2, TestLoginModule.size()); assertTrue(TestLoginModule.get(0).logoutCalled); assertTrue(TestLoginModule.get(1).logoutCalled); // additional cleanup to make it PerfTests compatible @@ -2030,7 +2030,7 @@ lc.login(); lc.logout(); // - assertTrue(TestCallbackHandler.size() == 1); + assertEquals(1, TestCallbackHandler.size()); // now, get abort() called TestLoginModule.staticMask = TestLoginModule.FAIL_AT_LOGIN; Index: modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/UnknownErrorTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/NoSuchFieldErrorTest.java (working copy) @@ -25,9 +25,9 @@ if (true) throw new NoSuchFieldError(); } catch (NoSuchFieldError e) { - assertTrue("Initializer failed.", e.getMessage() == null); - assertTrue("To string failed.", e.toString().equals( - "java.lang.NoSuchFieldError")); + assertNull("Initializer failed.", e.getMessage()); + assertEquals("To string failed.", + "java.lang.NoSuchFieldError", e.toString()); } } Index: modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ProcessTest.java (working copy) @@ -54,7 +54,7 @@ proc.waitFor(); Support_Exec.checkStderr(execArgs); proc.destroy(); - assertTrue(msg.toString(), msg.toString().equals("true")); + assertEquals("true", msg.toString(), msg.toString()); } catch (IOException e) { fail("IOException executing avail test: " + e); } catch (InterruptedException e) { Index: modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/AssertionErrorTest.java (working copy) @@ -21,8 +21,8 @@ */ public void test_ObjectConstructor() { AssertionError error = new AssertionError(new String("hi")); - assertTrue("non-null cause", error.getCause() == null); - assertTrue(error.getMessage().equals("hi")); + assertNull("non-null cause", error.getCause()); + assertEquals("hi", error.getMessage()); Exception exc = new NullPointerException(); error = new AssertionError(exc); assertTrue("non-null cause", error.getCause() == exc); Index: modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ThreadLocalTest.java (working copy) @@ -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); } Index: modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/StrictMathTest.java (working copy) @@ -114,9 +114,10 @@ */ public void test_ceilD() { // Test for method double java.lang.StrictMath.ceil(double) - assertTrue("Incorrect ceiling for double", StrictMath.ceil(78.89) == 79); - assertTrue("Incorrect ceiling for double", - StrictMath.ceil(-78.89) == -78); + assertEquals("Incorrect ceiling for double", + 79, StrictMath.ceil(78.89), 0.0); + assertEquals("Incorrect ceiling for double", + -78, StrictMath.ceil(-78.89), 0.0); } /** @@ -146,9 +147,10 @@ */ public void test_floorD() { // Test for method double java.lang.StrictMath.floor(double) - assertTrue("Incorrect floor for double", StrictMath.floor(78.89) == 78); - assertTrue("Incorrect floor for double", - StrictMath.floor(-78.89) == -79); + assertEquals("Incorrect floor for double", + 78, StrictMath.floor(78.89), 0.0); + assertEquals("Incorrect floor for double", + -79, StrictMath.floor(-78.89), 0.0); } /** @@ -157,8 +159,8 @@ public void test_IEEEremainderDD() { // Test for method double java.lang.StrictMath.IEEEremainder(double, // double) - assertTrue("Incorrect remainder returned", StrictMath.IEEEremainder( - 1.0, 1.0) == 0.0); + assertEquals("Incorrect remainder returned", 0.0, StrictMath.IEEEremainder( + 1.0, 1.0)); assertTrue( "Incorrect remainder returned", StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631647E-2 @@ -184,12 +186,12 @@ */ public void test_maxDD() { // Test for method double java.lang.StrictMath.max(double, double) - assertTrue("Incorrect double max value", StrictMath.max( - -1908897.6000089, 1908897.6000089) == 1908897.6000089); - assertTrue("Incorrect double max value", StrictMath.max(2.0, - 1908897.6000089) == 1908897.6000089); - assertTrue("Incorrect double max value", StrictMath.max(-2.0, - -1908897.6000089) == -2.0); + assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max( + -1908897.6000089, 1908897.6000089)); + assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(2.0, + 1908897.6000089)); + assertEquals("Incorrect double max value", -2.0, StrictMath.max(-2.0, + -1908897.6000089)); } @@ -211,12 +213,12 @@ */ public void test_maxII() { // Test for method int java.lang.StrictMath.max(int, int) - assertTrue("Incorrect int max value", StrictMath.max(-19088976, - 19088976) == 19088976); - assertTrue("Incorrect int max value", - StrictMath.max(20, 19088976) == 19088976); - assertTrue("Incorrect int max value", - StrictMath.max(-20, -19088976) == -20); + assertEquals("Incorrect int max value", 19088976, StrictMath.max(-19088976, + 19088976)); + assertEquals("Incorrect int max value", + 19088976, StrictMath.max(20, 19088976)); + assertEquals("Incorrect int max value", + -20, StrictMath.max(-20, -19088976)); } /** @@ -224,12 +226,12 @@ */ public void test_maxJJ() { // Test for method long java.lang.StrictMath.max(long, long) - assertTrue("Incorrect long max value", StrictMath.max(-19088976000089L, - 19088976000089L) == 19088976000089L); - assertTrue("Incorrect long max value", StrictMath.max(20, - 19088976000089L) == 19088976000089L); - assertTrue("Incorrect long max value", StrictMath.max(-20, - -19088976000089L) == -20); + assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(-19088976000089L, + 19088976000089L)); + assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(20, + 19088976000089L)); + assertEquals("Incorrect long max value", -20, StrictMath.max(-20, + -19088976000089L)); } /** @@ -237,12 +239,12 @@ */ public void test_minDD() { // Test for method double java.lang.StrictMath.min(double, double) - assertTrue("Incorrect double min value", StrictMath.min( - -1908897.6000089, 1908897.6000089) == -1908897.6000089); - assertTrue("Incorrect double min value", StrictMath.min(2.0, - 1908897.6000089) == 2.0); - assertTrue("Incorrect double min value", StrictMath.min(-2.0, - -1908897.6000089) == -1908897.6000089); + assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min( + -1908897.6000089, 1908897.6000089)); + assertEquals("Incorrect double min value", 2.0, StrictMath.min(2.0, + 1908897.6000089)); + assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(-2.0, + -1908897.6000089)); } /** @@ -263,12 +265,12 @@ */ public void test_minII() { // Test for method int java.lang.StrictMath.min(int, int) - assertTrue("Incorrect int min value", StrictMath.min(-19088976, - 19088976) == -19088976); - assertTrue("Incorrect int min value", - StrictMath.min(20, 19088976) == 20); - assertTrue("Incorrect int min value", - StrictMath.min(-20, -19088976) == -19088976); + assertEquals("Incorrect int min value", -19088976, StrictMath.min(-19088976, + 19088976)); + assertEquals("Incorrect int min value", + 20, StrictMath.min(20, 19088976)); + assertEquals("Incorrect int min value", + -19088976, StrictMath.min(-20, -19088976)); } @@ -277,12 +279,12 @@ */ public void test_minJJ() { // Test for method long java.lang.StrictMath.min(long, long) - assertTrue("Incorrect long min value", StrictMath.min(-19088976000089L, - 19088976000089L) == -19088976000089L); - assertTrue("Incorrect long min value", StrictMath.min(20, - 19088976000089L) == 20); - assertTrue("Incorrect long min value", StrictMath.min(-20, - -19088976000089L) == -19088976000089L); + assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-19088976000089L, + 19088976000089L)); + assertEquals("Incorrect long min value", 20, StrictMath.min(20, + 19088976000089L)); + assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-20, + -19088976000089L)); } /** @@ -301,12 +303,12 @@ */ public void test_rintD() { // Test for method double java.lang.StrictMath.rint(double) - assertTrue("Failed to round properly - up to odd", - StrictMath.rint(2.9) == 3.0); + assertEquals("Failed to round properly - up to odd", + 3.0, StrictMath.rint(2.9)); assertTrue("Failed to round properly - NaN", Double.isNaN(StrictMath .rint(Double.NaN))); - assertTrue("Failed to round properly down to even", StrictMath - .rint(2.1) == 2.0); + assertEquals("Failed to round properly down to even", 2.0, StrictMath + .rint(2.1)); assertTrue("Failed to round properly " + 2.5 + " to even", StrictMath .rint(2.5) == 2.0); } @@ -316,8 +318,8 @@ */ public void test_roundD() { // Test for method long java.lang.StrictMath.round(double) - assertTrue("Incorrect rounding of a float", - StrictMath.round(-90.89d) == -91); + assertEquals("Incorrect rounding of a float", + -91, StrictMath.round(-90.89d)); } /** @@ -325,8 +327,8 @@ */ public void test_roundF() { // Test for method int java.lang.StrictMath.round(float) - assertTrue("Incorrect rounding of a float", - StrictMath.round(-90.89f) == -91); + assertEquals("Incorrect rounding of a float", + -91, StrictMath.round(-90.89f)); } /** @@ -343,9 +345,9 @@ */ public void test_sqrtD() { // Test for method double java.lang.StrictMath.sqrt(double) - assertTrue("Incorrect root returned1", StrictMath.sqrt(StrictMath.pow( - StrictMath.sqrt(2), 4)) == 2); - assertTrue("Incorrect root returned2", StrictMath.sqrt(49) == 7); + assertEquals("Incorrect root returned1", + 2, StrictMath.sqrt(StrictMath.pow(StrictMath.sqrt(2), 4)), 0.0); + assertEquals("Incorrect root returned2", 7, StrictMath.sqrt(49), 0.0); } /** @@ -364,10 +366,10 @@ */ public void test_random() { // There isn't a place for these tests so just stick them here - assertTrue("Wrong value E", - Double.doubleToLongBits(StrictMath.E) == 4613303445314885481L); - assertTrue("Wrong value PI", - Double.doubleToLongBits(StrictMath.PI) == 4614256656552045848L); + assertEquals("Wrong value E", + 4613303445314885481L, Double.doubleToLongBits(StrictMath.E)); + assertEquals("Wrong value PI", + 4614256656552045848L, Double.doubleToLongBits(StrictMath.PI)); for (int i = 500; i >= 0; i--) { double d = StrictMath.random(); Index: modules/luni/src/test/java/tests/api/java/lang/SystemTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/SystemTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/SystemTest.java (working copy) @@ -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); Index: modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/LinkageErrorTest.java (working copy) @@ -27,8 +27,8 @@ } fail("Error not thrown."); } catch (LinkageError e) { - assertTrue("Error not initialized.", e.toString().equals( - "java.lang.LinkageError")); + assertEquals("Error not initialized.", + "java.lang.LinkageError", e.toString()); } } Index: modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ThreadGroupTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/NoClassDefFoundErrorTest.java (working copy) @@ -27,8 +27,8 @@ } fail("Error not thrown."); } catch (NoClassDefFoundError e) { - assertTrue("Error not intitialized.", e.toString().equals( - "java.lang.NoClassDefFoundError")); + assertEquals("Error not intitialized.", + "java.lang.NoClassDefFoundError", e.toString()); } } Index: modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/IntegerTest.java (working copy) @@ -27,7 +27,7 @@ public void test_ConstructorI() { // Test for method java.lang.Integer(int) Integer i = new Integer(-89000); - assertTrue("Incorrect Integer created", i.intValue() == -89000); + assertEquals("Incorrect Integer created", -89000, i.intValue()); } /** @@ -36,7 +36,7 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.lang.Integer(java.lang.String) Integer i = new Integer("65000"); - assertTrue("Created incorrect Integer", i.intValue() == 65000); + assertEquals("Created incorrect Integer", 65000, i.intValue()); } /** @@ -44,10 +44,10 @@ */ public void test_byteValue() { // Test for method byte java.lang.Integer.byteValue() - assertTrue("Returned incorrect byte value", new Integer(65535) - .byteValue() == -1); - assertTrue("Returned incorrect byte value", new Integer(127) - .byteValue() == 127); + assertEquals("Returned incorrect byte value", -1, new Integer(65535) + .byteValue()); + assertEquals("Returned incorrect byte value", 127, new Integer(127) + .byteValue()); } /** @@ -57,8 +57,8 @@ // Test for method int java.lang.Integer.compareTo(java.lang.Integer) assertTrue("-2 compared to 1 gave non-negative answer", new Integer(-2) .compareTo(new Integer(1)) < 0); - assertTrue("-2 compared to -2 gave non-zero answer", new Integer(-2) - .compareTo(new Integer(-2)) == 0); + assertEquals("-2 compared to -2 gave non-zero answer", 0, new Integer(-2) + .compareTo(new Integer(-2))); assertTrue("3 compared to 2 gave non-positive answer", new Integer(3) .compareTo(new Integer(2)) > 0); @@ -75,19 +75,19 @@ public void test_decodeLjava_lang_String() { // Test for method java.lang.Integer // java.lang.Integer.decode(java.lang.String) - assertTrue("Failed for 132233", - Integer.decode("132233").intValue() == 132233); - assertTrue("Failed for 07654321", - Integer.decode("07654321").intValue() == 07654321); + assertEquals("Failed for 132233", + 132233, Integer.decode("132233").intValue()); + assertEquals("Failed for 07654321", + 07654321, Integer.decode("07654321").intValue()); assertTrue("Failed for #1234567", Integer.decode("#1234567").intValue() == 0x1234567); assertTrue("Failed for 0xdAd", Integer.decode("0xdAd").intValue() == 0xdad); - assertTrue("Failed for -23", Integer.decode("-23").intValue() == -23); - assertTrue("Returned incorrect value for 0 decimal", Integer - .decode("0").intValue() == 0); - assertTrue("Returned incorrect value for 0 hex", Integer.decode("0x0") - .intValue() == 0); + assertEquals("Failed for -23", -23, Integer.decode("-23").intValue()); + assertEquals("Returned incorrect value for 0 decimal", 0, Integer + .decode("0").intValue()); + assertEquals("Returned incorrect value for 0 hex", 0, Integer.decode("0x0") + .intValue()); assertTrue("Returned incorrect value for most negative value decimal", Integer.decode("-2147483648").intValue() == 0x80000000); assertTrue("Returned incorrect value for most negative value hex", @@ -158,10 +158,10 @@ */ public void test_doubleValue() { // Test for method double java.lang.Integer.doubleValue() - assertTrue("Returned incorrect double value", new Integer(2147483647) - .doubleValue() == 2147483647.0); - assertTrue("Returned incorrect double value", new Integer(-2147483647) - .doubleValue() == -2147483647.0); + assertEquals("Returned incorrect double value", 2147483647.0, new Integer(2147483647) + .doubleValue()); + assertEquals("Returned incorrect double value", -2147483647.0, new Integer(-2147483647) + .doubleValue()); } /** @@ -197,8 +197,8 @@ System.setProperties(tProps); assertTrue("returned incorrect Integer", Integer.getInteger("testInt") .equals(new Integer(99))); - assertTrue("returned incorrect default Integer", Integer - .getInteger("ff") == null); + assertNull("returned incorrect default Integer", Integer + .getInteger("ff")); } /** @@ -250,7 +250,7 @@ // Test for method int java.lang.Integer.intValue() Integer i = new Integer(8900); - assertTrue("Returned incorrect int value", i.intValue() == 8900); + assertEquals("Returned incorrect int value", 8900, i.intValue()); } /** @@ -259,7 +259,7 @@ public void test_longValue() { // Test for method long java.lang.Integer.longValue() Integer i = new Integer(8900); - assertTrue("Returned incorrect long value", i.longValue() == 8900L); + assertEquals("Returned incorrect long value", 8900L, i.longValue()); } /** @@ -269,8 +269,8 @@ // Test for method int java.lang.Integer.parseInt(java.lang.String) int i = Integer.parseInt("-8900"); - assertTrue("Returned incorrect int", i == -8900); - assertTrue("Returned incorrect value for 0", Integer.parseInt("0") == 0); + assertEquals("Returned incorrect int", -8900, i); + assertEquals("Returned incorrect value for 0", 0, Integer.parseInt("0")); assertTrue("Returned incorrect value for most negative value", Integer .parseInt("-2147483648") == 0x80000000); assertTrue("Returned incorrect value for most positive value", Integer @@ -309,20 +309,20 @@ */ public void test_parseIntLjava_lang_StringI() { // Test for method int java.lang.Integer.parseInt(java.lang.String, int) - assertTrue("Parsed dec val incorrectly", - Integer.parseInt("-8000", 10) == -8000); - assertTrue("Parsed hex val incorrectly", - Integer.parseInt("FF", 16) == 255); - assertTrue("Parsed oct val incorrectly", - Integer.parseInt("20", 8) == 16); - assertTrue("Returned incorrect value for 0 hex", Integer.parseInt("0", - 16) == 0); + assertEquals("Parsed dec val incorrectly", + -8000, Integer.parseInt("-8000", 10)); + assertEquals("Parsed hex val incorrectly", + 255, Integer.parseInt("FF", 16)); + assertEquals("Parsed oct val incorrectly", + 16, Integer.parseInt("20", 8)); + assertEquals("Returned incorrect value for 0 hex", 0, Integer.parseInt("0", + 16)); assertTrue("Returned incorrect value for most negative value hex", Integer.parseInt("-80000000", 16) == 0x80000000); assertTrue("Returned incorrect value for most positive value hex", Integer.parseInt("7fffffff", 16) == 0x7fffffff); - assertTrue("Returned incorrect value for 0 decimal", Integer.parseInt( - "0", 10) == 0); + assertEquals("Returned incorrect value for 0 decimal", 0, Integer.parseInt( + "0", 10)); assertTrue("Returned incorrect value for most negative value decimal", Integer.parseInt("-2147483648", 10) == 0x80000000); assertTrue("Returned incorrect value for most positive value decimal", @@ -391,7 +391,7 @@ public void test_shortValue() { // Test for method short java.lang.Integer.shortValue() Integer i = new Integer(2147450880); - assertTrue("Returned incorrect long value", i.shortValue() == -32768); + assertEquals("Returned incorrect long value", -32768, i.shortValue()); } /** @@ -400,10 +400,10 @@ public void test_toBinaryStringI() { // Test for method java.lang.String // java.lang.Integer.toBinaryString(int) - assertTrue("Incorrect string returned", Integer.toBinaryString( - Integer.MAX_VALUE).equals("1111111111111111111111111111111")); - assertTrue("Incorrect string returned", Integer.toBinaryString( - Integer.MIN_VALUE).equals("10000000000000000000000000000000")); + assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toBinaryString( + Integer.MAX_VALUE)); + assertEquals("Incorrect string returned", "10000000000000000000000000000000", Integer.toBinaryString( + Integer.MIN_VALUE)); } /** @@ -433,10 +433,10 @@ public void test_toOctalStringI() { // Test for method java.lang.String java.lang.Integer.toOctalString(int) // Spec states that the int arg is treated as unsigned - assertTrue("Returned incorrect octal string", Integer.toOctalString( - Integer.MAX_VALUE).equals("17777777777")); - assertTrue("Returned incorrect octal string", Integer.toOctalString( - Integer.MIN_VALUE).equals("20000000000")); + assertEquals("Returned incorrect octal string", "17777777777", Integer.toOctalString( + Integer.MAX_VALUE)); + assertEquals("Returned incorrect octal string", "20000000000", Integer.toOctalString( + Integer.MIN_VALUE)); } /** @@ -447,7 +447,7 @@ Integer i = new Integer(-80001); - assertTrue("Returned incorrect String", i.toString().equals("-80001")); + assertEquals("Returned incorrect String", "-80001", i.toString()); } /** @@ -456,14 +456,14 @@ public void test_toStringI() { // Test for method java.lang.String java.lang.Integer.toString(int) - assertTrue("Returned incorrect String", Integer.toString(-80765) - .equals("-80765")); - assertTrue("Returned incorrect octal string", Integer.toString( - Integer.MAX_VALUE).equals("2147483647")); - assertTrue("Returned incorrect octal string", Integer.toString( - -Integer.MAX_VALUE).equals("-2147483647")); - assertTrue("Returned incorrect octal string", Integer.toString( - Integer.MIN_VALUE).equals("-2147483648")); + assertEquals("Returned incorrect String", "-80765", Integer.toString(-80765) + ); + assertEquals("Returned incorrect octal string", "2147483647", Integer.toString( + Integer.MAX_VALUE)); + assertEquals("Returned incorrect octal string", "-2147483647", Integer.toString( + -Integer.MAX_VALUE)); + assertEquals("Returned incorrect octal string", "-2147483648", Integer.toString( + Integer.MIN_VALUE)); } /** @@ -471,37 +471,37 @@ */ public void test_toStringII() { // Test for method java.lang.String java.lang.Integer.toString(int, int) - assertTrue("Returned incorrect octal string", Integer.toString( - 2147483647, 8).equals("17777777777")); + assertEquals("Returned incorrect octal string", "17777777777", Integer.toString( + 2147483647, 8)); assertTrue("Returned incorrect hex string--wanted 7fffffff but got: " + Integer.toString(2147483647, 16), Integer.toString( 2147483647, 16).equals("7fffffff")); - assertTrue("Incorrect string returned", Integer.toString(2147483647, 2) - .equals("1111111111111111111111111111111")); - assertTrue("Incorrect string returned", Integer - .toString(2147483647, 10).equals("2147483647")); + assertEquals("Incorrect string returned", "1111111111111111111111111111111", Integer.toString(2147483647, 2) + ); + assertEquals("Incorrect string returned", "2147483647", Integer + .toString(2147483647, 10)); - assertTrue("Returned incorrect octal string", Integer.toString( - -2147483647, 8).equals("-17777777777")); + assertEquals("Returned incorrect octal string", "-17777777777", Integer.toString( + -2147483647, 8)); assertTrue("Returned incorrect hex string--wanted -7fffffff but got: " + Integer.toString(-2147483647, 16), Integer.toString( -2147483647, 16).equals("-7fffffff")); - assertTrue("Incorrect string returned", Integer - .toString(-2147483647, 2).equals( - "-1111111111111111111111111111111")); - assertTrue("Incorrect string returned", Integer.toString(-2147483647, - 10).equals("-2147483647")); + assertEquals("Incorrect string returned", + "-1111111111111111111111111111111", Integer + .toString(-2147483647, 2)); + assertEquals("Incorrect string returned", "-2147483647", Integer.toString(-2147483647, + 10)); - assertTrue("Returned incorrect octal string", Integer.toString( - -2147483648, 8).equals("-20000000000")); + assertEquals("Returned incorrect octal string", "-20000000000", Integer.toString( + -2147483648, 8)); assertTrue("Returned incorrect hex string--wanted -80000000 but got: " + Integer.toString(-2147483648, 16), Integer.toString( -2147483648, 16).equals("-80000000")); - assertTrue("Incorrect string returned", Integer - .toString(-2147483648, 2).equals( - "-10000000000000000000000000000000")); - assertTrue("Incorrect string returned", Integer.toString(-2147483648, - 10).equals("-2147483648")); + assertEquals("Incorrect string returned", + "-10000000000000000000000000000000", Integer + .toString(-2147483648, 2)); + assertEquals("Incorrect string returned", "-2147483648", Integer.toString(-2147483648, + 10)); } /** @@ -510,8 +510,8 @@ public void test_valueOfLjava_lang_String() { // Test for method java.lang.Integer // java.lang.Integer.valueOf(java.lang.String) - assertTrue("Returned incorrect int", Integer.valueOf("8888888") - .intValue() == 8888888); + assertEquals("Returned incorrect int", 8888888, Integer.valueOf("8888888") + .intValue()); assertTrue("Returned incorrect int", Integer.valueOf("2147483647") .intValue() == Integer.MAX_VALUE); assertTrue("Returned incorrect int", Integer.valueOf("-2147483648") @@ -542,19 +542,19 @@ public void test_valueOfLjava_lang_StringI() { // Test for method java.lang.Integer // java.lang.Integer.valueOf(java.lang.String, int) - assertTrue("Returned incorrect int for hex string", Integer.valueOf( - "FF", 16).intValue() == 255); - assertTrue("Returned incorrect int for oct string", Integer.valueOf( - "20", 8).intValue() == 16); - assertTrue("Returned incorrect int for bin string", Integer.valueOf( - "100", 2).intValue() == 4); + assertEquals("Returned incorrect int for hex string", 255, Integer.valueOf( + "FF", 16).intValue()); + assertEquals("Returned incorrect int for oct string", 16, Integer.valueOf( + "20", 8).intValue()); + assertEquals("Returned incorrect int for bin string", 4, Integer.valueOf( + "100", 2).intValue()); - assertTrue("Returned incorrect int for - hex string", Integer.valueOf( - "-FF", 16).intValue() == -255); - assertTrue("Returned incorrect int for - oct string", Integer.valueOf( - "-20", 8).intValue() == -16); - assertTrue("Returned incorrect int for - bin string", Integer.valueOf( - "-100", 2).intValue() == -4); + assertEquals("Returned incorrect int for - hex string", -255, Integer.valueOf( + "-FF", 16).intValue()); + assertEquals("Returned incorrect int for - oct string", -16, Integer.valueOf( + "-20", 8).intValue()); + assertEquals("Returned incorrect int for - bin string", -4, Integer.valueOf( + "-100", 2).intValue()); assertTrue("Returned incorrect int", Integer.valueOf("2147483647", 10) .intValue() == Integer.MAX_VALUE); assertTrue("Returned incorrect int", Integer.valueOf("-2147483648", 10) Index: modules/luni/src/test/java/tests/api/java/lang/ExceptionInInitializerErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ExceptionInInitializerErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ExceptionInInitializerErrorTest.java (working copy) @@ -27,8 +27,8 @@ } catch (ExceptionInInitializerError e) { assertTrue("Initializer failed." + e.toString(), e.toString() .equals("java.lang.ExceptionInInitializerError")); - assertTrue("Initializer failed.", e.getException() == null); - assertTrue("Initializer failed.", e.getMessage() == null); + assertNull("Initializer failed.", e.getException()); + assertNull("Initializer failed.", e.getMessage()); return; } fail("Constructor failed."); @@ -60,8 +60,8 @@ } fail("Constructor failed."); } catch (ExceptionInInitializerError e) { - assertTrue("Initializer failed." + e.getMessage(), - e.getMessage() == null); + assertNull("Initializer failed." + e.getMessage(), + e.getMessage()); assertTrue("Initializer failed." + e.toString(), e.getException() != null && e.getException().getMessage().equals( Index: modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/reflect/MethodTest.java (working copy) @@ -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 { Index: modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/reflect/ProxyTest.java (working copy) @@ -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 { Index: modules/luni/src/test/java/tests/api/java/lang/reflect/FieldTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/reflect/FieldTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/reflect/FieldTest.java (working copy) @@ -125,8 +125,8 @@ f = x.getClass().getDeclaredField("doubleSField"); f.set(x, new Double(1.0)); val = (Double) f.get(x); - assertTrue("Returned incorrect double field value", val - .doubleValue() == 1.0); + assertEquals("Returned incorrect double field value", 1.0, val + .doubleValue()); // Try a get on a private field try { @@ -552,7 +552,7 @@ } catch (Exception e) { fail("Exception during getCharacter test: " + e.toString()); } - assertTrue("Returned incorrect char field value", val == 'T'); + assertEquals("Returned incorrect char field value", 'T', val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -749,8 +749,8 @@ } catch (Exception e) { fail("Exception during getType test : " + e.getMessage()); } - assertTrue("Returned incorrect field name", f.getName().equals( - "shortField")); + assertEquals("Returned incorrect field name", + "shortField", f.getName()); } /** @@ -818,7 +818,7 @@ } catch (Exception e) { fail("Exception during set test : " + e.getMessage()); } - assertTrue("Returned incorrect double field value", val == 1.0); + assertEquals("Returned incorrect double field value", 1.0, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -840,7 +840,7 @@ f = x.getClass().getDeclaredField("doubleSField"); f.set(x, new Double(1.0)); val = f.getDouble(x); - assertTrue("Returned incorrect double field value", val == 1.0); + assertEquals("Returned incorrect double field value", 1.0, val); } catch (Exception e) { fail("Exception during setDouble test: " + e.toString()); } @@ -904,7 +904,7 @@ } catch (Exception e) { fail("Exception during setByte test : " + e.getMessage()); } - assertTrue("Returned incorrect float field value", val == 1); + assertEquals("Returned incorrect float field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -945,7 +945,7 @@ } catch (Exception e) { fail("Exception during setChar test : " + e.getMessage()); } - assertTrue("Returned incorrect float field value", val == 1); + assertEquals("Returned incorrect float field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -986,7 +986,7 @@ } catch (Exception e) { fail("Exception during setDouble test: " + e.toString()); } - assertTrue("Returned incorrect double field value", val == 1.0); + assertEquals("Returned incorrect double field value", 1.0, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -1027,7 +1027,7 @@ } catch (Exception e) { fail("Exception during setFloat test : " + e.getMessage()); } - assertTrue("Returned incorrect float field value", val == 1); + assertEquals("Returned incorrect float field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -1067,7 +1067,7 @@ } catch (Exception e) { fail("Exception during setInteger test: " + e.toString()); } - assertTrue("Returned incorrect int field value", val == 1); + assertEquals("Returned incorrect int field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -1107,7 +1107,7 @@ } catch (Exception e) { fail("Exception during setLong test : " + e.getMessage()); } - assertTrue("Returned incorrect long field value", val == 1); + assertEquals("Returned incorrect long field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -1147,7 +1147,7 @@ } catch (Exception e) { fail("Exception during setShort test : " + e.getMessage()); } - assertTrue("Returned incorrect short field value", val == 1); + assertEquals("Returned incorrect short field value", 1, val); try { try { f = x.getClass().getDeclaredField("booleanField"); @@ -1183,12 +1183,11 @@ } catch (Exception e) { fail("Exception getting field : " + e.getMessage()); } - assertTrue( - "Field returned incorrect string", - f + assertEquals("Field returned incorrect string", + + "private static final int tests.api.java.lang.reflect.FieldTest$TestField.x", f .toString() - .equals( - "private static final int tests.api.java.lang.reflect.FieldTest$TestField.x")); + ); } /** Index: modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/reflect/ConstructorTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/reflect/ArrayTest.java (working copy) @@ -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) { Index: modules/luni/src/test/java/tests/api/java/lang/ClassTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ClassTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ClassTest.java (working copy) @@ -180,8 +180,8 @@ */ public void test_getClasses() { // Test for method java.lang.Class [] java.lang.Class.getClasses() - assertTrue("Incorrect class array returned", ClassTest.class - .getClasses().length == 2); + assertEquals("Incorrect class array returned", 2, ClassTest.class + .getClasses().length); } /** @@ -391,8 +391,8 @@ .getComponentType() == int.class); assertTrue("Object array does not have Object component type", Object[].class.getComponentType() == Object.class); - assertTrue("Object has non-null component type", Object.class - .getComponentType() == null); + assertNull("Object has non-null component type", Object.class + .getComponentType()); } /** @@ -424,8 +424,8 @@ try { java.lang.reflect.Constructor[] c = TestClass.class .getConstructors(); - assertTrue("Incorrect number of constructors returned", - c.length == 1); + assertEquals("Incorrect number of constructors returned", + 1, c.length); } catch (Exception e) { fail("Exception during getDeclaredConstructor test:" + e.toString()); @@ -438,8 +438,8 @@ public void test_getDeclaredClasses() { // Test for method java.lang.Class [] // java.lang.Class.getDeclaredClasses() - assertTrue("Incorrect class array returned", ClassTest.class - .getClasses().length == 2); + assertEquals("Incorrect class array returned", 2, ClassTest.class + .getClasses().length); } /** @@ -451,8 +451,8 @@ try { java.lang.reflect.Constructor c = TestClass.class .getDeclaredConstructor(new Class[0]); - assertTrue("Incorrect constructor returned", ((TestClass) (c - .newInstance(new Object[0]))).cValue() == null); + assertNull("Incorrect constructor returned", ((TestClass) (c + .newInstance(new Object[0]))).cValue()); c = TestClass.class .getDeclaredConstructor(new Class[] { Object.class }); } catch (NoSuchMethodException e) { @@ -473,8 +473,8 @@ try { java.lang.reflect.Constructor[] c = TestClass.class .getDeclaredConstructors(); - assertTrue("Incorrect number of constructors returned", - c.length == 2); + assertEquals("Incorrect number of constructors returned", + 2, c.length); } catch (Exception e) { fail("Exception during getDeclaredConstructor test:" + e.toString()); @@ -490,8 +490,8 @@ try { java.lang.reflect.Field f = TestClass.class .getDeclaredField("pubField"); - assertTrue("Returned incorrect field", - f.getInt(new TestClass()) == 2); + assertEquals("Returned incorrect field", + 2, f.getInt(new TestClass())); } catch (Exception e) { fail("Exception getting fields : " + e.getMessage()); } @@ -505,10 +505,10 @@ // java.lang.Class.getDeclaredFields() try { java.lang.reflect.Field[] f = TestClass.class.getDeclaredFields(); - assertTrue("Returned incorrect number of fields", f.length == 4); + assertEquals("Returned incorrect number of fields", 4, f.length); f = SubTestClass.class.getDeclaredFields(); // Declared fields do not include inherited - assertTrue("Returned incorrect number of fields", f.length == 0); + assertEquals("Returned incorrect number of fields", 0, f.length); } catch (Exception e) { fail("Exception getting fields : " + e.getMessage()); } @@ -525,8 +525,8 @@ try { java.lang.reflect.Method m = TestClass.class.getDeclaredMethod( "pubMethod", new Class[0]); - assertTrue("Returned incorrect method", ((Integer) (m.invoke( - new TestClass(), new Class[0]))).intValue() == 2); + assertEquals("Returned incorrect method", 2, ((Integer) (m.invoke( + new TestClass(), new Class[0]))).intValue()); m = TestClass.class.getDeclaredMethod("privMethod", new Class[0]); try { // Invoking private non-sub, non-package @@ -548,9 +548,9 @@ // java.lang.Class.getDeclaredMethods() try { java.lang.reflect.Method[] m = TestClass.class.getDeclaredMethods(); - assertTrue("Returned incorrect number of methods", m.length == 3); + assertEquals("Returned incorrect number of methods", 3, m.length); m = SubTestClass.class.getDeclaredMethods(); - assertTrue("Returned incorrect number of methods", m.length == 0); + assertEquals("Returned incorrect number of methods", 0, m.length); } catch (Exception e) { fail("Exception getting methods : " + e.getMessage()); } @@ -572,8 +572,8 @@ // java.lang.Class.getField(java.lang.String) try { java.lang.reflect.Field f = TestClass.class.getField("pubField"); - assertTrue("Returned incorrect field", - f.getInt(new TestClass()) == 2); + assertEquals("Returned incorrect field", + 2, f.getInt(new TestClass())); try { f = TestClass.class.getField("privField"); } catch (NoSuchFieldException e) { @@ -612,8 +612,8 @@ Class[] interfaces; List interfaceList; interfaces = java.lang.Object.class.getInterfaces(); - assertTrue("Incorrect interface list for Object", - interfaces.length == 0); + assertEquals("Incorrect interface list for Object", + 0, interfaces.length); interfaceList = Arrays.asList(java.util.Vector.class.getInterfaces()); assertTrue("Incorrect interface list for Vector", interfaceList .contains(java.lang.Cloneable.class) @@ -630,8 +630,8 @@ try { java.lang.reflect.Method m = TestClass.class.getMethod("pubMethod", new Class[0]); - assertTrue("Returned incorrect method", ((Integer) (m.invoke( - new TestClass(), new Class[0]))).intValue() == 2); + assertEquals("Returned incorrect method", 2, ((Integer) (m.invoke( + new TestClass(), new Class[0]))).intValue()); try { m = TestClass.class.getMethod("privMethod", new Class[0]); } catch (NoSuchMethodException e) { @@ -737,11 +737,11 @@ System.setSecurityManager(new SecurityManager()); try { java.net.URL res = Object.class.getResource("Object.class"); - assertTrue("Object.class should not be found", res == null); + assertNull("Object.class should not be found", res); - assertTrue("Security: the file " + name + assertNotNull("Security: the file " + name + " can not be found in this directory", ClassTest.class - .getResource(name) != null); + .getResource(name)); } finally { System.setSecurityManager(null); } @@ -762,27 +762,27 @@ fail( "Should be able to find the class tests.api.java.lang.ClassTest"); } - assertTrue("the file " + name + " can not be found in this directory", - clazz.getResourceAsStream(name) != null); + assertNotNull("the file " + name + " can not be found in this directory", + clazz.getResourceAsStream(name)); System.setSecurityManager(new SecurityManager()); try { InputStream res = Object.class.getResourceAsStream("Object.class"); - assertTrue("Object.class should not be found", res == null); + assertNull("Object.class should not be found", res); InputStream is = ClassTest.class.getResourceAsStream(name); - assertTrue("Security: the file " + name - + " can not be found in this directory", is != null); + assertNotNull("Security: the file " + name + + " can not be found in this directory", is); } finally { System.setSecurityManager(null); } name = "hyts_Foo.c"; - assertTrue("the file " + name + assertNull("the file " + name + " should not be found in this directory", clazz - .getResourceAsStream(name) == null); - assertTrue("the file " + name + .getResourceAsStream(name)); + assertNotNull("the file " + name + " can not be found in the root directory", clazz - .getResourceAsStream("/" + name) != null); + .getResourceAsStream("/" + name)); try { clazz = Class.forName("java.lang.Object"); @@ -790,12 +790,12 @@ fail("Should be able to find the class java.lang.Object"); } InputStream str = clazz.getResourceAsStream("Class.class"); - assertTrue( + assertNotNull( "java.lang.Object couldn't find its class with getResource...", - str != null); + str); try { assertTrue("Cannot read single byte", str.read() != -1); - assertTrue("Cannot read multiple bytes", str.read(new byte[5]) == 5); + assertEquals("Cannot read multiple bytes", 5, str.read(new byte[5])); str.close(); } catch (IOException e) { fail("Exception while closing resource stream 1."); @@ -803,11 +803,11 @@ InputStream str2 = getClass().getResourceAsStream( Support_Resources.RESOURCE_PACKAGE + "hyts_compressD.txt"); - assertTrue("Can't find resource", str2 != null); + assertNotNull("Can't find resource", str2); try { assertTrue("Cannot read single byte", str2.read() != -1); - assertTrue("Cannot read multiple bytes", - str2.read(new byte[5]) == 5); + assertEquals("Cannot read multiple bytes", + 5, str2.read(new byte[5])); str2.close(); } catch (IOException e) { fail("IOException while closing resource stream 2 : " @@ -822,17 +822,17 @@ public void test_getSuperclass() { // Test for method java.lang.Class java.lang.Class.getSuperclass() - assertTrue("Object has a superclass???", - Object.class.getSuperclass() == null); + assertNull("Object has a superclass???", + Object.class.getSuperclass()); assertTrue( "Normal class has bogus superclass", java.io.FileInputStream.class.getSuperclass() == java.io.InputStream.class); assertTrue("Array class has bogus superclass", java.io.FileInputStream[].class.getSuperclass() == Object.class); - assertTrue("Base class has a superclass", - int.class.getSuperclass() == null); - assertTrue("Interface class has a superclass", Cloneable.class - .getSuperclass() == null); + assertNull("Base class has a superclass", + int.class.getSuperclass()); + assertNull("Interface class has a superclass", Cloneable.class + .getSuperclass()); } /** @@ -980,8 +980,8 @@ } catch (ClassNotFoundException e) { fail("Should be able to find the class java.lang.Object"); } - assertTrue("new object instance was null", - clazz.newInstance() != null); + assertNotNull("new object instance was null", + clazz.newInstance()); } catch (Exception e) { fail("Unexpected exception " + e + " in newInstance()"); } @@ -1011,9 +1011,8 @@ } catch (Exception e) { r = 1; } - assertTrue( - "Exception for instantiating a newInstance with no default constructor is not thrown", - r == 1); + assertEquals("Exception for instantiating a newInstance with no default constructor is not thrown", + 1, r); // There needs to be considerably more testing here. } Index: modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/UnsatisfiedLinkErrorTest.java (working copy) @@ -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() { Index: modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/NoSuchMethodErrorTest.java (working copy) @@ -25,9 +25,9 @@ if (true) throw new NoSuchMethodError(); } catch (NoSuchMethodError e) { - assertTrue("Initializer failed.", e.getMessage() == null); - assertTrue("To string failed.", e.toString().equals( - "java.lang.NoSuchMethodError")); + assertNull("Initializer failed.", e.getMessage()); + assertEquals("To string failed.", + "java.lang.NoSuchMethodError", e.toString()); } } Index: modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ThrowableTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/UnsupportedOperationExceptionTest.java (working copy) @@ -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()); Index: modules/luni/src/test/java/tests/api/java/lang/MathTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/MathTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/MathTest.java (working copy) @@ -118,8 +118,10 @@ */ public void test_ceilD() { // Test for method double java.lang.Math.ceil(double) - assertTrue("Incorrect ceiling for double", Math.ceil(78.89) == 79); - assertTrue("Incorrect ceiling for double", Math.ceil(-78.89) == -78); + assertEquals("Incorrect ceiling for double", + 79, Math.ceil(78.89), 0); + assertEquals("Incorrect ceiling for double", + -78, Math.ceil(-78.89), 0); } /** @@ -127,8 +129,8 @@ */ public void test_cosD() { // Test for method double java.lang.Math.cos(double) - assertTrue("Incorrect answer", Math.cos(0) == 1.0); - assertTrue("Incorrect answer", Math.cos(1) == 0.5403023058681398); + assertEquals("Incorrect answer", 1.0, Math.cos(0)); + assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1)); } /** @@ -148,8 +150,10 @@ */ public void test_floorD() { // Test for method double java.lang.Math.floor(double) - assertTrue("Incorrect floor for double", Math.floor(78.89) == 78); - assertTrue("Incorrect floor for double", Math.floor(-78.89) == -79); + assertEquals("Incorrect floor for double", + 78, Math.floor(78.89), 0); + assertEquals("Incorrect floor for double", + -79, Math.floor(-78.89), 0); } /** @@ -157,8 +161,8 @@ */ public void test_IEEEremainderDD() { // Test for method double java.lang.Math.IEEEremainder(double, double) - assertTrue("Incorrect remainder returned", - Math.IEEEremainder(1.0, 1.0) == 0.0); + assertEquals("Incorrect remainder returned", + 0.0, Math.IEEEremainder(1.0, 1.0)); assertTrue("Incorrect remainder returned", Math.IEEEremainder(1.32, 89.765) >= 1.4705063220631647E-2 || Math.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2); @@ -182,12 +186,12 @@ */ public void test_maxDD() { // Test for method double java.lang.Math.max(double, double) - assertTrue("Incorrect double max value", Math.max(-1908897.6000089, - 1908897.6000089) == 1908897.6000089); - assertTrue("Incorrect double max value", - Math.max(2.0, 1908897.6000089) == 1908897.6000089); - assertTrue("Incorrect double max value", Math.max(-2.0, - -1908897.6000089) == -2.0); + assertEquals("Incorrect double max value", 1908897.6000089, Math.max(-1908897.6000089, + 1908897.6000089)); + assertEquals("Incorrect double max value", + 1908897.6000089, Math.max(2.0, 1908897.6000089)); + assertEquals("Incorrect double max value", -2.0, Math.max(-2.0, + -1908897.6000089)); } @@ -209,11 +213,11 @@ */ public void test_maxII() { // Test for method int java.lang.Math.max(int, int) - assertTrue("Incorrect int max value", - Math.max(-19088976, 19088976) == 19088976); - assertTrue("Incorrect int max value", - Math.max(20, 19088976) == 19088976); - assertTrue("Incorrect int max value", Math.max(-20, -19088976) == -20); + assertEquals("Incorrect int max value", + 19088976, Math.max(-19088976, 19088976)); + assertEquals("Incorrect int max value", + 19088976, Math.max(20, 19088976)); + assertEquals("Incorrect int max value", -20, Math.max(-20, -19088976)); } /** @@ -221,12 +225,12 @@ */ public void test_maxJJ() { // Test for method long java.lang.Math.max(long, long) - assertTrue("Incorrect long max value", Math.max(-19088976000089L, - 19088976000089L) == 19088976000089L); - assertTrue("Incorrect long max value", - Math.max(20, 19088976000089L) == 19088976000089L); - assertTrue("Incorrect long max value", - Math.max(-20, -19088976000089L) == -20); + assertEquals("Incorrect long max value", 19088976000089L, Math.max(-19088976000089L, + 19088976000089L)); + assertEquals("Incorrect long max value", + 19088976000089L, Math.max(20, 19088976000089L)); + assertEquals("Incorrect long max value", + -20, Math.max(-20, -19088976000089L)); } /** @@ -234,12 +238,12 @@ */ public void test_minDD() { // Test for method double java.lang.Math.min(double, double) - assertTrue("Incorrect double min value", Math.min(-1908897.6000089, - 1908897.6000089) == -1908897.6000089); - assertTrue("Incorrect double min value", - Math.min(2.0, 1908897.6000089) == 2.0); - assertTrue("Incorrect double min value", Math.min(-2.0, - -1908897.6000089) == -1908897.6000089); + assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-1908897.6000089, + 1908897.6000089)); + assertEquals("Incorrect double min value", + 2.0, Math.min(2.0, 1908897.6000089)); + assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0, + -1908897.6000089)); } /** @@ -260,11 +264,11 @@ */ public void test_minII() { // Test for method int java.lang.Math.min(int, int) - assertTrue("Incorrect int min value", - Math.min(-19088976, 19088976) == -19088976); - assertTrue("Incorrect int min value", Math.min(20, 19088976) == 20); - assertTrue("Incorrect int min value", - Math.min(-20, -19088976) == -19088976); + assertEquals("Incorrect int min value", + -19088976, Math.min(-19088976, 19088976)); + assertEquals("Incorrect int min value", 20, Math.min(20, 19088976)); + assertEquals("Incorrect int min value", + -19088976, Math.min(-20, -19088976)); } @@ -273,12 +277,12 @@ */ public void test_minJJ() { // Test for method long java.lang.Math.min(long, long) - assertTrue("Incorrect long min value", Math.min(-19088976000089L, - 19088976000089L) == -19088976000089L); - assertTrue("Incorrect long min value", - Math.min(20, 19088976000089L) == 20); - assertTrue("Incorrect long min value", - Math.min(-20, -19088976000089L) == -19088976000089L); + assertEquals("Incorrect long min value", -19088976000089L, Math.min(-19088976000089L, + 19088976000089L)); + assertEquals("Incorrect long min value", + 20, Math.min(20, 19088976000089L)); + assertEquals("Incorrect long min value", + -19088976000089L, Math.min(-20, -19088976000089L)); } /** @@ -290,8 +294,8 @@ (long) Math.pow(2, 8) == 256l); assertTrue("pow returned incorrect value", Math.pow(2, -8) == 0.00390625d); - assertTrue("Incorrect root returned1", Math.sqrt(Math.pow(Math.sqrt(2), - 4)) == 2); + assertEquals("Incorrect root returned1", + 2, Math.sqrt(Math.pow(Math.sqrt(2), 4)), 0); } /** @@ -299,12 +303,12 @@ */ public void test_rintD() { // Test for method double java.lang.Math.rint(double) - assertTrue("Failed to round properly - up to odd", - Math.rint(2.9) == 3.0); + assertEquals("Failed to round properly - up to odd", + 3.0, Math.rint(2.9)); assertTrue("Failed to round properly - NaN", Double.isNaN(Math .rint(Double.NaN))); - assertTrue("Failed to round properly down to even", - Math.rint(2.1) == 2.0); + assertEquals("Failed to round properly down to even", + 2.0, Math.rint(2.1)); assertTrue("Failed to round properly " + 2.5 + " to even", Math .rint(2.5) == 2.0); } @@ -314,7 +318,7 @@ */ public void test_roundD() { // Test for method long java.lang.Math.round(double) - assertTrue("Incorrect rounding of a float", Math.round(-90.89d) == -91); + assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89d)); } /** @@ -322,7 +326,7 @@ */ public void test_roundF() { // Test for method int java.lang.Math.round(float) - assertTrue("Incorrect rounding of a float", Math.round(-90.89f) == -91); + assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89f)); } /** @@ -330,8 +334,8 @@ */ public void test_sinD() { // Test for method double java.lang.Math.sin(double) - assertTrue("Incorrect answer", Math.sin(0) == 0.0); - assertTrue("Incorrect answer", Math.sin(1) == 0.8414709848078965); + assertEquals("Incorrect answer", 0.0, Math.sin(0)); + assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1)); } /** @@ -339,7 +343,7 @@ */ public void test_sqrtD() { // Test for method double java.lang.Math.sqrt(double) - assertTrue("Incorrect root returned2", Math.sqrt(49) == 7); + assertEquals("Incorrect root returned2", 7, Math.sqrt(49), 0); } /** @@ -347,8 +351,8 @@ */ public void test_tanD() { // Test for method double java.lang.Math.tan(double) - assertTrue("Incorrect answer", Math.tan(0) == 0.0); - assertTrue("Incorrect answer", Math.tan(1) == 1.5574077246549023); + assertEquals("Incorrect answer", 0.0, Math.tan(0)); + assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1)); } @@ -357,10 +361,10 @@ */ public void test_random() { // There isn't a place for these tests so just stick them here - assertTrue("Wrong value E", - Double.doubleToLongBits(Math.E) == 4613303445314885481L); - assertTrue("Wrong value PI", - Double.doubleToLongBits(Math.PI) == 4614256656552045848L); + assertEquals("Wrong value E", + 4613303445314885481L, Double.doubleToLongBits(Math.E)); + assertEquals("Wrong value PI", + 4614256656552045848L, Double.doubleToLongBits(Math.PI)); for (int i = 500; i >= 0; i--) { double d = Math.random(); Index: modules/luni/src/test/java/tests/api/java/lang/ErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ErrorTest.java (working copy) @@ -40,8 +40,8 @@ if (true) throw new Error("Throw an Error"); } catch (Error e) { - assertTrue("Incorrect message string generated", e.getMessage() - .equals("Throw an Error")); + assertEquals("Incorrect message string generated", "Throw an Error", e.getMessage() + ); return; } fail("Failed to generate Error"); Index: modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/IllegalArgumentExceptionTest.java (working copy) @@ -37,8 +37,8 @@ public void test_Constructor() { // Test for method java.lang.IllegalArgumentException() IllegalArgumentException ill = new IllegalArgumentException(); - assertTrue("failed to create an instance of illegalArgumentException", - ill.getMessage() == null); + assertNull("failed to create an instance of illegalArgumentException", + ill.getMessage()); try { try { new java.io.ByteArrayOutputStream(-12); @@ -58,9 +58,8 @@ // Test for method java.lang.IllegalArgumentException(java.lang.String) IllegalArgumentException ill = new IllegalArgumentException( "testing illArg exception"); - assertTrue( - "failed to create instance of illegalArgumentException(string)", - ill.getMessage().equals("testing illArg exception")); + assertEquals("failed to create instance of illegalArgumentException(string)", + "testing illArg exception", ill.getMessage()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/CharacterTest.java (working copy) @@ -22,7 +22,7 @@ */ public void test_ConstructorC() { // Test for method java.lang.Character(char) - assertTrue("Constructor failed", new Character('T').charValue() == 'T'); + assertEquals("Constructor failed", 'T', new Character('T').charValue()); } /** @@ -30,8 +30,8 @@ */ public void test_charValue() { // Test for method char java.lang.Character.charValue() - assertTrue("Incorrect char value returned", new Character('T') - .charValue() == 'T'); + assertEquals("Incorrect char value returned", 'T', new Character('T') + .charValue()); } /** @@ -45,9 +45,9 @@ Character y = new Character('b'); Character z = new Character('d'); - assertTrue("Returned false for same Character", c.compareTo(c) == 0); - assertTrue("Returned false for identical Character", - c.compareTo(x) == 0); + assertEquals("Returned false for same Character", 0, c.compareTo(c)); + assertEquals("Returned false for identical Character", + 0, c.compareTo(x)); assertTrue("Returned other than less than for lesser char", c .compareTo(y) > 0); assertTrue("Returned other than greater than for greater char", c @@ -59,8 +59,8 @@ */ public void test_digitCI() { // Test for method int java.lang.Character.digit(char, int) - assertTrue("Returned incorrect digit", Character.digit('1', 10) == 1); - assertTrue("Returned incorrect digit", Character.digit('F', 16) == 15); + assertEquals("Returned incorrect digit", 1, Character.digit('1', 10)); + assertEquals("Returned incorrect digit", 15, Character.digit('F', 16)); } /** @@ -102,18 +102,18 @@ */ public void test_getNumericValueC() { // Test for method int java.lang.Character.getNumericValue(char) - assertTrue("Returned incorrect numeric value 1", Character - .getNumericValue('1') == 1); - assertTrue("Returned incorrect numeric value 2", Character - .getNumericValue('F') == 15); - assertTrue("Returned incorrect numeric value 3", Character - .getNumericValue('\u221e') == -1); - assertTrue("Returned incorrect numeric value 4", Character - .getNumericValue('\u00be') == -2); - assertTrue("Returned incorrect numeric value 5", Character - .getNumericValue('\u2182') == 10000); - assertTrue("Returned incorrect numeric value 6", Character - .getNumericValue('\uff12') == 2); + assertEquals("Returned incorrect numeric value 1", 1, Character + .getNumericValue('1')); + assertEquals("Returned incorrect numeric value 2", 15, Character + .getNumericValue('F')); + assertEquals("Returned incorrect numeric value 3", -1, Character + .getNumericValue('\u221e')); + assertEquals("Returned incorrect numeric value 4", -2, Character + .getNumericValue('\u00be')); + assertEquals("Returned incorrect numeric value 5", 10000, Character + .getNumericValue('\u2182')); + assertEquals("Returned incorrect numeric value 6", 2, Character + .getNumericValue('\uff12')); } /** @@ -142,9 +142,9 @@ assertTrue("Returned incorrect type for: \u2029", Character .getType('\u2029') == Character.PARAGRAPH_SEPARATOR); - assertTrue("Wrong constant for FORMAT", Character.FORMAT == 16); - assertTrue("Wrong constant for PRIVATE_USE", - Character.PRIVATE_USE == 18); + assertEquals("Wrong constant for FORMAT", 16, Character.FORMAT); + assertEquals("Wrong constant for PRIVATE_USE", + 18, Character.PRIVATE_USE); } /** @@ -152,8 +152,8 @@ */ public void test_hashCode() { // Test for method int java.lang.Character.hashCode() - assertTrue("Incorrect hash returned", - new Character('Y').hashCode() == 89); + assertEquals("Incorrect hash returned", + 89, new Character('Y').hashCode()); } /** @@ -405,7 +405,7 @@ */ public void test_toLowerCaseC() { // Test for method char java.lang.Character.toLowerCase(char) - assertTrue("Failed to change case", Character.toLowerCase('T') == 't'); + assertEquals("Failed to change case", 't', Character.toLowerCase('T')); } /** @@ -413,8 +413,8 @@ */ public void test_toString() { // Test for method java.lang.String java.lang.Character.toString() - assertTrue("Incorrect String returned", new Character('T').toString() - .equals("T")); + assertEquals("Incorrect String returned", "T", new Character('T').toString() + ); } /** @@ -422,12 +422,12 @@ */ public void test_toTitleCaseC() { // Test for method char java.lang.Character.toTitleCase(char) - assertTrue("Incorrect title case for a", - Character.toTitleCase('a') == 'A'); - assertTrue("Incorrect title case for A", - Character.toTitleCase('A') == 'A'); - assertTrue("Incorrect title case for 1", - Character.toTitleCase('1') == '1'); + assertEquals("Incorrect title case for a", + 'A', Character.toTitleCase('a')); + assertEquals("Incorrect title case for A", + 'A', Character.toTitleCase('A')); + assertEquals("Incorrect title case for 1", + '1', Character.toTitleCase('1')); } /** @@ -435,12 +435,12 @@ */ public void test_toUpperCaseC() { // Test for method char java.lang.Character.toUpperCase(char) - assertTrue("Incorrect upper case for a", - Character.toUpperCase('a') == 'A'); - assertTrue("Incorrect upper case for A", - Character.toUpperCase('A') == 'A'); - assertTrue("Incorrect upper case for 1", - Character.toUpperCase('1') == '1'); + assertEquals("Incorrect upper case for a", + 'A', Character.toUpperCase('a')); + assertEquals("Incorrect upper case for A", + 'A', Character.toUpperCase('A')); + assertEquals("Incorrect upper case for 1", + '1', Character.toUpperCase('1')); } /** Index: modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/StringBufferTest.java (working copy) @@ -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() + ); } /** Index: modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/RuntimeExceptionTest.java (working copy) @@ -44,8 +44,8 @@ if (true) throw new RuntimeException("Runtime message"); } catch (RuntimeException e) { - assertTrue("Incorrect message", e.getMessage().equals( - "Runtime message")); + assertEquals("Incorrect message", + "Runtime message", e.getMessage()); return; } fail("Failed to throw Runtime Exception"); Index: modules/luni/src/test/java/tests/api/java/lang/StringTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/StringTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/StringTest.java (working copy) @@ -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)); } /** Index: modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ObjectTest.java (working copy) @@ -35,7 +35,7 @@ */ public void test_Constructor() { // Test for method java.lang.Object() - assertTrue("Constructor failed !!!", new Object() != null); + assertNotNull("Constructor failed !!!", new Object()); } /** @@ -232,7 +232,7 @@ */ public void test_toString() { // Test for method java.lang.String java.lang.Object.toString() - assertTrue("Object toString returned null.", obj1.toString() != null); + assertNotNull("Object toString returned null.", obj1.toString()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ThreadTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ArrayIndexOutOfBoundsExceptionTest.java (working copy) @@ -32,7 +32,7 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue("failed to generate ArrayIndexOutOfBoundsException", r == 1); + assertEquals("failed to generate ArrayIndexOutOfBoundsException", 1, r); } /** @@ -64,7 +64,7 @@ } catch (ArrayIndexOutOfBoundsException e) { r = 1; } - assertTrue("failed to generate ArrayIndexOutOfBoundsException", r == 1); + assertEquals("failed to generate ArrayIndexOutOfBoundsException", 1, r); } Index: modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/BooleanTest.java (working copy) @@ -104,8 +104,8 @@ // Test for method int java.lang.Boolean.hashCode() // Known values. See comments in java.lang.Boolean.hashCode(). - assertTrue("Incorrect hash for true Boolean.", t.hashCode() == 1231); - assertTrue("Incorrect hash for false Boolean.", f.hashCode() == 1237); + assertEquals("Incorrect hash for true Boolean.", 1231, t.hashCode()); + assertEquals("Incorrect hash for false Boolean.", 1237, f.hashCode()); } /** @@ -113,10 +113,10 @@ */ public void test_toString() { // Test for method java.lang.String java.lang.Boolean.toString() - assertTrue("Boolean true value printed wrong.", t.toString().equals( - "true")); - assertTrue("Boolean false value printed wrong.", f.toString().equals( - "false")); + assertEquals("Boolean true value printed wrong.", + "true", t.toString()); + assertEquals("Boolean false value printed wrong.", + "false", f.toString()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/VirtualMachineErrorTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/lang/IllegalStateExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/IllegalStateExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/IllegalStateExceptionTest.java (working copy) @@ -28,8 +28,8 @@ public void test_Constructor() { // Test for method java.lang.IllegalStateException() IllegalStateException ill = new IllegalStateException(); - assertTrue("failed to create an instance of illegalStateException", ill - .getMessage() == null); + assertNull("failed to create an instance of illegalStateException", + ill.getMessage()); } /** @@ -39,9 +39,8 @@ // Test for method java.lang.IllegalStateException(java.lang.String) IllegalStateException ill = new IllegalStateException( "testing illState exception"); - assertTrue( - "failed to create instance of illegalStateException(string)", - ill.getMessage().equals("testing illState exception")); + assertEquals("failed to create instance of illegalStateException(string)", + "testing illState exception", ill.getMessage()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/PackageTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/PackageTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/PackageTest.java (working copy) @@ -54,28 +54,22 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.C", true, ucl); - assertTrue( - "Package getImplementationTitle returns a wrong string (1)", - c.getPackage().getImplementationTitle().equals( - "p Implementation-Title")); - assertTrue( - "Package getImplementationVendor returns a wrong string (1)", - c.getPackage().getImplementationVendor().equals( - "p Implementation-Vendor")); - assertTrue( - "Package getImplementationVersion returns a wrong string (1)", - c.getPackage().getImplementationVersion().equals("2.2.2")); - assertTrue( - "Package getSpecificationTitle returns a wrong string (1)", - c.getPackage().getSpecificationTitle().equals( - "p Specification-Title")); - assertTrue( - "Package getSpecificationVendor returns a wrong string (1)", - c.getPackage().getSpecificationVendor().equals( - "p Specification-Vendor")); - assertTrue( - "Package getSpecificationVersion returns a wrong string (1)", - c.getPackage().getSpecificationVersion().equals("2.2.2")); + assertEquals("Package getImplementationTitle returns a wrong string (1)", + + "p Implementation-Title", c.getPackage().getImplementationTitle()); + assertEquals("Package getImplementationVendor returns a wrong string (1)", + + "p Implementation-Vendor", c.getPackage().getImplementationVendor()); + assertEquals("Package getImplementationVersion returns a wrong string (1)", + "2.2.2", c.getPackage().getImplementationVersion()); + assertEquals("Package getSpecificationTitle returns a wrong string (1)", + + "p Specification-Title", c.getPackage().getSpecificationTitle()); + assertEquals("Package getSpecificationVendor returns a wrong string (1)", + + "p Specification-Vendor", c.getPackage().getSpecificationVendor()); + assertEquals("Package getSpecificationVersion returns a wrong string (1)", + "2.2.2", c.getPackage().getSpecificationVersion()); } catch (Exception e) { fail("Exception during helperAttributes test : " + e.getMessage()); } @@ -88,28 +82,22 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.C", true, ucl); - assertTrue( - "Package getImplementationTitle returns a wrong string (2)", - c.getPackage().getImplementationTitle().equals( - "MF Implementation-Title")); - assertTrue( - "Package getImplementationVendor returns a wrong string (2)", - c.getPackage().getImplementationVendor().equals( - "MF Implementation-Vendor")); - assertTrue( - "Package getImplementationVersion returns a wrong string (2)", - c.getPackage().getImplementationVersion().equals("5.3.b1")); - assertTrue( - "Package getSpecificationTitle returns a wrong string (2)", - c.getPackage().getSpecificationTitle().equals( - "MF Specification-Title")); - assertTrue( - "Package getSpecificationVendor returns a wrong string (2)", - c.getPackage().getSpecificationVendor().equals( - "MF Specification-Vendor")); - assertTrue( - "Package getSpecificationVersion returns a wrong string (2)", - c.getPackage().getSpecificationVersion().equals("1.2.3")); + assertEquals("Package getImplementationTitle returns a wrong string (2)", + + "MF Implementation-Title", c.getPackage().getImplementationTitle()); + assertEquals("Package getImplementationVendor returns a wrong string (2)", + + "MF Implementation-Vendor", c.getPackage().getImplementationVendor()); + assertEquals("Package getImplementationVersion returns a wrong string (2)", + "5.3.b1", c.getPackage().getImplementationVersion()); + assertEquals("Package getSpecificationTitle returns a wrong string (2)", + + "MF Specification-Title", c.getPackage().getSpecificationTitle()); + assertEquals("Package getSpecificationVendor returns a wrong string (2)", + + "MF Specification-Vendor", c.getPackage().getSpecificationVendor()); + assertEquals("Package getSpecificationVersion returns a wrong string (2)", + "1.2.3", c.getPackage().getSpecificationVersion()); } catch (Exception e) { fail("Exception in helperAttributes test : " + e.getMessage()); } @@ -123,28 +111,22 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.C", true, ucl); - assertTrue( - "Package getImplementationTitle returns a wrong string (3)", - c.getPackage().getImplementationTitle().equals( - "MF Implementation-Title")); - assertTrue( - "Package getImplementationVendor returns a wrong string (3)", - c.getPackage().getImplementationVendor().equals( - "MF Implementation-Vendor")); - assertTrue( - "Package getImplementationVersion returns a wrong string (3)", - c.getPackage().getImplementationVersion().equals("5.3.b1")); - assertTrue( - "Package getSpecificationTitle returns a wrong string (3)", - c.getPackage().getSpecificationTitle().equals( - "MF Specification-Title")); - assertTrue( - "Package getSpecificationVendor returns a wrong string (3)", - c.getPackage().getSpecificationVendor().equals( - "MF Specification-Vendor")); - assertTrue( - "Package getSpecificationVersion returns a wrong string (3)", - c.getPackage().getSpecificationVersion().equals("1.2.3")); + assertEquals("Package getImplementationTitle returns a wrong string (3)", + + "MF Implementation-Title", c.getPackage().getImplementationTitle()); + assertEquals("Package getImplementationVendor returns a wrong string (3)", + + "MF Implementation-Vendor", c.getPackage().getImplementationVendor()); + assertEquals("Package getImplementationVersion returns a wrong string (3)", + "5.3.b1", c.getPackage().getImplementationVersion()); + assertEquals("Package getSpecificationTitle returns a wrong string (3)", + + "MF Specification-Title", c.getPackage().getSpecificationTitle()); + assertEquals("Package getSpecificationVendor returns a wrong string (3)", + + "MF Specification-Vendor", c.getPackage().getSpecificationVendor()); + assertEquals("Package getSpecificationVersion returns a wrong string (3)", + "1.2.3", c.getPackage().getSpecificationVersion()); } catch (Exception e) { fail("Exception during helperAttributes test : " + e.getMessage()); } @@ -158,28 +140,22 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.C", true, ucl); - assertTrue( - "Package getImplementationTitle returns a wrong string (4)", - c.getPackage().getImplementationTitle().equals( - "p Implementation-Title")); - assertTrue( - "Package getImplementationVendor returns a wrong string (4)", - c.getPackage().getImplementationVendor().equals( - "MF Implementation-Vendor")); - assertTrue( - "Package getImplementationVersion returns a wrong string (4)", - c.getPackage().getImplementationVersion().equals("2.2.2")); - assertTrue( - "Package getSpecificationTitle returns a wrong string (4)", - c.getPackage().getSpecificationTitle().equals( - "MF Specification-Title")); - assertTrue( - "Package getSpecificationVendor returns a wrong string (4)", - c.getPackage().getSpecificationVendor().equals( - "p Specification-Vendor")); - assertTrue( - "Package getSpecificationVersion returns a wrong string (4)", - c.getPackage().getSpecificationVersion().equals("2.2.2")); + assertEquals("Package getImplementationTitle returns a wrong string (4)", + + "p Implementation-Title", c.getPackage().getImplementationTitle()); + assertEquals("Package getImplementationVendor returns a wrong string (4)", + + "MF Implementation-Vendor", c.getPackage().getImplementationVendor()); + assertEquals("Package getImplementationVersion returns a wrong string (4)", + "2.2.2", c.getPackage().getImplementationVersion()); + assertEquals("Package getSpecificationTitle returns a wrong string (4)", + + "MF Specification-Title", c.getPackage().getSpecificationTitle()); + assertEquals("Package getSpecificationVendor returns a wrong string (4)", + + "p Specification-Vendor", c.getPackage().getSpecificationVendor()); + assertEquals("Package getSpecificationVersion returns a wrong string (4)", + "2.2.2", c.getPackage().getSpecificationVersion()); } catch (Exception e) { fail("Exception during helperAttributes test : " + e.getMessage()); } @@ -192,29 +168,23 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.q.C", true, ucl); - assertTrue( - "Package getImplementationTitle returns a wrong string (5)", - c.getPackage().getImplementationTitle().equals( - "p Implementation-Title")); - assertTrue( - "Package getImplementationVendor returns a wrong string (5)", - c.getPackage().getImplementationVendor().equals( - "p Implementation-Vendor")); - assertTrue( - "Package getImplementationVersion returns a wrong string (5)", - c.getPackage().getImplementationVersion().equals("1.1.3")); - assertTrue( - "Package getSpecificationTitle returns a wrong string (5)", - c.getPackage().getSpecificationTitle().equals( - "p Specification-Title")); - assertTrue( - "Package getSpecificationVendor returns a wrong string (5)", - c.getPackage().getSpecificationVendor().equals( - "p Specification-Vendor")); - assertTrue( - "Package getSpecificationVersion returns a wrong string (5)", - c.getPackage().getSpecificationVersion().equals( - "2.2.0.0.0.0.0.0.0.0.0")); + assertEquals("Package getImplementationTitle returns a wrong string (5)", + + "p Implementation-Title", c.getPackage().getImplementationTitle()); + assertEquals("Package getImplementationVendor returns a wrong string (5)", + + "p Implementation-Vendor", c.getPackage().getImplementationVendor()); + assertEquals("Package getImplementationVersion returns a wrong string (5)", + "1.1.3", c.getPackage().getImplementationVersion()); + assertEquals("Package getSpecificationTitle returns a wrong string (5)", + + "p Specification-Title", c.getPackage().getSpecificationTitle()); + assertEquals("Package getSpecificationVendor returns a wrong string (5)", + + "p Specification-Vendor", c.getPackage().getSpecificationVendor()); + assertEquals("Package getSpecificationVersion returns a wrong string (5)", + + "2.2.0.0.0.0.0.0.0.0.0", c.getPackage().getSpecificationVersion()); } catch (Exception e) { fail("Exception during helperAttributes test : " + e.getMessage()); @@ -261,8 +231,8 @@ urls[0] = resourceURL; ucl = new java.net.URLClassLoader(urls, null); c = Class.forName("p.q.C", true, ucl); - assertTrue("Package getName returns a wrong string", c.getPackage() - .getName().equals("p.q")); + assertEquals("Package getName returns a wrong string", "p.q", c.getPackage() + .getName()); } catch (Exception e) { fail("Exception during getName test : " + e.getMessage()); Index: modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceQueueTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ref/PhantomReferenceTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ref/ReferenceTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/RuntimePermissionTest.java (working copy) @@ -23,8 +23,8 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.lang.RuntimePermission(java.lang.String) RuntimePermission r = new RuntimePermission("createClassLoader"); - assertTrue("Returned incorrect name", r.getName().equals( - "createClassLoader")); + assertEquals("Returned incorrect name", + "createClassLoader", r.getName()); } @@ -36,8 +36,8 @@ // Test for method java.lang.RuntimePermission(java.lang.String, // java.lang.String) RuntimePermission r = new RuntimePermission("createClassLoader", null); - assertTrue("Returned incorrect name", r.getName().equals( - "createClassLoader")); + assertEquals("Returned incorrect name", + "createClassLoader", r.getName()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/ClassLoaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ClassLoaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ClassLoaderTest.java (working copy) @@ -25,11 +25,11 @@ // java.lang.ClassLoader.getResource(java.lang.String) java.net.URL u = ClassLoader.getSystemClassLoader().getResource( "hyts_Foo.c"); - assertTrue("Unable to find resource", u != null); + assertNotNull("Unable to find resource", u); java.io.InputStream is = null; try { is = u.openStream(); - assertTrue("Resource returned is invalid", is != null); + assertNotNull("Resource returned is invalid", is); is.close(); } catch (java.io.IOException e) { fail("IOException getting stream for resource : " + e.getMessage()); @@ -45,9 +45,9 @@ // Need better test... java.io.InputStream is = null; - assertTrue("Failed to find resource: hyts_Foo.c", + assertNotNull("Failed to find resource: hyts_Foo.c", (is = ClassLoader.getSystemClassLoader().getResourceAsStream( - "hyts_Foo.c")) != null); + "hyts_Foo.c"))); try { is.close(); } catch (java.io.IOException e) { @@ -63,7 +63,7 @@ // java.lang.ClassLoader.getSystemClassLoader() ClassLoader cl = ClassLoader.getSystemClassLoader(); java.io.InputStream is = cl.getResourceAsStream("hyts_Foo.c"); - assertTrue("Failed to find resource from system classpath", is != null); + assertNotNull("Failed to find resource from system classpath", is); try { is.close(); } catch (java.io.IOException e) { @@ -78,8 +78,8 @@ // Test for method java.net.URL // java.lang.ClassLoader.getSystemResource(java.lang.String) // Need better test... - assertTrue("Failed to find resource: hyts_Foo.c", ClassLoader - .getSystemResource("hyts_Foo.c") != null); + assertNotNull("Failed to find resource: hyts_Foo.c", ClassLoader + .getSystemResource("hyts_Foo.c")); } /** Index: modules/luni/src/test/java/tests/api/java/lang/ExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ExceptionTest.java (working copy) @@ -40,8 +40,8 @@ if (true) throw new Exception("Throw an Error"); } catch (Exception e) { - assertTrue("Incorrect message string generated", e.getMessage() - .equals("Throw an Error")); + assertEquals("Incorrect message string generated", "Throw an Error", e.getMessage() + ); return; } fail("Failed to generate Error"); Index: modules/luni/src/test/java/tests/api/java/lang/ShortTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ShortTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ShortTest.java (working copy) @@ -48,10 +48,10 @@ */ public void test_byteValue() { // Test for method byte java.lang.Short.byteValue() - assertTrue("Returned incorrect byte value", new Short(Short.MIN_VALUE) - .byteValue() == 0); - assertTrue("Returned incorrect byte value", new Short(Short.MAX_VALUE) - .byteValue() == -1); + assertEquals("Returned incorrect byte value", 0, new Short(Short.MIN_VALUE) + .byteValue()); + assertEquals("Returned incorrect byte value", -1, new Short(Short.MAX_VALUE) + .byteValue()); } /** @@ -69,8 +69,8 @@ "Should have returned positive value when compared to lesser short", s.compareTo(x) > 0); x = new Short((short) 1); - assertTrue("Should have returned zero when compared to equal short", s - .compareTo(x) == 0); + assertEquals("Should have returned zero when compared to equal short", + 0, s.compareTo(x)); try { new Short((short)0).compareTo(null); @@ -152,10 +152,10 @@ */ public void test_doubleValue() { // Test for method double java.lang.Short.doubleValue() - assertTrue("Returned incorrect double value", - new Short(Short.MIN_VALUE).doubleValue() == -32768.0); - assertTrue("Returned incorrect double value", - new Short(Short.MAX_VALUE).doubleValue() == 32767.0); + assertEquals("Returned incorrect double value", + -32768.0, new Short(Short.MIN_VALUE).doubleValue()); + assertEquals("Returned incorrect double value", + 32767.0, new Short(Short.MAX_VALUE).doubleValue()); } /** @@ -196,10 +196,10 @@ */ public void test_intValue() { // Test for method int java.lang.Short.intValue() - assertTrue("Returned incorrect int value", new Short(Short.MIN_VALUE) - .intValue() == -32768); - assertTrue("Returned incorrect int value", new Short(Short.MAX_VALUE) - .intValue() == 32767); + assertEquals("Returned incorrect int value", -32768, new Short(Short.MIN_VALUE) + .intValue()); + assertEquals("Returned incorrect int value", 32767, new Short(Short.MAX_VALUE) + .intValue()); } /** @@ -207,10 +207,10 @@ */ public void test_longValue() { // Test for method long java.lang.Short.longValue() - assertTrue("Returned incorrect long value", new Short(Short.MIN_VALUE) - .longValue() == -32768); - assertTrue("Returned incorrect long value", new Short(Short.MAX_VALUE) - .longValue() == 32767); + assertEquals("Returned incorrect long value", -32768, new Short(Short.MIN_VALUE) + .longValue()); + assertEquals("Returned incorrect long value", 32767, new Short(Short.MAX_VALUE) + .longValue()); } /** @@ -223,7 +223,7 @@ assertTrue("Incorrect parse of short", sp == (short) 32746 && (sn == (short) -32746)); - assertTrue("Returned incorrect value for 0", Short.parseShort("0") == 0); + assertEquals("Returned incorrect value for 0", 0, Short.parseShort("0")); assertTrue("Returned incorrect value for most negative value", Short .parseShort("-32768") == (short) 0x8000); assertTrue("Returned incorrect value for most positive value", Short @@ -255,28 +255,28 @@ // Test for method short java.lang.Short.parseShort(java.lang.String, // int) boolean aThrow = true; - assertTrue("Incorrectly parsed hex string", - Short.parseShort("FF", 16) == 255); - assertTrue("Incorrectly parsed oct string", - Short.parseShort("20", 8) == 16); - assertTrue("Incorrectly parsed dec string", - Short.parseShort("20", 10) == 20); - assertTrue("Incorrectly parsed bin string", - Short.parseShort("100", 2) == 4); - assertTrue("Incorrectly parsed -hex string", Short - .parseShort("-FF", 16) == -255); - assertTrue("Incorrectly parsed -oct string", - Short.parseShort("-20", 8) == -16); - assertTrue("Incorrectly parsed -bin string", Short - .parseShort("-100", 2) == -4); - assertTrue("Returned incorrect value for 0 hex", Short.parseShort("0", - 16) == 0); + assertEquals("Incorrectly parsed hex string", + 255, Short.parseShort("FF", 16)); + assertEquals("Incorrectly parsed oct string", + 16, Short.parseShort("20", 8)); + assertEquals("Incorrectly parsed dec string", + 20, Short.parseShort("20", 10)); + assertEquals("Incorrectly parsed bin string", + 4, Short.parseShort("100", 2)); + assertEquals("Incorrectly parsed -hex string", -255, Short + .parseShort("-FF", 16)); + assertEquals("Incorrectly parsed -oct string", + -16, Short.parseShort("-20", 8)); + assertEquals("Incorrectly parsed -bin string", -4, Short + .parseShort("-100", 2)); + assertEquals("Returned incorrect value for 0 hex", 0, Short.parseShort("0", + 16)); assertTrue("Returned incorrect value for most negative value hex", Short.parseShort("-8000", 16) == (short) 0x8000); assertTrue("Returned incorrect value for most positive value hex", Short.parseShort("7fff", 16) == 0x7fff); - assertTrue("Returned incorrect value for 0 decimal", Short.parseShort( - "0", 10) == 0); + assertEquals("Returned incorrect value for 0 decimal", 0, Short.parseShort( + "0", 10)); assertTrue("Returned incorrect value for most negative value decimal", Short.parseShort("-32768", 10) == (short) 0x8000); assertTrue("Returned incorrect value for most positive value decimal", @@ -357,12 +357,12 @@ // Test for method java.lang.String java.lang.Short.toString() assertTrue("Invalid string returned", sp.toString().equals("18000") && (sn.toString().equals("-19000"))); - assertTrue("Returned incorrect string", new Short((short) 32767) - .toString().equals("32767")); - assertTrue("Returned incorrect string", new Short((short) -32767) - .toString().equals("-32767")); - assertTrue("Returned incorrect string", new Short((short) -32768) - .toString().equals("-32768")); + assertEquals("Returned incorrect string", "32767", new Short((short) 32767) + .toString()); + assertEquals("Returned incorrect string", "-32767", new Short((short) -32767) + .toString()); + assertEquals("Returned incorrect string", "-32768", new Short((short) -32768) + .toString()); } /** @@ -370,12 +370,12 @@ */ public void test_toStringS() { // Test for method java.lang.String java.lang.Short.toString(short) - assertTrue("Returned incorrect string", Short.toString((short) 32767) - .equals("32767")); - assertTrue("Returned incorrect string", Short.toString((short) -32767) - .equals("-32767")); - assertTrue("Returned incorrect string", Short.toString((short) -32768) - .equals("-32768")); + assertEquals("Returned incorrect string", "32767", Short.toString((short) 32767) + ); + assertEquals("Returned incorrect string", "-32767", Short.toString((short) -32767) + ); + assertEquals("Returned incorrect string", "-32768", Short.toString((short) -32768) + ); } /** @@ -384,10 +384,10 @@ public void test_valueOfLjava_lang_String() { // Test for method java.lang.Short // java.lang.Short.valueOf(java.lang.String) - assertTrue("Returned incorrect short", Short.valueOf("-32768") - .shortValue() == -32768); - assertTrue("Returned incorrect short", Short.valueOf("32767") - .shortValue() == 32767); + assertEquals("Returned incorrect short", -32768, Short.valueOf("-32768") + .shortValue()); + assertEquals("Returned incorrect short", 32767, Short.valueOf("32767") + .shortValue()); } /** @@ -397,20 +397,20 @@ // Test for method java.lang.Short // java.lang.Short.valueOf(java.lang.String, int) boolean aThrow = true; - assertTrue("Incorrectly parsed hex string", Short.valueOf("FF", 16) - .shortValue() == 255); - assertTrue("Incorrectly parsed oct string", Short.valueOf("20", 8) - .shortValue() == 16); - assertTrue("Incorrectly parsed dec string", Short.valueOf("20", 10) - .shortValue() == 20); - assertTrue("Incorrectly parsed bin string", Short.valueOf("100", 2) - .shortValue() == 4); - assertTrue("Incorrectly parsed -hex string", Short.valueOf("-FF", 16) - .shortValue() == -255); - assertTrue("Incorrectly parsed -oct string", Short.valueOf("-20", 8) - .shortValue() == -16); - assertTrue("Incorrectly parsed -bin string", Short.valueOf("-100", 2) - .shortValue() == -4); + assertEquals("Incorrectly parsed hex string", 255, Short.valueOf("FF", 16) + .shortValue()); + assertEquals("Incorrectly parsed oct string", 16, Short.valueOf("20", 8) + .shortValue()); + assertEquals("Incorrectly parsed dec string", 20, Short.valueOf("20", 10) + .shortValue()); + assertEquals("Incorrectly parsed bin string", 4, Short.valueOf("100", 2) + .shortValue()); + assertEquals("Incorrectly parsed -hex string", -255, Short.valueOf("-FF", 16) + .shortValue()); + assertEquals("Incorrectly parsed -oct string", -16, Short.valueOf("-20", 8) + .shortValue()); + assertEquals("Incorrectly parsed -bin string", -4, Short.valueOf("-100", 2) + .shortValue()); assertTrue("Did not decode 32767 correctly", Short.valueOf("32767", 10) .shortValue() == (short) 32767); assertTrue("Did not decode -32767 correctly", Short.valueOf("-32767", Index: modules/luni/src/test/java/tests/api/java/lang/LongTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/LongTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/LongTest.java (working copy) @@ -27,7 +27,7 @@ // Test for method java.lang.Long(long) Long l = new Long(-8900000006L); - assertTrue("Created incorrect Long", l.longValue() == -8900000006L); + assertEquals("Created incorrect Long", -8900000006L, l.longValue()); } /** @@ -37,7 +37,7 @@ // Test for method java.lang.Long(java.lang.String) Long l = new Long("-8900000006"); - assertTrue("Created incorrect Long", l.longValue() == -8900000006L); + assertEquals("Created incorrect Long", -8900000006L, l.longValue()); } /** @@ -46,9 +46,9 @@ public void test_byteValue() { // Test for method byte java.lang.Long.byteValue() Long l = new Long(127); - assertTrue("Returned incorrect byte value", l.byteValue() == 127); - assertTrue("Returned incorrect byte value", new Long(Long.MAX_VALUE) - .byteValue() == -1); + assertEquals("Returned incorrect byte value", 127, l.byteValue()); + assertEquals("Returned incorrect byte value", -1, new Long(Long.MAX_VALUE) + .byteValue()); } /** @@ -58,8 +58,8 @@ // Test for method int java.lang.Long.compareTo(java.lang.Long) assertTrue("-2 compared to 1 gave non-negative answer", new Long(-2L) .compareTo(new Long(1L)) < 0); - assertTrue("-2 compared to -2 gave non-zero answer", new Long(-2L) - .compareTo(new Long(-2L)) == 0); + assertEquals("-2 compared to -2 gave non-zero answer", 0, new Long(-2L) + .compareTo(new Long(-2L))); assertTrue("3 compared to 2 gave non-positive answer", new Long(3L) .compareTo(new Long(2L)) > 0); @@ -76,14 +76,14 @@ public void test_decodeLjava_lang_String() { // Test for method java.lang.Long // java.lang.Long.decode(java.lang.String) - assertTrue("Returned incorrect value for hex string", Long.decode( - "0xFF").longValue() == 255L); - assertTrue("Returned incorrect value for dec string", Long.decode( - "-89000").longValue() == -89000L); - assertTrue("Returned incorrect value for 0 decimal", Long.decode("0") - .longValue() == 0); - assertTrue("Returned incorrect value for 0 hex", Long.decode("0x0") - .longValue() == 0); + assertEquals("Returned incorrect value for hex string", 255L, Long.decode( + "0xFF").longValue()); + assertEquals("Returned incorrect value for dec string", -89000L, Long.decode( + "-89000").longValue()); + assertEquals("Returned incorrect value for 0 decimal", 0, Long.decode("0") + .longValue()); + assertEquals("Returned incorrect value for 0 hex", 0, Long.decode("0x0") + .longValue()); assertTrue( "Returned incorrect value for most negative value decimal", Long.decode("-9223372036854775808").longValue() == 0x8000000000000000L); @@ -162,8 +162,8 @@ public void test_doubleValue() { // Test for method double java.lang.Long.doubleValue() Long l = new Long(10000000); - assertTrue("Returned incorrect double value", - l.doubleValue() == 10000000.0); + assertEquals("Returned incorrect double value", + 10000000.0, l.doubleValue()); } @@ -200,8 +200,8 @@ System.setProperties(tProps); assertTrue("returned incorrect Long", Long.getLong("testLong").equals( new Long(99))); - assertTrue("returned incorrect default Long", - Long.getLong("ff") == null); + assertNull("returned incorrect default Long", + Long.getLong("ff")); } /** @@ -255,9 +255,9 @@ public void test_intValue() { // Test for method int java.lang.Long.intValue() Long l = new Long(100000); - assertTrue("Returned incorrect int value", l.intValue() == 100000); - assertTrue("Returned incorrect int value", new Long(Long.MAX_VALUE) - .intValue() == -1); + assertEquals("Returned incorrect int value", 100000, l.intValue()); + assertEquals("Returned incorrect int value", -1, new Long(Long.MAX_VALUE) + .intValue()); } /** @@ -266,8 +266,8 @@ public void test_longValue() { // Test for method long java.lang.Long.longValue() Long l = new Long(89000000005L); - assertTrue("Returned incorrect long value", - l.longValue() == 89000000005L); + assertEquals("Returned incorrect long value", + 89000000005L, l.longValue()); } /** @@ -277,8 +277,8 @@ // Test for method long java.lang.Long.parseLong(java.lang.String) long l = Long.parseLong("89000000005"); - assertTrue("Parsed to incorrect long value", l == 89000000005L); - assertTrue("Returned incorrect value for 0", Long.parseLong("0") == 0); + assertEquals("Parsed to incorrect long value", 89000000005L, l); + assertEquals("Returned incorrect value for 0", 0, Long.parseLong("0")); assertTrue("Returned incorrect value for most negative value", Long .parseLong("-9223372036854775808") == 0x8000000000000000L); assertTrue("Returned incorrect value for most positive value", Long @@ -308,21 +308,21 @@ */ public void test_parseLongLjava_lang_StringI() { // Test for method long java.lang.Long.parseLong(java.lang.String, int) - assertTrue("Returned incorrect value", - Long.parseLong("100000000", 10) == 100000000L); - assertTrue("Returned incorrect value from hex string", Long.parseLong( - "FFFFFFFFF", 16) == 68719476735L); + assertEquals("Returned incorrect value", + 100000000L, Long.parseLong("100000000", 10)); + assertEquals("Returned incorrect value from hex string", 68719476735L, Long.parseLong( + "FFFFFFFFF", 16)); assertTrue("Returned incorrect value from octal string: " + Long.parseLong("77777777777"), Long.parseLong("77777777777", 8) == 8589934591L); - assertTrue("Returned incorrect value for 0 hex", Long - .parseLong("0", 16) == 0); + assertEquals("Returned incorrect value for 0 hex", 0, Long + .parseLong("0", 16)); assertTrue("Returned incorrect value for most negative value hex", Long .parseLong("-8000000000000000", 16) == 0x8000000000000000L); assertTrue("Returned incorrect value for most positive value hex", Long .parseLong("7fffffffffffffff", 16) == 0x7fffffffffffffffL); - assertTrue("Returned incorrect value for 0 decimal", Long.parseLong( - "0", 10) == 0); + assertEquals("Returned incorrect value for 0 decimal", 0, Long.parseLong( + "0", 10)); assertTrue( "Returned incorrect value for most negative value decimal", Long.parseLong("-9223372036854775808", 10) == 0x8000000000000000L); @@ -393,9 +393,9 @@ public void test_shortValue() { // Test for method short java.lang.Long.shortValue() Long l = new Long(10000); - assertTrue("Returned incorrect short value", l.shortValue() == 10000); - assertTrue("Returned incorrect short value", new Long(Long.MAX_VALUE) - .shortValue() == -1); + assertEquals("Returned incorrect short value", 10000, l.shortValue()); + assertEquals("Returned incorrect short value", -1, new Long(Long.MAX_VALUE) + .shortValue()); } /** @@ -403,20 +403,18 @@ */ public void test_toBinaryStringJ() { // Test for method java.lang.String java.lang.Long.toBinaryString(long) - assertTrue("Incorrect binary string returned", Long.toBinaryString( - 890000L).equals("11011001010010010000")); - assertTrue( - "Incorrect binary string returned", - Long + assertEquals("Incorrect binary string returned", "11011001010010010000", Long.toBinaryString( + 890000L)); + assertEquals("Incorrect binary string returned", + + "1000000000000000000000000000000000000000000000000000000000000000", Long .toBinaryString(Long.MIN_VALUE) - .equals( - "1000000000000000000000000000000000000000000000000000000000000000")); - assertTrue( - "Incorrect binary string returned", - Long + ); + assertEquals("Incorrect binary string returned", + + "111111111111111111111111111111111111111111111111111111111111111", Long .toBinaryString(Long.MAX_VALUE) - .equals( - "111111111111111111111111111111111111111111111111111111111111111")); + ); } /** @@ -424,12 +422,12 @@ */ public void test_toHexStringJ() { // Test for method java.lang.String java.lang.Long.toHexString(long) - assertTrue("Incorrect hex string returned", Long.toHexString(89000005L) - .equals("54e0845")); - assertTrue("Incorrect hex string returned", Long.toHexString( - Long.MIN_VALUE).equals("8000000000000000")); - assertTrue("Incorrect hex string returned", Long.toHexString( - Long.MAX_VALUE).equals("7fffffffffffffff")); + assertEquals("Incorrect hex string returned", "54e0845", Long.toHexString(89000005L) + ); + assertEquals("Incorrect hex string returned", "8000000000000000", Long.toHexString( + Long.MIN_VALUE)); + assertEquals("Incorrect hex string returned", "7fffffffffffffff", Long.toHexString( + Long.MAX_VALUE)); } /** @@ -437,12 +435,12 @@ */ public void test_toOctalStringJ() { // Test for method java.lang.String java.lang.Long.toOctalString(long) - assertTrue("Returned incorrect oct string", Long.toOctalString( - 8589934591L).equals("77777777777")); - assertTrue("Returned incorrect oct string", Long.toOctalString( - Long.MIN_VALUE).equals("1000000000000000000000")); - assertTrue("Returned incorrect oct string", Long.toOctalString( - Long.MAX_VALUE).equals("777777777777777777777")); + assertEquals("Returned incorrect oct string", "77777777777", Long.toOctalString( + 8589934591L)); + assertEquals("Returned incorrect oct string", "1000000000000000000000", Long.toOctalString( + Long.MIN_VALUE)); + assertEquals("Returned incorrect oct string", "777777777777777777777", Long.toOctalString( + Long.MAX_VALUE)); } /** @@ -451,12 +449,12 @@ public void test_toString() { // Test for method java.lang.String java.lang.Long.toString() Long l = new Long(89000000005L); - assertTrue("Returned incorrect String", l.toString().equals( - "89000000005")); - assertTrue("Returned incorrect String", new Long(Long.MIN_VALUE) - .toString().equals("-9223372036854775808")); - assertTrue("Returned incorrect String", new Long(Long.MAX_VALUE) - .toString().equals("9223372036854775807")); + assertEquals("Returned incorrect String", + "89000000005", l.toString()); + assertEquals("Returned incorrect String", "-9223372036854775808", new Long(Long.MIN_VALUE) + .toString()); + assertEquals("Returned incorrect String", "9223372036854775807", new Long(Long.MAX_VALUE) + .toString()); } /** @@ -465,12 +463,12 @@ public void test_toStringJ() { // Test for method java.lang.String java.lang.Long.toString(long) - assertTrue("Returned incorrect String", Long.toString(89000000005L) - .equals("89000000005")); - assertTrue("Returned incorrect String", Long.toString(Long.MIN_VALUE) - .equals("-9223372036854775808")); - assertTrue("Returned incorrect String", Long.toString(Long.MAX_VALUE) - .equals("9223372036854775807")); + assertEquals("Returned incorrect String", "89000000005", Long.toString(89000000005L) + ); + assertEquals("Returned incorrect String", "-9223372036854775808", Long.toString(Long.MIN_VALUE) + ); + assertEquals("Returned incorrect String", "9223372036854775807", Long.toString(Long.MAX_VALUE) + ); } /** @@ -478,23 +476,23 @@ */ public void test_toStringJI() { // Test for method java.lang.String java.lang.Long.toString(long, int) - assertTrue("Returned incorrect dec string", Long.toString(100000000L, - 10).equals("100000000")); - assertTrue("Returned incorrect hex string", Long.toString(68719476735L, - 16).equals("fffffffff")); - assertTrue("Returned incorrect oct string", Long.toString(8589934591L, - 8).equals("77777777777")); - assertTrue("Returned incorrect bin string", Long.toString( - 8796093022207L, 2).equals( - "1111111111111111111111111111111111111111111")); - assertTrue("Returned incorrect min string", Long.toString( - 0x8000000000000000L, 10).equals("-9223372036854775808")); - assertTrue("Returned incorrect max string", Long.toString( - 0x7fffffffffffffffL, 10).equals("9223372036854775807")); - assertTrue("Returned incorrect min string", Long.toString( - 0x8000000000000000L, 16).equals("-8000000000000000")); - assertTrue("Returned incorrect max string", Long.toString( - 0x7fffffffffffffffL, 16).equals("7fffffffffffffff")); + assertEquals("Returned incorrect dec string", "100000000", Long.toString(100000000L, + 10)); + assertEquals("Returned incorrect hex string", "fffffffff", Long.toString(68719476735L, + 16)); + assertEquals("Returned incorrect oct string", "77777777777", Long.toString(8589934591L, + 8)); + assertEquals("Returned incorrect bin string", + "1111111111111111111111111111111111111111111", Long.toString( + 8796093022207L, 2)); + assertEquals("Returned incorrect min string", "-9223372036854775808", Long.toString( + 0x8000000000000000L, 10)); + assertEquals("Returned incorrect max string", "9223372036854775807", Long.toString( + 0x7fffffffffffffffL, 10)); + assertEquals("Returned incorrect min string", "-8000000000000000", Long.toString( + 0x8000000000000000L, 16)); + assertEquals("Returned incorrect max string", "7fffffffffffffff", Long.toString( + 0x7fffffffffffffffL, 16)); } /** @@ -503,8 +501,8 @@ public void test_valueOfLjava_lang_String() { // Test for method java.lang.Long // java.lang.Long.valueOf(java.lang.String) - assertTrue("Returned incorrect value", Long.valueOf("100000000") - .longValue() == 100000000L); + assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000") + .longValue()); assertTrue("Returned incorrect value", Long.valueOf( "9223372036854775807").longValue() == Long.MAX_VALUE); assertTrue("Returned incorrect value", Long.valueOf( @@ -548,10 +546,10 @@ public void test_valueOfLjava_lang_StringI() { // Test for method java.lang.Long // java.lang.Long.valueOf(java.lang.String, int) - assertTrue("Returned incorrect value", Long.valueOf("100000000", 10) - .longValue() == 100000000L); - assertTrue("Returned incorrect value from hex string", Long.valueOf( - "FFFFFFFFF", 16).longValue() == 68719476735L); + assertEquals("Returned incorrect value", 100000000L, Long.valueOf("100000000", 10) + .longValue()); + assertEquals("Returned incorrect value from hex string", 68719476735L, Long.valueOf( + "FFFFFFFFF", 16).longValue()); assertTrue("Returned incorrect value from octal string: " + Long.valueOf("77777777777", 8).toString(), Long.valueOf( "77777777777", 8).longValue() == 8589934591L); Index: modules/luni/src/test/java/tests/api/java/lang/ByteTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/ByteTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/ByteTest.java (working copy) @@ -58,8 +58,8 @@ (byte) 2)) < 0); assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte( (byte) -2)) > 0); - assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte( - (byte) 1)) == 0); + assertEquals("Comparison failed", 0, new Byte((byte) 1).compareTo(new Byte( + (byte) 1))); } /** @@ -159,8 +159,8 @@ */ public void test_hashCode() { // Test for method int java.lang.Byte.hashCode() - assertTrue("Incorrect hash returned", - new Byte((byte) 127).hashCode() == 127); + assertEquals("Incorrect hash returned", + 127, new Byte((byte) 127).hashCode()); } /** @@ -168,8 +168,8 @@ */ public void test_intValue() { // Test for method int java.lang.Byte.intValue() - assertTrue("Returned incorrect int value", new Byte((byte) 127) - .intValue() == 127); + assertEquals("Returned incorrect int value", 127, new Byte((byte) 127) + .intValue()); } /** @@ -177,8 +177,8 @@ */ public void test_longValue() { // Test for method long java.lang.Byte.longValue() - assertTrue("Returned incorrect long value", new Byte((byte) 127) - .longValue() == 127L); + assertEquals("Returned incorrect long value", 127L, new Byte((byte) 127) + .longValue()); } /** @@ -191,7 +191,7 @@ byte bn = Byte.parseByte("-128"); assertTrue("Invalid parse of byte", b == (byte) 127 && (bn == (byte) -128)); - assertTrue("Returned incorrect value for 0", Byte.parseByte("0") == 0); + assertEquals("Returned incorrect value for 0", 0, Byte.parseByte("0")); assertTrue("Returned incorrect value for most negative value", Byte .parseByte("-128") == (byte) 0x80); assertTrue("Returned incorrect value for most positive value", Byte @@ -234,15 +234,15 @@ byte bn = Byte.parseByte("-128", 10); assertTrue("Invalid parse of dec byte", b == (byte) 127 && (bn == (byte) -128)); - assertTrue("Failed to parse hex value", Byte.parseByte("A", 16) == 10); - assertTrue("Returned incorrect value for 0 hex", Byte - .parseByte("0", 16) == 0); + assertEquals("Failed to parse hex value", 10, Byte.parseByte("A", 16)); + assertEquals("Returned incorrect value for 0 hex", 0, Byte + .parseByte("0", 16)); assertTrue("Returned incorrect value for most negative value hex", Byte .parseByte("-80", 16) == (byte) 0x80); assertTrue("Returned incorrect value for most positive value hex", Byte .parseByte("7f", 16) == 0x7f); - assertTrue("Returned incorrect value for 0 decimal", Byte.parseByte( - "0", 10) == 0); + assertEquals("Returned incorrect value for 0 decimal", 0, Byte.parseByte( + "0", 10)); assertTrue("Returned incorrect value for most negative value decimal", Byte.parseByte("-128", 10) == (byte) 0x80); assertTrue("Returned incorrect value for most positive value decimal", @@ -308,12 +308,12 @@ */ public void test_toString() { // Test for method java.lang.String java.lang.Byte.toString() - assertTrue("Returned incorrect String", new Byte((byte) 127).toString() - .equals("127")); - assertTrue("Returned incorrect String", new Byte((byte) -127) - .toString().equals("-127")); - assertTrue("Returned incorrect String", new Byte((byte) -128) - .toString().equals("-128")); + assertEquals("Returned incorrect String", "127", new Byte((byte) 127).toString() + ); + assertEquals("Returned incorrect String", "-127", new Byte((byte) -127) + .toString()); + assertEquals("Returned incorrect String", "-128", new Byte((byte) -128) + .toString()); } /** @@ -321,12 +321,12 @@ */ public void test_toStringB() { // Test for method java.lang.String java.lang.Byte.toString(byte) - assertTrue("Returned incorrect String", Byte.toString((byte) 127) - .equals("127")); - assertTrue("Returned incorrect String", Byte.toString((byte) -127) - .equals("-127")); - assertTrue("Returned incorrect String", Byte.toString((byte) -128) - .equals("-128")); + assertEquals("Returned incorrect String", "127", Byte.toString((byte) 127) + ); + assertEquals("Returned incorrect String", "-127", Byte.toString((byte) -127) + ); + assertEquals("Returned incorrect String", "-128", Byte.toString((byte) -128) + ); } /** @@ -335,14 +335,14 @@ public void test_valueOfLjava_lang_String() { // Test for method java.lang.Byte // java.lang.Byte.valueOf(java.lang.String) - assertTrue("Returned incorrect byte", - Byte.valueOf("0").byteValue() == 0); - assertTrue("Returned incorrect byte", - Byte.valueOf("127").byteValue() == 127); - assertTrue("Returned incorrect byte", - Byte.valueOf("-127").byteValue() == -127); - assertTrue("Returned incorrect byte", - Byte.valueOf("-128").byteValue() == -128); + assertEquals("Returned incorrect byte", + 0, Byte.valueOf("0").byteValue()); + assertEquals("Returned incorrect byte", + 127, Byte.valueOf("127").byteValue()); + assertEquals("Returned incorrect byte", + -127, Byte.valueOf("-127").byteValue()); + assertEquals("Returned incorrect byte", + -128, Byte.valueOf("-128").byteValue()); try { Byte.valueOf("128"); @@ -359,20 +359,20 @@ public void test_valueOfLjava_lang_StringI() { // Test for method java.lang.Byte // java.lang.Byte.valueOf(java.lang.String, int) - assertTrue("Returned incorrect byte", - Byte.valueOf("A", 16).byteValue() == 10); - assertTrue("Returned incorrect byte", Byte.valueOf("127", 10) - .byteValue() == 127); - assertTrue("Returned incorrect byte", Byte.valueOf("-127", 10) - .byteValue() == -127); - assertTrue("Returned incorrect byte", Byte.valueOf("-128", 10) - .byteValue() == -128); - assertTrue("Returned incorrect byte", Byte.valueOf("7f", 16) - .byteValue() == 127); - assertTrue("Returned incorrect byte", Byte.valueOf("-7f", 16) - .byteValue() == -127); - assertTrue("Returned incorrect byte", Byte.valueOf("-80", 16) - .byteValue() == -128); + assertEquals("Returned incorrect byte", + 10, Byte.valueOf("A", 16).byteValue()); + assertEquals("Returned incorrect byte", 127, Byte.valueOf("127", 10) + .byteValue()); + assertEquals("Returned incorrect byte", -127, Byte.valueOf("-127", 10) + .byteValue()); + assertEquals("Returned incorrect byte", -128, Byte.valueOf("-128", 10) + .byteValue()); + assertEquals("Returned incorrect byte", 127, Byte.valueOf("7f", 16) + .byteValue()); + assertEquals("Returned incorrect byte", -127, Byte.valueOf("-7f", 16) + .byteValue()); + assertEquals("Returned incorrect byte", -128, Byte.valueOf("-80", 16) + .byteValue()); try { Byte.valueOf("128", 10); Index: modules/luni/src/test/java/tests/api/java/lang/FloatTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/FloatTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/FloatTest.java (working copy) @@ -349,11 +349,10 @@ * @tests java.lang.Float#parseFloat(java.lang.String) */ public void test_parseFloatLjava_lang_String() { - assertTrue("Incorrect float returned, expected zero.", Float - .parseFloat("7.0064923216240853546186479164495e-46") == 0.0); - assertTrue( - "Incorrect float returned, expected minimum float.", - Float.parseFloat("7.0064923216240853546186479164496e-46") == Float.MIN_VALUE); + assertEquals("Incorrect float returned, expected zero.", + 0.0, Float.parseFloat("7.0064923216240853546186479164495e-46"), 0.0); + assertEquals("Incorrect float returned, expected minimum float.", + Float.MIN_VALUE, Float.parseFloat("7.0064923216240853546186479164496e-46"), 0.0); doTestCompareRawBits( "0.000000000000000000000000000000000000011754942807573642917278829910357665133228589927589904276829631184250030649651730385585324256680905818939208984375", Index: modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java (working copy) @@ -290,8 +290,8 @@ public void test_ConstructorD() { // Test for method java.lang.Double(double) Double d = new Double(39089.88888888888888888888888888888888); - assertTrue("Created incorrect double", - d.doubleValue() == 39089.88888888888888888888888888888888); + assertEquals("Created incorrect double", + 39089.88888888888888888888888888888888, d.doubleValue()); } /** @@ -301,8 +301,8 @@ // Test for method java.lang.Double(java.lang.String) Double d = new Double("39089.88888888888888888888888888888888"); - assertTrue("Created incorrect double", - d.doubleValue() == 39089.88888888888888888888888888888888); + assertEquals("Created incorrect double", + 39089.88888888888888888888888888888888, d.doubleValue()); } /** @@ -377,9 +377,8 @@ */ public void test_doubleValue() { // Test for method double java.lang.Double.doubleValue() - assertTrue( - "Incorrect double value returned", - new Double(999999999999999.9999999999999).doubleValue() == 999999999999999.9999999999999); + assertEquals("Incorrect double value returned", + 999999999999999.9999999999999, new Double(999999999999999.9999999999999).doubleValue()); } /** @@ -428,8 +427,8 @@ assertTrue("Invalid hash for equal but not identical doubles ", d .hashCode() == dd.hashCode()); } - assertTrue("Magic assumption hasCode (0.0) = 0 failed", new Double(0.0) - .hashCode() == 0); + assertEquals("Magic assumption hasCode (0.0) = 0 failed", 0, new Double(0.0) + .hashCode()); } /** @@ -438,7 +437,7 @@ public void test_intValue() { // Test for method int java.lang.Double.intValue() Double d = new Double(1923311.47712); - assertTrue("Returned incorrect int value", d.intValue() == 1923311); + assertEquals("Returned incorrect int value", 1923311, d.intValue()); } /** @@ -505,15 +504,15 @@ public void test_longValue() { // Test for method long java.lang.Double.longValue() Double d = new Double(1923311.47712); - assertTrue("Returned incorrect long value", d.longValue() == 1923311); + assertEquals("Returned incorrect long value", 1923311, d.longValue()); } /** * @tests java.lang.Double#parseDouble(java.lang.String) */ public void test_parseDoubleLjava_lang_String() { - assertTrue("Incorrect double returned, expected zero.", Double - .parseDouble("2.4703282292062327208828439643411e-324") == 0.0); + assertEquals("Incorrect double returned, expected zero.", 0.0, Double + .parseDouble("2.4703282292062327208828439643411e-324")); assertTrue( "Incorrect double returned, expected minimum double.", Double.parseDouble("2.4703282292062327208828439643412e-324") == Double.MIN_VALUE); @@ -669,7 +668,7 @@ public void test_shortValue() { // Test for method short java.lang.Double.shortValue() Double d = new Double(1923311.47712); - assertTrue("Returned incorrect short value", d.shortValue() == 22767); + assertEquals("Returned incorrect short value", 22767, d.shortValue()); } /** Index: modules/luni/src/test/java/tests/api/java/lang/CompilerTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/CompilerTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/CompilerTest.java (working copy) @@ -24,8 +24,8 @@ // Test for method java.lang.Object // java.lang.Compiler.command(java.lang.Object) try { - assertTrue("Incorrect behavior.", - Compiler.command(new Object()) == null); + assertNull("Incorrect behavior.", + Compiler.command(new Object())); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/VerifyErrorTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/lang/InternalErrorTest.java (working copy) @@ -41,8 +41,8 @@ if (true) throw new InternalError("Test"); } catch (InternalError e) { - assertTrue("Returned incorrect message", e.getMessage().equals( - "Test")); + assertEquals("Returned incorrect message", + "Test", e.getMessage()); return; } fail("Failed to throw Runtime Exception"); Index: modules/luni/src/test/java/tests/api/java/net/URITest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/URITest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/URITest.java (working copy) @@ -253,15 +253,15 @@ URI uri; try { uri = new URI("mailto", "mduerst@ifi.unizh.ch", null); - assertTrue("wrong userinfo", uri.getUserInfo() == null); - assertTrue("wrong hostname", uri.getHost() == null); - assertTrue("wrong authority", uri.getAuthority() == null); - assertTrue("wrong port number", uri.getPort() == -1); - assertTrue("wrong path", uri.getPath() == null); - assertTrue("wrong query", uri.getQuery() == null); - assertTrue("wrong fragment", uri.getFragment() == null); - assertTrue("wrong SchemeSpecificPart", uri.getSchemeSpecificPart() - .equals("mduerst@ifi.unizh.ch")); + assertNull("wrong userinfo", uri.getUserInfo()); + assertNull("wrong hostname", uri.getHost()); + assertNull("wrong authority", uri.getAuthority()); + assertEquals("wrong port number", -1, uri.getPort()); + assertNull("wrong path", uri.getPath()); + assertNull("wrong query", uri.getQuery()); + assertNull("wrong fragment", uri.getFragment()); + assertEquals("wrong SchemeSpecificPart", "mduerst@ifi.unizh.ch", uri.getSchemeSpecificPart() + ); } catch (URISyntaxException e) { fail("Unexpected Exception: " + e); } @@ -350,14 +350,14 @@ try { uri = new URI("http", "us:e@r", "hostname", 85, "/file/dir#/qu?e/", "qu?er#y", "frag#me?nt"); - assertTrue("wrong userinfo", uri.getUserInfo().equals("us:e@r")); - assertTrue("wrong hostname", uri.getHost().equals("hostname")); - assertTrue("wrong port number", uri.getPort() == 85); - assertTrue("wrong path", uri.getPath().equals("/file/dir#/qu?e/")); - assertTrue("wrong query", uri.getQuery().equals("qu?er#y")); - assertTrue("wrong fragment", uri.getFragment().equals("frag#me?nt")); - assertTrue("wrong SchemeSpecificPart", uri.getSchemeSpecificPart() - .equals("//us:e@r@hostname:85/file/dir#/qu?e/?qu?er#y")); + assertEquals("wrong userinfo", "us:e@r", uri.getUserInfo()); + assertEquals("wrong hostname", "hostname", uri.getHost()); + assertEquals("wrong port number", 85, uri.getPort()); + assertEquals("wrong path", "/file/dir#/qu?e/", uri.getPath()); + assertEquals("wrong query", "qu?er#y", uri.getQuery()); + assertEquals("wrong fragment", "frag#me?nt", uri.getFragment()); + assertEquals("wrong SchemeSpecificPart", "//us:e@r@hostname:85/file/dir#/qu?e/?qu?er#y", uri.getSchemeSpecificPart() + ); } catch (URISyntaxException e) { fail("Unexpected Exception: " + e); } @@ -447,29 +447,28 @@ fail("Unexpected URISyntaxException: " + e); } - assertTrue("wrong scheme", uri.getScheme().equals("ht12-3+tp")); - assertTrue("wrong authority", uri.getUserInfo() == null); - assertTrue("wrong userinfo", uri.getUserInfo() == null); - assertTrue("wrong hostname", uri.getHost() == null); - assertTrue("wrong port number", uri.getPort() == -1); - assertTrue("wrong path", uri.getPath().equals("/p#a%E2%82%ACth")); - assertTrue("wrong query", uri.getQuery().equals("q^u%25ery")); - assertTrue("wrong fragment", uri.getFragment().equals("f/r\u00DFag")); + assertEquals("wrong scheme", "ht12-3+tp", uri.getScheme()); + assertNull("wrong authority", uri.getUserInfo()); + assertNull("wrong userinfo", uri.getUserInfo()); + assertNull("wrong hostname", uri.getHost()); + assertEquals("wrong port number", -1, uri.getPort()); + assertEquals("wrong path", "/p#a%E2%82%ACth", uri.getPath()); + assertEquals("wrong query", "q^u%25ery", uri.getQuery()); + assertEquals("wrong fragment", "f/r\u00DFag", uri.getFragment()); // equivalent to = assertTrue("wrong fragment", // uri.getFragment().equals("f/r\u00dfag")); - assertTrue("wrong SchemeSpecificPart", uri.getSchemeSpecificPart() - .equals("///p#a%E2%82%ACth?q^u%25ery")); - assertTrue("wrong RawSchemeSpecificPart", uri - .getRawSchemeSpecificPart().equals( - "///p%23a%25E2%2582%25ACth?q%5Eu%2525ery")); - assertTrue("incorrect toString()", uri.toString().equals( - "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r\u00dfag")); - assertTrue( - "incorrect toASCIIString()", - uri + assertEquals("wrong SchemeSpecificPart", "///p#a%E2%82%ACth?q^u%25ery", uri.getSchemeSpecificPart() + ); + assertEquals("wrong RawSchemeSpecificPart", + "///p%23a%25E2%2582%25ACth?q%5Eu%2525ery", uri + .getRawSchemeSpecificPart()); + assertEquals("incorrect toString()", + "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r\u00dfag", uri.toString()); + assertEquals("incorrect toASCIIString()", + + "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r%C3%9Fag", uri .toASCIIString() - .equals( - "ht12-3+tp:///p%23a%25E2%2582%25ACth?q%5Eu%2525ery#f/r%C3%9Fag")); + ); } /** Index: modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/MulticastSocketTest.java (working copy) @@ -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 Index: modules/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/URLClassLoaderTest.java (working copy) @@ -74,8 +74,8 @@ URL[] u = new URL[0]; ucl = new URLClassLoader(u, cl); URL res = ucl.getResource("J"); - assertTrue("Failed to set parent", res == null ? false : res.getFile() - .equals("/BogusClassLoader")); + assertEquals("Failed to set parent", "/BogusClassLoader", res == null ? false : res.getFile() + ); } /** @@ -162,10 +162,10 @@ try { res = cl.getClassLoader().getResource("XX.class"); - assertTrue("Failed to load class", cl != null); - assertTrue( + assertNotNull("Failed to load class", cl); + assertNotNull( "Loaded class unable to access resource from same codeSource", - res != null); + res); cl = null; } catch (Error e) { fail("Test error : " + e.getMessage()); @@ -178,7 +178,7 @@ } catch (Exception e) { fail("Exception using explicit jar : " + e.getMessage()); } - assertTrue("Failed to load class from explicit jar URL", cl != null); + assertNotNull("Failed to load class from explicit jar URL", cl); } /** @@ -190,8 +190,8 @@ URL[] u = new URL[0]; ucl = URLClassLoader.newInstance(u, cl); URL res = ucl.getResource("J"); - assertTrue("Failed to set parent", res == null ? false : res.getFile() - .equals("/BogusClassLoader")); + assertEquals("Failed to set parent", "/BogusClassLoader", res == null ? false : res.getFile() + ); } /** @@ -208,8 +208,8 @@ URL[] u = new URL[0]; ucl = new URLClassLoader(u, cl, new TestFactory()); URL res = ucl.getResource("J"); - assertTrue("Failed to set parent", res == null ? false : res.getFile() - .equals("/BogusClassLoader")); + assertEquals("Failed to set parent", "/BogusClassLoader", res == null ? false : res.getFile() + ); } /** @@ -313,8 +313,8 @@ .copyFile(resources, "JarIndex", "hyts_22-new.jar"); urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_22-new.jar"); ucl = URLClassLoader.newInstance(urls, null); - assertTrue("Cannot find resource", - ucl.findResource("cpack/") != null); + assertNotNull("Cannot find resource", + ucl.findResource("cpack/")); Support_Resources.copyFile(resources, "JarIndex", "hyts_11.jar"); urls[0] = new URL("file:/" + resPath + "/JarIndex/hyts_31.jar"); ucl = URLClassLoader.newInstance(urls, null); Index: modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/ServerSocketTest.java (working copy) @@ -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(); Index: modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/JarURLConnectionTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/URLConnectionTest.java (working copy) @@ -84,8 +84,8 @@ */ public void test_getContentEncoding() { // should not be known for a file - assertTrue("getContentEncoding failed: " + uc.getContentEncoding(), uc - .getContentEncoding() == null); + assertNull("getContentEncoding failed: " + uc.getContentEncoding(), uc + .getContentEncoding()); } /** @@ -109,8 +109,8 @@ Support_Resources.copyFile(resources, null, "Harmony.GIF"); URL url = new URL("file:/" + resources.toString() + "/Harmony.GIF"); URLConnection conn = url.openConnection(); - assertTrue("type not GIF", conn.getContentType() - .equals("image/gif")); + assertEquals("type not GIF", "image/gif", conn.getContentType() + ); } catch (MalformedURLException e) { fail("MalformedURLException for .gif"); } catch (IOException e) { @@ -152,19 +152,19 @@ public void test_getDefaultRequestPropertyLjava_lang_String() { try { URLConnection.setDefaultRequestProperty("Shmoo", "Blah"); - assertTrue( + assertNull( "setDefaultRequestProperty should have returned: null, but returned: " + URLConnection.getDefaultRequestProperty("Shmoo"), - URLConnection.getDefaultRequestProperty("Shmoo") == null); + URLConnection.getDefaultRequestProperty("Shmoo")); URLConnection.setDefaultRequestProperty("Shmoo", "Boom"); - assertTrue( + assertNull( "setDefaultRequestProperty should have returned: null, but returned: " + URLConnection.getDefaultRequestProperty("Shmoo"), - URLConnection.getDefaultRequestProperty("Shmoo") == null); - assertTrue( + URLConnection.getDefaultRequestProperty("Shmoo")); + assertNull( "setDefaultRequestProperty should have returned: null, but returned: " + URLConnection.getDefaultRequestProperty("Kapow"), - URLConnection.getDefaultRequestProperty("Kapow") == null); + URLConnection.getDefaultRequestProperty("Kapow")); URLConnection.setDefaultRequestProperty("Shmoo", null); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); @@ -227,8 +227,8 @@ } }); try { - assertTrue("Incorrect FileNameMap returned", URLConnection.getFileNameMap() - .getContentTypeFor(null).equals("Spam!")); + assertEquals("Incorrect FileNameMap returned", "Spam!", URLConnection.getFileNameMap() + .getContentTypeFor(null)); } finally { // unset the map so other tests don't fail URLConnection.setFileNameMap(null); @@ -270,7 +270,7 @@ assertEquals("yo2", uc.getRequestProperty("prop")); Map map = uc.getRequestProperties(); List props = (List) uc.getRequestProperties().get("prop"); - assertTrue(props.size() == 1); + assertEquals(1, props.size()); try { // the map should be unmodifiable @@ -293,7 +293,7 @@ JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection(); map = con1.getRequestProperties(); assertNotNull(map); - assertTrue(map.size() == 0); + assertEquals(0, map.size()); try { // the map should be unmodifiable map.put("hi", "bye"); @@ -337,7 +337,7 @@ JarURLConnection con1 = (JarURLConnection) fUrl1.openConnection(); headers = con1.getHeaderFields(); assertNotNull(headers); - assertTrue(headers.size() == 0); + assertEquals(0, headers.size()); try { // the map should be unmodifiable headers.put("hi", "bye"); @@ -387,9 +387,9 @@ String hf; hf = uc.getHeaderField("Content-Encoding"); if (hf != null) { - assertTrue( + assertNull( "Wrong value returned for header field 'Content-Encoding': " - + hf, hf == null); + + hf, hf); } hf = uc.getHeaderField("Content-Length"); if (hf != null) { @@ -415,9 +415,9 @@ } hf = uc.getHeaderField("Expires"); if (hf != null) { - assertTrue( + assertNull( "Wrong value returned for header field 'Expires': " + hf, - hf == null); + hf); } hf = uc.getHeaderField("SERVER"); if (hf != null) { @@ -441,8 +441,8 @@ } hf = uc.getHeaderField("DoesNotExist"); if (hf != null) { - assertTrue("Wrong value returned for header field 'DoesNotExist': " - + hf, hf == null); + assertNull("Wrong value returned for header field 'DoesNotExist': " + + hf, hf); } } @@ -494,8 +494,8 @@ */ public void test_getIfModifiedSince() { uc.setIfModifiedSince(200); - assertTrue("Returned wrong ifModifiedSince value", uc - .getIfModifiedSince() == 200); + assertEquals("Returned wrong ifModifiedSince value", 200, uc + .getIfModifiedSince()); } /** @@ -833,8 +833,8 @@ uc.setRequestProperty("Yo", "yo"); assertTrue("Wrong property returned: " + uc.getRequestProperty("Yo"), uc.getRequestProperty("Yo").equals("yo")); - assertTrue("Wrong property returned: " + uc.getRequestProperty("No"), - uc.getRequestProperty("No") == null); + assertNull("Wrong property returned: " + uc.getRequestProperty("No"), + uc.getRequestProperty("No")); } /** @@ -864,10 +864,10 @@ byte[] bytes = new byte[in.available()]; in.read(bytes, 0, bytes.length); in.close(); - assertTrue("Should have returned text/html", - URLConnection.guessContentTypeFromStream( + assertEquals("Should have returned text/html", + "text/html", URLConnection.guessContentTypeFromStream( new ByteArrayInputStream(bytes)) - .equals("text/html")); + ); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); } @@ -934,9 +934,9 @@ cal.clear(); cal.set(2000, Calendar.MARCH, 5); connection.setIfModifiedSince(cal.getTime().getTime()); - assertTrue("Wrong date set", connection.getRequestProperty( + assertEquals("Wrong date set", "Sun, 05 Mar 2000 00:00:00 GMT", connection.getRequestProperty( "If-Modified-Since") - .equals("Sun, 05 Mar 2000 00:00:00 GMT")); + ); } catch (MalformedURLException e) { fail("MalformedURLException : " + e.getMessage()); } catch (IOException e) { Index: modules/luni/src/test/java/tests/api/java/net/URLDecoderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/URLDecoderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/URLDecoderTest.java (working copy) @@ -28,7 +28,7 @@ public void test_Constructor() { try { URLDecoder ud = new URLDecoder(); - assertTrue("Constructor failed.", ud != null); + assertNotNull("Constructor failed.", ud); } catch (Exception e) { fail("Constructor failed : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/NetPermissionTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/SocketPermissionTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/net/URLTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/URLTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/URLTest.java (working copy) @@ -91,114 +91,114 @@ // basic parsing test u = new URL( "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1"); - assertTrue("u returns a wrong protocol", u.getProtocol().equals( - "http")); - assertTrue("u returns a wrong host", u.getHost().equals( - "www.yahoo1.com")); - assertTrue("u returns a wrong port", u.getPort() == 8080); - assertTrue("u returns a wrong file", u.getFile().equals( - "/dir1/dir2/test.cgi?point1.html")); - assertTrue("u returns a wrong anchor", u.getRef().equals("anchor1")); + assertEquals("u returns a wrong protocol", + "http", u.getProtocol()); + assertEquals("u returns a wrong host", + "www.yahoo1.com", u.getHost()); + assertEquals("u returns a wrong port", 8080, u.getPort()); + assertEquals("u returns a wrong file", + "/dir1/dir2/test.cgi?point1.html", u.getFile()); + assertEquals("u returns a wrong anchor", "anchor1", u.getRef()); // test for no file u1 = new URL("http://www.yahoo2.com:9999"); - assertTrue("u1 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("u1 returns a wrong host", u1.getHost().equals( - "www.yahoo2.com")); - assertTrue("u1 returns a wrong port", u1.getPort() == 9999); + assertEquals("u1 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("u1 returns a wrong host", + "www.yahoo2.com", u1.getHost()); + assertEquals("u1 returns a wrong port", 9999, u1.getPort()); assertTrue("u1 returns a wrong file", u1.getFile().equals("")); - assertTrue("u1 returns a wrong anchor", u1.getRef() == null); + assertNull("u1 returns a wrong anchor", u1.getRef()); // test for no port u2 = new URL( "http://www.yahoo3.com/dir1/dir2/test.cgi?point1.html#anchor1"); - assertTrue("u2 returns a wrong protocol", u2.getProtocol().equals( - "http")); - assertTrue("u2 returns a wrong host", u2.getHost().equals( - "www.yahoo3.com")); - assertTrue("u2 returns a wrong port", u2.getPort() == -1); - assertTrue("u2 returns a wrong file", u2.getFile().equals( - "/dir1/dir2/test.cgi?point1.html")); - assertTrue("u2 returns a wrong anchor", u2.getRef().equals( - "anchor1")); + assertEquals("u2 returns a wrong protocol", + "http", u2.getProtocol()); + assertEquals("u2 returns a wrong host", + "www.yahoo3.com", u2.getHost()); + assertEquals("u2 returns a wrong port", -1, u2.getPort()); + assertEquals("u2 returns a wrong file", + "/dir1/dir2/test.cgi?point1.html", u2.getFile()); + assertEquals("u2 returns a wrong anchor", + "anchor1", u2.getRef()); // test for no port URL u2a = new URL( "file://www.yahoo3.com/dir1/dir2/test.cgi#anchor1"); - assertTrue("u2a returns a wrong protocol", u2a.getProtocol() - .equals("file")); - assertTrue("u2a returns a wrong host", u2a.getHost().equals( - "www.yahoo3.com")); - assertTrue("u2a returns a wrong port", u2a.getPort() == -1); - assertTrue("u2a returns a wrong file", u2a.getFile().equals( - "/dir1/dir2/test.cgi")); - assertTrue("u2a returns a wrong anchor", u2a.getRef().equals( - "anchor1")); + assertEquals("u2a returns a wrong protocol", "file", u2a.getProtocol() + ); + assertEquals("u2a returns a wrong host", + "www.yahoo3.com", u2a.getHost()); + assertEquals("u2a returns a wrong port", -1, u2a.getPort()); + assertEquals("u2a returns a wrong file", + "/dir1/dir2/test.cgi", u2a.getFile()); + assertEquals("u2a returns a wrong anchor", + "anchor1", u2a.getRef()); // test for no file, no port u3 = new URL("http://www.yahoo4.com/"); - assertTrue("u3 returns a wrong protocol", u3.getProtocol().equals( - "http")); - assertTrue("u3 returns a wrong host", u3.getHost().equals( - "www.yahoo4.com")); - assertTrue("u3 returns a wrong port", u3.getPort() == -1); - assertTrue("u3 returns a wrong file", u3.getFile().equals("/")); - assertTrue("u3 returns a wrong anchor", u3.getRef() == null); + assertEquals("u3 returns a wrong protocol", + "http", u3.getProtocol()); + assertEquals("u3 returns a wrong host", + "www.yahoo4.com", u3.getHost()); + assertEquals("u3 returns a wrong port", -1, u3.getPort()); + assertEquals("u3 returns a wrong file", "/", u3.getFile()); + assertNull("u3 returns a wrong anchor", u3.getRef()); // test for no file, no port URL u3a = new URL("file://www.yahoo4.com/"); - assertTrue("u3a returns a wrong protocol", u3a.getProtocol() - .equals("file")); - assertTrue("u3a returns a wrong host", u3a.getHost().equals( - "www.yahoo4.com")); - assertTrue("u3a returns a wrong port", u3a.getPort() == -1); - assertTrue("u3a returns a wrong file", u3a.getFile().equals("/")); - assertTrue("u3a returns a wrong anchor", u3a.getRef() == null); + assertEquals("u3a returns a wrong protocol", "file", u3a.getProtocol() + ); + assertEquals("u3a returns a wrong host", + "www.yahoo4.com", u3a.getHost()); + assertEquals("u3a returns a wrong port", -1, u3a.getPort()); + assertEquals("u3a returns a wrong file", "/", u3a.getFile()); + assertNull("u3a returns a wrong anchor", u3a.getRef()); // test for no file, no port URL u3b = new URL("file://www.yahoo4.com"); - assertTrue("u3b returns a wrong protocol", u3b.getProtocol() - .equals("file")); - assertTrue("u3b returns a wrong host", u3b.getHost().equals( - "www.yahoo4.com")); - assertTrue("u3b returns a wrong port", u3b.getPort() == -1); + assertEquals("u3b returns a wrong protocol", "file", u3b.getProtocol() + ); + assertEquals("u3b returns a wrong host", + "www.yahoo4.com", u3b.getHost()); + assertEquals("u3b returns a wrong port", -1, u3b.getPort()); assertTrue("u3b returns a wrong file", u3b.getFile().equals("")); - assertTrue("u3b returns a wrong anchor", u3b.getRef() == null); + assertNull("u3b returns a wrong anchor", u3b.getRef()); // test for non-port ":" and wierd characters occurrences u4 = new URL( "http://www.yahoo5.com/di!@$%^&*()_+r1/di:::r2/test.cgi?point1.html#anchor1"); - assertTrue("u4 returns a wrong protocol", u4.getProtocol().equals( - "http")); - assertTrue("u4 returns a wrong host", u4.getHost().equals( - "www.yahoo5.com")); - assertTrue("u4 returns a wrong port", u4.getPort() == -1); - assertTrue("u4 returns a wrong file", u4.getFile().equals( - "/di!@$%^&*()_+r1/di:::r2/test.cgi?point1.html")); - assertTrue("u4 returns a wrong anchor", u4.getRef().equals( - "anchor1")); + assertEquals("u4 returns a wrong protocol", + "http", u4.getProtocol()); + assertEquals("u4 returns a wrong host", + "www.yahoo5.com", u4.getHost()); + assertEquals("u4 returns a wrong port", -1, u4.getPort()); + assertEquals("u4 returns a wrong file", + "/di!@$%^&*()_+r1/di:::r2/test.cgi?point1.html", u4.getFile()); + assertEquals("u4 returns a wrong anchor", + "anchor1", u4.getRef()); u5 = new URL("file:/testing.tst"); - assertTrue("u5 returns a wrong protocol", u5.getProtocol().equals( - "file")); + assertEquals("u5 returns a wrong protocol", + "file", u5.getProtocol()); assertTrue("u5 returns a wrong host", u5.getHost().equals("")); - assertTrue("u5 returns a wrong port", u5.getPort() == -1); - assertTrue("u5 returns a wrong file", u5.getFile().equals( - "/testing.tst")); - assertTrue("u5 returns a wrong anchor", u5.getRef() == null); + assertEquals("u5 returns a wrong port", -1, u5.getPort()); + assertEquals("u5 returns a wrong file", + "/testing.tst", u5.getFile()); + assertNull("u5 returns a wrong anchor", u5.getRef()); URL u5a = new URL("file:testing.tst"); - assertTrue("u5a returns a wrong protocol", u5a.getProtocol() - .equals("file")); + assertEquals("u5a returns a wrong protocol", "file", u5a.getProtocol() + ); assertTrue("u5a returns a wrong host", u5a.getHost().equals("")); - assertTrue("u5a returns a wrong port", u5a.getPort() == -1); - assertTrue("u5a returns a wrong file", u5a.getFile().equals( - "testing.tst")); - assertTrue("u5a returns a wrong anchor", u5a.getRef() == null); + assertEquals("u5a returns a wrong port", -1, u5a.getPort()); + assertEquals("u5a returns a wrong file", + "testing.tst", u5a.getFile()); + assertNull("u5a returns a wrong anchor", u5a.getRef()); URL u6 = new URL("http://host:/file"); - assertTrue("u6 return a wrong port", u6.getPort() == -1); + assertEquals("u6 return a wrong port", -1, u6.getPort()); URL u7 = new URL("file:../../file.txt"); assertTrue("u7 returns a wrong file: " + u7.getFile(), u7.getFile() @@ -213,8 +213,8 @@ u8.getPort() == 35); assertTrue("u8 returns a wrong file " + u8.getFile(), u8.getFile() .equals("/file.txt")); - assertTrue("u8 returns a wrong anchor " + u8.getRef(), - u8.getRef() == null); + assertNull("u8 returns a wrong anchor " + u8.getRef(), + u8.getRef()); URL u9 = new URL( "file://[fec0::1:20d:60ff:fe24:7410]/file.txt#sogood"); @@ -326,217 +326,217 @@ URL uf = new URL("file://www.yahoo.com"); // basic ones u1 = new URL(u, "file.java"); - assertTrue("1 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("1 returns a wrong host", u1.getHost().equals( - "www.yahoo.com")); - assertTrue("1 returns a wrong port", u1.getPort() == -1); - assertTrue("1 returns a wrong file", u1.getFile().equals( - "/file.java")); - assertTrue("1 returns a wrong anchor", u1.getRef() == null); + assertEquals("1 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("1 returns a wrong host", + "www.yahoo.com", u1.getHost()); + assertEquals("1 returns a wrong port", -1, u1.getPort()); + assertEquals("1 returns a wrong file", + "/file.java", u1.getFile()); + assertNull("1 returns a wrong anchor", u1.getRef()); URL u1f = new URL(uf, "file.java"); - assertTrue("1f returns a wrong protocol", u1f.getProtocol().equals( - "file")); - assertTrue("1f returns a wrong host", u1f.getHost().equals( - "www.yahoo.com")); - assertTrue("1f returns a wrong port", u1f.getPort() == -1); - assertTrue("1f returns a wrong file", u1f.getFile().equals( - "/file.java")); - assertTrue("1f returns a wrong anchor", u1f.getRef() == null); + assertEquals("1f returns a wrong protocol", + "file", u1f.getProtocol()); + assertEquals("1f returns a wrong host", + "www.yahoo.com", u1f.getHost()); + assertEquals("1f returns a wrong port", -1, u1f.getPort()); + assertEquals("1f returns a wrong file", + "/file.java", u1f.getFile()); + assertNull("1f returns a wrong anchor", u1f.getRef()); u1 = new URL(u, "dir1/dir2/../file.java"); - assertTrue("3 returns a wrong protocol", u1.getProtocol().equals( - "http")); + assertEquals("3 returns a wrong protocol", + "http", u1.getProtocol()); assertTrue("3 returns a wrong host: " + u1.getHost(), u1.getHost() .equals("www.yahoo.com")); - assertTrue("3 returns a wrong port", u1.getPort() == -1); - assertTrue("3 returns a wrong file", u1.getFile().equals( - "/dir1/dir2/../file.java")); - assertTrue("3 returns a wrong anchor", u1.getRef() == null); + assertEquals("3 returns a wrong port", -1, u1.getPort()); + assertEquals("3 returns a wrong file", + "/dir1/dir2/../file.java", u1.getFile()); + assertNull("3 returns a wrong anchor", u1.getRef()); u1 = new URL(u, "http:dir1/dir2/../file.java"); - assertTrue("3a returns a wrong protocol", u1.getProtocol().equals( - "http")); + assertEquals("3a returns a wrong protocol", + "http", u1.getProtocol()); assertTrue("3a returns a wrong host: " + u1.getHost(), u1.getHost() .equals("")); - assertTrue("3a returns a wrong port", u1.getPort() == -1); - assertTrue("3a returns a wrong file", u1.getFile().equals( - "dir1/dir2/../file.java")); - assertTrue("3a returns a wrong anchor", u1.getRef() == null); + assertEquals("3a returns a wrong port", -1, u1.getPort()); + assertEquals("3a returns a wrong file", + "dir1/dir2/../file.java", u1.getFile()); + assertNull("3a returns a wrong anchor", u1.getRef()); u = new URL("http://www.apache.org/testing/"); u1 = new URL(u, "file.java"); - assertTrue("4 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("4 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("4 returns a wrong port", u1.getPort() == -1); - assertTrue("4 returns a wrong file", u1.getFile().equals( - "/testing/file.java")); - assertTrue("4 returns a wrong anchor", u1.getRef() == null); + assertEquals("4 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("4 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("4 returns a wrong port", -1, u1.getPort()); + assertEquals("4 returns a wrong file", + "/testing/file.java", u1.getFile()); + assertNull("4 returns a wrong anchor", u1.getRef()); uf = new URL("file://www.apache.org/testing/"); u1f = new URL(uf, "file.java"); - assertTrue("4f returns a wrong protocol", u1f.getProtocol().equals( - "file")); - assertTrue("4f returns a wrong host", u1f.getHost().equals( - "www.apache.org")); - assertTrue("4f returns a wrong port", u1f.getPort() == -1); - assertTrue("4f returns a wrong file", u1f.getFile().equals( - "/testing/file.java")); - assertTrue("4f returns a wrong anchor", u1f.getRef() == null); + assertEquals("4f returns a wrong protocol", + "file", u1f.getProtocol()); + assertEquals("4f returns a wrong host", + "www.apache.org", u1f.getHost()); + assertEquals("4f returns a wrong port", -1, u1f.getPort()); + assertEquals("4f returns a wrong file", + "/testing/file.java", u1f.getFile()); + assertNull("4f returns a wrong anchor", u1f.getRef()); uf = new URL("file:/testing/"); u1f = new URL(uf, "file.java"); - assertTrue("4fa returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("4fa returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("4fa returns a wrong host", u1f.getHost().equals("")); - assertTrue("4fa returns a wrong port", u1f.getPort() == -1); - assertTrue("4fa returns a wrong file", u1f.getFile().equals( - "/testing/file.java")); - assertTrue("4fa returns a wrong anchor", u1f.getRef() == null); + assertEquals("4fa returns a wrong port", -1, u1f.getPort()); + assertEquals("4fa returns a wrong file", + "/testing/file.java", u1f.getFile()); + assertNull("4fa returns a wrong anchor", u1f.getRef()); uf = new URL("file:testing/"); u1f = new URL(uf, "file.java"); - assertTrue("4fb returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("4fb returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("4fb returns a wrong host", u1f.getHost().equals("")); - assertTrue("4fb returns a wrong port", u1f.getPort() == -1); - assertTrue("4fb returns a wrong file", u1f.getFile().equals( - "testing/file.java")); - assertTrue("4fb returns a wrong anchor", u1f.getRef() == null); + assertEquals("4fb returns a wrong port", -1, u1f.getPort()); + assertEquals("4fb returns a wrong file", + "testing/file.java", u1f.getFile()); + assertNull("4fb returns a wrong anchor", u1f.getRef()); u1f = new URL(uf, "file:file.java"); - assertTrue("4fc returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("4fc returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("4fc returns a wrong host", u1f.getHost().equals("")); - assertTrue("4fc returns a wrong port", u1f.getPort() == -1); - assertTrue("4fc returns a wrong file", u1f.getFile().equals( - "file.java")); - assertTrue("4fc returns a wrong anchor", u1f.getRef() == null); + assertEquals("4fc returns a wrong port", -1, u1f.getPort()); + assertEquals("4fc returns a wrong file", + "file.java", u1f.getFile()); + assertNull("4fc returns a wrong anchor", u1f.getRef()); u1f = new URL(uf, "file:"); - assertTrue("4fd returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("4fd returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("4fd returns a wrong host", u1f.getHost().equals("")); - assertTrue("4fd returns a wrong port", u1f.getPort() == -1); + assertEquals("4fd returns a wrong port", -1, u1f.getPort()); assertTrue("4fd returns a wrong file", u1f.getFile().equals("")); - assertTrue("4fd returns a wrong anchor", u1f.getRef() == null); + assertNull("4fd returns a wrong anchor", u1f.getRef()); u = new URL("http://www.apache.org/testing"); u1 = new URL(u, "file.java"); - assertTrue("5 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("5 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("5 returns a wrong port", u1.getPort() == -1); - assertTrue("5 returns a wrong file", u1.getFile().equals( - "/file.java")); - assertTrue("5 returns a wrong anchor", u1.getRef() == null); + assertEquals("5 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("5 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("5 returns a wrong port", -1, u1.getPort()); + assertEquals("5 returns a wrong file", + "/file.java", u1.getFile()); + assertNull("5 returns a wrong anchor", u1.getRef()); uf = new URL("file://www.apache.org/testing"); u1f = new URL(uf, "file.java"); - assertTrue("5f returns a wrong protocol", u1f.getProtocol().equals( - "file")); - assertTrue("5f returns a wrong host", u1f.getHost().equals( - "www.apache.org")); - assertTrue("5f returns a wrong port", u1f.getPort() == -1); - assertTrue("5f returns a wrong file", u1f.getFile().equals( - "/file.java")); - assertTrue("5f returns a wrong anchor", u1f.getRef() == null); + assertEquals("5f returns a wrong protocol", + "file", u1f.getProtocol()); + assertEquals("5f returns a wrong host", + "www.apache.org", u1f.getHost()); + assertEquals("5f returns a wrong port", -1, u1f.getPort()); + assertEquals("5f returns a wrong file", + "/file.java", u1f.getFile()); + assertNull("5f returns a wrong anchor", u1f.getRef()); uf = new URL("file:/testing"); u1f = new URL(uf, "file.java"); - assertTrue("5fa returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("5fa returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("5fa returns a wrong host", u1f.getHost().equals("")); - assertTrue("5fa returns a wrong port", u1f.getPort() == -1); - assertTrue("5fa returns a wrong file", u1f.getFile().equals( - "/file.java")); - assertTrue("5fa returns a wrong anchor", u1f.getRef() == null); + assertEquals("5fa returns a wrong port", -1, u1f.getPort()); + assertEquals("5fa returns a wrong file", + "/file.java", u1f.getFile()); + assertNull("5fa returns a wrong anchor", u1f.getRef()); uf = new URL("file:testing"); u1f = new URL(uf, "file.java"); - assertTrue("5fb returns a wrong protocol", u1f.getProtocol() - .equals("file")); + assertEquals("5fb returns a wrong protocol", "file", u1f.getProtocol() + ); assertTrue("5fb returns a wrong host", u1f.getHost().equals("")); - assertTrue("5fb returns a wrong port", u1f.getPort() == -1); - assertTrue("5fb returns a wrong file", u1f.getFile().equals( - "file.java")); - assertTrue("5fb returns a wrong anchor", u1f.getRef() == null); + assertEquals("5fb returns a wrong port", -1, u1f.getPort()); + assertEquals("5fb returns a wrong file", + "file.java", u1f.getFile()); + assertNull("5fb returns a wrong anchor", u1f.getRef()); u = new URL("http://www.apache.org/testing/foobaz"); u1 = new URL(u, "/file.java"); - assertTrue("6 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("6 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("6 returns a wrong port", u1.getPort() == -1); - assertTrue("6 returns a wrong file", u1.getFile().equals( - "/file.java")); - assertTrue("6 returns a wrong anchor", u1.getRef() == null); + assertEquals("6 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("6 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("6 returns a wrong port", -1, u1.getPort()); + assertEquals("6 returns a wrong file", + "/file.java", u1.getFile()); + assertNull("6 returns a wrong anchor", u1.getRef()); uf = new URL("file://www.apache.org/testing/foobaz"); u1f = new URL(uf, "/file.java"); - assertTrue("6f returns a wrong protocol", u1f.getProtocol().equals( - "file")); - assertTrue("6f returns a wrong host", u1f.getHost().equals( - "www.apache.org")); - assertTrue("6f returns a wrong port", u1f.getPort() == -1); - assertTrue("6f returns a wrong file", u1f.getFile().equals( - "/file.java")); - assertTrue("6f returns a wrong anchor", u1f.getRef() == null); + assertEquals("6f returns a wrong protocol", + "file", u1f.getProtocol()); + assertEquals("6f returns a wrong host", + "www.apache.org", u1f.getHost()); + assertEquals("6f returns a wrong port", -1, u1f.getPort()); + assertEquals("6f returns a wrong file", + "/file.java", u1f.getFile()); + assertNull("6f returns a wrong anchor", u1f.getRef()); u = new URL("http://www.apache.org:8000/testing/foobaz"); u1 = new URL(u, "/file.java"); - assertTrue("7 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("7 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("7 returns a wrong port", u1.getPort() == 8000); - assertTrue("7 returns a wrong file", u1.getFile().equals( - "/file.java")); - assertTrue("7 returns a wrong anchor", u1.getRef() == null); + assertEquals("7 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("7 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("7 returns a wrong port", 8000, u1.getPort()); + assertEquals("7 returns a wrong file", + "/file.java", u1.getFile()); + assertNull("7 returns a wrong anchor", u1.getRef()); u = new URL("http://www.apache.org/index.html"); u1 = new URL(u, "#bar"); - assertTrue("8 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("8 returns a wrong file", u1.getFile().equals( - "/index.html")); - assertTrue("8 returns a wrong anchor", u1.getRef().equals("bar")); + assertEquals("8 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("8 returns a wrong file", + "/index.html", u1.getFile()); + assertEquals("8 returns a wrong anchor", "bar", u1.getRef()); u = new URL("http://www.apache.org/index.html#foo"); u1 = new URL(u, "http:#bar"); - assertTrue("9 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("9 returns a wrong file", u1.getFile().equals( - "/index.html")); - assertTrue("9 returns a wrong anchor", u1.getRef().equals("bar")); + assertEquals("9 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("9 returns a wrong file", + "/index.html", u1.getFile()); + assertEquals("9 returns a wrong anchor", "bar", u1.getRef()); u = new URL("http://www.apache.org/index.html"); u1 = new URL(u, ""); - assertTrue("10 returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("10 returns a wrong file", u1.getFile().equals( - "/index.html")); - assertTrue("10 returns a wrong anchor", u1.getRef() == null); + assertEquals("10 returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("10 returns a wrong file", + "/index.html", u1.getFile()); + assertNull("10 returns a wrong anchor", u1.getRef()); uf = new URL("file://www.apache.org/index.html"); u1f = new URL(uf, ""); - assertTrue("10f returns a wrong host", u1.getHost().equals( - "www.apache.org")); - assertTrue("10f returns a wrong file", u1.getFile().equals( - "/index.html")); - assertTrue("10f returns a wrong anchor", u1.getRef() == null); + assertEquals("10f returns a wrong host", + "www.apache.org", u1.getHost()); + assertEquals("10f returns a wrong file", + "/index.html", u1.getFile()); + assertNull("10f returns a wrong anchor", u1.getRef()); u = new URL("http://www.apache.org/index.html"); u1 = new URL(u, "http://www.apache.org"); - assertTrue("11 returns a wrong host", u1.getHost().equals( - "www.apache.org")); + assertEquals("11 returns a wrong host", + "www.apache.org", u1.getHost()); assertTrue("11 returns a wrong file", u1.getFile().equals("")); - assertTrue("11 returns a wrong anchor", u1.getRef() == null); + assertNull("11 returns a wrong anchor", u1.getRef()); // test for question mark processing u = new URL("http://www.foo.com/d0/d1/d2/cgi-bin?foo=bar/baz"); @@ -548,8 +548,8 @@ // test for absolute and relative file processing u1 = new URL(u, "/../dir1/./dir2/../file.java"); - assertTrue("B) returns a wrong file", u1.getFile().equals( - "/../dir1/./dir2/../file.java")); + assertEquals("B) returns a wrong file", + "/../dir1/./dir2/../file.java", u1.getFile()); } catch (Exception e) { fail("1 Exception during tests : " + e.getMessage()); } @@ -578,34 +578,34 @@ u = new URL("http://www.yahoo.com"); // basic ones u1 = new URL(u, "file.java", new MyHandler()); - assertTrue("1 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("1 returns a wrong host", u1.getHost().equals( - "www.yahoo.com")); - assertTrue("1 returns a wrong port", u1.getPort() == -1); - assertTrue("1 returns a wrong file", u1.getFile().equals( - "/file.java")); - assertTrue("1 returns a wrong anchor", u1.getRef() == null); + assertEquals("1 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("1 returns a wrong host", + "www.yahoo.com", u1.getHost()); + assertEquals("1 returns a wrong port", -1, u1.getPort()); + assertEquals("1 returns a wrong file", + "/file.java", u1.getFile()); + assertNull("1 returns a wrong anchor", u1.getRef()); u1 = new URL(u, "systemresource:/+/FILE0/test.java", new MyHandler()); - assertTrue("2 returns a wrong protocol", u1.getProtocol().equals( - "systemresource")); + assertEquals("2 returns a wrong protocol", + "systemresource", u1.getProtocol()); assertTrue("2 returns a wrong host", u1.getHost().equals("")); - assertTrue("2 returns a wrong port", u1.getPort() == -1); - assertTrue("2 returns a wrong file", u1.getFile().equals( - "/+/FILE0/test.java")); - assertTrue("2 returns a wrong anchor", u1.getRef() == null); + assertEquals("2 returns a wrong port", -1, u1.getPort()); + assertEquals("2 returns a wrong file", + "/+/FILE0/test.java", u1.getFile()); + assertNull("2 returns a wrong anchor", u1.getRef()); u1 = new URL(u, "dir1/dir2/../file.java", null); - assertTrue("3 returns a wrong protocol", u1.getProtocol().equals( - "http")); - assertTrue("3 returns a wrong host", u1.getHost().equals( - "www.yahoo.com")); - assertTrue("3 returns a wrong port", u1.getPort() == -1); - assertTrue("3 returns a wrong file", u1.getFile().equals( - "/dir1/dir2/../file.java")); - assertTrue("3 returns a wrong anchor", u1.getRef() == null); + assertEquals("3 returns a wrong protocol", + "http", u1.getProtocol()); + assertEquals("3 returns a wrong host", + "www.yahoo.com", u1.getHost()); + assertEquals("3 returns a wrong port", -1, u1.getPort()); + assertEquals("3 returns a wrong file", + "/dir1/dir2/../file.java", u1.getFile()); + assertNull("3 returns a wrong anchor", u1.getRef()); // test for question mark processing u = new URL("http://www.foo.com/d0/d1/d2/cgi-bin?foo=bar/baz"); @@ -617,8 +617,8 @@ // test for absolute and relative file processing u1 = new URL(u, "/../dir1/dir2/../file.java", null); - assertTrue("B) returns a wrong file", u1.getFile().equals( - "/../dir1/dir2/../file.java")); + assertEquals("B) returns a wrong file", + "/../dir1/dir2/../file.java", u1.getFile()); } catch (Exception e) { fail("1 Exception during tests : " + e.getMessage()); } @@ -659,13 +659,13 @@ // java.lang.String) try { u = new URL("http", "www.yahoo.com:8080", "test.html#foo"); - assertTrue("SSS returns a wrong protocol", u.getProtocol().equals( - "http")); + assertEquals("SSS returns a wrong protocol", + "http", u.getProtocol()); assertTrue("SSS returns a wrong host: " + u.getHost(), u.getHost() .equals("www.yahoo.com:8080")); - assertTrue("SSS returns a wrong port", u.getPort() == -1); - assertTrue("SSS returns a wrong file", u.getFile().equals( - "test.html")); + assertEquals("SSS returns a wrong port", -1, u.getPort()); + assertEquals("SSS returns a wrong file", + "test.html", u.getFile()); assertTrue("SSS returns a wrong anchor: " + u.getRef(), u.getRef() .equals("foo")); } catch (Exception e) { @@ -682,13 +682,13 @@ // java.lang.String) try { u = new URL("http", "www.yahoo.com", 8080, "test.html#foo"); - assertTrue("SSIS returns a wrong protocol", u.getProtocol().equals( - "http")); - assertTrue("SSIS returns a wrong host", u.getHost().equals( - "www.yahoo.com")); - assertTrue("SSIS returns a wrong port", u.getPort() == 8080); - assertTrue("SSIS returns a wrong file", u.getFile().equals( - "test.html")); + assertEquals("SSIS returns a wrong protocol", + "http", u.getProtocol()); + assertEquals("SSIS returns a wrong host", + "www.yahoo.com", u.getHost()); + assertEquals("SSIS returns a wrong port", 8080, u.getPort()); + assertEquals("SSIS returns a wrong file", + "test.html", u.getFile()); assertTrue("SSIS returns a wrong anchor: " + u.getRef(), u.getRef() .equals("foo")); } catch (Exception e) { @@ -706,13 +706,13 @@ // java.lang.String, java.net.URLStreamHandler) try { u = new URL("http", "www.yahoo.com", 8080, "test.html#foo", null); - assertTrue("SSISH1 returns a wrong protocol", u.getProtocol() - .equals("http")); - assertTrue("SSISH1 returns a wrong host", u.getHost().equals( - "www.yahoo.com")); - assertTrue("SSISH1 returns a wrong port", u.getPort() == 8080); - assertTrue("SSISH1 returns a wrong file", u.getFile().equals( - "test.html")); + assertEquals("SSISH1 returns a wrong protocol", "http", u.getProtocol() + ); + assertEquals("SSISH1 returns a wrong host", + "www.yahoo.com", u.getHost()); + assertEquals("SSISH1 returns a wrong port", 8080, u.getPort()); + assertEquals("SSISH1 returns a wrong file", + "test.html", u.getFile()); assertTrue("SSISH1 returns a wrong anchor: " + u.getRef(), u .getRef().equals("foo")); } catch (Exception e) { @@ -722,13 +722,13 @@ try { u = new URL("http", "www.yahoo.com", 8080, "test.html#foo", new MyHandler()); - assertTrue("SSISH2 returns a wrong protocol", u.getProtocol() - .equals("http")); - assertTrue("SSISH2 returns a wrong host", u.getHost().equals( - "www.yahoo.com")); - assertTrue("SSISH2 returns a wrong port", u.getPort() == 8080); - assertTrue("SSISH2 returns a wrong file", u.getFile().equals( - "test.html")); + assertEquals("SSISH2 returns a wrong protocol", "http", u.getProtocol() + ); + assertEquals("SSISH2 returns a wrong host", + "www.yahoo.com", u.getHost()); + assertEquals("SSISH2 returns a wrong port", 8080, u.getPort()); + assertEquals("SSISH2 returns a wrong file", + "test.html", u.getFile()); assertTrue("SSISH2 returns a wrong anchor: " + u.getRef(), u .getRef().equals("foo")); } catch (Exception e) { @@ -850,7 +850,7 @@ + "/nettest.txt"); InputStream in = u.openStream(); byte[] buf = new byte[3]; - assertTrue("Incompete read 2", in.read(buf) == 3); + assertEquals("Incompete read 2", 3, in.read(buf)); in.close(); assertTrue("Returned incorrect data 2", buf[0] == 0x54 && buf[1] == 0x68 && buf[2] == 0x69); @@ -869,7 +869,7 @@ int result = in.read(buf); in.close(); test.delete(); - assertTrue("Incompete read 3", result == 3); + assertEquals("Incompete read 3", 3, result); assertTrue("Returned incorrect data 3", buf[0] == 0x55 && buf[1] == (byte) 0xaa && buf[2] == 0x14); } catch (java.io.IOException e) { @@ -885,7 +885,7 @@ try { u = new URL("systemresource:/FILE4/+/types.properties"); URLConnection uConn = u.openConnection(); - assertTrue("u.openConnection() returns null", uConn != null); + assertNotNull("u.openConnection() returns null", uConn); } catch (Exception e) { } } @@ -899,14 +899,13 @@ u1 = new URL("http://www.yahoo2.com:9999"); u = new URL( "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1"); - assertTrue( - "a) Does not return the right url string", - u + assertEquals("a) Does not return the right url string", + + "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1", u .toString() - .equals( - "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1")); - assertTrue("b) Does not return the right url string", u1.toString() - .equals("http://www.yahoo2.com:9999")); + ); + assertEquals("b) Does not return the right url string", "http://www.yahoo2.com:9999", u1.toString() + ); assertTrue("c) Does not return the right url string", u .equals(new URL(u.toString()))); } catch (Exception e) { @@ -922,24 +921,23 @@ u1 = new URL("http://www.yahoo2.com:9999"); u = new URL( "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1"); - assertTrue( - "a) Does not return the right url string", - u + assertEquals("a) Does not return the right url string", + + "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1", u .toString() - .equals( - "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1")); - assertTrue("b) Does not return the right url string", u1.toString() - .equals("http://www.yahoo2.com:9999")); + ); + assertEquals("b) Does not return the right url string", "http://www.yahoo2.com:9999", u1.toString() + ); assertTrue("c) Does not return the right url string", u .equals(new URL(u.toString()))); u = new URL("http:index"); - assertTrue("2 wrong external form", u.toExternalForm().equals( - "http:index")); + assertEquals("2 wrong external form", + "http:index", u.toExternalForm()); u = new URL("http", null, "index"); - assertTrue("2 wrong external form", u.toExternalForm().equals( - "http:index")); + assertEquals("2 wrong external form", + "http:index", u.toExternalForm()); } catch (Exception e) { } } @@ -952,8 +950,8 @@ try { u = new URL("http", "www.yahoo.com:8080", 1233, "test/!@$%^&*/test.html#foo"); - assertTrue("returns a wrong file", u.getFile().equals( - "test/!@$%^&*/test.html")); + assertEquals("returns a wrong file", + "test/!@$%^&*/test.html", u.getFile()); u = new URL("http", "www.yahoo.com:8080", 1233, ""); assertTrue("returns a wrong file", u.getFile().equals("")); } catch (Exception e) { @@ -979,7 +977,7 @@ assertTrue("return wrong port number " + u.getPort(), u.getPort() == 9999); u = new URL("http://member12.c++.com:9999/"); - assertTrue("return wrong port number", u.getPort() == 9999); + assertEquals("return wrong port number", 9999, u.getPort()); } catch (Exception e) { fail("Threw exception : " + e.getMessage()); } @@ -1009,13 +1007,13 @@ u1 = new URL("http://www.yahoo2.com:9999"); u = new URL( "http://www.yahoo1.com:8080/dir1/dir2/test.cgi?point1.html#anchor1"); - assertTrue("returns a wrong anchor1", u.getRef().equals("anchor1")); - assertTrue("returns a wrong anchor2", u1.getRef() == null); + assertEquals("returns a wrong anchor1", "anchor1", u.getRef()); + assertNull("returns a wrong anchor2", u1.getRef()); u1 = new URL("http://www.yahoo2.com#ref"); - assertTrue("returns a wrong anchor3", u1.getRef().equals("ref")); + assertEquals("returns a wrong anchor3", "ref", u1.getRef()); u1 = new URL("http://www.yahoo2.com/file#ref1#ref2"); - assertTrue("returns a wrong anchor4", u1.getRef().equals( - "ref1#ref2")); + assertEquals("returns a wrong anchor4", + "ref1#ref2", u1.getRef()); } catch (MalformedURLException e) { fail("Incorrect URL format : " + e.getMessage()); } @@ -1029,21 +1027,21 @@ URL url = new URL("http", "u:p@home", 80, "/java?q1#ref"); assertTrue("wrong authority: " + url.getAuthority(), url .getAuthority().equals("u:p@home:80")); - assertTrue("wrong userInfo", url.getUserInfo().equals("u:p")); - assertTrue("wrong host", url.getHost().equals("home")); - assertTrue("wrong file", url.getFile().equals("/java?q1")); - assertTrue("wrong path", url.getPath().equals("/java")); - assertTrue("wrong query", url.getQuery().equals("q1")); - assertTrue("wrong ref", url.getRef().equals("ref")); + assertEquals("wrong userInfo", "u:p", url.getUserInfo()); + assertEquals("wrong host", "home", url.getHost()); + assertEquals("wrong file", "/java?q1", url.getFile()); + assertEquals("wrong path", "/java", url.getPath()); + assertEquals("wrong query", "q1", url.getQuery()); + assertEquals("wrong ref", "ref", url.getRef()); url = new URL("http", "home", -1, "/java"); - assertTrue("wrong authority2", url.getAuthority().equals("home")); - assertTrue("wrong userInfo2", url.getUserInfo() == null); - assertTrue("wrong host2", url.getHost().equals("home")); - assertTrue("wrong file2", url.getFile().equals("/java")); - assertTrue("wrong path2", url.getPath().equals("/java")); - assertTrue("wrong query2", url.getQuery() == null); - assertTrue("wrong ref2", url.getRef() == null); + assertEquals("wrong authority2", "home", url.getAuthority()); + assertNull("wrong userInfo2", url.getUserInfo()); + assertEquals("wrong host2", "home", url.getHost()); + assertEquals("wrong file2", "/java", url.getFile()); + assertEquals("wrong path2", "/java", url.getPath()); + assertNull("wrong query2", url.getQuery()); + assertNull("wrong ref2", url.getRef()); } catch (MalformedURLException e) { fail("Unexpected MalformedURLException : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/DatagramPacketTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/NetworkInterfaceTest.java (working copy) @@ -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("")); } Index: modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/NoRouteToHostExceptionTest.java (working copy) @@ -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"); Index: modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/HttpURLConnectionTest.java (working copy) @@ -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()); } Index: modules/luni/src/test/java/tests/api/java/net/SocketTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/SocketTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/SocketTest.java (working copy) @@ -348,7 +348,7 @@ s = new Socket(InetAddress.getLocalHost(), sport, null, portNumber); (t = new SServer()).start(); java.io.InputStream is = s.getInputStream(); - assertTrue("Failed to get stream", is != null); + assertNotNull("Failed to get stream", is); s.setSoTimeout(6000); is.read(); s.close(); @@ -500,7 +500,7 @@ int portNumber = Support_PortManager.getNextPort(); s = new Socket(InetAddress.getLocalHost(), sport, null, portNumber); java.io.OutputStream os = s.getOutputStream(); - assertTrue("Failed to get stream", os != null); + assertNotNull("Failed to get stream", os); tearDown(); } catch (Exception e) { fail("Exception during getOutputStream test" + e.toString()); @@ -589,7 +589,7 @@ int portNumber = Support_PortManager.getNextPort(); s = new Socket(InetAddress.getLocalHost(), sport, null, portNumber); s.setSoLinger(true, 200); - assertTrue("Returned incorrect linger", s.getSoLinger() == 200); + assertEquals("Returned incorrect linger", 200, s.getSoLinger()); ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_LINGER); s.setSoLinger(false, 0); } catch (Exception e) { @@ -640,7 +640,7 @@ int sport = startServer("SServer getSoTimeout"); s = new Socket(InetAddress.getLocalHost(), sport); s.setSoTimeout(100); - assertTrue("Returned incorrect sotimeout", s.getSoTimeout() == 100); + assertEquals("Returned incorrect sotimeout", 100, s.getSoTimeout()); ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_TIMEOUT); } catch (Exception e) { handleException(e, SO_TIMEOUT); @@ -738,7 +738,7 @@ int portNumber = Support_PortManager.getNextPort(); s = new Socket(InetAddress.getLocalHost(), sport, null, portNumber); s.setSoLinger(true, 500); - assertTrue("Set incorrect linger", s.getSoLinger() == 500); + assertEquals("Set incorrect linger", 500, s.getSoLinger()); ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_LINGER); s.setSoLinger(false, 0); } catch (Exception e) { @@ -756,7 +756,7 @@ int portNumber = Support_PortManager.getNextPort(); s = new Socket(InetAddress.getLocalHost(), sport, null, portNumber); s.setSoTimeout(100); - assertTrue("Set incorrect sotimeout", s.getSoTimeout() == 100); + assertEquals("Set incorrect sotimeout", 100, s.getSoTimeout()); ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_TIMEOUT); } catch (Exception e) { handleException(e, SO_TIMEOUT); @@ -906,9 +906,9 @@ // now create a socket that is not bound and validate we get the // right answer Socket theSocket = new Socket(); - 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(); @@ -999,10 +999,10 @@ 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(), @@ -1208,8 +1208,8 @@ // all is ok theSocket = new Socket(); 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 @@ -1808,12 +1808,12 @@ connector.start(); theSocket.setSoTimeout(100); Thread.sleep(10); - assertTrue("Socket option not set during connect: 10 ", theSocket - .getSoTimeout() == 100); + assertEquals("Socket option not set during connect: 10 ", 100, theSocket + .getSoTimeout()); Thread.sleep(50); theSocket.setSoTimeout(200); - assertTrue("Socket option not set during connect: 50 ", theSocket - .getSoTimeout() == 200); + assertEquals("Socket option not set during connect: 50 ", 200, theSocket + .getSoTimeout()); Thread.sleep(5000); theSocket.close(); } catch (Exception e) { Index: modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/net/DatagramSocketTest.java (working copy) @@ -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(); Index: modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/CharArrayReaderTest.java (working copy) @@ -84,7 +84,7 @@ cr.mark(100); cr.read(); cr.reset(); - assertTrue("Failed to mark correct position", cr.read() == 'W'); + assertEquals("Failed to mark correct position", 'W', cr.read()); } catch (IOException e) { fail("Exception during mark test: " + e.getMessage()); } @@ -106,7 +106,7 @@ // Test for method int java.io.CharArrayReader.read() try { cr = new CharArrayReader(hw); - assertTrue("Read returned incorrect char", cr.read() == 'H'); + assertEquals("Read returned incorrect char", 'H', cr.read()); cr = new CharArrayReader(new char[] { '\u8765' }); assertTrue("Incorrect double byte char", cr.read() == '\u8765'); } catch (IOException e) { @@ -170,8 +170,8 @@ cr.mark(100); cr.read(); cr.reset(); - assertTrue("Reset failed to return to marker position", - cr.read() == 'W'); + assertEquals("Reset failed to return to marker position", + 'W', cr.read()); } catch (IOException e) { fail("Exception during reset test : " + e.getMessage()); } @@ -189,9 +189,9 @@ } catch (IOException e) { fail("Exception during skip test : " + e.getMessage()); } - assertTrue("Failed to skip correct number of chars", skipped == 5L); + assertEquals("Failed to skip correct number of chars", 5L, skipped); try { - assertTrue("Skip skipped wrong chars", cr.read() == 'W'); + assertEquals("Skip skipped wrong chars", 'W', cr.read()); } catch (IOException e) { fail("read exception during skip test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/ByteArrayOutputStreamTest.java (working copy) @@ -51,7 +51,7 @@ public void test_ConstructorI() { // Test for method java.io.ByteArrayOutputStream(int) bos = new java.io.ByteArrayOutputStream(100); - assertTrue("Failed to create stream", bos.size() == 0); + assertEquals("Failed to create stream", 0, bos.size()); } /** @@ -60,7 +60,7 @@ public void test_Constructor() { // Test for method java.io.ByteArrayOutputStream() bos = new java.io.ByteArrayOutputStream(); - assertTrue("Failed to create stream", bos.size() == 0); + assertEquals("Failed to create stream", 0, bos.size()); } /** @@ -97,7 +97,7 @@ bos = new java.io.ByteArrayOutputStream(); bos.write(fileString.getBytes(), 0, 100); bos.reset(); - assertTrue("reset failed", bos.size() == 0); + assertEquals("reset failed", 0, bos.size()); } /** @@ -107,9 +107,9 @@ // Test for method int java.io.ByteArrayOutputStream.size() bos = new java.io.ByteArrayOutputStream(); bos.write(fileString.getBytes(), 0, 100); - assertTrue("size test failed", bos.size() == 100); + assertEquals("size test failed", 100, bos.size()); bos.reset(); - assertTrue("size test failed", bos.size() == 0); + assertEquals("size test failed", 0, bos.size()); } /** @@ -187,8 +187,8 @@ bos = new java.io.ByteArrayOutputStream(); bos.write('t'); byte[] result = bos.toByteArray(); - assertTrue("Wrote incorrect bytes", - new String(result, 0, result.length).equals("t")); + assertEquals("Wrote incorrect bytes", + "t", new String(result, 0, result.length)); } /** Index: modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/StringWriterTest.java (working copy) @@ -49,7 +49,7 @@ // Test for method void java.io.StringWriter.flush() sw.flush(); sw.write('c'); - assertTrue("Failed to flush char", sw.toString().equals("c")); + assertEquals("Failed to flush char", "c", sw.toString()); } /** @@ -61,8 +61,8 @@ sw.write("This is a test string"); StringBuffer sb = sw.getBuffer(); - assertTrue("Incorrect buffer returned", sb.toString().equals( - "This is a test string")); + assertEquals("Incorrect buffer returned", + "This is a test string", sb.toString()); } /** @@ -71,8 +71,8 @@ public void test_toString() { // Test for method java.lang.String java.io.StringWriter.toString() sw.write("This is a test string"); - assertTrue("Incorrect string returned", sw.toString().equals( - "This is a test string")); + assertEquals("Incorrect string returned", + "This is a test string", sw.toString()); } /** @@ -83,8 +83,8 @@ char[] c = new char[1000]; "This is a test string".getChars(0, 21, c, 0); sw.write(c, 0, 21); - assertTrue("Chars not written properly", sw.toString().equals( - "This is a test string")); + assertEquals("Chars not written properly", + "This is a test string", sw.toString()); } /** @@ -93,7 +93,7 @@ public void test_writeI() { // Test for method void java.io.StringWriter.write(int) sw.write('c'); - assertTrue("Char not written properly", sw.toString().equals("c")); + assertEquals("Char not written properly", "c", sw.toString()); } /** @@ -102,8 +102,8 @@ public void test_writeLjava_lang_String() { // Test for method void java.io.StringWriter.write(java.lang.String) sw.write("This is a test string"); - assertTrue("String not written properly", sw.toString().equals( - "This is a test string")); + assertEquals("String not written properly", + "This is a test string", sw.toString()); } /** @@ -113,7 +113,7 @@ // Test for method void java.io.StringWriter.write(java.lang.String, // int, int) sw.write("This is a test string", 2, 2); - assertTrue("String not written properly", sw.toString().equals("is")); + assertEquals("String not written properly", "is", sw.toString()); } /** Index: modules/luni/src/test/java/tests/api/java/io/SerializationStressTest2.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/SerializationStressTest2.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/SerializationStressTest2.java (working copy) @@ -1297,8 +1297,8 @@ System.out.println("Obj = " + objToSave); objLoaded = dumpAndReload(objToSave); // Has to have worked - assertTrue(MSG_TEST_FAILED + objToSave, - ((NestedPutField) objLoaded).field1 != null); + assertNotNull(MSG_TEST_FAILED + objToSave, + ((NestedPutField) objLoaded).field1); } catch (IOException e) { fail("IOException serializing " + objToSave + " : " Index: modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/CharArrayWriterTest.java (working copy) @@ -34,7 +34,7 @@ public void test_Constructor() { // Test for method java.io.CharArrayWriter() cw = new CharArrayWriter(90); - assertTrue("Created incorrect writer", cw.size() == 0); + assertEquals("Created incorrect writer", 0, cw.size()); } /** @@ -43,7 +43,7 @@ public void test_ConstructorI() { // Test for method java.io.CharArrayWriter(int) cw = new CharArrayWriter(); - assertTrue("Created incorrect writer", cw.size() == 0); + assertEquals("Created incorrect writer", 0, cw.size()); } /** @@ -74,8 +74,8 @@ try { char[] c = new char[100]; cr.read(c, 0, 5); - assertTrue("Reset failed to reset buffer", "Hello" - .equals(new String(c, 0, 5))); + assertEquals("Reset failed to reset buffer", + "Hello", new String(c, 0, 5)); } catch (IOException e) { fail("Exception during reset test : " + e.getMessage()); } @@ -86,9 +86,9 @@ */ public void test_size() { // Test for method int java.io.CharArrayWriter.size() - assertTrue("Returned incorrect size", cw.size() == 0); + assertEquals("Returned incorrect size", 0, cw.size()); cw.write(hw, 5, 5); - assertTrue("Returned incorrect size", cw.size() == 5); + assertEquals("Returned incorrect size", 5, cw.size()); } /** @@ -101,8 +101,8 @@ try { char[] c = new char[100]; cr.read(c, 0, 10); - assertTrue("toCharArray failed to return correct array", - "HelloWorld".equals(new String(c, 0, 10))); + assertEquals("toCharArray failed to return correct array", + "HelloWorld", new String(c, 0, 10)); } catch (IOException e) { fail("Exception during toCharArray test : " + e.getMessage()); } @@ -115,7 +115,8 @@ // Test for method java.lang.String java.io.CharArrayWriter.toString() cw.write("HelloWorld", 5, 5); cr = new CharArrayReader(cw.toCharArray()); - assertTrue("Returned incorrect string", "World".equals(cw.toString())); + assertEquals("Returned incorrect string", + "World", cw.toString()); } /** @@ -128,8 +129,8 @@ try { char[] c = new char[100]; cr.read(c, 0, 5); - assertTrue("Writer failed to write correct chars", "World" - .equals(new String(c, 0, 5))); + assertEquals("Writer failed to write correct chars", + "World", new String(c, 0, 5)); } catch (IOException e) { fail("Exception during write test : " + e.getMessage()); } @@ -143,7 +144,8 @@ cw.write('T'); cr = new CharArrayReader(cw.toCharArray()); try { - assertTrue("Writer failed to write char", cr.read() == 'T'); + assertEquals("Writer failed to write char", + 'T', cr.read()); } catch (IOException e) { fail("Exception during write test : " + e.getMessage()); } @@ -160,8 +162,8 @@ try { char[] c = new char[100]; cr.read(c, 0, 5); - assertTrue("Writer failed to write correct chars", "World" - .equals(new String(c, 0, 5))); + assertEquals("Writer failed to write correct chars", + "World", new String(c, 0, 5)); } catch (IOException e) { fail("Exception during write test : " + e.getMessage()); } @@ -176,8 +178,8 @@ StringWriter sw = new StringWriter(); try { cw.writeTo(sw); - assertTrue("Writer failed to write correct chars", "HelloWorld" - .equals(sw.toString())); + assertEquals("Writer failed to write correct chars", + "HelloWorld", sw.toString()); } catch (IOException e) { fail("Exception during writeTo test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java (working copy) @@ -199,13 +199,13 @@ InputStream in = new BufferedInputStream( new ByteArrayInputStream(bytes), 12); try { - assertTrue("Wrong initial byte", in.read() == 0); // Fill the + assertEquals("Wrong initial byte", 0, in.read()); // Fill the // buffer byte[] buf = new byte[14]; in.read(buf, 0, 14); // Read greater than the buffer assertTrue("Wrong block read data", new String(buf, 0, 14) .equals(new String(bytes, 1, 14))); - assertTrue("Wrong bytes", in.read() == 15); // Check next byte + assertEquals("Wrong bytes", 15, in.read()); // Check next byte } catch (IOException e) { fail("Exception during read test 2"); } Index: modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/ByteArrayInputStreamTest.java (working copy) @@ -49,8 +49,8 @@ java.io.InputStream bis = new java.io.ByteArrayInputStream(zz, 0, 100); try { - assertTrue("Unable to create ByteArrayInputStream", - bis.available() == 100); + assertEquals("Unable to create ByteArrayInputStream", + 100, bis.available()); } catch (Exception e) { fail("Exception during Constructor test"); } Index: modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java (working copy) @@ -414,8 +414,8 @@ try { is = new InputStreamReader(fis, "8859_1"); } catch (UnsupportedEncodingException e) { - assertTrue("Returned incorrect encoding", is.getEncoding().equals( - "8859_1")); + assertEquals("Returned incorrect encoding", + "8859_1", is.getEncoding()); } } Index: modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/ObjectOutputStreamTest.java (working copy) @@ -628,11 +628,11 @@ ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); sth = (SerializableTestHelper) (ois.readObject()); - assertTrue("readFields / writeFields failed--first field not set", - sth.getText1().equals("Gabba")); - assertTrue( + assertEquals("readFields / writeFields failed--first field not set", + "Gabba", sth.getText1()); + assertNull( "readFields / writeFields failed--second field should not have been set", - sth.getText2() == null); + sth.getText2()); } catch (Exception e) { fail("Exception thrown : " + e.getMessage()); } @@ -728,8 +728,8 @@ .toByteArray())); ois.read(buf, 0, 10); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -749,8 +749,8 @@ .toByteArray())); ois.read(buf, 0, 10); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -766,7 +766,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect byte", ois.read() == 'T'); + assertEquals("Read incorrect byte", 'T', ois.read()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -799,7 +799,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Wrote incorrect byte value", ois.readByte() == 127); + assertEquals("Wrote incorrect byte value", 127, ois.readByte()); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -819,8 +819,8 @@ .toByteArray())); ois.readFully(buf); ois.close(); - assertTrue("Wrote incorrect bytes value", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Wrote incorrect bytes value", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -836,7 +836,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Wrote incorrect char value", ois.readChar() == 'T'); + assertEquals("Wrote incorrect char value", 'T', ois.readChar()); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -860,8 +860,8 @@ for (int i = 0; i < avail; ++i) buf[i] = ois.readChar(); ois.close(); - assertTrue("Wrote incorrect chars", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Wrote incorrect chars", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -1010,7 +1010,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Wrote incorrect short value", ois.readShort() == 127); + assertEquals("Wrote incorrect short value", 127, ois.readShort()); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -1027,8 +1027,8 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Wrote incorrect UTF value", ois.readUTF().equals( - "HelloWorld")); + assertEquals("Wrote incorrect UTF value", + "HelloWorld", ois.readUTF()); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/DataOutputStreamTest.java (working copy) @@ -52,7 +52,7 @@ openDataInputStream(); int c = dis.readInt(); dis.close(); - assertTrue("Failed to flush correctly", c == 9087589); + assertEquals("Failed to flush correctly", 9087589, c); } catch (IOException e) { fail("Exception during flush test : " + e.getMessage()); } @@ -71,7 +71,7 @@ byte[] rbuf = new byte[150]; dis.read(rbuf, 0, 150); dis.close(); - assertTrue("Incorrect size returned", os.size() == 150); + assertEquals("Incorrect size returned", 150, os.size()); } catch (IOException e) { fail("Exception during write test : " + e.getMessage()); } @@ -179,7 +179,7 @@ openDataInputStream(); char c = dis.readChar(); dis.close(); - assertTrue("Incorrect char written", c == 'T'); + assertEquals("Incorrect char written", 'T', c); } catch (IOException e) { fail("Exception during writeChar test : " + e.getMessage()); } @@ -199,8 +199,8 @@ int i, a = dis.available() / 2; for (i = 0; i < a; i++) chars[i] = dis.readChar(); - assertTrue("Incorrect chars written", new String(chars, 0, i) - .equals("Test String")); + assertEquals("Incorrect chars written", "Test String", new String(chars, 0, i) + ); } catch (IOException e) { fail("Exception during writeChars test : " + e.getMessage()); } @@ -217,7 +217,7 @@ openDataInputStream(); double c = dis.readDouble(); dis.close(); - assertTrue("Incorrect double written", c == 908755555456.98); + assertEquals("Incorrect double written", 908755555456.98, c); } catch (IOException e) { fail("Exception during writeDouble test : " + e.getMessage()); } @@ -251,7 +251,7 @@ openDataInputStream(); int c = dis.readInt(); dis.close(); - assertTrue("Incorrect int written", c == 9087589); + assertEquals("Incorrect int written", 9087589, c); } catch (IOException e) { fail("Exception during writeInt test : " + e.getMessage()); } @@ -268,7 +268,7 @@ openDataInputStream(); long c = dis.readLong(); dis.close(); - assertTrue("Incorrect long written", c == 908755555456L); + assertEquals("Incorrect long written", 908755555456L, c); } catch (IOException e) { fail("Exception during writeLong test" + e.getMessage()); } @@ -285,7 +285,7 @@ openDataInputStream(); short c = dis.readShort(); dis.close(); - assertTrue("Incorrect short written", c == 9087); + assertEquals("Incorrect short written", 9087, c); } catch (IOException e) { fail("Exception during writeShort test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/ObjectStreamClassTest.java (working copy) @@ -52,10 +52,10 @@ // Test for method java.io.ObjectStreamField // java.io.ObjectStreamClass.getField(java.lang.String) ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class); - assertTrue("getField did not return correct field", osc.getField("bam") - .getTypeCode() == 'J'); - assertTrue("getField did not null for non-existent field", osc - .getField("wham") == null); + assertEquals("getField did not return correct field", 'J', osc.getField("bam") + .getTypeCode()); + assertNull("getField did not null for non-existent field", osc + .getField("wham")); } /** Index: modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FileOutputStreamTest.java (working copy) @@ -195,7 +195,7 @@ fos = new java.io.FileOutputStream(f.getPath()); fos.write('t'); fis = new java.io.FileInputStream(f.getPath()); - assertTrue("Incorrect char written", fis.read() == 't'); + assertEquals("Incorrect char written", 't', fis.read()); } catch (java.io.IOException e) { fail("Exception during write test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/FilterOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FilterOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FilterOutputStreamTest.java (working copy) @@ -51,7 +51,7 @@ os = new java.io.FilterOutputStream(bos); os.write(fileString.getBytes(), 0, 500); os.flush(); - assertTrue("Bytes not written after flush", bos.size() == 500); + assertEquals("Bytes not written after flush", 500, bos.size()); os.close(); } catch (java.io.IOException e) { fail("Close test failed : " + e.getMessage()); @@ -68,7 +68,7 @@ os = new java.io.FilterOutputStream(bos); os.write(fileString.getBytes(), 0, 500); os.flush(); - assertTrue("Bytes not written after flush", bos.size() == 500); + assertEquals("Bytes not written after flush", 500, bos.size()); os.close(); } catch (java.io.IOException e) { fail("Flush test failed : " + e.getMessage()); @@ -131,10 +131,10 @@ os.write('t'); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); os.flush(); - assertTrue("Byte not written after flush", bis.available() == 1); + assertEquals("Byte not written after flush", 1, bis.available()); byte[] wbytes = new byte[1]; bis.read(wbytes, 0, 1); - assertTrue("Incorrect byte written", wbytes[0] == 't'); + assertEquals("Incorrect byte written", 't', wbytes[0]); } catch (java.io.IOException e) { fail("Write test failed : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/CharConversionExceptionTest.java (working copy) @@ -29,9 +29,9 @@ throw new java.io.CharConversionException(); fail("Exception not thrown"); } catch (java.io.CharConversionException e) { - assertTrue( + assertNull( "Exception defined with no message answers non-null to getMessage()", - e.getMessage() == null); + e.getMessage()); } } @@ -45,9 +45,8 @@ throw new java.io.CharConversionException("Blah"); fail("Exception not thrown"); } catch (java.io.CharConversionException e) { - assertTrue( - "Exception defined with no message answers non-null to getMessage()", - e.getMessage().equals("Blah")); + assertEquals("Exception defined with no message answers non-null to getMessage()", + "Blah", e.getMessage()); } } Index: modules/luni/src/test/java/tests/api/java/io/FileReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FileReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FileReaderTest.java (working copy) @@ -44,8 +44,8 @@ char[] buf = new char[100]; int r = br.read(buf); br.close(); - assertTrue("Failed to read correct chars", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } @@ -66,8 +66,8 @@ int r = br.read(buf); br.close(); fis.close(); - assertTrue("Failed to read correct chars", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } @@ -86,8 +86,8 @@ char[] buf = new char[100]; int r = br.read(buf); br.close(); - assertTrue("Failed to read correct chars", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } Index: modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/ObjectInputStreamTest.java (working copy) @@ -227,7 +227,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect bytes", ois.available() == 10); + assertEquals("Read incorrect bytes", 10, ois.available()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -285,7 +285,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect byte value", ois.read() == 'T'); + assertEquals("Read incorrect byte value", 'T', ois.read()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -305,8 +305,8 @@ .toByteArray())); ois.read(buf, 0, 10); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -339,7 +339,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect byte value", ois.readByte() == 127); + assertEquals("Read incorrect byte value", 127, ois.readByte()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -356,7 +356,7 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect char value", ois.readChar() == 'T'); + assertEquals("Read incorrect char value", 'T', ois.readChar()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -403,11 +403,11 @@ ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); sth = (SerializableTestHelper) (ois.readObject()); - assertTrue("readFields / writeFields failed--first field not set", - sth.getText1().equals("Gabba")); - assertTrue( + assertEquals("readFields / writeFields failed--first field not set", + "Gabba", sth.getText1()); + assertNull( "readFields / writeFields failed--second field should not have been set", - sth.getText2() == null); + sth.getText2()); } catch (Exception e) { fail("Exception serializing data : " + e.getMessage()); } @@ -444,8 +444,8 @@ .toByteArray())); ois.readFully(buf); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -465,8 +465,8 @@ .toByteArray())); ois.readFully(buf, 0, 10); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } @@ -501,8 +501,8 @@ ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); ois.readLine(); - assertTrue("Read incorrect string value", ois.readLine().equals( - "SecondLine")); + assertEquals("Read incorrect string value", + "SecondLine", ois.readLine()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -599,8 +599,8 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect unsignedByte value", ois - .readUnsignedByte() == 255); + assertEquals("Read incorrect unsignedByte value", 255, ois + .readUnsignedByte()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -617,8 +617,8 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect unsignedShort value", ois - .readUnsignedShort() == 65535); + assertEquals("Read incorrect unsignedShort value", 65535, ois + .readUnsignedShort()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -635,8 +635,8 @@ oos.close(); ois = new ObjectInputStream(new ByteArrayInputStream(bao .toByteArray())); - assertTrue("Read incorrect utf value", ois.readUTF().equals( - "HelloWorld")); + assertEquals("Read incorrect utf value", + "HelloWorld", ois.readUTF()); ois.close(); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); @@ -657,8 +657,8 @@ ois.skipBytes(5); ois.read(buf, 0, 5); ois.close(); - assertTrue("Skipped incorrect bytes", new String(buf, 0, 5) - .equals("World")); + assertEquals("Skipped incorrect bytes", "World", new String(buf, 0, 5) + ); } catch (IOException e) { fail("Exception serializing data : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java (working copy) @@ -151,13 +151,13 @@ Reader in = new BufferedReader(new Support_StringReader(new String( chars)), 12); try { - assertTrue("Wrong initial char", in.read() == 0); // Fill the + assertEquals("Wrong initial char", 0, in.read()); // Fill the // buffer char[] buf = new char[14]; in.read(buf, 0, 14); // Read greater than the buffer assertTrue("Wrong block read data", new String(buf) .equals(new String(chars, 1, 14))); - assertTrue("Wrong chars", in.read() == 15); // Check next byte + assertEquals("Wrong chars", 15, in.read()); // Check next byte } catch (IOException e) { fail("Exception during read test 2:" + e); } @@ -268,8 +268,8 @@ try { br = new BufferedReader(new Support_StringReader(testString)); String r = br.readLine(); - assertTrue("readLine returned incorrect string", r - .equals("Test_All_Tests")); + assertEquals("readLine returned incorrect string", "Test_All_Tests", r + ); } catch (java.io.IOException e) { fail("Exception during readLine test"); } Index: modules/luni/src/test/java/tests/api/java/io/FileWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FileWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FileWriterTest.java (working copy) @@ -53,8 +53,8 @@ char[] buf = new char[100]; int r = br.read(buf); br.close(); - assertTrue("Failed to write correct chars", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } @@ -99,8 +99,8 @@ char[] buf = new char[100]; int r = br.read(buf); br.close(); - assertTrue("Failed to write correct chars", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } @@ -123,8 +123,8 @@ char[] buf = new char[100]; int r = br.read(buf); br.close(); - assertTrue("Failed to append to file", new String(buf, 0, r) - .equals("Test String After test string")); + assertEquals("Failed to append to file", "Test String After test string", new String(buf, 0, r) + ); fos = new FileOutputStream(f.getPath()); fos.write("Test String".getBytes()); @@ -136,8 +136,8 @@ buf = new char[100]; r = br.read(buf); br.close(); - assertTrue("Failed to overwrite file", new String(buf, 0, r) - .equals(" After test string")); + assertEquals("Failed to overwrite file", " After test string", new String(buf, 0, r) + ); } catch (Exception e) { fail("Exception during Constructor test " + e.toString()); } Index: modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/BufferedWriterTest.java (working copy) @@ -37,7 +37,7 @@ sw = new Support_StringWriter(); bw = new BufferedWriter(sw); sw.write("Hi"); - assertTrue("Constructor failed", sw.toString().equals("Hi")); + assertEquals("Constructor failed", "Hi", sw.toString()); } @@ -71,8 +71,8 @@ bw.write("This should not cause a flush"); assertTrue("Bytes written without flush", sw.toString().equals("")); bw.flush(); - assertTrue("Bytes not flushed", sw.toString().equals( - "This should not cause a flush")); + assertEquals("Bytes not flushed", + "This should not cause a flush", sw.toString()); } catch (Exception e) { fail("Exception during flush test"); } @@ -120,7 +120,7 @@ bw.write('T'); assertTrue("Char written without flush", sw.toString().equals("")); bw.flush(); - assertTrue("Incorrect char written", sw.toString().equals("T")); + assertEquals("Incorrect char written", "T", sw.toString()); } catch (Exception e) { fail("Exception during write test"); } Index: modules/luni/src/test/java/tests/api/java/io/FileTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FileTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FileTest.java (working copy) @@ -303,8 +303,8 @@ File f3 = new File("thatFile.tst"); String notAFile = "notAFile.tst"; - assertTrue("Equal files did not answer zero for compareTo", f1 - .compareTo(f2) == 0); + assertEquals("Equal files did not answer zero for compareTo", 0, f1 + .compareTo(f2)); assertTrue("f3.compareTo(f1) did not result in value < 0", f3 .compareTo(f1) < 0); assertTrue("f1.compareTo(f3) did not result in vale > 0", f1 @@ -320,7 +320,7 @@ boolean onWindows = File.separatorChar == '\\'; boolean onUnix = File.separatorChar == '/'; if (onWindows) { - assertTrue("Files Should Return Equal.", f1.compareTo(f3) == 0); + assertEquals("Files Should Return Equal.", 0, f1.compareTo(f3)); } else if (onUnix) { assertTrue("Files Should NOT Return Equal.", f1.compareTo(f3) != 0); } @@ -335,8 +335,8 @@ File f2 = new File("thisFile.file"); File f3 = new File("thatFile.file"); String notAFile = "notAFile.file"; - assertTrue("Equal files did not answer zero for compareTo", f1 - .compareTo((Object) f2) == 0); + assertEquals("Equal files did not answer zero for compareTo", 0, f1 + .compareTo((Object) f2)); assertTrue("f3.compareTo(f1) did not result in value < 0", f3 .compareTo((Object) f1) < 0); assertTrue("f1.compareTo(f3) did not result in vale > 0", f1 @@ -397,8 +397,8 @@ assertTrue("File Saved To Wrong Directory.", dirName.equals(dir .getPath() + slash)); - assertTrue("File Saved With Incorrect Name.", f1.getName() - .equals("tempfile.tst")); + assertEquals("File Saved With Incorrect Name.", "tempfile.tst", f1.getName() + ); // Test for creating a file that already exists. assertTrue( @@ -724,16 +724,16 @@ base += slash; File f = new File(base, "temp.tst"); File f2 = f.getAbsoluteFile(); - assertTrue("Test 1: Incorrect File Returned.", f2.compareTo(f - .getAbsoluteFile()) == 0); + assertEquals("Test 1: Incorrect File Returned.", 0, f2.compareTo(f + .getAbsoluteFile())); f = new File(base + "Temp" + slash + slash + "temp.tst"); f2 = f.getAbsoluteFile(); - assertTrue("Test 2: Incorrect File Returned.", f2.compareTo(f - .getAbsoluteFile()) == 0); + assertEquals("Test 2: Incorrect File Returned.", 0, f2.compareTo(f + .getAbsoluteFile())); f = new File(base + slash + ".." + slash + "temp.tst"); f2 = f.getAbsoluteFile(); - assertTrue("Test 3: Incorrect File Returned.", f2.compareTo(f - .getAbsoluteFile()) == 0); + assertEquals("Test 3: Incorrect File Returned.", 0, f2.compareTo(f + .getAbsoluteFile())); f.delete(); f2.delete(); } @@ -771,17 +771,17 @@ base += slash; File f = new File(base, "temp.tst"); File f2 = f.getCanonicalFile(); - assertTrue("Test 1: Incorrect File Returned.", f2 - .getCanonicalFile().compareTo(f.getCanonicalFile()) == 0); + assertEquals("Test 1: Incorrect File Returned.", 0, f2 + .getCanonicalFile().compareTo(f.getCanonicalFile())); f = new File(base + "Temp" + slash + slash + "temp.tst"); f2 = f.getCanonicalFile(); - assertTrue("Test 2: Incorrect File Returned.", f2 - .getCanonicalFile().compareTo(f.getCanonicalFile()) == 0); + assertEquals("Test 2: Incorrect File Returned.", 0, f2 + .getCanonicalFile().compareTo(f.getCanonicalFile())); f = new File(base + "Temp" + slash + slash + ".." + slash + "temp.tst"); f2 = f.getCanonicalFile(); - assertTrue("Test 3: Incorrect File Returned.", f2 - .getCanonicalFile().compareTo(f.getCanonicalFile()) == 0); + assertEquals("Test 3: Incorrect File Returned.", 0, f2 + .getCanonicalFile().compareTo(f.getCanonicalFile())); // Test for when long directory/file names in Windows String osName = System.getProperty("os.name", "unknown"); @@ -796,9 +796,9 @@ dir.mkdir(); f = new File(dir, "longfilename.tst"); f2 = f.getCanonicalFile(); - assertTrue("Test 4: Incorrect File Returned.", - f2.getCanonicalFile().compareTo( - f.getCanonicalFile()) == 0); + assertEquals("Test 4: Incorrect File Returned.", + 0, f2.getCanonicalFile().compareTo( + f.getCanonicalFile())); FileOutputStream fos = new FileOutputStream(f); fos.close(); f2 = new File(testdir + slash + "longdi~1" + slash @@ -932,8 +932,8 @@ public void test_getName() { // Test for method java.lang.String java.io.File.getName() File f = new File("name.tst"); - assertTrue("Test 1: Returned incorrect name", f.getName().equals( - "name.tst")); + assertEquals("Test 1: Returned incorrect name", + "name.tst", f.getName()); f = new File(""); assertTrue("Test 2: Returned incorrect name", f.getName().equals("")); @@ -947,7 +947,7 @@ public void test_getParent() { // Test for method java.lang.String java.io.File.getParent() File f = new File("p.tst"); - assertTrue("Incorrect path returned", f.getParent() == null); + assertNull("Incorrect path returned", f.getParent()); f = new File(System.getProperty("user.home"), "p.tst"); assertTrue("Incorrect path returned", f.getParent().equals( System.getProperty("user.home"))); @@ -963,11 +963,11 @@ assertTrue("Wrong parent test 2", f1.getParent().equals( slash + "directory")); f1 = new File("directory/file"); - assertTrue("Wrong parent test 3", f1.getParent().equals("directory")); + assertEquals("Wrong parent test 3", "directory", f1.getParent()); f1 = new File("/"); - assertTrue("Wrong parent test 4", f1.getParent() == null); + assertNull("Wrong parent test 4", f1.getParent()); f1 = new File("directory"); - assertTrue("Wrong parent test 5", f1.getParent() == null); + assertNull("Wrong parent test 5", f1.getParent()); if (File.separatorChar == '\\' && new File("d:/").isAbsolute()) { f1 = new File("d:/directory"); @@ -977,12 +977,12 @@ assertTrue("Wrong parent test 2a", f1.getParent().equals( "d:" + slash + "directory")); f1 = new File("d:directory/file"); - assertTrue("Wrong parent test 3a", f1.getParent().equals( - "d:directory")); + assertEquals("Wrong parent test 3a", + "d:directory", f1.getParent()); f1 = new File("d:/"); - assertTrue("Wrong parent test 4a", f1.getParent() == null); + assertNull("Wrong parent test 4a", f1.getParent()); f1 = new File("d:directory"); - assertTrue("Wrong parent test 5a", f1.getParent().equals("d:")); + assertEquals("Wrong parent test 5a", "d:", f1.getParent()); } } @@ -992,13 +992,13 @@ public void test_getParentFile() { // Test for method java.io.File.getParentFile() File f = new File("tempfile.tst"); - assertTrue("Incorrect path returned", f.getParentFile() == null); + assertNull("Incorrect path returned", f.getParentFile()); f = new File(System.getProperty("user.dir"), "tempfile1.tmp"); File f2 = new File(System.getProperty("user.dir"), "tempfile2.tmp"); File f3 = new File(System.getProperty("user.dir"), "/a/tempfile.tmp"); + assertEquals("Incorrect File Returned", 0, f.getParentFile().compareTo( + f2.getParentFile())); assertTrue("Incorrect File Returned", f.getParentFile().compareTo( - f2.getParentFile()) == 0); - assertTrue("Incorrect File Returned", f.getParentFile().compareTo( f3.getParentFile()) != 0); f.delete(); f2.delete(); @@ -1148,8 +1148,8 @@ + "lModTest.tst"); f.delete(); long lastModifiedTime = f.lastModified(); - assertTrue("LastModified Time Should Have Returned 0.", - lastModifiedTime == 0); + assertEquals("LastModified Time Should Have Returned 0.", + 0, lastModifiedTime); FileOutputStream fos = new FileOutputStream(f); fos.close(); f.setLastModified(315550800000L); @@ -1170,7 +1170,7 @@ try { File f = new File(System.getProperty("user.dir"), platformId + "input.tst"); - assertTrue("File Length Should Have Returned 0.", f.length() == 0); + assertEquals("File Length Should Have Returned 0.", 0, f.length()); FileOutputStream fos = new FileOutputStream(f); fos.write(fileString.getBytes()); fos.close(); @@ -1207,24 +1207,23 @@ String[] flist = dir.list(); - assertTrue("Method list() Should Have Returned null.", flist == null); + assertNull("Method list() Should Have Returned null.", flist); assertTrue("Could not create parent directory for list test", dir .mkdir()); String[] files = { "mtzz1.xx", "mtzz2.xx", "mtzz3.yy", "mtzz4.yy" }; try { - assertTrue( - "Method list() Should Have Returned An Array Of Length 0.", - dir.list().length == 0); + assertEquals("Method list() Should Have Returned An Array Of Length 0.", + 0, dir.list().length); File file = new File(dir, "notADir.tst"); try { FileOutputStream fos = new FileOutputStream(file); fos.close(); - assertTrue( + assertNull( "listFiles Should Have Returned Null When Used On A File Instead Of A Directory.", - file.list() == null); + file.list()); } catch (IOException e) { fail("Unexpected IOException during test : " + e.getMessage()); } finally { @@ -1264,7 +1263,7 @@ if (check[i] == false) checkCount++; } - assertTrue("Invalid file returned in listing", checkCount == 0); + assertEquals("Invalid file returned in listing", 0, checkCount); for (int i = 0; i < files.length; i++) { File f = new File(dir, files[i]); @@ -1308,22 +1307,22 @@ } } // Test for attempting to cal listFiles on a non-existent directory. - assertTrue("listFiles Should Return Null.", dir.listFiles() == null); + assertNull("listFiles Should Return Null.", dir.listFiles()); assertTrue("Failed To Create Parent Directory.", dir.mkdir()); String[] files = { "1.tst", "2.tst", "3.tst", "" }; try { - assertTrue("listFiles Should Return An Array Of Length 0.", dir - .listFiles().length == 0); + assertEquals("listFiles Should Return An Array Of Length 0.", 0, dir + .listFiles().length); File file = new File(dir, "notADir.tst"); try { FileOutputStream fos = new FileOutputStream(file); fos.close(); - assertTrue( + assertNull( "listFiles Should Have Returned Null When Used On A File Instead Of A Directory.", - file.listFiles() == null); + file.listFiles()); } catch (IOException e) { fail("Unexpected IOException during test : " + e.getMessage()); } finally { @@ -1341,8 +1340,8 @@ // Test to make sure that only the 3 files that were created are // listed. - assertTrue("Incorrect Number Of Files Returned.", - flist.length == 3); + assertEquals("Incorrect Number Of Files Returned.", + 3, flist.length); // Test to make sure that listFiles can read hidden files. boolean onUnix = File.separatorChar == '/'; @@ -1363,8 +1362,8 @@ fos.close(); } flist = dir.listFiles(); - assertTrue("Incorrect Number Of Files Returned.", - flist.length == 4); + assertEquals("Incorrect Number Of Files Returned.", + 4, flist.length); // Checking to make sure the correct files were are listed in // the array. @@ -1384,7 +1383,7 @@ if (check[i] == false) checkCount++; } - assertTrue("Invalid file returned in listing", checkCount == 0); + assertEquals("Invalid file returned in listing", 0, checkCount); if (onWindows) { Runtime r = Runtime.getRuntime(); @@ -1445,24 +1444,24 @@ } }; - assertTrue("listFiles Should Return Null.", baseDir - .listFiles(dirFilter) == null); + assertNull("listFiles Should Return Null.", baseDir + .listFiles(dirFilter)); assertTrue("Failed To Create Parent Directory.", baseDir.mkdir()); File dir1 = null; String[] files = { "1.tst", "2.tst", "3.tst" }; try { - assertTrue("listFiles Should Return An Array Of Length 0.", baseDir - .listFiles(dirFilter).length == 0); + assertEquals("listFiles Should Return An Array Of Length 0.", 0, baseDir + .listFiles(dirFilter).length); File file = new File(baseDir, "notADir.tst"); try { FileOutputStream fos = new FileOutputStream(file); fos.close(); - assertTrue( + assertNull( "listFiles Should Have Returned Null When Used On A File Instead Of A Directory.", - file.listFiles(dirFilter) == null); + file.listFiles(dirFilter)); } catch (IOException e) { fail("Unexpected IOException During Test."); } finally { @@ -1493,12 +1492,12 @@ // Test to see if the correct number of directories are returned. File[] directories = baseDir.listFiles(dirFilter); - assertTrue("Incorrect Number Of Directories Returned.", - directories.length == 1); + assertEquals("Incorrect Number Of Directories Returned.", + 1, directories.length); // Test to see if the directory was saved with the correct name. - assertTrue("Incorrect Directory Returned.", directories[0] - .compareTo(dir1) == 0); + assertEquals("Incorrect Directory Returned.", 0, directories[0] + .compareTo(dir1)); // Test to see if the correct number of files are returned. File[] flist = baseDir.listFiles(fileFilter); @@ -1523,7 +1522,7 @@ if (check[i] == false) checkCount++; } - assertTrue("Invalid file returned in listing", checkCount == 0); + assertEquals("Invalid file returned in listing", 0, checkCount); for (int i = 0; i < files.length; i++) { File f = new File(baseDir, files[i]); @@ -1576,23 +1575,23 @@ } }; - assertTrue("listFiles Should Return Null.", - dir.listFiles(tstFilter) == null); + assertNull("listFiles Should Return Null.", + dir.listFiles(tstFilter)); assertTrue("Failed To Create Parent Directory.", dir.mkdir()); String[] files = { "1.tst", "2.tst", "3.tmp" }; try { - assertTrue("listFiles Should Return An Array Of Length 0.", dir - .listFiles(tstFilter).length == 0); + assertEquals("listFiles Should Return An Array Of Length 0.", 0, dir + .listFiles(tstFilter).length); File file = new File(dir, "notADir.tst"); try { FileOutputStream fos = new FileOutputStream(file); fos.close(); - assertTrue( + assertNull( "listFiles Should Have Returned Null When Used On A File Instead Of A Directory.", - file.listFiles(tstFilter) == null); + file.listFiles(tstFilter)); } catch (IOException e) { fail("Unexpected IOException during test : " + e.getMessage()); } finally { @@ -1622,15 +1621,15 @@ // Tests to see if the correct number of files were returned. File[] flist = dir.listFiles(tstFilter); - assertTrue("Incorrect Number Of Files Passed Through tstFilter.", - flist.length == 2); + assertEquals("Incorrect Number Of Files Passed Through tstFilter.", + 2, flist.length); for (int i = 0; i < flist.length; i++) assertTrue("File Should Not Have Passed The tstFilter.", flist[i].getPath().endsWith(".tst")); flist = dir.listFiles(tmpFilter); - assertTrue("Incorrect Number Of Files Passed Through tmpFilter.", - flist.length == 1); + assertEquals("Incorrect Number Of Files Passed Through tmpFilter.", + 1, flist.length); assertTrue("File Should Not Have Passed The tmpFilter.", flist[0] .getPath().endsWith(".tmp")); @@ -1678,8 +1677,8 @@ }; String[] flist = dir.list(filter); - assertTrue("Method list(FilenameFilter) Should Have Returned Null.", - flist == null); + assertNull("Method list(FilenameFilter) Should Have Returned Null.", + flist); assertTrue("Could not create parent directory for test", dir.mkdir()); @@ -1694,14 +1693,14 @@ * File file = new File(dir, "notADir.tst"); try { FileOutputStream * fos = new FileOutputStream(file); fos.close(); } catch * (IOException e) { fail("Unexpected IOException During - * Test."); } flist = dir.list(filter); assertTrue("listFiles + * Test."); } flist = dir.list(filter); assertNull("listFiles * Should Have Returned Null When Used On A File Instead Of A - * Directory.", flist == null); file.delete(); + * Directory.", flist); file.delete(); */ flist = dir.list(filter); - assertTrue("Array Of Length 0 Should Have Returned.", - flist.length == 0); + assertEquals("Array Of Length 0 Should Have Returned.", + 0, flist.length); try { for (int i = 0; i < files.length; i++) { @@ -1738,7 +1737,7 @@ if (check[i] == false) checkCount++; } - assertTrue("Invalid file returned in listing", checkCount == 0); + assertEquals("Invalid file returned in listing", 0, checkCount); for (int i = 0; i < files.length; i++) { File f = new File(dir, files[i]); @@ -1765,8 +1764,8 @@ boolean onUnix = File.separatorChar == '/'; boolean onWindows = File.separatorChar == '\\'; if (onUnix) { - assertTrue("Incorrect Number Of Root Directories.", - roots.length == 1); + assertEquals("Incorrect Number Of Root Directories.", + 1, roots.length); String fileLoc = roots[0].getPath(); assertTrue("Incorrect Root Directory Returned.", fileLoc .startsWith(slash)); Index: modules/luni/src/test/java/tests/api/java/io/SerializationStressTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/SerializationStressTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/SerializationStressTest.java (working copy) @@ -398,7 +398,7 @@ oos.write('T'); oos.close(); ois = new ObjectInputStream(loadStream()); - assertTrue("Read incorrect byte", ois.read() == 'T'); + assertEquals("Read incorrect byte", 'T', ois.read()); ois.close(); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); @@ -414,8 +414,8 @@ ois = new ObjectInputStream(loadStream()); ois.read(buf, 0, 10); ois.close(); - assertTrue("Read incorrect bytes", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Read incorrect bytes", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -439,7 +439,7 @@ oos.writeByte(127); oos.close(); ois = new ObjectInputStream(loadStream()); - assertTrue("Wrote incorrect byte value", ois.readByte() == 127); + assertEquals("Wrote incorrect byte value", 127, ois.readByte()); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -455,8 +455,8 @@ ois = new ObjectInputStream(loadStream()); ois.readFully(buf); ois.close(); - assertTrue("Wrote incorrect bytes value", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Wrote incorrect bytes value", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -468,7 +468,7 @@ oos.writeChar('T'); oos.close(); ois = new ObjectInputStream(loadStream()); - assertTrue("Wrote incorrect char value", ois.readChar() == 'T'); + assertEquals("Wrote incorrect char value", 'T', ois.readChar()); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -488,8 +488,8 @@ for (int i = 0; i < avail; ++i) buf[i] = ois.readChar(); ois.close(); - assertTrue("Wrote incorrect chars", new String(buf, 0, 10) - .equals("HelloWorld")); + assertEquals("Wrote incorrect chars", "HelloWorld", new String(buf, 0, 10) + ); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -556,7 +556,7 @@ oos.writeShort(127); oos.close(); ois = new ObjectInputStream(loadStream()); - assertTrue("Wrote incorrect short value", ois.readShort() == 127); + assertEquals("Wrote incorrect short value", 127, ois.readShort()); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -569,8 +569,8 @@ oos.writeUTF("HelloWorld"); oos.close(); ois = new ObjectInputStream(loadStream()); - assertTrue("Wrote incorrect UTF value", ois.readUTF().equals( - "HelloWorld")); + assertEquals("Wrote incorrect UTF value", + "HelloWorld", ois.readUTF()); } catch (IOException e) { fail("IOException serializing data : " + e.getMessage()); } @@ -591,8 +591,8 @@ available2 = ois.available(); obj2 = ois.readObject(); - assertTrue("available returned incorrect value", available1 == 0); - assertTrue("available returned incorrect value", available2 == 0); + assertEquals("available returned incorrect value", 0, available1); + assertEquals("available returned incorrect value", 0, available2); assertTrue("available caused incorrect reading", FOO.equals(obj1)); assertTrue("available returned incorrect value", FOO.equals(obj2)); @@ -656,7 +656,7 @@ Class[] resolvedClasses = ((ObjectInputStreamSubclass) ois) .resolvedClasses(); - assertTrue("missing resolved", resolvedClasses.length == 3); + assertEquals("missing resolved", 3, resolvedClasses.length); assertTrue("resolved class 1", resolvedClasses[0] == Object[].class); assertTrue("resolved class 2", resolvedClasses[1] == Integer.class); assertTrue("resolved class 3", resolvedClasses[2] == Number.class); @@ -679,9 +679,9 @@ assertTrue("incorrect output", Arrays.equals(input, result)); ois = new ObjectInputStreamSubclass(loadStream()); - assertTrue("Wrong result from readObject()", ois.readObject() - .equals("R")); - assertTrue("Wrong result from readByte()", ois.readByte() == 24); + assertEquals("Wrong result from readObject()", "R", ois.readObject() + ); + assertEquals("Wrong result from readByte()", 24, ois.readByte()); ois.close(); } catch (IOException e1) { fail("IOException : " + e1.getMessage()); @@ -770,7 +770,7 @@ } catch (ClassNotFoundException e) { fail(e.toString()); } - assertTrue("String not resolved", "ABC".equals(result.field1)); + assertEquals("String not resolved", "ABC", result.field1); assertTrue("Second reference not resolved", result.field1 == result.field2); } catch (IOException e) { Index: modules/luni/src/test/java/tests/api/java/io/PushbackReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/PushbackReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/PushbackReaderTest.java (working copy) @@ -203,8 +203,8 @@ numSkipped += pReader2.skip(10); numSkipped += pReader2.skip(10); numSkipped += pReader2.skip(10); - assertTrue("Did not skip correct number of characters", - numSkipped == 7); + assertEquals("Did not skip correct number of characters", + 7, numSkipped); numSkipped = 0; numSkipped += pReader.skip(2); pReader.unread('i'); @@ -223,9 +223,9 @@ numSkipped += pReader.skip(1); numSkipped += pReader.skip(1); numSkipped += pReader.skip(1); - assertTrue("Failed to skip all characters", numSkipped == 6); + assertEquals("Failed to skip all characters", 6, numSkipped); long nextSkipped = pReader.skip(1); - assertTrue("skipped empty reader", nextSkipped == 0); + assertEquals("skipped empty reader", 0, nextSkipped); } catch (IOException e) { fail("Failed to skip more characters" + e); } Index: modules/luni/src/test/java/tests/api/java/io/LineNumberReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/LineNumberReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/LineNumberReaderTest.java (working copy) @@ -31,7 +31,7 @@ public void test_ConstructorLjava_io_Reader() { // Test for method java.io.LineNumberReader(java.io.Reader) lnr = new LineNumberReader(new StringReader(text), 4092); - assertTrue("Failed to create reader", lnr.getLineNumber() == 0); + assertEquals("Failed to create reader", 0, lnr.getLineNumber()); } /** @@ -40,7 +40,7 @@ public void test_ConstructorLjava_io_ReaderI() { // Test for method java.io.LineNumberReader(java.io.Reader, int) lnr = new LineNumberReader(new StringReader(text)); - assertTrue("Failed to create reader", lnr.getLineNumber() == 0); + assertEquals("Failed to create reader", 0, lnr.getLineNumber()); } /** @@ -49,8 +49,8 @@ public void test_getLineNumber() { // Test for method int java.io.LineNumberReader.getLineNumber() lnr = new LineNumberReader(new StringReader(text)); - assertTrue("Returned incorrect line number--expected 0, got ", lnr - .getLineNumber() == 0); + assertEquals("Returned incorrect line number--expected 0, got ", 0, lnr + .getLineNumber()); try { lnr.readLine(); lnr.readLine(); @@ -91,14 +91,14 @@ try { int c = lnr.read(); - assertTrue("Read returned incorrect character", c == '0'); + assertEquals("Read returned incorrect character", '0', c); } catch (IOException e) { fail("Exception during read test : " + e.getMessage()); } try { lnr.read(); - assertTrue("Read failed to inc lineNumber", - lnr.getLineNumber() == 1); + assertEquals("Read failed to inc lineNumber", + 1, lnr.getLineNumber()); } catch (IOException e) { fail("Exception during read test:" + e.getMessage()); } @@ -119,7 +119,7 @@ } catch (IOException e) { fail("Exception during read test : " + e.getMessage()); } - assertTrue("Read failed to inc lineNumber", lnr.getLineNumber() == 2); + assertEquals("Read failed to inc lineNumber", 2, lnr.getLineNumber()); } /** @@ -128,7 +128,7 @@ public void test_readLine() { // Test for method java.lang.String java.io.LineNumberReader.readLine() lnr = new LineNumberReader(new StringReader(text)); - assertTrue("Returned incorrect line number", lnr.getLineNumber() == 0); + assertEquals("Returned incorrect line number", 0, lnr.getLineNumber()); String line = null; try { lnr.readLine(); @@ -136,7 +136,7 @@ } catch (IOException e) { fail("Exception during getLineNumberTest: " + e.toString()); } - assertTrue("Returned incorrect string", "1".equals(line)); + assertEquals("Returned incorrect string", "1", line); assertTrue("Returned incorrect line number :" + lnr.getLineNumber(), lnr.getLineNumber() == 2); } @@ -147,7 +147,7 @@ public void test_reset() { // Test for method void java.io.LineNumberReader.reset() lnr = new LineNumberReader(new StringReader(text)); - assertTrue("Returned incorrect line number", lnr.getLineNumber() == 0); + assertEquals("Returned incorrect line number", 0, lnr.getLineNumber()); String line = null; try { lnr.mark(100); @@ -157,7 +157,7 @@ } catch (IOException e) { fail("Exception during getLineNumberTest: " + e.toString()); } - assertTrue("Failed to reset reader", "0".equals(line)); + assertEquals("Failed to reset reader", "0", line); } /** @@ -167,7 +167,7 @@ // Test for method void java.io.LineNumberReader.setLineNumber(int) lnr = new LineNumberReader(new StringReader(text)); lnr.setLineNumber(1001); - assertTrue("set incorrect line number", lnr.getLineNumber() == 1001); + assertEquals("set incorrect line number", 1001, lnr.getLineNumber()); } /** Index: modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/StreamTokenizerTest.java (working copy) @@ -81,9 +81,8 @@ st.ordinaryChar('/'); st.commentChar('*'); try { - assertTrue( - "nextTokent() did not return the character / skiping the comments starting with *", - st.nextToken() == 47); + assertEquals("nextTokent() did not return the character / skiping the comments starting with *", + 47, st.nextToken()); assertTrue("the next token returned should be the digit 8", st .nextToken() == StreamTokenizer.TT_NUMBER && st.nval == 8.0); @@ -135,12 +134,12 @@ public void test_lineno() { setTest("d\n 8\n"); try { - assertTrue("the lineno should be 1", st.lineno() == 1); + assertEquals("the lineno should be 1", 1, st.lineno()); st.nextToken(); st.nextToken(); - assertTrue("the lineno should be 2", st.lineno() == 2); + assertEquals("the lineno should be 2", 2, st.lineno()); st.nextToken(); - assertTrue("the next line no should be 3", st.lineno() == 3); + assertEquals("the next line no should be 3", 3, st.lineno()); } catch (IOException e) { fail( "IOException occured while trying to read an input stream - constructor"); @@ -156,8 +155,8 @@ st.lowerCaseMode(true); try { st.nextToken(); - assertTrue("sval not converted to lowercase.", st.sval - .equals("helloworld")); + assertEquals("sval not converted to lowercase.", "helloworld", st.sval + ); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); } @@ -225,7 +224,7 @@ tokenizer.eolIsSignificant(true); assertTrue("Wrong token 2,1", tokenizer.nextToken() == '\n'); assertTrue("Wrong token 2,2", tokenizer.nextToken() == '\n'); - assertTrue("Wrong token 2,3", tokenizer.nextToken() == '#'); + assertEquals("Wrong token 2,3", '#', tokenizer.nextToken()); } catch (IOException e) { fail("IOException during test 2 : " + e.getMessage()); } @@ -255,8 +254,8 @@ setTest("azbc iof z 893"); st.ordinaryChars('a', 'z'); try { - assertTrue("OrdinaryChars failed.", st.nextToken() == 'a'); - assertTrue("OrdinaryChars failed.", st.nextToken() == 'z'); + assertEquals("OrdinaryChars failed.", 'a', st.nextToken()); + assertEquals("OrdinaryChars failed.", 'z', st.nextToken()); } catch (Exception e) { fail("Exception during test : " + e.getMessage()); } @@ -272,7 +271,7 @@ assertTrue("Base behavior failed.", st.nextToken() == StreamTokenizer.TT_NUMBER); st.ordinaryChars('0', '9'); - assertTrue("setOrdinary failed.", st.nextToken() == '6'); + assertEquals("setOrdinary failed.", '6', st.nextToken()); st.parseNumbers(); assertTrue("parseNumbers failed.", st.nextToken() == StreamTokenizer.TT_NUMBER); @@ -305,12 +304,12 @@ setTest(" 0", holaField .compareTo(hamField) > 0); - assertTrue("Int compared to itself did not return 0", hamField - .compareTo(hamField) == 0); + assertEquals("Int compared to itself did not return 0", 0, hamField + .compareTo(hamField)); assertTrue("(Int)ham compared to (Int)sam did not return < 0", hamField .compareTo(samField) < 0); } @@ -76,8 +76,8 @@ */ public void test_getName() { // Test for method java.lang.String java.io.ObjectStreamField.getName() - assertTrue("Field did not return correct name", holaField.getName() - .equals("hola")); + assertEquals("Field did not return correct name", "hola", holaField.getName() + ); } /** @@ -89,12 +89,12 @@ osfArray = osc.getFields(); assertTrue("getOffset did not return reasonable values", osfArray[0] .getOffset() != osfArray[1].getOffset()); - assertTrue("getOffset for osfArray[0].getOffset() did not return 0", - osfArray[0].getOffset() == 0); - assertTrue("osfArray[1].getOffset() did not return 8", osfArray[1] - .getOffset() == 8); - assertTrue("osfArray[2].getOffset() did not return 12", osfArray[2] - .getOffset() == 12); + assertEquals("getOffset for osfArray[0].getOffset() did not return 0", + 0, osfArray[0].getOffset()); + assertEquals("osfArray[1].getOffset() did not return 8", 8, osfArray[1] + .getOffset()); + assertEquals("osfArray[2].getOffset() did not return 12", 12, osfArray[2] + .getOffset()); } /** @@ -111,10 +111,10 @@ */ public void test_getTypeCode() { // Test for method char java.io.ObjectStreamField.getTypeCode() - assertTrue("getTypeCode on an Object field did not answer 'L'", - holaField.getTypeCode() == 'L'); - assertTrue("getTypeCode on a long field did not answer 'J'", bamField - .getTypeCode() == 'J'); + assertEquals("getTypeCode on an Object field did not answer 'L'", + 'L', holaField.getTypeCode()); + assertEquals("getTypeCode on a long field did not answer 'J'", 'J', bamField + .getTypeCode()); } /** Index: modules/luni/src/test/java/tests/api/java/io/LineNumberInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/LineNumberInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/LineNumberInputStreamTest.java (working copy) @@ -55,19 +55,19 @@ */ public void test_getLineNumber() { // Test for method int java.io.LineNumberInputStream.getLineNumber() - assertTrue("New stream returned line number other than zero", lnis - .getLineNumber() == 0); + assertEquals("New stream returned line number other than zero", 0, lnis + .getLineNumber()); try { lnis.read(); lnis.read(); } catch (IOException e) { fail("Exception during getLineNumber test : " + e.getMessage()); } - assertTrue("stream returned incorrect line number after read", lnis - .getLineNumber() == 1); + assertEquals("stream returned incorrect line number after read", 1, lnis + .getLineNumber()); lnis.setLineNumber(89); - assertTrue("stream returned incorrect line number after set", lnis - .getLineNumber() == 89); + assertEquals("stream returned incorrect line number after set", 89, lnis + .getLineNumber()); } /** @@ -79,8 +79,8 @@ lnis.mark(40); lnis.skip(4); lnis.reset(); - assertTrue("Failed to mark", lnis.getLineNumber() == 0); - assertTrue("Failed to mark", lnis.read() == '0'); + assertEquals("Failed to mark", 0, lnis.getLineNumber()); + assertEquals("Failed to mark", '0', lnis.read()); } catch (IOException e) { fail("Exception during mark test : " + e.getMessage()); } @@ -92,17 +92,17 @@ public void test_read() { // Test for method int java.io.LineNumberInputStream.read() try { - assertTrue("Failed to read correct byte", lnis.read() == '0'); + assertEquals("Failed to read correct byte", '0', lnis.read()); + assertEquals("Failed to read correct byte on dos text", + '0', lnis2.read()); assertTrue("Failed to read correct byte on dos text", - lnis2.read() == '0'); - assertTrue("Failed to read correct byte on dos text", lnis2.read() == '\n'); + assertEquals("Failed to read correct byte on dos text", + '1', lnis2.read()); assertTrue("Failed to read correct byte on dos text", - lnis2.read() == '1'); - assertTrue("Failed to read correct byte on dos text", lnis2.read() == '\n'); - assertTrue("Failed to read correct byte on dos text", - lnis2.read() == '2'); + assertEquals("Failed to read correct byte on dos text", + '2', lnis2.read()); } catch (IOException e) { fail("Exception during read test : " + e.getMessage()); } @@ -134,8 +134,8 @@ lnis.mark(40); lnis.skip(4); lnis.reset(); - assertTrue("Failed to reset", lnis.getLineNumber() == 0); - assertTrue("Failed to reset", lnis.read() == '0'); + assertEquals("Failed to reset", 0, lnis.getLineNumber()); + assertEquals("Failed to reset", '0', lnis.read()); lnis.reset(); } catch (IOException e) { fail("Exception during mark test : " + e.getMessage()); @@ -158,7 +158,7 @@ public void test_setLineNumberI() { // Test for method void java.io.LineNumberInputStream.setLineNumber(int) lnis.setLineNumber(89); - assertTrue("Failed to set line number", lnis.getLineNumber() == 89); + assertEquals("Failed to set line number", 89, lnis.getLineNumber()); } /** @@ -168,8 +168,8 @@ // Test for method long java.io.LineNumberInputStream.skip(long) try { lnis.skip(4); - assertTrue("Skip failed to increment lineNumber", lnis - .getLineNumber() == 2); + assertEquals("Skip failed to increment lineNumber", 2, lnis + .getLineNumber()); } catch (IOException e) { fail("Exception during skip test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/PipedOutputStreamTest.java (working copy) @@ -141,8 +141,8 @@ out.write("HelloWorld".getBytes(), 0, 10); assertTrue("Bytes written before flush", reader.available() != 0); out.flush(); - assertTrue("Wrote incorrect bytes", reader.read(10).equals( - "HelloWorld")); + assertEquals("Wrote incorrect bytes", + "HelloWorld", reader.read(10)); } catch (IOException e) { fail("IOException during write test : " + e.getMessage()); } @@ -160,8 +160,8 @@ rt.start(); out.write("HelloWorld".getBytes(), 0, 10); out.flush(); - assertTrue("Wrote incorrect bytes", reader.read(10).equals( - "HelloWorld")); + assertEquals("Wrote incorrect bytes", + "HelloWorld", reader.read(10)); } catch (IOException e) { fail("IOException during write test : " + e.getMessage()); } @@ -178,7 +178,7 @@ rt.start(); out.write('c'); out.flush(); - assertTrue("Wrote incorrect byte", reader.read(1).equals("c")); + assertEquals("Wrote incorrect byte", "c", reader.read(1)); } catch (IOException e) { fail("IOException during write test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/SerializationStressTest1.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/SerializationStressTest1.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/SerializationStressTest1.java (working copy) @@ -742,8 +742,8 @@ objLoaded = dumpAndReload(objToSave); // non-serializable inst var has to be initialized from top // constructor - assertTrue(MSG_TEST_FAILED + objToSave, - ((SpecTest) objLoaded).instVar == null); + assertNull(MSG_TEST_FAILED + objToSave, + ((SpecTest) objLoaded).instVar); // instVar from non-serialized class, cant be saved/restored // by serialization but serialized ivar has to be restored as it // was in the object when dumped @@ -780,8 +780,8 @@ objLoaded = dumpAndReload(objToSave); // non-serializable inst var cant be saved, and it is not init'ed // from top constructor in this case - assertTrue(MSG_TEST_FAILED + objToSave, - ((SpecTestSubclass) objLoaded).transientInstVar == null); + assertNull(MSG_TEST_FAILED + objToSave, + ((SpecTestSubclass) objLoaded).transientInstVar); // transient slot, cant be saved/restored by serialization } catch (IOException e) { fail("Exception serializing " + objToSave + "\t->" Index: modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/DataInputStreamTest.java (working copy) @@ -128,7 +128,7 @@ os.writeChar('t'); os.close(); openDataInputStream(); - assertTrue("Incorrect char read", dis.readChar() == 't'); + assertEquals("Incorrect char read", 't', dis.readChar()); } catch (IOException e) { fail("IOException during readChar test : " + e.getMessage()); } @@ -143,8 +143,8 @@ os.writeDouble(2345.76834720202); os.close(); openDataInputStream(); - assertTrue("Incorrect double read", - dis.readDouble() == 2345.76834720202); + assertEquals("Incorrect double read", + 2345.76834720202, dis.readDouble()); } catch (IOException e) { fail("IOException during readDouble test" + e.toString()); } @@ -211,7 +211,7 @@ os.writeInt(768347202); os.close(); openDataInputStream(); - assertTrue("Incorrect int read", dis.readInt() == 768347202); + assertEquals("Incorrect int read", 768347202, dis.readInt()); } catch (IOException e) { fail("IOException during readInt test : " + e.getMessage()); } @@ -242,7 +242,7 @@ os.writeLong(9875645283333L); os.close(); openDataInputStream(); - assertTrue("Incorrect long read", dis.readLong() == 9875645283333L); + assertEquals("Incorrect long read", 9875645283333L, dis.readLong()); } catch (IOException e) { fail("read long test failed : " + e.getMessage()); } @@ -272,7 +272,7 @@ os.writeByte((byte) -127); os.close(); openDataInputStream(); - assertTrue("Incorrect byte read", dis.readUnsignedByte() == 129); + assertEquals("Incorrect byte read", 129, dis.readUnsignedByte()); } catch (IOException e) { fail("IOException during readUnsignedByte test : " + e.getMessage()); } @@ -287,7 +287,7 @@ os.writeShort(9875); os.close(); openDataInputStream(); - assertTrue("Incorrect short read", dis.readUnsignedShort() == 9875); + assertEquals("Incorrect short read", 9875, dis.readUnsignedShort()); } catch (IOException e) { fail("Exception during readShort test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/PrintStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/PrintStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/PrintStreamTest.java (working copy) @@ -121,7 +121,7 @@ os = new java.io.PrintStream(bos); os.print(fileString.substring(0, 501)); os.flush(); - assertTrue("Bytes not written after flush.", bos.size() == 501); + assertEquals("Bytes not written after flush.", 501, bos.size()); bos.close(); } catch (java.io.IOException e) { fail("Flush test failed with IOException: " + e.toString()); @@ -147,9 +147,8 @@ } catch (NullPointerException ex) { r = 1; } - assertTrue( - "expected null Pointer Exception for print(char[]) not thrown", - r == 1); + assertEquals("expected null Pointer Exception for print(char[]) not thrown", + 1, r); os = new java.io.PrintStream(bos, true); char[] sc = new char[4000]; @@ -171,7 +170,7 @@ os = new java.io.PrintStream(bos, true); os.print('t'); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); - assertTrue("Incorrect char written", bis.read() == 't'); + assertEquals("Incorrect char written", 't', bis.read()); } /** @@ -184,8 +183,8 @@ os.print(2345.76834720202); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 16); - assertTrue("Incorrect double written", new String(rbuf, 0, 16) - .equals("2345.76834720202")); + assertEquals("Incorrect double written", "2345.76834720202", new String(rbuf, 0, 16) + ); } /** @@ -199,8 +198,8 @@ os.flush(); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 8); - assertTrue("Incorrect float written", new String(rbuf, 0, 8) - .equals("29.08764")); + assertEquals("Incorrect float written", "29.08764", new String(rbuf, 0, 8) + ); } @@ -214,8 +213,8 @@ byte[] rbuf = new byte[18]; bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 9); - assertTrue("Incorrect int written", new String(rbuf, 0, 9) - .equals("768347202")); + assertEquals("Incorrect int written", "768347202", new String(rbuf, 0, 9) + ); } /** @@ -229,8 +228,8 @@ os.close(); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 13); - assertTrue("Incorrect long written", new String(rbuf, 0, 13) - .equals("9875645283333")); + assertEquals("Incorrect long written", "9875645283333", new String(rbuf, 0, 13) + ); } /** @@ -244,8 +243,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] nullbytes = new byte[4]; bis.read(nullbytes, 0, 4); - assertTrue("null should be written", new String(nullbytes, 0, 4) - .equals("null")); + assertEquals("null should be written", "null", new String(nullbytes, 0, 4) + ); try { bis.close(); bos.close(); @@ -259,8 +258,8 @@ bis = new java.io.ByteArrayInputStream(bos1.toByteArray()); byte[] rbytes = new byte[2]; bis.read(rbytes, 0, 2); - assertTrue("Incorrect Object written", new String(rbytes, 0, 2) - .equals("[]")); + assertEquals("Incorrect Object written", "[]", new String(rbytes, 0, 2) + ); } /** @@ -273,8 +272,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] nullbytes = new byte[4]; bis.read(nullbytes, 0, 4); - assertTrue("null should be written", new String(nullbytes, 0, 4) - .equals("null")); + assertEquals("null should be written", "null", new String(nullbytes, 0, 4) + ); try { bis.close(); bos.close(); @@ -288,8 +287,8 @@ bis = new java.io.ByteArrayInputStream(bos1.toByteArray()); byte rbytes[] = new byte[100]; bis.read(rbytes, 0, 11); - assertTrue("Incorrect string written", new String(rbytes, 0, 11) - .equals("Hello World")); + assertEquals("Incorrect string written", "Hello World", new String(rbytes, 0, 11) + ); } /** @@ -359,7 +358,7 @@ os = new java.io.PrintStream(bos, true); os.println('t'); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); - assertTrue("Incorrect char written", bis.read() == 't'); + assertEquals("Incorrect char written", 't', bis.read()); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -374,8 +373,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] rbuf = new byte[100]; bis.read(rbuf, 0, 16); - assertTrue("Incorrect double written", new String(rbuf, 0, 16) - .equals("2345.76834720202")); + assertEquals("Incorrect double written", "2345.76834720202", new String(rbuf, 0, 16) + ); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -390,8 +389,8 @@ os.println(29.08764f); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 8); - assertTrue("Incorrect float written", new String(rbuf, 0, 8) - .equals("29.08764")); + assertEquals("Incorrect float written", "29.08764", new String(rbuf, 0, 8) + ); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -406,8 +405,8 @@ byte[] rbuf = new byte[100]; bis = new java.io.ByteArrayInputStream(bos.toByteArray()); bis.read(rbuf, 0, 9); - assertTrue("Incorrect int written", new String(rbuf, 0, 9) - .equals("768347202")); + assertEquals("Incorrect int written", "768347202", new String(rbuf, 0, 9) + ); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -422,8 +421,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] rbuf = new byte[100]; bis.read(rbuf, 0, 13); - assertTrue("Incorrect long written", new String(rbuf, 0, 13) - .equals("9875645283333")); + assertEquals("Incorrect long written", "9875645283333", new String(rbuf, 0, 13) + ); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -438,8 +437,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] rbytes = new byte[2]; bis.read(rbytes, 0, 2); - assertTrue("Incorrect Vector written", new String(rbytes, 0, 2) - .equals("[]")); + assertEquals("Incorrect Vector written", "[]", new String(rbytes, 0, 2) + ); assertTrue("Newline not written", (c = (char) bis.read()) == '\r' || c == '\n'); } @@ -455,8 +454,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte rbytes[] = new byte[100]; bis.read(rbytes, 0, 11); - assertTrue("Incorrect string written", new String(rbytes, 0, 11) - .equals("Hello World")); + assertEquals("Incorrect string written", "Hello World", new String(rbytes, 0, 11) + ); assertTrue("Newline not written", (c = (char) bis.read()) == '\r' || c == '\n'); } @@ -472,8 +471,8 @@ bis = new java.io.ByteArrayInputStream(bos.toByteArray()); byte[] rbuf = new byte[100]; bis.read(rbuf, 0, 4); - assertTrue("Incorrect boolean written", new String(rbuf, 0, 4) - .equals("true")); + assertEquals("Incorrect boolean written", "true", new String(rbuf, 0, 4) + ); assertTrue("Newline not written", (c = bis.read()) == '\r' || c == '\n'); } @@ -499,7 +498,7 @@ os = new java.io.PrintStream(bos, true); os.write('t'); bis = new java.io.ByteArrayInputStream(bos.toByteArray()); - assertTrue("Incorrect char written", bis.read() == 't'); + assertEquals("Incorrect char written", 't', bis.read()); } /** Index: modules/luni/src/test/java/tests/api/java/io/OutputStreamWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/OutputStreamWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/OutputStreamWriterTest.java (working copy) @@ -525,8 +525,8 @@ writer.write(new char[] { '\u3048' }); writer.close(); // there should not be a mode switch between writes - assertTrue("invalid conversion 4", new String(bout.toByteArray(), - "ISO8859_1").equals("\u001b$B$($(\u001b(B")); + assertEquals("invalid conversion 4", "\u001b$B$($(\u001b(B", new String(bout.toByteArray(), + "ISO8859_1")); } catch (UnsupportedEncodingException e) { // Can't test missing converter System.out.println(e); @@ -562,8 +562,8 @@ try { osw = new OutputStreamWriter(fos, "8859_1"); } catch (UnsupportedEncodingException e) { - assertTrue("Returned incorrect encoding", osw.getEncoding().equals( - "8859_1")); + assertEquals("Returned incorrect encoding", + "8859_1", osw.getEncoding()); } } @@ -596,7 +596,7 @@ osw.close(); openInputStream(); int c = isr.read(); - assertTrue("Incorrect char returned", (char) c == 'T'); + assertEquals("Incorrect char returned", 'T', (char) c); } catch (Exception e) { fail("Exception during write test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/SerializablePermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/SerializablePermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/SerializablePermissionTest.java (working copy) @@ -24,9 +24,9 @@ */ public void test_ConstructorLjava_lang_String() { // Test for method java.io.SerializablePermission(java.lang.String) - assertTrue("permission ill-formed", new SerializablePermission( - "enableSubclassImplementation").getName().equals( - "enableSubclassImplementation")); + assertEquals("permission ill-formed", + "enableSubclassImplementation", new SerializablePermission( + "enableSubclassImplementation").getName()); } /** @@ -36,9 +36,9 @@ public void test_ConstructorLjava_lang_StringLjava_lang_String() { // Test for method java.io.SerializablePermission(java.lang.String, // java.lang.String) - assertTrue("permission ill-formed", new SerializablePermission( - "enableSubclassImplementation", "").getName().equals( - "enableSubclassImplementation")); + assertEquals("permission ill-formed", + "enableSubclassImplementation", new SerializablePermission( + "enableSubclassImplementation", "").getName()); } /** Index: modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/BufferedOutputStreamTest.java (working copy) @@ -70,8 +70,8 @@ os = new java.io.BufferedOutputStream(baos, 600); os.write(fileString.getBytes(), 0, 500); os.flush(); - assertTrue("Bytes not written after flush", - ((ByteArrayOutputStream) baos).size() == 500); + assertEquals("Bytes not written after flush", + 500, ((ByteArrayOutputStream) baos).size()); } catch (java.io.IOException e) { fail("Flush test failed"); } @@ -88,10 +88,10 @@ baos = new java.io.ByteArrayOutputStream()); os.write(fileString.getBytes(), 0, 500); bais = new java.io.ByteArrayInputStream(baos.toByteArray()); - assertTrue("Bytes written, not buffered", bais.available() == 0); + assertEquals("Bytes written, not buffered", 0, bais.available()); os.flush(); bais = new java.io.ByteArrayInputStream(baos.toByteArray()); - assertTrue("Bytes not written after flush", bais.available() == 500); + assertEquals("Bytes not written after flush", 500, bais.available()); os.write(fileString.getBytes(), 500, 513); bais = new java.io.ByteArrayInputStream(baos.toByteArray()); assertTrue("Bytes not written when buffer full", @@ -117,13 +117,13 @@ os = new java.io.BufferedOutputStream(baos); os.write('t'); bais = new java.io.ByteArrayInputStream(baos.toByteArray()); - assertTrue("Byte written, not buffered", bais.available() == 0); + assertEquals("Byte written, not buffered", 0, bais.available()); os.flush(); bais = new java.io.ByteArrayInputStream(baos.toByteArray()); - assertTrue("Byte not written after flush", bais.available() == 1); + assertEquals("Byte not written after flush", 1, bais.available()); byte[] wbytes = new byte[1]; bais.read(wbytes, 0, 1); - assertTrue("Incorrect byte written", wbytes[0] == 't'); + assertEquals("Incorrect byte written", 't', wbytes[0]); } catch (java.io.IOException e) { fail("Write test failed"); } Index: modules/luni/src/test/java/tests/api/java/io/FilePermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/FilePermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/FilePermissionTest.java (working copy) @@ -43,10 +43,9 @@ assertTrue("Used to test", true); FilePermission constructFile = new FilePermission("test constructor", "write"); + assertEquals("action given to the constructor did not correspond - constructor failed", + "write", constructFile.getActions()); assertTrue( - "action given to the constructor did not correspond - constructor failed", - constructFile.getActions().equals("write")); - assertTrue( "name given to the construcotr did not correspond - construcotr failed", constructFile.getName() == "test constructor"); @@ -57,10 +56,10 @@ */ public void test_getActions() { // Test for method java.lang.String java.io.FilePermission.getActions() - assertTrue("getActions should have returned only read", readAllFiles - .getActions().equals("read")); - assertTrue("getActions should have returned all actions", allInCurrent - .getActions().equals("read,write,execute,delete")); + assertEquals("getActions should have returned only read", "read", readAllFiles + .getActions()); + assertEquals("getActions should have returned all actions", "read,write,execute,delete", allInCurrent + .getActions()); } /** Index: modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/StringReaderTest.java (working copy) @@ -86,7 +86,7 @@ try { sr = new StringReader(testString); int r = sr.read(); - assertTrue("Failed to read char", r == 'T'); + assertEquals("Failed to read char", 'T', r); sr = new StringReader(new String(new char[] { '\u8765' })); assertTrue("Wrong double byte char", sr.read() == '\u8765'); } catch (Exception e) { @@ -126,7 +126,7 @@ } catch (IOException e) { r = 1; } - assertTrue("Expected IOException not thrown in read()", r == 1); + assertEquals("Expected IOException not thrown in read()", 1, r); } catch (IOException e) { fail("IOException during ready test : " + e.getMessage()); } Index: modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java (working copy) @@ -98,8 +98,8 @@ pw = new PrintWriter(sw = new Support_StringWriter()); pw.print("Hello"); pw.flush(); - assertTrue("Failed to construct proper writer", sw.toString().equals( - "Hello")); + assertEquals("Failed to construct proper writer", + "Hello", sw.toString()); } /** @@ -111,8 +111,8 @@ pw = new PrintWriter(sw = new Support_StringWriter(), true); pw.print("Hello"); // Auto-flush should have happened - assertTrue("Failed to construct proper writer", sw.toString().equals( - "Hello")); + assertEquals("Failed to construct proper writer", + "Hello", sw.toString()); } /** @@ -172,9 +172,8 @@ } catch (NullPointerException e) { r = 1; } - assertTrue( - "null pointer exception for printing null char[] is not caught", - r == 1); + assertEquals("null pointer exception for printing null char[] is not caught", + 1, r); } /** @@ -184,8 +183,8 @@ // Test for method void java.io.PrintWriter.print(char) pw.print('c'); pw.flush(); - assertTrue("Wrote incorrect char string", new String(bao.toByteArray()) - .equals("c")); + assertEquals("Wrote incorrect char string", "c", new String(bao.toByteArray()) + ); } /** @@ -219,8 +218,8 @@ // Test for method void java.io.PrintWriter.print(int) pw.print(4908765); pw.flush(); - assertTrue("Wrote incorrect int string", new String(bao.toByteArray()) - .equals("4908765")); + assertEquals("Wrote incorrect int string", "4908765", new String(bao.toByteArray()) + ); } /** @@ -230,8 +229,8 @@ // Test for method void java.io.PrintWriter.print(long) pw.print(49087650000L); pw.flush(); - assertTrue("Wrote incorrect long string", new String(bao.toByteArray()) - .equals("49087650000")); + assertEquals("Wrote incorrect long string", "49087650000", new String(bao.toByteArray()) + ); } /** @@ -241,14 +240,14 @@ // Test for method void java.io.PrintWriter.print(java.lang.Object) pw.print((Object) null); pw.flush(); - assertTrue("Did not write null", new String(bao.toByteArray()) - .equals("null")); + assertEquals("Did not write null", "null", new String(bao.toByteArray()) + ); bao.reset(); pw.print(new Bogus()); pw.flush(); - assertTrue("Wrote in incorrect Object string", new String(bao - .toByteArray()).equals("Bogus")); + assertEquals("Wrote in incorrect Object string", "Bogus", new String(bao + .toByteArray())); } /** @@ -258,14 +257,14 @@ // Test for method void java.io.PrintWriter.print(java.lang.String) pw.print((String) null); pw.flush(); - assertTrue("did not write null", new String(bao.toByteArray()) - .equals("null")); + assertEquals("did not write null", "null", new String(bao.toByteArray()) + ); bao.reset(); pw.print("Hello World"); pw.flush(); - assertTrue("Wrote incorrect string", new String(bao.toByteArray()) - .equals("Hello World")); + assertEquals("Wrote incorrect string", "Hello World", new String(bao.toByteArray()) + ); } /** @@ -275,8 +274,8 @@ // Test for method void java.io.PrintWriter.print(boolean) pw.print(true); pw.flush(); - assertTrue("Wrote in incorrect boolean string", new String(bao - .toByteArray()).equals("true")); + assertEquals("Wrote in incorrect boolean string", "true", new String(bao + .toByteArray())); } /** Index: modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/io/StringBufferInputStreamTest.java (working copy) @@ -33,8 +33,8 @@ */ public void test_available() { // Test for method int java.io.StringBufferInputStream.available() - assertTrue("Returned incorrect number of available bytes", sbis - .available() == 11); + assertEquals("Returned incorrect number of available bytes", 11, sbis + .available()); } /** @@ -45,7 +45,7 @@ byte[] buf = new byte[5]; sbis.skip(6); sbis.read(buf, 0, 5); - assertTrue("Returned incorrect chars", new String(buf).equals("World")); + assertEquals("Returned incorrect chars", "World", new String(buf)); } /** @@ -54,7 +54,7 @@ public void test_read$BII() { // Test for method int java.io.StringBufferInputStream.read(byte [], // int, int) - assertTrue("Read returned incorrect char", sbis.read() == 'H'); + assertEquals("Read returned incorrect char", 'H', sbis.read()); } /** @@ -63,9 +63,9 @@ public void test_reset() { // Test for method void java.io.StringBufferInputStream.reset() long s = sbis.skip(6); - assertTrue("Unable to skip correct umber of chars", s == 6); + assertEquals("Unable to skip correct umber of chars", 6, s); sbis.reset(); - assertTrue("Failed to reset", sbis.read() == 'H'); + assertEquals("Failed to reset", 'H', sbis.read()); } /** @@ -74,8 +74,8 @@ public void test_skipJ() { // Test for method long java.io.StringBufferInputStream.skip(long) long s = sbis.skip(6); - assertTrue("Unable to skip correct umber of chars", s == 6); - assertTrue("Skip positioned at incorrect char", sbis.read() == 'W'); + assertEquals("Unable to skip correct umber of chars", 6, s); + assertEquals("Skip positioned at incorrect char", 'W', sbis.read()); } /** Index: modules/luni/src/test/java/tests/api/java/util/LocaleTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/LocaleTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/LocaleTest.java (working copy) @@ -99,7 +99,7 @@ Locale.setDefault(l); Locale x = Locale.getDefault(); Locale.setDefault(org); - assertTrue("Failed to get locale", x.toString().equals("fr_CA_WIN32")); + assertEquals("Failed to get locale", "fr_CA_WIN32", x.toString()); } /** @@ -118,8 +118,8 @@ public void test_getDisplayCountryLjava_util_Locale() { // Test for method java.lang.String // java.util.Locale.getDisplayCountry(java.util.Locale) - assertTrue("Returned incorrect country", Locale.ITALY - .getDisplayCountry(l).equals("Italie")); + assertEquals("Returned incorrect country", "Italie", Locale.ITALY + .getDisplayCountry(l)); } /** @@ -272,14 +272,14 @@ Locale.setDefault(l); Locale x = Locale.getDefault(); Locale.setDefault(org); - assertTrue("Failed to set locale", x.toString().equals("fr_CA_WIN32")); + assertEquals("Failed to set locale", "fr_CA_WIN32", x.toString()); Locale.setDefault(new Locale("tr", "")); String res1 = "\u0069".toUpperCase(); String res2 = "\u0049".toLowerCase(); Locale.setDefault(org); - assertTrue("Wrong toUppercase conversion", res1.equals("\u0130")); - assertTrue("Wrong toLowercase conversion", res2.equals("\u0131")); + assertEquals("Wrong toUppercase conversion", "\u0130", res1); + assertEquals("Wrong toLowercase conversion", "\u0131", res2); } /** @@ -287,21 +287,21 @@ */ public void test_toString() { // Test for method java.lang.String java.util.Locale.toString() - assertTrue("Returned incorrect string representation", testLocale - .toString().equals("en_CA_WIN32")); + assertEquals("Returned incorrect string representation", "en_CA_WIN32", testLocale + .toString()); Locale l = new Locale("en", ""); - assertTrue("Wrong representation 1", l.toString().equals("en")); + assertEquals("Wrong representation 1", "en", l.toString()); l = new Locale("", "CA"); - assertTrue("Wrong representation 2", l.toString().equals("_CA")); + assertEquals("Wrong representation 2", "_CA", l.toString()); l = new Locale("", "CA", "var"); - assertTrue("Wrong representation 2.5", l.toString().equals("_CA_var")); + assertEquals("Wrong representation 2.5", "_CA_var", l.toString()); l = new Locale("en", "", "WIN"); - assertTrue("Wrong representation 4", l.toString().equals("en__WIN")); + assertEquals("Wrong representation 4", "en__WIN", l.toString()); l = new Locale("en", "CA"); - assertTrue("Wrong representation 6", l.toString().equals("en_CA")); + assertEquals("Wrong representation 6", "en_CA", l.toString()); l = new Locale("en", "CA", "VAR"); - assertTrue("Wrong representation 7", l.toString().equals("en_CA_VAR")); + assertEquals("Wrong representation 7", "en_CA_VAR", l.toString()); } /** Index: modules/luni/src/test/java/tests/api/java/util/HashSetTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/HashSetTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/HashSetTest.java (working copy) @@ -37,7 +37,7 @@ public void test_Constructor() { // Test for method java.util.HashSet() HashSet hs2 = new HashSet(); - assertTrue("Created incorrect HashSet", hs2.size() == 0); + assertEquals("Created incorrect HashSet", 0, hs2.size()); } /** @@ -46,7 +46,7 @@ public void test_ConstructorI() { // Test for method java.util.HashSet(int) HashSet hs2 = new HashSet(5); - assertTrue("Created incorrect HashSet", hs2.size() == 0); + assertEquals("Created incorrect HashSet", 0, hs2.size()); try { new HashSet(-1); } catch (IllegalArgumentException e) { @@ -62,7 +62,7 @@ public void test_ConstructorIF() { // Test for method java.util.HashSet(int, float) HashSet hs2 = new HashSet(5, (float) 0.5); - assertTrue("Created incorrect HashSet", hs2.size() == 0); + assertEquals("Created incorrect HashSet", 0, hs2.size()); try { new HashSet(0, 0); } catch (IllegalArgumentException e) { @@ -107,7 +107,7 @@ Set orgSet = (Set) hs.clone(); hs.clear(); Iterator i = orgSet.iterator(); - assertTrue("Returned non-zero size after clear", hs.size() == 0); + assertEquals("Returned non-zero size after clear", 0, hs.size()); while (i.hasNext()) assertTrue("Failed to clear set", !hs.contains(i.next())); } @@ -161,7 +161,7 @@ HashSet s = new HashSet(); s.add(null); - assertTrue("Cannot handle null", s.iterator().next() == null); + assertNull("Cannot handle null", s.iterator().next()); } /** @@ -186,7 +186,7 @@ // Test for method int java.util.HashSet.size() assertTrue("Returned incorrect size", hs.size() == (objArray.length + 1)); hs.clear(); - assertTrue("Cleared set returned non-zero size", hs.size() == 0); + assertEquals("Cleared set returned non-zero size", 0, hs.size()); } /** Index: modules/luni/src/test/java/tests/api/java/util/ArraysTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/ArraysTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/ArraysTest.java (working copy) @@ -103,8 +103,8 @@ for (byte counter = 0; counter < arraySize; counter++) assertTrue("Binary search on byte[] answered incorrect position", Arrays.binarySearch(byteArray, counter) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(intArray, (byte) -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(intArray, (byte) -1)); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(intArray, (byte) arraySize) == -(arraySize + 1)); @@ -125,8 +125,8 @@ assertTrue( "Binary search on char[] answered incorrect position", Arrays.binarySearch(charArray, (char) (counter + 1)) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(charArray, '\u0000') == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(charArray, '\u0000')); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(charArray, (char) (arraySize + 1)) == -(arraySize + 1)); @@ -141,8 +141,8 @@ assertTrue( "Binary search on double[] answered incorrect position", Arrays.binarySearch(doubleArray, (double) counter) == (double) counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(doubleArray, (double) -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(doubleArray, (double) -1)); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(doubleArray, (double) arraySize) == -(arraySize + 1)); @@ -161,8 +161,8 @@ int result = Arrays.binarySearch(specials, specials[i]); assertTrue(specials[i] + " invalid: " + result, result == i); } - assertTrue("-1d", Arrays.binarySearch(specials, -1d) == -4); - assertTrue("1d", Arrays.binarySearch(specials, 1d) == -8); + assertEquals("-1d", -4, Arrays.binarySearch(specials, -1d)); + assertEquals("1d", -8, Arrays.binarySearch(specials, 1d)); } @@ -175,8 +175,8 @@ assertTrue( "Binary search on float[] answered incorrect position", Arrays.binarySearch(floatArray, (float) counter) == (float) counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(floatArray, (float) -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(floatArray, (float) -1)); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(floatArray, (float) arraySize) == -(arraySize + 1)); @@ -195,8 +195,8 @@ int result = Arrays.binarySearch(specials, specials[i]); assertTrue(specials[i] + " invalid: " + result, result == i); } - assertTrue("-1f", Arrays.binarySearch(specials, -1f) == -4); - assertTrue("1f", Arrays.binarySearch(specials, 1f) == -8); + assertEquals("-1f", -4, Arrays.binarySearch(specials, -1f)); + assertEquals("1f", -8, Arrays.binarySearch(specials, 1f)); } /** @@ -207,8 +207,8 @@ for (int counter = 0; counter < arraySize; counter++) assertTrue("Binary search on int[] answered incorrect position", Arrays.binarySearch(intArray, counter) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(intArray, -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(intArray, -1)); assertTrue("Binary search succeeded for value not present in array 2", Arrays.binarySearch(intArray, arraySize) == -(arraySize + 1)); for (int counter = 0; counter < arraySize; counter++) @@ -227,8 +227,8 @@ for (long counter = 0; counter < arraySize; counter++) assertTrue("Binary search on long[] answered incorrect position", Arrays.binarySearch(longArray, counter) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(longArray, (long) -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(longArray, (long) -1)); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(longArray, (long) arraySize) == -(arraySize + 1)); @@ -251,8 +251,8 @@ assertTrue( "Binary search on Object[] answered incorrect position", Arrays.binarySearch(objectArray, objArray[counter]) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(objectArray, new Integer(-1)) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(objectArray, new Integer(-1))); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(objectArray, new Integer(arraySize)) == -(arraySize + 1)); @@ -271,9 +271,8 @@ assertTrue( "Binary search succeeded for value not present in array 1", Arrays.binarySearch(objectArray, new Integer(-1), comp) == -(arraySize + 1)); - assertTrue( - "Binary search succeeded for value not present in array 2", - Arrays.binarySearch(objectArray, new Integer(arraySize), comp) == -1); + assertEquals("Binary search succeeded for value not present in array 2", + -1, Arrays.binarySearch(objectArray, new Integer(arraySize), comp)); for (int counter = 0; counter < arraySize; counter++) assertTrue( "Binary search on Object[] with custom comparator answered incorrect position", @@ -289,8 +288,8 @@ for (short counter = 0; counter < arraySize; counter++) assertTrue("Binary search on short[] answered incorrect position", Arrays.binarySearch(shortArray, counter) == counter); - assertTrue("Binary search succeeded for value not present in array 1", - Arrays.binarySearch(intArray, (short) -1) == -1); + assertEquals("Binary search succeeded for value not present in array 1", + -1, Arrays.binarySearch(intArray, (short) -1)); assertTrue( "Binary search succeeded for value not present in array 2", Arrays.binarySearch(intArray, (short) arraySize) == -(arraySize + 1)); @@ -337,7 +336,7 @@ } catch (IllegalArgumentException e) { result = 2; } - assertTrue("Wrong exception1", result == 2); + assertEquals("Wrong exception1", 2, result); try { Arrays.fill(new byte[2], -1, 1, (byte) 27); result = 0; @@ -346,7 +345,7 @@ } catch (IllegalArgumentException e) { result = 2; } - assertTrue("Wrong exception2", result == 1); + assertEquals("Wrong exception2", 1, result); try { Arrays.fill(new byte[2], 1, 4, (byte) 27); result = 0; @@ -355,7 +354,7 @@ } catch (IllegalArgumentException e) { result = 2; } - assertTrue("Wrong exception", result == 1); + assertEquals("Wrong exception", 1, result); } /** @@ -394,7 +393,7 @@ char d[] = new char[1000]; Arrays.fill(d, 'V'); for (int i = 0; i < d.length; i++) - assertTrue("Failed to fill char array correctly", d[i] == 'V'); + assertEquals("Failed to fill char array correctly", 'V', d[i]); } /** @@ -576,8 +575,8 @@ Arrays.fill(d, 400, d.length, null); for (int i = 400; i < d.length; i++) - assertTrue("Failed to fill Object array correctly with nulls", - d[i] == null); + assertNull("Failed to fill Object array correctly with nulls", + d[i]); } /** Index: modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/StringTokenizerTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/TimerTaskTest.java (working copy) @@ -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 Index: modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java (working copy) @@ -40,12 +40,12 @@ public void test_ConstructorIII() { // Test for method java.util.GregorianCalendar(int, int, int) GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13); - assertTrue("Incorrect calendar constructed 1", - gc.get(Calendar.YEAR) == 1972); + assertEquals("Incorrect calendar constructed 1", + 1972, gc.get(Calendar.YEAR)); assertTrue("Incorrect calendar constructed 2", gc.get(Calendar.MONTH) == Calendar.OCTOBER); - assertTrue("Incorrect calendar constructed 3", gc - .get(Calendar.DAY_OF_MONTH) == 13); + assertEquals("Incorrect calendar constructed 3", 13, gc + .get(Calendar.DAY_OF_MONTH)); assertTrue("Incorrect calendar constructed 4", gc.getTimeZone().equals( TimeZone.getDefault())); } @@ -58,17 +58,17 @@ // Test for method java.util.GregorianCalendar(int, int, int, int, int) GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9); + assertEquals("Incorrect calendar constructed", + 1972, gc.get(Calendar.YEAR)); assertTrue("Incorrect calendar constructed", - gc.get(Calendar.YEAR) == 1972); - assertTrue("Incorrect calendar constructed", gc.get(Calendar.MONTH) == Calendar.OCTOBER); - assertTrue("Incorrect calendar constructed", gc - .get(Calendar.DAY_OF_MONTH) == 13); - assertTrue("Incorrect calendar constructed", gc.get(Calendar.HOUR) == 7); - assertTrue("Incorrect calendar constructed", - gc.get(Calendar.AM_PM) == 1); - assertTrue("Incorrect calendar constructed", - gc.get(Calendar.MINUTE) == 9); + assertEquals("Incorrect calendar constructed", 13, gc + .get(Calendar.DAY_OF_MONTH)); + assertEquals("Incorrect calendar constructed", 7, gc.get(Calendar.HOUR)); + assertEquals("Incorrect calendar constructed", + 1, gc.get(Calendar.AM_PM)); + assertEquals("Incorrect calendar constructed", + 9, gc.get(Calendar.MINUTE)); assertTrue("Incorrect calendar constructed", gc.getTimeZone().equals( TimeZone.getDefault())); } @@ -82,19 +82,19 @@ // int) GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59); + assertEquals("Incorrect calendar constructed", + 1972, gc.get(Calendar.YEAR)); assertTrue("Incorrect calendar constructed", - gc.get(Calendar.YEAR) == 1972); - assertTrue("Incorrect calendar constructed", gc.get(Calendar.MONTH) == Calendar.OCTOBER); - assertTrue("Incorrect calendar constructed", gc - .get(Calendar.DAY_OF_MONTH) == 13); - assertTrue("Incorrect calendar constructed", gc.get(Calendar.HOUR) == 7); - assertTrue("Incorrect calendar constructed", - gc.get(Calendar.AM_PM) == 1); - assertTrue("Incorrect calendar constructed", - gc.get(Calendar.MINUTE) == 9); - assertTrue("Incorrect calendar constructed", - gc.get(Calendar.SECOND) == 59); + assertEquals("Incorrect calendar constructed", 13, gc + .get(Calendar.DAY_OF_MONTH)); + assertEquals("Incorrect calendar constructed", 7, gc.get(Calendar.HOUR)); + assertEquals("Incorrect calendar constructed", + 1, gc.get(Calendar.AM_PM)); + assertEquals("Incorrect calendar constructed", + 9, gc.get(Calendar.MINUTE)); + assertEquals("Incorrect calendar constructed", + 59, gc.get(Calendar.SECOND)); assertTrue("Incorrect calendar constructed", gc.getTimeZone().equals( TimeZone.getDefault())); } @@ -167,72 +167,72 @@ // Test for method void java.util.GregorianCalendar.add(int, int) GregorianCalendar gc1 = new GregorianCalendar(1998, 11, 6); gc1.add(GregorianCalendar.YEAR, 1); - assertTrue("Add failed to Increment", - gc1.get(GregorianCalendar.YEAR) == 1999); + assertEquals("Add failed to Increment", + 1999, gc1.get(GregorianCalendar.YEAR)); gc1 = new GregorianCalendar(1999, Calendar.JULY, 31); gc1.add(Calendar.MONTH, 7); - assertTrue("Wrong result year 1", gc1.get(Calendar.YEAR) == 2000); + assertEquals("Wrong result year 1", 2000, gc1.get(Calendar.YEAR)); assertTrue("Wrong result month 1", gc1.get(Calendar.MONTH) == Calendar.FEBRUARY); - assertTrue("Wrong result date 1", gc1.get(Calendar.DATE) == 29); + assertEquals("Wrong result date 1", 29, gc1.get(Calendar.DATE)); gc1.add(Calendar.YEAR, -1); - assertTrue("Wrong result year 2", gc1.get(Calendar.YEAR) == 1999); + assertEquals("Wrong result year 2", 1999, gc1.get(Calendar.YEAR)); assertTrue("Wrong result month 2", gc1.get(Calendar.MONTH) == Calendar.FEBRUARY); - assertTrue("Wrong result date 2", gc1.get(Calendar.DATE) == 28); + assertEquals("Wrong result date 2", 28, gc1.get(Calendar.DATE)); gc1 = new GregorianCalendar(TimeZone.getTimeZone("EST")); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.MILLISECOND, 24 * 60 * 60 * 1000); - assertTrue("Wrong time after MILLISECOND change", gc1 - .get(Calendar.HOUR_OF_DAY) == 17); + assertEquals("Wrong time after MILLISECOND change", 17, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.SECOND, 24 * 60 * 60); - assertTrue("Wrong time after SECOND change", gc1 - .get(Calendar.HOUR_OF_DAY) == 17); + assertEquals("Wrong time after SECOND change", 17, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.MINUTE, 24 * 60); - assertTrue("Wrong time after MINUTE change", gc1 - .get(Calendar.HOUR_OF_DAY) == 17); + assertEquals("Wrong time after MINUTE change", 17, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.HOUR, 24); - assertTrue("Wrong time after HOUR change", gc1 - .get(Calendar.HOUR_OF_DAY) == 17); + assertEquals("Wrong time after HOUR change", 17, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.HOUR_OF_DAY, 24); - assertTrue("Wrong time after HOUR_OF_DAY change", gc1 - .get(Calendar.HOUR_OF_DAY) == 17); + assertEquals("Wrong time after HOUR_OF_DAY change", 17, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.AM_PM, 2); - assertTrue("Wrong time after AM_PM change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after AM_PM change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.DATE, 1); - assertTrue("Wrong time after DATE change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after DATE change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.DAY_OF_YEAR, 1); - assertTrue("Wrong time after DAY_OF_YEAR change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after DAY_OF_YEAR change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.DAY_OF_WEEK, 1); - assertTrue("Wrong time after DAY_OF_WEEK change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after DAY_OF_WEEK change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.WEEK_OF_YEAR, 1); - assertTrue("Wrong time after WEEK_OF_YEAR change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after WEEK_OF_YEAR change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.WEEK_OF_MONTH, 1); - assertTrue("Wrong time after WEEK_OF_MONTH change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after WEEK_OF_MONTH change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.set(1999, Calendar.APRIL, 3, 16, 0); // day before DST change gc1.add(Calendar.DAY_OF_WEEK_IN_MONTH, 1); - assertTrue("Wrong time after DAY_OF_WEEK_IN_MONTH change", gc1 - .get(Calendar.HOUR_OF_DAY) == 16); + assertEquals("Wrong time after DAY_OF_WEEK_IN_MONTH change", 16, gc1 + .get(Calendar.HOUR_OF_DAY)); gc1.clear(); gc1.set(2000, Calendar.APRIL, 1, 23, 0); @@ -269,26 +269,26 @@ GregorianCalendar gc4 = new GregorianCalendar(2000, 1, 1); GregorianCalendar gc5 = new GregorianCalendar(2000, 9, 9); GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1900", - gc1.getActualMaximum(Calendar.DAY_OF_MONTH) == 28); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1996", - gc2.getActualMaximum(Calendar.DAY_OF_MONTH) == 29); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 1998", - gc3.getActualMaximum(Calendar.DAY_OF_MONTH) == 28); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Feb 2000", - gc4.getActualMaximum(Calendar.DAY_OF_MONTH) == 29); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Oct 2000", - gc5.getActualMaximum(Calendar.DAY_OF_MONTH) == 31); - assertTrue("Wrong actual maximum value for DAY_OF_MONTH for Apr 2000", - gc6.getActualMaximum(Calendar.DAY_OF_MONTH) == 30); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1900", + 28, gc1.getActualMaximum(Calendar.DAY_OF_MONTH)); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1996", + 29, gc2.getActualMaximum(Calendar.DAY_OF_MONTH)); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 1998", + 28, gc3.getActualMaximum(Calendar.DAY_OF_MONTH)); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Feb 2000", + 29, gc4.getActualMaximum(Calendar.DAY_OF_MONTH)); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Oct 2000", + 31, gc5.getActualMaximum(Calendar.DAY_OF_MONTH)); + assertEquals("Wrong actual maximum value for DAY_OF_MONTH for Apr 2000", + 30, gc6.getActualMaximum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong actual maximum value for MONTH", gc1 .getActualMaximum(Calendar.MONTH) == Calendar.DECEMBER); - assertTrue("Wrong actual maximum value for HOUR_OF_DAY", gc1 - .getActualMaximum(Calendar.HOUR_OF_DAY) == 23); - assertTrue("Wrong actual maximum value for HOUR", gc1 - .getActualMaximum(Calendar.HOUR) == 11); - assertTrue("Wrong actual maximum value for DAY_OF_WEEK_IN_MONTH", gc6 - .getActualMaximum(Calendar.DAY_OF_WEEK_IN_MONTH) == 4); + assertEquals("Wrong actual maximum value for HOUR_OF_DAY", 23, gc1 + .getActualMaximum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong actual maximum value for HOUR", 11, gc1 + .getActualMaximum(Calendar.HOUR)); + assertEquals("Wrong actual maximum value for DAY_OF_WEEK_IN_MONTH", 4, gc6 + .getActualMaximum(Calendar.DAY_OF_WEEK_IN_MONTH)); } /** @@ -302,16 +302,16 @@ new GregorianCalendar(2000, 1, 1); new GregorianCalendar(2000, 9, 9); GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3); - assertTrue("Wrong actual minimum value for DAY_OF_MONTH for Feb 1900", - gc1.getActualMinimum(Calendar.DAY_OF_MONTH) == 1); + assertEquals("Wrong actual minimum value for DAY_OF_MONTH for Feb 1900", + 1, gc1.getActualMinimum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong actual minimum value for MONTH", gc1 .getActualMinimum(Calendar.MONTH) == Calendar.JANUARY); - assertTrue("Wrong actual minimum value for HOUR_OF_DAY", gc1 - .getActualMinimum(Calendar.HOUR_OF_DAY) == 0); - assertTrue("Wrong actual minimum value for HOUR", gc1 - .getActualMinimum(Calendar.HOUR) == 0); - assertTrue("Wrong actual minimum value for DAY_OF_WEEK_IN_MONTH", gc6 - .getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH) == -1); + assertEquals("Wrong actual minimum value for HOUR_OF_DAY", 0, gc1 + .getActualMinimum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong actual minimum value for HOUR", 0, gc1 + .getActualMinimum(Calendar.HOUR)); + assertEquals("Wrong actual minimum value for DAY_OF_WEEK_IN_MONTH", -1, gc6 + .getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH)); } /** @@ -321,14 +321,14 @@ // Test for method int // java.util.GregorianCalendar.getGreatestMinimum(int) GregorianCalendar gc = new GregorianCalendar(); - assertTrue("Wrong greatest minimum value for DAY_OF_MONTH", gc - .getGreatestMinimum(Calendar.DAY_OF_MONTH) == 1); + assertEquals("Wrong greatest minimum value for DAY_OF_MONTH", 1, gc + .getGreatestMinimum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong greatest minimum value for MONTH", gc .getGreatestMinimum(Calendar.MONTH) == Calendar.JANUARY); - assertTrue("Wrong greatest minimum value for HOUR_OF_DAY", gc - .getGreatestMinimum(Calendar.HOUR_OF_DAY) == 0); - assertTrue("Wrong greatest minimum value for HOUR", gc - .getGreatestMinimum(Calendar.HOUR) == 0); + assertEquals("Wrong greatest minimum value for HOUR_OF_DAY", 0, gc + .getGreatestMinimum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong greatest minimum value for HOUR", 0, gc + .getGreatestMinimum(Calendar.HOUR)); BitSet result = new BitSet(); int[] min = { 0, 1, 0, 1, 0, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, -43200000, @@ -350,12 +350,12 @@ GregorianCalendar returnedChange = new GregorianCalendar(TimeZone .getTimeZone("EST")); returnedChange.setTime(gc.getGregorianChange()); - assertTrue("Returned incorrect year", - returnedChange.get(Calendar.YEAR) == 1582); + assertEquals("Returned incorrect year", + 1582, returnedChange.get(Calendar.YEAR)); assertTrue("Returned incorrect month", returnedChange .get(Calendar.MONTH) == Calendar.OCTOBER); - assertTrue("Returned incorrect day of month", returnedChange - .get(Calendar.DAY_OF_MONTH) == 4); + assertEquals("Returned incorrect day of month", 4, returnedChange + .get(Calendar.DAY_OF_MONTH)); } /** @@ -364,14 +364,14 @@ public void test_getLeastMaximumI() { // Test for method int java.util.GregorianCalendar.getLeastMaximum(int) GregorianCalendar gc = new GregorianCalendar(); - assertTrue("Wrong least maximum value for DAY_OF_MONTH", gc - .getLeastMaximum(Calendar.DAY_OF_MONTH) == 28); + assertEquals("Wrong least maximum value for DAY_OF_MONTH", 28, gc + .getLeastMaximum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong least maximum value for MONTH", gc .getLeastMaximum(Calendar.MONTH) == Calendar.DECEMBER); - assertTrue("Wrong least maximum value for HOUR_OF_DAY", gc - .getLeastMaximum(Calendar.HOUR_OF_DAY) == 23); - assertTrue("Wrong least maximum value for HOUR", gc - .getLeastMaximum(Calendar.HOUR) == 11); + assertEquals("Wrong least maximum value for HOUR_OF_DAY", 23, gc + .getLeastMaximum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong least maximum value for HOUR", 11, gc + .getLeastMaximum(Calendar.HOUR)); BitSet result = new BitSet(); Vector values = new Vector(); @@ -393,14 +393,14 @@ public void test_getMaximumI() { // Test for method int java.util.GregorianCalendar.getMaximum(int) GregorianCalendar gc = new GregorianCalendar(); - assertTrue("Wrong maximum value for DAY_OF_MONTH", gc - .getMaximum(Calendar.DAY_OF_MONTH) == 31); + assertEquals("Wrong maximum value for DAY_OF_MONTH", 31, gc + .getMaximum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong maximum value for MONTH", gc .getMaximum(Calendar.MONTH) == Calendar.DECEMBER); - assertTrue("Wrong maximum value for HOUR_OF_DAY", gc - .getMaximum(Calendar.HOUR_OF_DAY) == 23); - assertTrue("Wrong maximum value for HOUR", - gc.getMaximum(Calendar.HOUR) == 11); + assertEquals("Wrong maximum value for HOUR_OF_DAY", 23, gc + .getMaximum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong maximum value for HOUR", + 11, gc.getMaximum(Calendar.HOUR)); BitSet result = new BitSet(); Vector values = new Vector(); @@ -422,14 +422,14 @@ public void test_getMinimumI() { // Test for method int java.util.GregorianCalendar.getMinimum(int) GregorianCalendar gc = new GregorianCalendar(); - assertTrue("Wrong minimum value for DAY_OF_MONTH", gc - .getMinimum(Calendar.DAY_OF_MONTH) == 1); + assertEquals("Wrong minimum value for DAY_OF_MONTH", 1, gc + .getMinimum(Calendar.DAY_OF_MONTH)); assertTrue("Wrong minimum value for MONTH", gc .getMinimum(Calendar.MONTH) == Calendar.JANUARY); - assertTrue("Wrong minimum value for HOUR_OF_DAY", gc - .getMinimum(Calendar.HOUR_OF_DAY) == 0); - assertTrue("Wrong minimum value for HOUR", - gc.getMinimum(Calendar.HOUR) == 0); + assertEquals("Wrong minimum value for HOUR_OF_DAY", 0, gc + .getMinimum(Calendar.HOUR_OF_DAY)); + assertEquals("Wrong minimum value for HOUR", + 0, gc.getMinimum(Calendar.HOUR)); BitSet result = new BitSet(); int[] min = { 0, 1, 0, 1, 0, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, -43200000, @@ -507,14 +507,14 @@ } catch (IllegalArgumentException e) { result = 1; } - assertTrue("ZONE_OFFSET roll", result == 1); + assertEquals("ZONE_OFFSET roll", 1, result); try { cal.roll(Calendar.DST_OFFSET, true); result = 0; } catch (IllegalArgumentException e) { result = 1; } - assertTrue("ZONE_OFFSET roll", result == 1); + assertEquals("ZONE_OFFSET roll", 1, result); cal.set(2004, Calendar.DECEMBER, 31, 5, 0, 0); cal.roll(Calendar.WEEK_OF_YEAR, true); Index: modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/ArrayListTest.java (working copy) @@ -53,7 +53,7 @@ public void test_ConstructorI() { // Test for method java.util.ArrayList(int) ArrayList al = new ArrayList(5); - assertTrue("Incorrect arrayList created", al.size() == 0); + assertEquals("Incorrect arrayList created", 0, al.size()); } /** @@ -84,7 +84,7 @@ && (alist.get(52) == objArray[51])); Object oldItem = alist.get(25); alist.add(25, null); - assertTrue("Should have returned null", alist.get(25) == null); + assertNull("Should have returned null", alist.get(25)); assertTrue("Should have returned the old item from slot 25", alist .get(26) == oldItem); } @@ -98,7 +98,7 @@ alist.add(o); assertTrue("Failed to add Object", alist.get(alist.size() - 1) == o); alist.add(null); - assertTrue("Failed to add null", alist.get(alist.size() - 1) == null); + assertNull("Failed to add null", alist.get(alist.size() - 1)); } /** @@ -108,8 +108,8 @@ // Test for method boolean java.util.ArrayList.addAll(int, // java.util.Collection) alist.addAll(50, alist); - assertTrue("Returned incorrect size after adding to existing list", - alist.size() == 200); + assertEquals("Returned incorrect size after adding to existing list", + 200, alist.size()); for (int i = 0; i < 50; i++) assertTrue("Manipulated elements < index", alist.get(i) == objArray[i]); @@ -127,13 +127,13 @@ listWithNulls.add(null); alist.addAll(100, listWithNulls); assertTrue("Incorrect size: " + alist.size(), alist.size() == 205); - assertTrue("Item at slot 100 should be null", alist.get(100) == null); - assertTrue("Item at slot 101 should be null", alist.get(101) == null); - assertTrue("Item at slot 102 should be 'yoink'", alist.get(102).equals( - "yoink")); - assertTrue("Item at slot 103 should be 'kazoo'", alist.get(103).equals( - "kazoo")); - assertTrue("Item at slot 104 should be null", alist.get(104) == null); + assertNull("Item at slot 100 should be null", alist.get(100)); + assertNull("Item at slot 101 should be null", alist.get(101)); + assertEquals("Item at slot 102 should be 'yoink'", + "yoink", alist.get(102)); + assertEquals("Item at slot 103 should be 'kazoo'", + "kazoo", alist.get(103)); + assertNull("Item at slot 104 should be null", alist.get(104)); alist.addAll(205, listWithNulls); assertTrue("Incorrect size2: " + alist.size(), alist.size() == 210); } @@ -150,8 +150,8 @@ assertTrue("Failed to add elements properly", l.get(i).equals( alist.get(i))); alist.addAll(alist); - assertTrue("Returned incorrect size after adding to existing list", - alist.size() == 200); + assertEquals("Returned incorrect size after adding to existing list", + 200, alist.size()); for (int i = 0; i < 100; i++) { assertTrue("Added to list in incorrect order", alist.get(i) .equals(l.get(i))); @@ -181,16 +181,16 @@ public void test_clear() { // Test for method void java.util.ArrayList.clear() alist.clear(); - assertTrue("List did not clear", alist.size() == 0); + assertEquals("List did not clear", 0, alist.size()); alist.add(null); alist.add(null); alist.add(null); alist.add("bam"); alist.clear(); - assertTrue("List with nulls did not clear", alist.size() == 0); + assertEquals("List with nulls did not clear", 0, alist.size()); /* - * for (int i = 0; i < alist.size(); i++) assertTrue("Failed to clear - * list", alist.get(i) == null); + * for (int i = 0; i < alist.size(); i++) assertNull("Failed to clear + * list", alist.get(i)); */ } @@ -289,10 +289,10 @@ */ public void test_indexOfLjava_lang_Object() { // Test for method int java.util.ArrayList.indexOf(java.lang.Object) - assertTrue("Returned incorrect index", - alist.indexOf(objArray[87]) == 87); - assertTrue("Returned index for invalid Object", alist - .indexOf(new Object()) == -1); + assertEquals("Returned incorrect index", + 87, alist.indexOf(objArray[87])); + assertEquals("Returned index for invalid Object", -1, alist + .indexOf(new Object())); alist.add(25, null); alist.add(50, null); assertTrue("Wrong indexOf for null. Wanted 25 got: " @@ -316,10 +316,10 @@ public void test_lastIndexOfLjava_lang_Object() { // Test for method int java.util.ArrayList.lastIndexOf(java.lang.Object) alist.add(new Integer(99)); - assertTrue("Returned incorrect index", - alist.lastIndexOf(objArray[99]) == 100); - assertTrue("Returned index for invalid Object", alist - .lastIndexOf(new Object()) == -1); + assertEquals("Returned incorrect index", + 100, alist.lastIndexOf(objArray[99])); + assertEquals("Returned index for invalid Object", -1, alist + .lastIndexOf(new Object())); alist.add(25, null); alist.add(50, null); assertTrue("Wrong lastIndexOf for null. Wanted 50 got: " @@ -332,8 +332,8 @@ public void test_removeI() { // Test for method java.lang.Object java.util.ArrayList.remove(int) alist.remove(10); - assertTrue("Failed to remove element", - alist.indexOf(objArray[10]) == -1); + assertEquals("Failed to remove element", + -1, alist.indexOf(objArray[10])); boolean exception = false; try { alist.remove(999); @@ -387,7 +387,7 @@ alist.set(65, obj = new Object()); assertTrue("Failed to set object", alist.get(65) == obj); alist.set(50, null); - assertTrue("Setting to null did not work", alist.get(50) == null); + assertNull("Setting to null did not work", alist.get(50)); assertTrue("Setting increased the list's size to: " + alist.size(), alist.size() == 100); } @@ -397,10 +397,10 @@ */ public void test_size() { // Test for method int java.util.ArrayList.size() - assertTrue("Returned incorrect size for exiting list", - alist.size() == 100); - assertTrue("Returned incorrect size for new list", new ArrayList() - .size() == 0); + assertEquals("Returned incorrect size for exiting list", + 100, alist.size()); + assertEquals("Returned incorrect size for new list", 0, new ArrayList() + .size()); } /** @@ -416,8 +416,8 @@ for (int i = 0; i < obj.length; i++) { if ((i == 25) || (i == 75)) - assertTrue("Should be null at: " + i + " but instead got: " - + obj[i], obj[i] == null); + assertNull("Should be null at: " + i + " but instead got: " + + obj[i], obj[i]); else assertTrue("Returned incorrect array: " + i, obj[i] == objArray[i]); @@ -439,11 +439,11 @@ assertTrue("Returned different array than passed", retArray == argArray); argArray = new Integer[1000]; retArray = alist.toArray(argArray); - assertTrue("Failed to set first extra element to null", argArray[alist - .size()] == null); + assertNull("Failed to set first extra element to null", argArray[alist + .size()]); for (int i = 0; i < 100; i++) { if ((i == 25) || (i == 75)) - assertTrue("Should be null: " + i, retArray[i] == null); + assertNull("Should be null: " + i, retArray[i]); else assertTrue("Returned incorrect array: " + i, retArray[i] == objArray[i]); @@ -458,7 +458,7 @@ for (int i = 99; i > 24; i--) alist.remove(i); ((ArrayList) alist).trimToSize(); - assertTrue("Returned incorrect size after trim", alist.size() == 25); + assertEquals("Returned incorrect size after trim", 25, alist.size()); for (int i = 0; i < alist.size(); i++) assertTrue("Trimmed list contained incorrect elements", alist .get(i) == objArray[i]); Index: modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/TreeSetTest.java (working copy) @@ -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])); } Index: modules/luni/src/test/java/tests/api/java/util/DateTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/DateTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/DateTest.java (working copy) @@ -157,16 +157,14 @@ Date d3 = new Date(someNumber + 1); Date d4 = new Date(someNumber - 1); Integer i = new Integer(0); - assertTrue("Comparing a date to itself did not answer zero", d1 - .compareTo((Object) d1) == 0); - assertTrue("Comparing equal dates did not answer zero", d1 - .compareTo((Object) d2) == 0); - assertTrue( - "date1.compareTo(date2), where date1 > date2, did not result in 1", - d1.compareTo((Object) d4) == 1); - assertTrue( - "date1.compareTo(date2), where date1 < date2, did not result in -1", - d1.compareTo((Object) d3) == -1); + assertEquals("Comparing a date to itself did not answer zero", 0, d1 + .compareTo((Object) d1)); + assertEquals("Comparing equal dates did not answer zero", 0, d1 + .compareTo((Object) d2)); + assertEquals("date1.compareTo(date2), where date1 > date2, did not result in 1", + 1, d1.compareTo((Object) d4)); + assertEquals("date1.compareTo(date2), where date1 < date2, did not result in -1", + -1, d1.compareTo((Object) d3)); try { d1.compareTo(i); } catch (ClassCastException e) { @@ -186,16 +184,14 @@ Date d2 = new Date(someNumber); Date d3 = new Date(someNumber + 1); Date d4 = new Date(someNumber - 1); - assertTrue("Comparing a date to itself did not answer zero", d1 - .compareTo(d1) == 0); - assertTrue("Comparing equal dates did not answer zero", d1 - .compareTo(d2) == 0); - assertTrue( - "date1.compareTo(date2), where date1 > date2, did not result in 1", - d1.compareTo(d4) == 1); - assertTrue( - "date1.compareTo(date2), where date1 < date2, did not result in -1", - d1.compareTo(d3) == -1); + assertEquals("Comparing a date to itself did not answer zero", 0, d1 + .compareTo(d1)); + assertEquals("Comparing equal dates did not answer zero", 0, d1 + .compareTo(d2)); + assertEquals("date1.compareTo(date2), where date1 > date2, did not result in 1", + 1, d1.compareTo(d4)); + assertEquals("date1.compareTo(date2), where date1 < date2, did not result in -1", + -1, d1.compareTo(d3)); } @@ -218,7 +214,7 @@ // Test for method int java.util.Date.getDate() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect date", d.getDate() == 13); + assertEquals("Returned incorrect date", 13, d.getDate()); } /** @@ -228,7 +224,7 @@ // Test for method int java.util.Date.getDay() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect day", d.getDay() == 2); + assertEquals("Returned incorrect day", 2, d.getDay()); } /** @@ -238,7 +234,7 @@ // Test for method int java.util.Date.getHours() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect hours", d.getHours() == 19); + assertEquals("Returned incorrect hours", 19, d.getHours()); } /** @@ -248,7 +244,7 @@ // Test for method int java.util.Date.getMinutes() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect minutes", d.getMinutes() == 9); + assertEquals("Returned incorrect minutes", 9, d.getMinutes()); } /** @@ -258,7 +254,7 @@ // Test for method int java.util.Date.getMonth() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect month", d.getMonth() == 9); + assertEquals("Returned incorrect month", 9, d.getMonth()); } /** @@ -268,7 +264,7 @@ // Test for method int java.util.Date.getSeconds() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect seconds", d.getSeconds() == 0); + assertEquals("Returned incorrect seconds", 0, d.getSeconds()); } /** @@ -278,8 +274,8 @@ // Test for method long java.util.Date.getTime() Date d1 = new Date(0); Date d2 = new Date(1900000); - assertTrue("Returned incorrect time", d2.getTime() == 1900000); - assertTrue("Returned incorrect time", d1.getTime() == 0); + assertEquals("Returned incorrect time", 1900000, d2.getTime()); + assertEquals("Returned incorrect time", 0, d1.getTime()); } /** @@ -297,7 +293,7 @@ // Test for method int java.util.Date.getYear() Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); - assertTrue("Returned incorrect year", d.getYear() == 98); + assertEquals("Returned incorrect year", 98, d.getYear()); } /** @@ -307,8 +303,8 @@ // Test for method int java.util.Date.hashCode() Date d1 = new Date(0); Date d2 = new Date(1900000); - assertTrue("Returned incorrect hash", d2.hashCode() == 1900000); - assertTrue("Returned incorrect hash", d1.hashCode() == 0); + assertEquals("Returned incorrect hash", 1900000, d2.hashCode()); + assertEquals("Returned incorrect hash", 0, d1.hashCode()); } /** @@ -319,9 +315,9 @@ Date d = new Date(Date.parse("13 October 1998")); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(d); - assertTrue("Parsed incorrect month", cal.get(Calendar.MONTH) == 9); - assertTrue("Parsed incorrect year", cal.get(Calendar.YEAR) == 1998); - assertTrue("Parsed incorrect date", cal.get(Calendar.DATE) == 13); + assertEquals("Parsed incorrect month", 9, cal.get(Calendar.MONTH)); + assertEquals("Parsed incorrect year", 1998, cal.get(Calendar.YEAR)); + assertEquals("Parsed incorrect date", 13, cal.get(Calendar.DATE)); d = new Date(Date.parse("Jan-12 1999")); assertTrue("Wrong parsed date 1", d.equals(new GregorianCalendar(1999, @@ -362,7 +358,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setDate(23); - assertTrue("Set incorrect date", d.getDate() == 23); + assertEquals("Set incorrect date", 23, d.getDate()); } /** @@ -373,7 +369,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setHours(23); - assertTrue("Set incorrect hours", d.getHours() == 23); + assertEquals("Set incorrect hours", 23, d.getHours()); } /** @@ -384,7 +380,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setMinutes(45); - assertTrue("Set incorrect mins", d.getMinutes() == 45); + assertEquals("Set incorrect mins", 45, d.getMinutes()); } /** @@ -395,7 +391,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setMonth(0); - assertTrue("Set incorrect month", d.getMonth() == 0); + assertEquals("Set incorrect month", 0, d.getMonth()); } /** @@ -406,7 +402,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setSeconds(13); - assertTrue("Set incorrect seconds", d.getSeconds() == 13); + assertEquals("Set incorrect seconds", 13, d.getSeconds()); } /** @@ -418,8 +414,8 @@ Date d2 = new Date(1900000); d1.setTime(900); d2.setTime(890000); - assertTrue("Returned incorrect time", d2.getTime() == 890000); - assertTrue("Returned incorrect time", d1.getTime() == 900); + assertEquals("Returned incorrect time", 890000, d2.getTime()); + assertEquals("Returned incorrect time", 900, d1.getTime()); } /** @@ -430,7 +426,7 @@ Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9) .getTime(); d.setYear(8); - assertTrue("Set incorrect year", d.getYear() == 8); + assertEquals("Set incorrect year", 8, d.getYear()); } /** @@ -438,11 +434,11 @@ */ public void test_toGMTString() { // Test for method java.lang.String java.util.Date.toGMTString() - assertTrue("Did not convert epoch to GMT string correctly", new Date(0) - .toGMTString().equals("1 Jan 1970 00:00:00 GMT")); - assertTrue("Did not convert epoch + 1yr to GMT string correctly", - new Date((long) 365 * 24 * 60 * 60 * 1000).toGMTString() - .equals("1 Jan 1971 00:00:00 GMT")); + assertEquals("Did not convert epoch to GMT string correctly", "1 Jan 1970 00:00:00 GMT", new Date(0) + .toGMTString()); + assertEquals("Did not convert epoch + 1yr to GMT string correctly", + "1 Jan 1971 00:00:00 GMT", new Date((long) 365 * 24 * 60 * 60 * 1000).toGMTString() + ); } /** Index: modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/CollectionsTest.java (working copy) @@ -403,13 +403,13 @@ assertTrue("Fill modified list size", size == ll.size()); Iterator i = ll.iterator(); while (i.hasNext()) - assertTrue("Failed to fill elements", i.next().equals("k")); + assertEquals("Failed to fill elements", "k", i.next()); Collections.fill(ll, null); assertTrue("Fill with nulls modified list size", size == ll.size()); i = ll.iterator(); while (i.hasNext()) - assertTrue("Failed to fill with nulls", i.next() == null); + assertNull("Failed to fill with nulls", i.next()); } /** @@ -477,7 +477,7 @@ Iterator i = l.iterator(); Object first = i.next(); assertTrue("Returned list consists of copies not refs", first == o); - assertTrue("Returned list of incorrect size", l.size() == 100); + assertEquals("Returned list of incorrect size", 100, l.size()); assertTrue("Contains", l.contains(o)); assertTrue("Contains null", !l.contains(null)); assertTrue("null nCopies contains", !Collections.nCopies(2, null) @@ -488,7 +488,7 @@ i = l.iterator(); for (int counter = 0; i.hasNext(); counter++) { assertTrue("List is too large", counter < 20); - assertTrue("Element should be null: " + counter, i.next() == null); + assertNull("Element should be null: " + counter, i.next()); } try { l.add(o); @@ -529,8 +529,8 @@ Collections.reverse(myList); assertTrue("Did not reverse correctly--first element is: " + myList.get(0), myList.get(0).equals(new Integer(20))); - assertTrue("Did not reverse correctly--second element is: " - + myList.get(1), myList.get(1) == null); + assertNull("Did not reverse correctly--second element is: " + + myList.get(1), myList.get(1)); } /** @@ -633,7 +633,7 @@ // java.util.Collections.singleton(java.lang.Object) Object o = new Object(); Set single = Collections.singleton(o); - assertTrue("Wrong size", single.size() == 1); + assertEquals("Wrong size", 1, single.size()); assertTrue("Contains", single.contains(o)); assertTrue("Contains null", !single.contains(null)); assertTrue("null nCopies contains", !Collections.singleton(null) @@ -1338,8 +1338,8 @@ fail(type + " list tests: join() interrupted"); } synchList.set(25, null); - assertTrue(type + " list tests: Trying to use nulls in list failed", - synchList.get(25) == null); + assertNull(type + " list tests: Trying to use nulls in list failed", + synchList.get(25)); } /** @@ -1387,8 +1387,8 @@ // synchronized map does not have to permit null keys or values synchMap.put(new Long(25), null); synchMap.put(null, new Long(30)); - assertTrue("Trying to use a null value in map failed", synchMap - .get(new Long(25)) == null); + assertNull("Trying to use a null value in map failed", synchMap + .get(new Long(25))); assertTrue("Trying to use a null key in map failed", synchMap.get(null) .equals(new Long(30))); @@ -1399,12 +1399,12 @@ synchMap = Collections.synchronizedMap(smallMap); new Support_UnmodifiableMapTest("", synchMap).runTest(); synchMap.keySet().remove(objArray[50].toString()); - assertTrue( + assertNull( "Removing a key from the keySet of the synchronized map did not remove it from the synchronized map: ", - synchMap.get(objArray[50].toString()) == null); - assertTrue( + synchMap.get(objArray[50].toString())); + assertNull( "Removing a key from the keySet of the synchronized map did not remove it from the original map", - smallMap.get(objArray[50].toString()) == null); + smallMap.get(objArray[50].toString())); } /** @@ -1510,12 +1510,12 @@ synchMap = Collections.synchronizedSortedMap(smallMap); new Support_UnmodifiableMapTest("", synchMap).runTest(); synchMap.keySet().remove(objArray[50].toString()); - assertTrue( + assertNull( "Removing a key from the keySet of the synchronized map did not remove it from the synchronized map", - synchMap.get(objArray[50].toString()) == null); - assertTrue( + synchMap.get(objArray[50].toString())); + assertNull( "Removing a key from the keySet of the synchronized map did not remove it from the original map", - smallMap.get(objArray[50].toString()) == null); + smallMap.get(objArray[50].toString())); } /** @@ -1656,7 +1656,7 @@ smallList.add(null); smallList.add("yoink"); c = Collections.unmodifiableList(smallList); - assertTrue("First element should be null", c.get(0) == null); + assertNull("First element should be null", c.get(0)); assertTrue("List should contain null", c.contains(null)); assertTrue( "T1. Returned List should implement Random Access interface", @@ -1751,8 +1751,8 @@ smallMap.put(new Long(25), null); Map unmodMap = Collections.unmodifiableMap(smallMap); - assertTrue("Trying to use a null value in map failed", unmodMap - .get(new Long(25)) == null); + assertNull("Trying to use a null value in map failed", unmodMap + .get(new Long(25))); assertTrue("Trying to use a null key in map failed", unmodMap.get(null) .equals(new Long(30))); Index: modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java (working copy) @@ -145,7 +145,7 @@ .contains(intArray[i])); duplicates.add(intArray[i]); } - assertTrue("End of list should be null", intArray[100] == null); + assertNull("End of list should be null", intArray[100]); intArray = new Integer[1]; intArray = (Integer[]) org.toArray(intArray); Index: modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java (working copy) @@ -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() { Index: modules/luni/src/test/java/tests/api/java/util/ObservableTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/ObservableTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/ObservableTest.java (working copy) @@ -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)); } Index: modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/PropertyResourceBundleTest.java (working copy) @@ -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")); } Index: modules/luni/src/test/java/tests/api/java/util/BitSetTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/BitSetTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/BitSetTest.java (working copy) @@ -29,9 +29,9 @@ BitSet bs = new BitSet(); // Default size for a BitSet should be 64 elements; - assertTrue("Created BitSet of incorrect size", bs.size() == 64); - assertTrue("New BitSet had invalid string representation", bs - .toString().equals("{}")); + assertEquals("Created BitSet of incorrect size", 64, bs.size()); + assertEquals("New BitSet had invalid string representation", "{}", bs + .toString()); } /** @@ -42,14 +42,14 @@ BitSet bs = new BitSet(128); // Default size for a BitSet should be 64 elements; - assertTrue("Created BitSet of incorrect size", bs.size() == 128); + assertEquals("Created BitSet of incorrect size", 128, bs.size()); assertTrue("New BitSet had invalid string representation: " + bs.toString(), bs.toString().equals("{}")); // All BitSets are created with elements of multiples of 64 bs = new BitSet(89); - assertTrue("Failed to round BitSet element size", bs.size() == 128); + assertEquals("Failed to round BitSet element size", 128, bs.size()); try { bs = new BitSet(-9); @@ -196,7 +196,7 @@ initialSize = bs.size(); bs.set(0, initialSize); bs.clear(7, 64); - assertTrue("Failed to grow BitSet", bs.size() == 128); + assertEquals("Failed to grow BitSet", 128, bs.size()); for (int i = 0; i < 7; i++) assertTrue("Shouldn't have cleared bit " + i, bs.get(i)); for (int i = 7; i < 64; i++) @@ -449,7 +449,7 @@ // Try setting a bit on a 64 boundary bs.set(128); - assertTrue("Failed to grow BitSet", bs.size() == 192); + assertEquals("Failed to grow BitSet", 192, bs.size()); assertTrue("Failed to set bit", bs.get(128)); bs = new BitSet(64); @@ -510,7 +510,7 @@ // pos1 and pos2 is in the same bitset element, boundary testing bs = new BitSet(16); bs.set(7, 64); - assertTrue("Failed to grow BitSet", bs.size() == 128); + assertEquals("Failed to grow BitSet", 128, bs.size()); for (int i = 0; i < 7; i++) assertTrue("Shouldn't have set bit " + i, !bs.get(i)); for (int i = 7; i < 64; i++) @@ -641,7 +641,7 @@ // Try setting a bit on a 64 boundary bs.flip(128); - assertTrue("Failed to grow BitSet", bs.size() == 192); + assertEquals("Failed to grow BitSet", 192, bs.size()); assertTrue("Failed to flip bit", bs.get(128)); bs = new BitSet(64); @@ -657,16 +657,16 @@ } BitSet bs0 = new BitSet(0); - assertTrue("Test1: Wrong size", bs0.size() == 0); - assertTrue("Test1: Wrong length", bs0.length() == 0); + assertEquals("Test1: Wrong size", 0, bs0.size()); + assertEquals("Test1: Wrong length", 0, bs0.length()); bs0.flip(0); - assertTrue("Test2: Wrong size", bs0.size() == 64); - assertTrue("Test2: Wrong length", bs0.length() == 1); + assertEquals("Test2: Wrong size", 64, bs0.size()); + assertEquals("Test2: Wrong length", 1, bs0.length()); bs0.flip(63); - assertTrue("Test3: Wrong size", bs0.size() == 64); - assertTrue("Test3: Wrong length", bs0.length() == 64); + assertEquals("Test3: Wrong size", 64, bs0.size()); + assertEquals("Test3: Wrong length", 64, bs0.length()); eightbs.flip(7); assertTrue("Failed to flip bit 7", !eightbs.get(7)); @@ -706,7 +706,7 @@ bs.set(7); bs.set(10); bs.flip(7, 64); - assertTrue("Failed to grow BitSet", bs.size() == 128); + assertEquals("Failed to grow BitSet", 128, bs.size()); for (int i = 0; i < 7; i++) assertTrue("Shouldn't have flipped bit " + i, !bs.get(i)); assertTrue("Failed to flip bit 7", !bs.get(7)); @@ -825,8 +825,8 @@ assertTrue("Bit got flipped incorrectly ", eightbs.get(0)); BitSet bsnew = eightbs.get(2, 2); - assertTrue("BitSet retrieved incorrectly ", - bsnew.cardinality() == 0); + assertEquals("BitSet retrieved incorrectly ", + 0, bsnew.cardinality()); eightbs.set(10, 10); assertTrue("Bit got set incorrectly ", !eightbs.get(10)); @@ -946,12 +946,12 @@ bs2.set(2); bs2.set(3); bs.andNot(bs2); - assertTrue("Incorrect bitset after andNot", bs.toString().equals( - "{0, 1, 4, 6, 7}")); + assertEquals("Incorrect bitset after andNot", + "{0, 1, 4, 6, 7}", bs.toString()); bs = new BitSet(0); bs.andNot(bs2); - assertTrue("Incorrect size", bs.size() == 0); + assertEquals("Incorrect size", 0, bs.size()); } /** @@ -997,7 +997,7 @@ bs = new BitSet(); bs.set(63); - assertTrue("Test highest bit", bs.toString().equals("{63}")); + assertEquals("Test highest bit", "{63}", bs.toString()); } /** @@ -1005,7 +1005,7 @@ */ public void test_size() { // Test for method int java.util.BitSet.size() - assertTrue("Returned incorrect size", eightbs.size() == 64); + assertEquals("Returned incorrect size", 64, eightbs.size()); eightbs.set(129); assertTrue("Returned incorrect size", eightbs.size() >= 129); @@ -1016,11 +1016,11 @@ */ public void test_toString() { // Test for method java.lang.String java.util.BitSet.toString() - assertTrue("Returned incorrect string representation", eightbs - .toString().equals("{0, 1, 2, 3, 4, 5, 6, 7}")); + assertEquals("Returned incorrect string representation", "{0, 1, 2, 3, 4, 5, 6, 7}", eightbs + .toString()); eightbs.clear(2); - assertTrue("Returned incorrect string representation", eightbs - .toString().equals("{0, 1, 3, 4, 5, 6, 7}")); + assertEquals("Returned incorrect string representation", "{0, 1, 3, 4, 5, 6, 7}", eightbs + .toString()); } /** Index: modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/CurrencyTest.java (working copy) @@ -77,9 +77,9 @@ Locale loc = new Locale("", "AQ"); try { Currency curr = Currency.getInstance(loc); - assertTrue( + assertNull( "Currency.getInstance(new Locale(\"\", \"AQ\")) did not return null", - curr == null); + curr); } catch (IllegalArgumentException e) { fail("Unexpected IllegalArgumentException " + e); } Index: modules/luni/src/test/java/tests/api/java/util/HashtableTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/HashtableTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/HashtableTest.java (working copy) @@ -56,7 +56,7 @@ Hashtable h = new Hashtable(); - assertTrue("Created incorrect hashtable", h.size() == 0); + assertEquals("Created incorrect hashtable", 0, h.size()); } /** @@ -66,10 +66,10 @@ // Test for method java.util.Hashtable(int) Hashtable h = new Hashtable(9); - assertTrue("Created incorrect hashtable", h.size() == 0); + assertEquals("Created incorrect hashtable", 0, h.size()); Hashtable empty = new Hashtable(0); - 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"); } @@ -80,10 +80,10 @@ public void test_ConstructorIF() { // Test for method java.util.Hashtable(int, float) Hashtable h = new java.util.Hashtable(10, 0.5f); - assertTrue("Created incorrect hashtable", h.size() == 0); + assertEquals("Created incorrect hashtable", 0, h.size()); Hashtable empty = new Hashtable(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"); } @@ -112,7 +112,7 @@ // Test for method void java.util.Hashtable.clear() Hashtable h = hashtableClone(htfull); h.clear(); - assertTrue("Hashtable was not cleared", h.size() == 0); + assertEquals("Hashtable was not cleared", 0, h.size()); Enumeration el = h.elements(); Enumeration keys = h.keys(); assertTrue("Hashtable improperly cleared", !el.hasMoreElements() @@ -190,7 +190,7 @@ ++i; } - assertTrue("All keys not retrieved", ht10.size() == 10); + assertEquals("All keys not retrieved", 10, ht10.size()); } /** @@ -216,10 +216,10 @@ try { // cached "12" Object result = en.nextElement(); - assertTrue("unexpected: " + result, result == null); + assertNull("unexpected: " + result, result); // next is removed "9" result = en.nextElement(); - assertTrue("unexpected: " + result, result == null); + assertNull("unexpected: " + result, result); result = en.nextElement(); assertTrue("unexpected: " + result, "b".equals(result)); } catch (NoSuchElementException e) { @@ -243,8 +243,8 @@ assertTrue("Returned incorrect entry set", s2.contains(e .nextElement())); - assertTrue("Not synchronized", s.getClass().getName().equals( - "java.util.Collections$SynchronizedSet")); + assertEquals("Not synchronized", + "java.util.Collections$SynchronizedSet", s.getClass().getName()); boolean exception = false; try { @@ -274,8 +274,8 @@ // Test for method java.lang.Object // java.util.Hashtable.get(java.lang.Object) Hashtable h = hashtableClone(htfull); - assertTrue("Could not retrieve element", ((String) h.get("FKey 2")) - .equals("FVal 2")); + assertEquals("Could not retrieve element", "FVal 2", ((String) h.get("FKey 2")) + ); // Regression for HARMONY-262 @@ -357,7 +357,7 @@ ++i; } - assertTrue("All keys not retrieved", ht10.size() == 10); + assertEquals("All keys not retrieved", 10, ht10.size()); } /** @@ -391,8 +391,8 @@ assertTrue("Returned incorrect key set", s .contains(e.nextElement())); - assertTrue("Not synchronized", s.getClass().getName().equals( - "java.util.Collections$SynchronizedSet")); + assertEquals("Not synchronized", + "java.util.Collections$SynchronizedSet", s.getClass().getName()); Map map = new Hashtable(101); map.put(new Integer(1), "1"); @@ -408,7 +408,7 @@ list.remove(remove1); list.remove(remove2); assertTrue("Wrong result", it.next().equals(list.get(0))); - assertTrue("Wrong size", map.size() == 1); + assertEquals("Wrong size", 1, map.size()); assertTrue("Wrong contents", map.keySet().iterator().next().equals( list.get(0))); @@ -425,7 +425,7 @@ it2.hasNext(); it2.remove(); assertTrue("Wrong result 2", it2.next().equals(next)); - assertTrue("Wrong size 2", map2.size() == 1); + assertEquals("Wrong size 2", 1, map2.size()); assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals( next)); } @@ -595,8 +595,8 @@ public void test_toString() { // Test for method java.lang.String java.util.Hashtable.toString() Hashtable h = new Hashtable(); - assertTrue("Incorrect toString for Empty table", h.toString().equals( - "{}")); + assertEquals("Incorrect toString for Empty table", + "{}", h.toString()); h.put("one", "1"); h.put("two", h); @@ -616,8 +616,8 @@ while (e.hasMoreElements()) assertTrue("Returned incorrect values", c.contains(e.nextElement())); - assertTrue("Not synchronized", c.getClass().getName().equals( - "java.util.Collections$SynchronizedCollection")); + assertEquals("Not synchronized", + "java.util.Collections$SynchronizedCollection", c.getClass().getName()); Hashtable myHashtable = new Hashtable(); for (int i = 0; i < 100; i++) Index: modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/TooManyListenersExceptionTest.java (working copy) @@ -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()); } } Index: modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/MissingResourceExceptionTest.java (working copy) @@ -44,8 +44,8 @@ try { ResourceBundle.getBundle("Non-ExistentBundle"); } catch (MissingResourceException e) { - assertTrue("Returned incorrect class name", e.getClassName() - .equals("Non-ExistentBundle")); + assertEquals("Returned incorrect class name", "Non-ExistentBundle", e.getClassName() + ); } } Index: modules/luni/src/test/java/tests/api/java/util/VectorTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/VectorTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/VectorTest.java (working copy) @@ -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) { Index: modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/LinkedListTest.java (working copy) @@ -70,7 +70,7 @@ assertTrue("Failed to fix up list after insert", ll.get(51) == objArray[50] && (ll.get(52) == objArray[51])); ll.add(50, null); - assertTrue("Did not add null correctly", ll.get(50) == null); + assertNull("Did not add null correctly", ll.get(50)); } /** @@ -82,7 +82,7 @@ ll.add(o = new Object()); assertTrue("Failed to add Object", ll.getLast() == o); ll.add(null); - assertTrue("Did not add null correctly", ll.get(ll.size() - 1) == null); + assertNull("Did not add null correctly", ll.get(ll.size() - 1)); } /** @@ -92,8 +92,8 @@ // Test for method boolean java.util.LinkedList.addAll(int, // java.util.Collection) ll.addAll(50, (Collection) ll.clone()); - assertTrue("Returned incorrect size after adding to existing list", ll - .size() == 200); + assertEquals("Returned incorrect size after adding to existing list", 200, ll + .size()); for (int i = 0; i < 50; i++) assertTrue("Manipulated elements < index", ll.get(i) == objArray[i]); for (int i = 0; i >= 50 && (i < 150); i++) @@ -109,13 +109,13 @@ myList.add("Booga"); myList.add(null); ll.addAll(50, myList); - assertTrue("a) List w/nulls not added correctly", ll.get(50) == null); - assertTrue("b) List w/nulls not added correctly", ll.get(51).equals( - "Blah")); - assertTrue("c) List w/nulls not added correctly", ll.get(52) == null); - assertTrue("d) List w/nulls not added correctly", ll.get(53).equals( - "Booga")); - assertTrue("e) List w/nulls not added correctly", ll.get(54) == null); + assertNull("a) List w/nulls not added correctly", ll.get(50)); + assertEquals("b) List w/nulls not added correctly", + "Blah", ll.get(51)); + assertNull("c) List w/nulls not added correctly", ll.get(52)); + assertEquals("d) List w/nulls not added correctly", + "Booga", ll.get(53)); + assertNull("e) List w/nulls not added correctly", ll.get(54)); } /** @@ -130,8 +130,8 @@ assertTrue("Failed to add elements properly", l.get(i).equals( ll.get(i))); ll.addAll((Collection) ll.clone()); - assertTrue("Returned incorrect siZe after adding to existing list", ll - .size() == 200); + assertEquals("Returned incorrect siZe after adding to existing list", 200, ll + .size()); for (int i = 0; i < 100; i++) { assertTrue("Added to list in incorrect order", ll.get(i).equals( l.get(i))); @@ -145,13 +145,13 @@ myList.add("Booga"); myList.add(null); ll.addAll(myList); - assertTrue("a) List w/nulls not added correctly", ll.get(200) == null); - assertTrue("b) List w/nulls not added correctly", ll.get(201).equals( - "Blah")); - assertTrue("c) List w/nulls not added correctly", ll.get(202) == null); - assertTrue("d) List w/nulls not added correctly", ll.get(203).equals( - "Booga")); - assertTrue("e) List w/nulls not added correctly", ll.get(204) == null); + assertNull("a) List w/nulls not added correctly", ll.get(200)); + assertEquals("b) List w/nulls not added correctly", + "Blah", ll.get(201)); + assertNull("c) List w/nulls not added correctly", ll.get(202)); + assertEquals("d) List w/nulls not added correctly", + "Booga", ll.get(203)); + assertNull("e) List w/nulls not added correctly", ll.get(204)); } /** @@ -163,7 +163,7 @@ ll.addFirst(o = new Object()); assertTrue("Failed to add Object", ll.getFirst() == o); ll.addFirst(null); - assertTrue("Failed to add null", ll.getFirst() == null); + assertNull("Failed to add null", ll.getFirst()); } /** @@ -175,7 +175,7 @@ ll.addLast(o = new Object()); assertTrue("Failed to add Object", ll.getLast() == o); ll.addLast(null); - assertTrue("Failed to add null", ll.getLast() == null); + assertNull("Failed to add null", ll.getLast()); } /** @@ -185,7 +185,7 @@ // Test for method void java.util.LinkedList.clear() ll.clear(); for (int i = 0; i < ll.size(); i++) - assertTrue("Failed to clear list", ll.get(i) == null); + assertNull("Failed to clear list", ll.get(i)); } /** @@ -258,9 +258,9 @@ */ public void test_indexOfLjava_lang_Object() { // Test for method int java.util.LinkedList.indexOf(java.lang.Object) - assertTrue("Returned incorrect index", ll.indexOf(objArray[87]) == 87); - assertTrue("Returned index for invalid Object", ll - .indexOf(new Object()) == -1); + assertEquals("Returned incorrect index", 87, ll.indexOf(objArray[87])); + assertEquals("Returned index for invalid Object", -1, ll + .indexOf(new Object())); ll.add(20, null); ll.add(24, null); assertTrue("Index of null should be 20, but got: " + ll.indexOf(null), @@ -274,10 +274,10 @@ // Test for method int // java.util.LinkedList.lastIndexOf(java.lang.Object) ll.add(new Integer(99)); - assertTrue("Returned incorrect index", - ll.lastIndexOf(objArray[99]) == 100); - assertTrue("Returned index for invalid Object", ll - .lastIndexOf(new Object()) == -1); + assertEquals("Returned incorrect index", + 100, ll.lastIndexOf(objArray[99])); + assertEquals("Returned index for invalid Object", -1, ll + .lastIndexOf(new Object())); ll.add(20, null); ll.add(24, null); assertTrue("Last index of null should be 20, but got: " @@ -322,15 +322,15 @@ myList.add(null); ListIterator li = myList.listIterator(); assertTrue("li.hasPrevious() should be false", !li.hasPrevious()); - assertTrue("li.next() should be null", li.next() == null); + assertNull("li.next() should be null", li.next()); assertTrue("li.hasPrevious() should be true", li.hasPrevious()); - assertTrue("li.prev() should be null", li.previous() == null); - assertTrue("li.next() should be null", li.next() == null); - assertTrue("li.next() should be Blah", li.next().equals("Blah")); - assertTrue("li.next() should be null", li.next() == null); - assertTrue("li.next() should be Booga", li.next().equals("Booga")); + assertNull("li.prev() should be null", li.previous()); + assertNull("li.next() should be null", li.next()); + assertEquals("li.next() should be Blah", "Blah", li.next()); + assertNull("li.next() should be null", li.next()); + assertEquals("li.next() should be Booga", "Booga", li.next()); assertTrue("li.hasNext() should be true", li.hasNext()); - assertTrue("li.next() should be null", li.next() == null); + assertNull("li.next() should be null", li.next()); assertTrue("li.hasNext() should be false", !li.hasNext()); } @@ -340,7 +340,7 @@ public void test_removeI() { // Test for method java.lang.Object java.util.LinkedList.remove(int) ll.remove(10); - assertTrue("Failed to remove element", ll.indexOf(objArray[10]) == -1); + assertEquals("Failed to remove element", -1, ll.indexOf(objArray[10])); try { ll.remove(999); } catch (IndexOutOfBoundsException e) { @@ -350,7 +350,7 @@ fail("Failed to throw expected exception when index out of range"); ll.add(20, null); ll.remove(20); - assertTrue("Should have removed null", ll.get(20) != null); + assertNotNull("Should have removed null", ll.get(20)); } /** @@ -360,7 +360,7 @@ // Test for method boolean java.util.LinkedList.remove(java.lang.Object) assertTrue("Failed to remove valid Object", ll.remove(objArray[87])); assertTrue("Removed invalid object", !ll.remove(new Object())); - assertTrue("Found Object after removal", ll.indexOf(objArray[87]) == -1); + assertEquals("Found Object after removal", -1, ll.indexOf(objArray[87])); ll.add(null); ll.remove(null); assertTrue("Should not contain null afrer removal", !ll.contains(null)); @@ -418,8 +418,8 @@ for (int i = 0; i < obj.length - 1; i++) assertTrue("Returned incorrect array: " + i, obj[i] == objArray[i]); - assertTrue("Returned incorrect array--end isn't null", - obj[obj.length - 1] == null); + assertNull("Returned incorrect array--end isn't null", + obj[obj.length - 1]); } /** @@ -439,8 +439,8 @@ assertTrue("Lists are not equal", li.next() == ri.next()); argArray = new Integer[1000]; retArray = ll.toArray(argArray); - assertTrue("Failed to set first extra element to null", argArray[ll - .size()] == null); + assertNull("Failed to set first extra element to null", argArray[ll + .size()]); for (int i = 0; i < ll.size(); i++) assertTrue("Returned incorrect array: " + i, retArray[i] == objArray[i]); Index: modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/SimpleTimeZoneTest.java (working copy) @@ -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); } Index: modules/luni/src/test/java/tests/api/java/util/StackTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/StackTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/StackTest.java (working copy) @@ -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)); } /** Index: modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/LinkedHashMapTest.java (working copy) @@ -63,7 +63,7 @@ new Support_MapTest2(new LinkedHashMap()).runTest(); LinkedHashMap hm2 = new LinkedHashMap(); - assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0); + assertEquals("Created incorrect LinkedHashMap", 0, hm2.size()); } /** @@ -72,7 +72,7 @@ public void test_ConstructorI() { // Test for method java.util.LinkedHashMap(int) LinkedHashMap hm2 = new LinkedHashMap(5); - assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0); + assertEquals("Created incorrect LinkedHashMap", 0, hm2.size()); try { new LinkedHashMap(-1); } catch (IllegalArgumentException e) { @@ -82,7 +82,7 @@ "Failed to throw IllegalArgumentException for initial capacity < 0"); LinkedHashMap empty = new LinkedHashMap(0); - assertTrue("Empty LinkedHashMap access", empty.get("nothing") == null); + assertNull("Empty LinkedHashMap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); } @@ -93,7 +93,7 @@ public void test_ConstructorIF() { // Test for method java.util.LinkedHashMap(int, float) LinkedHashMap hm2 = new LinkedHashMap(5, (float) 0.5); - assertTrue("Created incorrect LinkedHashMap", hm2.size() == 0); + assertEquals("Created incorrect LinkedHashMap", 0, hm2.size()); try { new LinkedHashMap(0, 0); } catch (IllegalArgumentException e) { @@ -102,7 +102,7 @@ fail( "Failed to throw IllegalArgumentException for initial load factor <= 0"); LinkedHashMap empty = new LinkedHashMap(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"); } @@ -127,17 +127,17 @@ public void test_getLjava_lang_Object() { // Test for method java.lang.Object // java.util.LinkedHashMap.get(java.lang.Object) - assertTrue("Get returned non-null for non existent key", - hm.get("T") == null); + assertNull("Get returned non-null for non existent key", + hm.get("T")); hm.put("T", "HELLO"); - assertTrue("Get returned incorecct value for existing key", hm.get("T") - .equals("HELLO")); + assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T") + ); LinkedHashMap m = new LinkedHashMap(); m.put(null, "test"); - assertTrue("Failed with null key", m.get(null).equals("test")); - assertTrue("Failed with missing key matching null hash", m - .get(new Integer(0)) == null); + assertEquals("Failed with null key", "test", m.get(null)); + assertNull("Failed with missing key matching null hash", m + .get(new Integer(0))); } /** @@ -147,17 +147,17 @@ // Test for method java.lang.Object // java.util.LinkedHashMap.put(java.lang.Object, java.lang.Object) hm.put("KEY", "VALUE"); - assertTrue("Failed to install key/value pair", hm.get("KEY").equals( - "VALUE")); + assertEquals("Failed to install key/value pair", + "VALUE", hm.get("KEY")); LinkedHashMap m = new LinkedHashMap(); m.put(new Short((short) 0), "short"); m.put(null, "test"); m.put(new Integer(0), "int"); - assertTrue("Failed adding to bucket containing null", m.get( - new Short((short) 0)).equals("short")); - assertTrue("Failed adding to bucket containing null2", m.get( - new Integer(0)).equals("int")); + assertEquals("Failed adding to bucket containing null", "short", m.get( + new Short((short) 0))); + assertEquals("Failed adding to bucket containing null2", "int", m.get( + new Integer(0))); } /** @@ -202,7 +202,7 @@ LinkedHashMap m = new LinkedHashMap(); m.put(null, "test"); assertTrue("Failed with null key", m.keySet().contains(null)); - assertTrue("Failed with null key", m.keySet().iterator().next() == null); + assertNull("Failed with null key", m.keySet().iterator().next()); Map map = new LinkedHashMap(101); map.put(new Integer(1), "1"); @@ -219,7 +219,7 @@ list.remove(remove1); list.remove(remove2); assertTrue("Wrong result", it.next().equals(list.get(0))); - assertTrue("Wrong size", map.size() == 1); + assertEquals("Wrong size", 1, map.size()); assertTrue("Wrong contents", map.keySet().iterator().next().equals( list.get(0))); @@ -236,7 +236,7 @@ it2.hasNext(); it2.remove(); assertTrue("Wrong result 2", it2.next().equals(next)); - assertTrue("Wrong size 2", map2.size() == 1); + assertEquals("Wrong size 2", 1, map2.size()); assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals( next)); } @@ -277,16 +277,16 @@ Integer y = new Integer(9); Integer x = ((Integer) hm.remove(y.toString())); assertTrue("Remove returned incorrect value", x.equals(new Integer(9))); - assertTrue("Failed to remove given key", hm.get(new Integer(9)) == null); + assertNull("Failed to remove given key", hm.get(new Integer(9))); assertTrue("Failed to decrement size", hm.size() == (size - 1)); - assertTrue("Remove of non-existent key returned non-null", hm - .remove("LCLCLC") == null); + assertNull("Remove of non-existent key returned non-null", hm + .remove("LCLCLC")); LinkedHashMap m = new LinkedHashMap(); m.put(null, "test"); - assertTrue("Failed with same hash as null", - m.remove(new Integer(0)) == null); - assertTrue("Failed with null key", m.remove(null).equals("test")); + assertNull("Failed with same hash as null", + m.remove(new Integer(0))); + assertEquals("Failed with null key", "test", m.remove(null)); } /** @@ -295,10 +295,10 @@ public void test_clear() { // Test for method void java.util.LinkedHashMap.clear() hm.clear(); - assertTrue("Clear failed to reset size", hm.size() == 0); + assertEquals("Clear failed to reset size", 0, hm.size()); for (int i = 0; i < hmSize; i++) - assertTrue("Failed to clear all elements", - hm.get(objArray2[i]) == null); + assertNull("Failed to clear all elements", + hm.get(objArray2[i])); } @@ -318,24 +318,24 @@ // 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()); } /** @@ -428,7 +428,7 @@ String ii = (String) lruhm.get(new Integer(i)); p = p + Integer.parseInt(ii); } - assertTrue("invalid sum of even numbers", p == 2450); + assertEquals("invalid sum of even numbers", 2450, p); Set s2 = lruhm.entrySet(); Iterator it2 = s2.iterator(); @@ -487,7 +487,7 @@ String ii = (String) lruhm.get(new Integer(i)); p = p + Integer.parseInt(ii); } - assertTrue("invalid sum of even numbers", p == 2450); + assertEquals("invalid sum of even numbers", 2450, p); Set s2 = lruhm.keySet(); Iterator it2 = s2.iterator(); Index: modules/luni/src/test/java/tests/api/java/util/CalendarTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/CalendarTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/CalendarTest.java (working copy) @@ -370,7 +370,7 @@ Calendar cal = Calendar.getInstance(); // Use millisecond time for testing in Core cal.setTime(new Date(884581200000L)); // (98, Calendar.JANUARY, 12) - assertTrue("incorrect millis", cal.getTime().getTime() == 884581200000L); + assertEquals("incorrect millis", 884581200000L, cal.getTime().getTime()); cal.setTimeZone(TimeZone.getTimeZone("EST")); cal.setTime(new Date(943506000000L)); // (99, Calendar.NOVEMBER, 25) assertTrue("incorrect fields", cal.get(Calendar.YEAR) == 1999 Index: modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/IdentityHashMap2Test.java (working copy) @@ -40,9 +40,9 @@ result = map.put(null, null); assertTrue("testA can not find null key", map.containsKey(null)); assertTrue("testA can not find null value", map.containsValue(null)); - assertTrue("testA can not get null value for null key", - map.get(null) == null); - assertTrue("testA put returned wrong value", result == null); + assertNull("testA can not get null value for null key", + map.get(null)); + assertNull("testA put returned wrong value", result); // null value String value = "a value"; @@ -52,7 +52,7 @@ .containsValue(value)); assertTrue("testB can not get value for null key", map.get(null) == value); - assertTrue("testB put returned wrong value", result == null); + assertNull("testB put returned wrong value", result); // a null key String key = "a key"; @@ -60,8 +60,8 @@ assertTrue("testC can not find a key with null value", map .containsKey(key)); assertTrue("testC can not find null value", map.containsValue(null)); - assertTrue("testC can not get null value for key", map.get(key) == null); - assertTrue("testC put returned wrong value", result == null); + assertNull("testC can not get null value for key", map.get(key)); + assertNull("testC put returned wrong value", result); // another null key String anothervalue = "another value"; @@ -79,8 +79,8 @@ assertTrue("testE should not find null key", !map.containsKey(null)); assertTrue("testE should not find a value with null key", !map .containsValue(anothervalue)); - assertTrue("testE should not get value for null key", - map.get(null) == null); + assertNull("testE should not get value for null key", + map.get(null)); } /** @@ -100,7 +100,7 @@ assertTrue("Modified key2", map.get("key2") != null && map.get("key2") == "value2"); - assertTrue("Modified null entry", map.get(null) == null); + assertNull("Modified null entry", map.get(null)); } /** @@ -151,7 +151,7 @@ Set set = map.entrySet(); set.removeAll(set); - assertTrue("did not remove all elements in the map", map.size() == 0); + assertEquals("did not remove all elements in the map", 0, map.size()); assertTrue("did not remove all elements in the entryset", set.isEmpty()); Iterator it = set.iterator(); @@ -170,7 +170,7 @@ Set set = map.keySet(); set.clear(); - assertTrue("did not remove all elements in the map", map.size() == 0); + assertEquals("did not remove all elements in the map", 0, map.size()); assertTrue("did not remove all elements in the keyset", set.isEmpty()); Iterator it = set.iterator(); @@ -224,7 +224,7 @@ .containsValue(value)); vals.clear(); - assertTrue("Did not remove all entries as expected", map.size() == 0); + assertEquals("Did not remove all entries as expected", 0, map.size()); } /** @@ -239,7 +239,7 @@ Set set = map.keySet(); set.removeAll(set); - assertTrue("did not remove all elements in the map", map.size() == 0); + assertEquals("did not remove all elements in the map", 0, map.size()); assertTrue("did not remove all elements in the keyset", set.isEmpty()); Iterator it = set.iterator(); @@ -259,12 +259,12 @@ // retain all the elements boolean result = set.retainAll(set); assertTrue("retain all should return false", !result); - assertTrue("did not retain all", set.size() == 1000); + assertEquals("did not retain all", 1000, set.size()); // send empty set to retainAll result = set.retainAll(new TreeSet()); assertTrue("retain all should return true", result); - assertTrue("did not remove all elements in the map", map.size() == 0); + assertEquals("did not remove all elements in the map", 0, map.size()); assertTrue("did not remove all elements in the keyset", set.isEmpty()); Iterator it = set.iterator(); Index: modules/luni/src/test/java/tests/api/java/util/TimerTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/TimerTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/TimerTest.java (working copy) @@ -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 Index: modules/luni/src/test/java/tests/api/java/util/HashMapTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/HashMapTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/HashMapTest.java (working copy) @@ -54,7 +54,7 @@ new Support_MapTest2(new HashMap()).runTest(); HashMap hm2 = new HashMap(); - assertTrue("Created incorrect HashMap", hm2.size() == 0); + assertEquals("Created incorrect HashMap", 0, hm2.size()); } /** @@ -63,7 +63,7 @@ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); - assertTrue("Created incorrect HashMap", hm2.size() == 0); + assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); } catch (IllegalArgumentException e) { @@ -73,7 +73,7 @@ "Failed to throw IllegalArgumentException for initial capacity < 0"); HashMap empty = new HashMap(0); - assertTrue("Empty hashmap access", empty.get("nothing") == null); + assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); } @@ -84,7 +84,7 @@ public void test_ConstructorIF() { // Test for method java.util.HashMap(int, float) HashMap hm2 = new HashMap(5, (float) 0.5); - assertTrue("Created incorrect HashMap", hm2.size() == 0); + assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(0, 0); } catch (IllegalArgumentException e) { @@ -94,7 +94,7 @@ "Failed to throw IllegalArgumentException for initial load factor <= 0"); HashMap empty = new HashMap(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"); } @@ -119,10 +119,10 @@ public void test_clear() { // Test for method void java.util.HashMap.clear() hm.clear(); - assertTrue("Clear failed to reset size", hm.size() == 0); + assertEquals("Clear failed to reset size", 0, hm.size()); for (int i = 0; i < hmSize; i++) - assertTrue("Failed to clear all elements", - hm.get(objArray2[i]) == null); + assertNull("Failed to clear all elements", + hm.get(objArray2[i])); } @@ -142,23 +142,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,17 +212,17 @@ public void test_getLjava_lang_Object() { // Test for method java.lang.Object // java.util.HashMap.get(java.lang.Object) - assertTrue("Get returned non-null for non existent key", - hm.get("T") == null); + assertNull("Get returned non-null for non existent key", + hm.get("T")); hm.put("T", "HELLO"); - assertTrue("Get returned incorecct value for existing key", hm.get("T") - .equals("HELLO")); + assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T") + ); HashMap m = new HashMap(); m.put(null, "test"); - assertTrue("Failed with null key", m.get(null).equals("test")); - assertTrue("Failed with missing key matching null hash", m - .get(new Integer(0)) == null); + assertEquals("Failed with null key", "test", m.get(null)); + assertNull("Failed with missing key matching null hash", m + .get(new Integer(0))); // Regression for HARMONY-206 ReusableKey k = new ReusableKey(); @@ -260,7 +260,7 @@ HashMap m = new HashMap(); m.put(null, "test"); assertTrue("Failed with null key", m.keySet().contains(null)); - assertTrue("Failed with null key", m.keySet().iterator().next() == null); + assertNull("Failed with null key", m.keySet().iterator().next()); Map map = new HashMap(101); map.put(new Integer(1), "1"); @@ -277,7 +277,7 @@ list.remove(remove1); list.remove(remove2); assertTrue("Wrong result", it.next().equals(list.get(0))); - assertTrue("Wrong size", map.size() == 1); + assertEquals("Wrong size", 1, map.size()); assertTrue("Wrong contents", map.keySet().iterator().next().equals( list.get(0))); @@ -294,7 +294,7 @@ it2.hasNext(); it2.remove(); assertTrue("Wrong result 2", it2.next().equals(next)); - assertTrue("Wrong size 2", map2.size() == 1); + assertEquals("Wrong size 2", 1, map2.size()); assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals( next)); } @@ -306,17 +306,17 @@ // Test for method java.lang.Object // java.util.HashMap.put(java.lang.Object, java.lang.Object) hm.put("KEY", "VALUE"); - assertTrue("Failed to install key/value pair", hm.get("KEY").equals( - "VALUE")); + assertEquals("Failed to install key/value pair", + "VALUE", hm.get("KEY")); HashMap m = new HashMap(); m.put(new Short((short) 0), "short"); m.put(null, "test"); m.put(new Integer(0), "int"); - assertTrue("Failed adding to bucket containing null", m.get( - new Short((short) 0)).equals("short")); - assertTrue("Failed adding to bucket containing null2", m.get( - new Integer(0)).equals("int")); + assertEquals("Failed adding to bucket containing null", "short", m.get( + new Short((short) 0))); + assertEquals("Failed adding to bucket containing null2", "int", m.get( + new Integer(0))); } /** @@ -341,16 +341,16 @@ Integer y = new Integer(9); Integer x = ((Integer) hm.remove(y.toString())); assertTrue("Remove returned incorrect value", x.equals(new Integer(9))); - assertTrue("Failed to remove given key", hm.get(new Integer(9)) == null); + assertNull("Failed to remove given key", hm.get(new Integer(9))); assertTrue("Failed to decrement size", hm.size() == (size - 1)); - assertTrue("Remove of non-existent key returned non-null", hm - .remove("LCLCLC") == null); + assertNull("Remove of non-existent key returned non-null", hm + .remove("LCLCLC")); HashMap m = new HashMap(); m.put(null, "test"); - assertTrue("Failed with same hash as null", - m.remove(new Integer(0)) == null); - assertTrue("Failed with null key", m.remove(null).equals("test")); + assertNull("Failed with same hash as null", + m.remove(new Integer(0))); + assertEquals("Failed with null key", "test", m.remove(null)); } /** Index: modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/LinkedHashSetTest.java (working copy) @@ -40,7 +40,7 @@ public void test_Constructor() { // Test for method java.util.LinkedHashSet() LinkedHashSet hs2 = new LinkedHashSet(); - assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0); + assertEquals("Created incorrect LinkedHashSet", 0, hs2.size()); } /** @@ -49,7 +49,7 @@ public void test_ConstructorI() { // Test for method java.util.LinkedHashSet(int) LinkedHashSet hs2 = new LinkedHashSet(5); - assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0); + assertEquals("Created incorrect LinkedHashSet", 0, hs2.size()); try { new LinkedHashSet(-1); } catch (IllegalArgumentException e) { @@ -65,7 +65,7 @@ public void test_ConstructorIF() { // Test for method java.util.LinkedHashSet(int, float) LinkedHashSet hs2 = new LinkedHashSet(5, (float) 0.5); - assertTrue("Created incorrect LinkedHashSet", hs2.size() == 0); + assertEquals("Created incorrect LinkedHashSet", 0, hs2.size()); try { new LinkedHashSet(0, 0); } catch (IllegalArgumentException e) { @@ -110,7 +110,7 @@ Set orgSet = (Set) hs.clone(); hs.clear(); Iterator i = orgSet.iterator(); - assertTrue("Returned non-zero size after clear", hs.size() == 0); + assertEquals("Returned non-zero size after clear", 0, hs.size()); while (i.hasNext()) assertTrue("Failed to clear set", !hs.contains(i.next())); } @@ -172,7 +172,7 @@ LinkedHashSet s = new LinkedHashSet(); s.add(null); - assertTrue("Cannot handle null", s.iterator().next() == null); + assertNull("Cannot handle null", s.iterator().next()); } /** @@ -198,7 +198,7 @@ // Test for method int java.util.LinkedHashSet.size() assertTrue("Returned incorrect size", hs.size() == (objArray.length + 1)); hs.clear(); - assertTrue("Cleared set returned non-zero size", hs.size() == 0); + assertEquals("Cleared set returned non-zero size", 0, hs.size()); } /** Index: modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/WeakHashMapTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/IdentityHashMapTest.java (working copy) @@ -59,7 +59,7 @@ new Support_MapTest2(new IdentityHashMap()).runTest(); IdentityHashMap hm2 = new IdentityHashMap(); - assertTrue("Created incorrect IdentityHashMap", hm2.size() == 0); + assertEquals("Created incorrect IdentityHashMap", 0, hm2.size()); } /** @@ -68,7 +68,7 @@ public void test_ConstructorI() { // Test for method java.util.IdentityHashMap(int) IdentityHashMap hm2 = new IdentityHashMap(5); - assertTrue("Created incorrect IdentityHashMap", hm2.size() == 0); + assertEquals("Created incorrect IdentityHashMap", 0, hm2.size()); try { new IdentityHashMap(-1); } catch (IllegalArgumentException e) { @@ -78,7 +78,7 @@ "Failed to throw IllegalArgumentException for initial capacity < 0"); IdentityHashMap empty = new IdentityHashMap(0); - assertTrue("Empty IdentityHashMap access", empty.get("nothing") == null); + assertNull("Empty IdentityHashMap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); } @@ -103,10 +103,10 @@ public void test_clear() { // Test for method void java.util.IdentityHashMap.clear() hm.clear(); - assertTrue("Clear failed to reset size", hm.size() == 0); + assertEquals("Clear failed to reset size", 0, hm.size()); for (int i = 0; i < hmSize; i++) - assertTrue("Failed to clear all elements", - hm.get(objArray2[i]) == null); + assertNull("Failed to clear all elements", + hm.get(objArray2[i])); } @@ -126,23 +126,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()); } /** @@ -198,17 +198,17 @@ public void test_getLjava_lang_Object() { // Test for method java.lang.Object // java.util.IdentityHashMap.get(java.lang.Object) - assertTrue("Get returned non-null for non existent key", - hm.get("T") == null); + assertNull("Get returned non-null for non existent key", + hm.get("T")); hm.put("T", "HELLO"); - assertTrue("Get returned incorecct value for existing key", hm.get("T") - .equals("HELLO")); + assertEquals("Get returned incorecct value for existing key", "HELLO", hm.get("T") + ); IdentityHashMap m = new IdentityHashMap(); m.put(null, "test"); - assertTrue("Failed with null key", m.get(null).equals("test")); - assertTrue("Failed with missing key matching null hash", m - .get(new Integer(0)) == null); + assertEquals("Failed with null key", "test", m.get(null)); + assertNull("Failed with missing key matching null hash", m + .get(new Integer(0))); } /** @@ -236,7 +236,7 @@ IdentityHashMap m = new IdentityHashMap(); m.put(null, "test"); assertTrue("Failed with null key", m.keySet().contains(null)); - assertTrue("Failed with null key", m.keySet().iterator().next() == null); + assertNull("Failed with null key", m.keySet().iterator().next()); Map map = new IdentityHashMap(101); map.put(new Integer(1), "1"); @@ -253,7 +253,7 @@ list.remove(remove1); list.remove(remove2); assertTrue("Wrong result", it.next().equals(list.get(0))); - assertTrue("Wrong size", map.size() == 1); + assertEquals("Wrong size", 1, map.size()); assertTrue("Wrong contents", map.keySet().iterator().next().equals( list.get(0))); @@ -270,7 +270,7 @@ it2.hasNext(); it2.remove(); assertTrue("Wrong result 2", it2.next().equals(next)); - assertTrue("Wrong size 2", map2.size() == 1); + assertEquals("Wrong size 2", 1, map2.size()); assertTrue("Wrong contents 2", map2.keySet().iterator().next().equals( next)); } @@ -282,8 +282,8 @@ // Test for method java.lang.Object // java.util.IdentityHashMap.put(java.lang.Object, java.lang.Object) hm.put("KEY", "VALUE"); - assertTrue("Failed to install key/value pair", hm.get("KEY").equals( - "VALUE")); + assertEquals("Failed to install key/value pair", + "VALUE", hm.get("KEY")); IdentityHashMap m = new IdentityHashMap(); Short s0 = new Short((short) 0); @@ -291,10 +291,10 @@ m.put(null, "test"); Integer i0 = new Integer(0); m.put(i0, "int"); - assertTrue("Failed adding to bucket containing null", m.get(s0).equals( - "short")); - assertTrue("Failed adding to bucket containing null2", m.get(i0) - .equals("int")); + assertEquals("Failed adding to bucket containing null", + "short", m.get(s0)); + assertEquals("Failed adding to bucket containing null2", "int", m.get(i0) + ); } /** @@ -318,16 +318,16 @@ int size = hm.size(); Integer x = ((Integer) hm.remove(objArray2[9])); assertTrue("Remove returned incorrect value", x.equals(new Integer(9))); - assertTrue("Failed to remove given key", hm.get(objArray2[9]) == null); + assertNull("Failed to remove given key", hm.get(objArray2[9])); assertTrue("Failed to decrement size", hm.size() == (size - 1)); - assertTrue("Remove of non-existent key returned non-null", hm - .remove("LCLCLC") == null); + assertNull("Remove of non-existent key returned non-null", hm + .remove("LCLCLC")); IdentityHashMap m = new IdentityHashMap(); m.put(null, "test"); - assertTrue("Failed with same hash as null", - m.remove(objArray[0]) == null); - assertTrue("Failed with null key", m.remove(null).equals("test")); + assertNull("Failed with same hash as null", + m.remove(objArray[0])); + assertEquals("Failed with null key", "test", m.remove(null)); } /** Index: modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/PropertiesTest.java (working copy) @@ -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") + ); } /** Index: modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/PropertyPermissionTest.java (working copy) @@ -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()); } /** Index: modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java (revision 396457) +++ modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java (working copy) @@ -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); } /** Index: modules/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java =================================================================== --- modules/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java (revision 396457) +++ modules/luni/src/test/java/org/apache/harmony/tests/java/util/ArraysTest.java (working copy) @@ -36,10 +36,10 @@ assertTrue("Assert 0: " + specials[i] + " invalid: " + result, result == i); } - assertTrue("Assert 1: Invalid search index for -1d", - Arrays.binarySearch(specials, -1d) == -4); - assertTrue("Assert 2: Invalid search index for 1d", - Arrays.binarySearch(specials, 1d) == -8); + assertEquals("Assert 1: Invalid search index for -1d", + -4, Arrays.binarySearch(specials, -1d)); + assertEquals("Assert 2: Invalid search index for 1d", + -8, Arrays.binarySearch(specials, 1d)); } /** @@ -56,10 +56,10 @@ assertTrue("Assert 0: " + specials[i] + " invalid: " + result, result == i); } - assertTrue("Assert 1: Invalid search index for -1f", - Arrays.binarySearch(specials, -1f) == -4); - assertTrue("Assert 2: Invalid search index for 1f", - Arrays.binarySearch(specials, 1f) == -8); + assertEquals("Assert 1: Invalid search index for -1f", + -4, Arrays.binarySearch(specials, -1f)); + assertEquals("Assert 2: Invalid search index for 1f", + -8, Arrays.binarySearch(specials, 1f)); } /** Index: modules/security/src/test/java/common/java/security/DigestInputStreamTest.java =================================================================== --- modules/security/src/test/java/common/java/security/DigestInputStreamTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/DigestInputStreamTest.java (working copy) @@ -161,9 +161,9 @@ dis.read(); } // check that subsequent read() calls return -1 (eos) - assertTrue("retval1", dis.read() == -1); - assertTrue("retval2", dis.read() == -1); - assertTrue("retval3", dis.read() == -1); + assertEquals("retval1", -1, dis.read()); + assertEquals("retval2", -1, dis.read()); + assertEquals("retval3", -1, dis.read()); // check that 3 previous read() calls did not update digest assertTrue("update", Arrays.equals(dis.getMessageDigest().digest(), @@ -331,7 +331,7 @@ public final void testReadbyteArrayintint02() throws IOException { // check precondition - assertTrue(MY_MESSAGE_LEN % CHUNK_SIZE == 0); + assertEquals(0, MY_MESSAGE_LEN % CHUNK_SIZE); for (int ii=0; iiECFieldF2m */ public final void testGetFieldSize() { - assertTrue(new ECFieldF2m(2000).getFieldSize() == 2000); + assertEquals(2000, new ECFieldF2m(2000).getFieldSize()); } /** @@ -566,7 +566,7 @@ * Assertion: returns m value for ECFieldF2m */ public final void testGetM() { - assertTrue(new ECFieldF2m(2000).getM() == 2000); + assertEquals(2000, new ECFieldF2m(2000).getM()); } /** @@ -589,7 +589,7 @@ * Assertion: returns null for normal basis */ public final void testGetMidTermsOfReductionPolynomial02() { - assertTrue(new ECFieldF2m(2000).getMidTermsOfReductionPolynomial() == null); + assertNull(new ECFieldF2m(2000).getMidTermsOfReductionPolynomial()); } /** @@ -620,7 +620,7 @@ * Assertion: returns null for normal basis */ public final void testGetReductionPolynomial02() { - assertTrue(new ECFieldF2m(2000).getReductionPolynomial() == null); + assertNull(new ECFieldF2m(2000).getReductionPolynomial()); } /** Index: modules/security/src/test/java/common/java/security/spec/RSAOtherPrimeInfoTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/RSAOtherPrimeInfoTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/RSAOtherPrimeInfoTest.java (working copy) @@ -118,7 +118,7 @@ new RSAOtherPrimeInfo(BigInteger.valueOf(1L), BigInteger.valueOf(2L), BigInteger.valueOf(3L)); - assertTrue(ropi.getCrtCoefficient().longValue() == 3L); + assertEquals(3L, ropi.getCrtCoefficient().longValue()); } /** @@ -130,7 +130,7 @@ new RSAOtherPrimeInfo(BigInteger.valueOf(1L), BigInteger.valueOf(2L), BigInteger.valueOf(3L)); - assertTrue(ropi.getPrime().longValue() == 1L); + assertEquals(1L, ropi.getPrime().longValue()); } /** @@ -142,7 +142,7 @@ new RSAOtherPrimeInfo(BigInteger.valueOf(1L), BigInteger.valueOf(2L), BigInteger.valueOf(3L)); - assertTrue(ropi.getExponent().longValue() == 2L); + assertEquals(2L, ropi.getExponent().longValue()); } } Index: modules/security/src/test/java/common/java/security/spec/RSAKeyGenParameterSpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/RSAKeyGenParameterSpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/RSAKeyGenParameterSpecTest.java (working copy) @@ -58,7 +58,7 @@ public final void testGetKeysize() { RSAKeyGenParameterSpec rkgps = new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L)); - assertTrue(rkgps.getKeysize() == 512); + assertEquals(512, rkgps.getKeysize()); } /** @@ -68,7 +68,7 @@ public final void testGetPublicExponent() { RSAKeyGenParameterSpec rkgps = new RSAKeyGenParameterSpec(512, BigInteger.valueOf(0L)); - assertTrue(rkgps.getPublicExponent().intValue() == 0); + assertEquals(0, rkgps.getPublicExponent().intValue()); } /** @@ -76,7 +76,7 @@ * Assertion: the public exponent value F0 = 3 */ public final void testF0Value() { - assertTrue(RSAKeyGenParameterSpec.F0.intValue() == 3); + assertEquals(3, RSAKeyGenParameterSpec.F0.intValue()); } /** @@ -84,7 +84,7 @@ * Assertion: the public exponent value F0 = 65537 */ public final void testF4Value() { - assertTrue(RSAKeyGenParameterSpec.F4.intValue() == 65537); + assertEquals(65537, RSAKeyGenParameterSpec.F4.intValue()); } } Index: modules/security/src/test/java/common/java/security/spec/RSAPrivateKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/RSAPrivateKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/RSAPrivateKeySpecTest.java (working copy) @@ -59,7 +59,7 @@ RSAPrivateKeySpec rpks = new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L), BigInteger.valueOf(3L)); - assertTrue(rpks.getModulus().longValue() == 1234567890L); + assertEquals(1234567890L, rpks.getModulus().longValue()); } /** @@ -70,7 +70,7 @@ RSAPrivateKeySpec rpks = new RSAPrivateKeySpec(BigInteger.valueOf(1234567890L), BigInteger.valueOf(3L)); - assertTrue(rpks.getPrivateExponent().longValue() == 3L); + assertEquals(3L, rpks.getPrivateExponent().longValue()); } } Index: modules/security/src/test/java/common/java/security/spec/MGF1ParameterSpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/MGF1ParameterSpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/MGF1ParameterSpecTest.java (working copy) @@ -83,9 +83,9 @@ * digest used by the mask generation function */ public final void testFieldsGetDigestAlgorithm() { - assertTrue("SHA-1".equals(MGF1ParameterSpec.SHA1.getDigestAlgorithm())); - assertTrue("SHA-256".equals(MGF1ParameterSpec.SHA256.getDigestAlgorithm())); - assertTrue("SHA-384".equals(MGF1ParameterSpec.SHA384.getDigestAlgorithm())); - assertTrue("SHA-512".equals(MGF1ParameterSpec.SHA512.getDigestAlgorithm())); + assertEquals("SHA-1", MGF1ParameterSpec.SHA1.getDigestAlgorithm()); + assertEquals("SHA-256", MGF1ParameterSpec.SHA256.getDigestAlgorithm()); + assertEquals("SHA-384", MGF1ParameterSpec.SHA384.getDigestAlgorithm()); + assertEquals("SHA-512", MGF1ParameterSpec.SHA512.getDigestAlgorithm()); } } Index: modules/security/src/test/java/common/java/security/spec/X509EncodedKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/X509EncodedKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/X509EncodedKeySpecTest.java (working copy) @@ -80,7 +80,7 @@ X509EncodedKeySpec meks = new X509EncodedKeySpec(encodedKey); - assertTrue("X.509".equals(meks.getFormat())); + assertEquals("X.509", meks.getFormat()); } /** Index: modules/security/src/test/java/common/java/security/spec/ECFieldFpTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/ECFieldFpTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/ECFieldFpTest.java (working copy) @@ -142,7 +142,7 @@ * Assertion: returns field size in bits which is prime size */ public final void testGetFieldSize() { - assertTrue(new ECFieldFp(BigInteger.valueOf(23L)).getFieldSize() == 5); + assertEquals(5, new ECFieldFp(BigInteger.valueOf(23L)).getFieldSize()); } /** Index: modules/security/src/test/java/common/java/security/spec/PSSParameterSpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/PSSParameterSpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/PSSParameterSpecTest.java (working copy) @@ -165,7 +165,7 @@ public final void testGetDigestAlgorithm() { PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1); - assertTrue("SHA-1".equals(pssps.getDigestAlgorithm())); + assertEquals("SHA-1", pssps.getDigestAlgorithm()); } /** @@ -175,7 +175,7 @@ public final void testGetMGFAlgorithm() { PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1); - assertTrue("MGF1".equals(pssps.getMGFAlgorithm())); + assertEquals("MGF1", pssps.getMGFAlgorithm()); } /** @@ -197,7 +197,7 @@ public final void testGetMGFParameters02() { PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", null, 20, 1); - assertTrue(pssps.getMGFParameters() == null); + assertNull(pssps.getMGFParameters()); } @@ -207,7 +207,7 @@ */ public final void testGetSaltLength() { PSSParameterSpec pssps = new PSSParameterSpec(20); - assertTrue(pssps.getSaltLength() == 20); + assertEquals(20, pssps.getSaltLength()); } /** @@ -217,7 +217,7 @@ public final void testGetTrailerField() { PSSParameterSpec pssps = new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, 1); - assertTrue(pssps.getTrailerField() == 1); + assertEquals(1, pssps.getTrailerField()); } /** @@ -225,7 +225,7 @@ * Assertion: default message digest algorithm name is "SHA-1" */ public final void testDEFAULTmdName() { - assertTrue("SHA-1".equals(PSSParameterSpec.DEFAULT.getDigestAlgorithm())); + assertEquals("SHA-1", PSSParameterSpec.DEFAULT.getDigestAlgorithm()); } /** @@ -233,7 +233,7 @@ * Assertion: default mask generation function algorithm name is "MGF1" */ public final void testDEFAULTmgfName() { - assertTrue("MGF1".equals(PSSParameterSpec.DEFAULT.getMGFAlgorithm())); + assertEquals("MGF1", PSSParameterSpec.DEFAULT.getMGFAlgorithm()); } /** @@ -250,7 +250,7 @@ * Assertion: default salt length value is 20 */ public final void testDEFAULTsaltLen() { - assertTrue(PSSParameterSpec.DEFAULT.getSaltLength() == 20); + assertEquals(20, PSSParameterSpec.DEFAULT.getSaltLength()); } /** @@ -258,6 +258,6 @@ * Assertion: default trailer field value is 1 */ public final void testDEFAULTtrailerField() { - assertTrue(PSSParameterSpec.DEFAULT.getTrailerField() == 1); + assertEquals(1, PSSParameterSpec.DEFAULT.getTrailerField()); } } Index: modules/security/src/test/java/common/java/security/spec/DSAParameterSpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/DSAParameterSpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/DSAParameterSpecTest.java (working copy) @@ -61,7 +61,7 @@ new BigInteger("2"), new BigInteger("3")); - assertTrue(dps.getG().intValue() == 3); + assertEquals(3, dps.getG().intValue()); } /** @@ -73,7 +73,7 @@ new BigInteger("2"), new BigInteger("3")); - assertTrue(dps.getP().intValue() == 1); + assertEquals(1, dps.getP().intValue()); } /** @@ -85,6 +85,6 @@ new BigInteger("2"), new BigInteger("3")); - assertTrue(dps.getQ().intValue() == 2); + assertEquals(2, dps.getQ().intValue()); } } Index: modules/security/src/test/java/common/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/RSAMultiPrimePrivateCrtKeySpecTest.java (working copy) @@ -565,7 +565,7 @@ BigInteger.ONE, BigInteger.ONE, null); - assertTrue(ks.getOtherPrimeInfo() == null); + assertNull(ks.getOtherPrimeInfo()); } // Index: modules/security/src/test/java/common/java/security/spec/DSAPrivateKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/DSAPrivateKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/DSAPrivateKeySpecTest.java (working copy) @@ -63,7 +63,7 @@ new BigInteger("3"), new BigInteger("4")); - assertTrue(dpks.getG().intValue() == 4); + assertEquals(4, dpks.getG().intValue()); } /** @@ -76,7 +76,7 @@ new BigInteger("3"), new BigInteger("4")); - assertTrue(dpks.getP().intValue() == 2); + assertEquals(2, dpks.getP().intValue()); } /** @@ -89,7 +89,7 @@ new BigInteger("3"), new BigInteger("4")); - assertTrue(dpks.getQ().intValue() == 3); + assertEquals(3, dpks.getQ().intValue()); } /** @@ -102,7 +102,7 @@ new BigInteger("3"), new BigInteger("4")); - assertTrue(dpks.getX().intValue() == 1); + assertEquals(1, dpks.getX().intValue()); } } Index: modules/security/src/test/java/common/java/security/spec/DSAPublicKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/DSAPublicKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/DSAPublicKeySpecTest.java (working copy) @@ -63,7 +63,7 @@ new BigInteger("3"), // q new BigInteger("4"));// g - assertTrue(dpks.getG().intValue() == 4); + assertEquals(4, dpks.getG().intValue()); } /** @@ -76,7 +76,7 @@ new BigInteger("3"), // q new BigInteger("4"));// g - assertTrue(dpks.getP().intValue() == 2); + assertEquals(2, dpks.getP().intValue()); } /** @@ -89,7 +89,7 @@ new BigInteger("3"), // q new BigInteger("4"));// g - assertTrue(dpks.getQ().intValue() == 3); + assertEquals(3, dpks.getQ().intValue()); } /** @@ -102,6 +102,6 @@ new BigInteger("3"), // q new BigInteger("4"));// g - assertTrue(dpks.getY().intValue() == 1); + assertEquals(1, dpks.getY().intValue()); } } Index: modules/security/src/test/java/common/java/security/spec/PKCS8EncodedKeySpecTest.java =================================================================== --- modules/security/src/test/java/common/java/security/spec/PKCS8EncodedKeySpecTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/spec/PKCS8EncodedKeySpecTest.java (working copy) @@ -80,7 +80,7 @@ PKCS8EncodedKeySpec meks = new PKCS8EncodedKeySpec(encodedKey); - assertTrue("PKCS#8".equals(meks.getFormat())); + assertEquals("PKCS#8", meks.getFormat()); } /** Index: modules/security/src/test/java/common/java/security/CodeSourceTest.java =================================================================== --- modules/security/src/test/java/common/java/security/CodeSourceTest.java (revision 396457) +++ modules/security/src/test/java/common/java/security/CodeSourceTest.java (working copy) @@ -471,7 +471,7 @@ // must get exactly 3 CodeSigner-s: one for the chain, and one // for each of single certs - assertTrue(signers.length == 3); + assertEquals(3, signers.length); } finally { TestCertUtils.uninstall_test_x509_factory(); } Index: modules/security/src/test/java/common/tests/api/java/security/KeyStoreTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/KeyStoreTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/KeyStoreTest.java (working copy) @@ -297,8 +297,8 @@ && cert[1].getPublicKey() == certRes[1].getPublicKey()); java.security.cert.Certificate[] certResNull = keyTest .getCertificateChain("alias1"); - assertTrue("the certificate chain returned from " - + "getCertificateChain is NOT null", certResNull == null); + assertNull("the certificate chain returned from " + + "getCertificateChain is NOT null", certResNull); } /** @@ -596,7 +596,7 @@ // alias 3 keyTest.setCertificateEntry("alias3", cert[1]); - assertTrue("the size of the keyStore is not 3", keyTest.size() == 3); + assertEquals("the size of the keyStore is not 3", 3, keyTest.size()); } /** Index: modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java (working copy) @@ -35,8 +35,8 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.security.ProviderException(java.lang.String) ProviderException e = new ProviderException("test message"); - assertTrue("Failed toString test for constructed instance", e - .toString().equals( - "java.security.ProviderException: test message")); + assertEquals("Failed toString test for constructed instance", + "java.security.ProviderException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java (working copy) @@ -124,7 +124,7 @@ DSAParameterSpec spec = (DSAParameterSpec) params .getParameterSpec(dsaps.getClass()); - assertTrue("param spec is null", spec != null); + assertNotNull("param spec is null", spec); assertTrue("p is wrong ", spec.getP().equals(BigInteger.ONE)); assertTrue("q is wrong ", spec.getQ().equals(BigInteger.ONE)); assertTrue("g is wrong ", spec.getG().equals(BigInteger.ONE)); @@ -138,7 +138,7 @@ // java.security.AlgorithmParameters.getProvider() try { Provider p = AlgorithmParameters.getInstance("DSA").getProvider(); - assertTrue("provider is null", p != null); + assertNotNull("provider is null", p); } catch (NoSuchAlgorithmException e) { fail("getInstance did not find algorithm"); } @@ -154,7 +154,7 @@ params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE)); byte[] encoded = params.getEncoded(); - assertTrue("encoded spec is null", encoded != null); + assertNotNull("encoded spec is null", encoded); AlgorithmParameters params2 = AlgorithmParameters .getInstance("DSA"); params2.init(encoded); @@ -181,7 +181,7 @@ params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE)); byte[] encoded = params.getEncoded(); - assertTrue("encoded spec is null", encoded != null); + assertNotNull("encoded spec is null", encoded); AlgorithmParameters params2 = AlgorithmParameters .getInstance("DSA"); params2.init(encoded, "ASN.1"); @@ -201,7 +201,7 @@ params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE, BigInteger.ONE)); byte[] encoded = params.getEncoded(); - assertTrue("encoded spec is null", encoded != null); + assertNotNull("encoded spec is null", encoded); params.init(encoded, "DOUGLASMAWSON"); fail("unsupported format should have raised IOException"); } catch (NoSuchAlgorithmException e) { Index: modules/security/src/test/java/common/tests/api/java/security/InvalidKeyExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/InvalidKeyExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/InvalidKeyExceptionTest.java (working copy) @@ -26,8 +26,8 @@ // Test for method java.security.InvalidKeyException() InvalidKeyException e = new InvalidKeyException(); assertNotNull("Constructor returned a null", e); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.InvalidKeyException")); + assertEquals("Failed toString test for constructed instance", "java.security.InvalidKeyException", e + .toString()); } /** @@ -37,8 +37,8 @@ // Test for method java.security.InvalidKeyException(java.lang.String) InvalidKeyException e = new InvalidKeyException("test message"); assertNotNull("Constructor returned a null", e); - assertTrue("Failed toString test for constructed instance", e - .toString().equals( - "java.security.InvalidKeyException: test message")); + assertEquals("Failed toString test for constructed instance", + "java.security.InvalidKeyException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java (working copy) @@ -24,9 +24,9 @@ */ public void test_ConstructorLjava_lang_String() { // Test for method java.security.SecurityPermission(java.lang.String) - assertTrue("create securityPermission constructor(string) failed", - new SecurityPermission("SecurityPermission(string)").getName() - .equals("SecurityPermission(string)")); + assertEquals("create securityPermission constructor(string) failed", + "SecurityPermission(string)", new SecurityPermission("SecurityPermission(string)").getName() + ); } @@ -38,9 +38,8 @@ // Test for method java.security.SecurityPermission(java.lang.String, // java.lang.String) SecurityPermission sp = new SecurityPermission("security.file", "write"); - assertTrue( - "creat securityPermission constructor(string,string) failed", - sp.getName().equals("security.file")); + assertEquals("creat securityPermission constructor(string,string) failed", + "security.file", sp.getName()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/KeyStoreExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/KeyStoreExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/KeyStoreExceptionTest.java (working copy) @@ -25,8 +25,8 @@ public void test_Constructor() { // Test for method java.security.KeyStoreException() KeyStoreException e = new KeyStoreException(); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.KeyStoreException")); + assertEquals("Failed toString test for constructed instance", "java.security.KeyStoreException", e + .toString()); } /** @@ -35,8 +35,8 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.security.KeyStoreException(java.lang.String) KeyStoreException e = new KeyStoreException("test message"); - assertTrue("Failed toString test for constructed instance", e - .toString().equals( - "java.security.KeyStoreException: test message")); + assertEquals("Failed toString test for constructed instance", + "java.security.KeyStoreException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/GeneralSecurityExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/GeneralSecurityExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/GeneralSecurityExceptionTest.java (working copy) @@ -26,8 +26,8 @@ // Test for method java.security.GeneralSecurityException() GeneralSecurityException e = new GeneralSecurityException(); assertNotNull("Constructor returned null instance", e); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.GeneralSecurityException")); + assertEquals("Failed toString test for constructed instance", "java.security.GeneralSecurityException", e + .toString()); } /** @@ -39,8 +39,8 @@ GeneralSecurityException e = new GeneralSecurityException( "test message"); assertNotNull("Constructor returned null instance", e); - assertTrue("Failed toString test for constructed instance", e - .toString().equals( - "java.security.GeneralSecurityException: test message")); + assertEquals("Failed toString test for constructed instance", + "java.security.GeneralSecurityException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java (working copy) @@ -25,8 +25,8 @@ public void test_Constructor() { // Test for method java.security.UnrecoverableKeyException() UnrecoverableKeyException e = new UnrecoverableKeyException(); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.UnrecoverableKeyException")); + assertEquals("Failed toString test for constructed instance", "java.security.UnrecoverableKeyException", e + .toString()); } /** Index: modules/security/src/test/java/common/tests/api/java/security/PermissionCollectionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/PermissionCollectionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/PermissionCollectionTest.java (working copy) @@ -170,12 +170,12 @@ StringTokenizer resultTokenizer = new StringTokenizer(result, ","); // Check the test result from the new VM process - assertTrue("Permission should be granted", resultTokenizer - .nextToken().equals("true")); - assertTrue("signed Permission should be granted", resultTokenizer - .nextToken().equals("true")); - assertTrue("Permission should not be granted", resultTokenizer - .nextToken().equals("false")); + assertEquals("Permission should be granted", "true", resultTokenizer + .nextToken()); + assertEquals("signed Permission should be granted", "true", resultTokenizer + .nextToken()); + assertEquals("Permission should not be granted", "false", resultTokenizer + .nextToken()); } catch (IOException e) { fail("IOException during test : " + e); } catch (InterruptedException e) { Index: modules/security/src/test/java/common/tests/api/java/security/InvalidParameterExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/InvalidParameterExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/InvalidParameterExceptionTest.java (working copy) @@ -25,8 +25,8 @@ public void test_Constructor() { // Test for method java.security.InvalidParameterException() InvalidParameterException e = new InvalidParameterException(); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.InvalidParameterException")); + assertEquals("Failed toString test for constructed instance", "java.security.InvalidParameterException", e + .toString()); } /** @@ -37,11 +37,10 @@ // java.security.InvalidParameterException(java.lang.String) InvalidParameterException e = new InvalidParameterException( "test message"); - assertTrue( - "Failed toString test for constructed instance", - e + assertEquals("Failed toString test for constructed instance", + + "java.security.InvalidParameterException: test message", e .toString() - .equals( - "java.security.InvalidParameterException: test message")); + ); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/KeyExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/KeyExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/KeyExceptionTest.java (working copy) @@ -25,8 +25,8 @@ public void test_Constructor() { // Test for method java.security.KeyException() KeyException e = new KeyException(); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.KeyException")); + assertEquals("Failed toString test for constructed instance", "java.security.KeyException", e + .toString()); } /** @@ -35,7 +35,7 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.security.KeyException(java.lang.String) KeyException e = new KeyException("test message"); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.KeyException: test message")); + assertEquals("Failed toString test for constructed instance", "java.security.KeyException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java (working copy) @@ -37,10 +37,9 @@ // Test for method java.lang.String // java.security.Security.getProperty(java.lang.String) Security.setProperty("keyTestAlternate", "testing a property set"); - assertTrue( - "the property value returned for keyTestAlternate was incorrect", - Security.getProperty("keyTestAlternate").equals( - "testing a property set")); + assertEquals("the property value returned for keyTestAlternate was incorrect", + + "testing a property set", Security.getProperty("keyTestAlternate")); } /** @@ -53,9 +52,9 @@ // java.lang.String) Security.setProperty("keyTest", "permission to set property"); - assertTrue("the property value returned for keyTest was not correct", - Security.getProperty("keyTest").equals( - "permission to set property")); + assertEquals("the property value returned for keyTest was not correct", + + "permission to set property", Security.getProperty("keyTest")); } @@ -172,10 +171,10 @@ Provider provTest[] = Security.getProviders(); assertEquals("the number of providers is not 2 it was: " + provTest.length, 2, provTest.length); - assertTrue("the first provider should be DRLCertFactory", provTest[0] - .getName().equals("DRLCertFactory")); - assertTrue("the second provider should be BC", provTest[1].getName() - .equals("BC")); + assertEquals("the first provider should be DRLCertFactory", "DRLCertFactory", provTest[0] + .getName()); + assertEquals("the second provider should be BC", "BC", provTest[1].getName() + ); } /** @@ -368,8 +367,8 @@ filter.put("Signature.SHA1withDSA", ""); Provider provTest[] = Security.getProviders(filter); if (provTest == null) { - assertTrue("Filter : ,", - getProvidersCount(filter) == 0); + assertEquals("Filter : ,", + 0, getProvidersCount(filter)); } else { assertEquals("Filter : ,", getProvidersCount(filter), provTest.length); @@ -381,9 +380,8 @@ filter.put("KeyFactory.RSA", ""); provTest = Security.getProviders(filter); if (provTest == null) { - assertTrue( - "Filter : ,,", - getProvidersCount(filter) == 0); + assertEquals("Filter : ,,", + 0, getProvidersCount(filter)); } else { assertEquals( "Filter : ,,", @@ -395,9 +393,8 @@ filter.put("CertificateFactory.X.509", ""); provTest = Security.getProviders(filter); if (provTest == null) { - assertTrue( - "Filter : ", - getProvidersCount(filter) == 0); + assertEquals("Filter : ", + 0, getProvidersCount(filter)); } else { assertEquals( "Filter : ", @@ -408,8 +405,8 @@ filter.put("CertificateFactory.X509", ""); provTest = Security.getProviders(filter); if (provTest == null) { - assertTrue("Filter : ", - getProvidersCount(filter) == 0); + assertEquals("Filter : ", + 0, getProvidersCount(filter)); } else { assertEquals("Filter : ", getProvidersCount(filter), provTest.length); @@ -419,8 +416,8 @@ filter.put("Provider.id name", "DRLCertFactory"); provTest = Security.getProviders(filter); if (provTest == null) { - assertTrue("Filter : ", - getProvidersCount(filter) == 0); + assertEquals("Filter : ", + 0, getProvidersCount(filter)); } else { assertEquals("Filter : ", getProvidersCount(filter), provTest.length); @@ -507,9 +504,9 @@ assertTrue("Failed to add provider", addResult != -1); Security.removeProvider(test.getName()); - assertTrue( + assertNull( "the provider TestProvider is found after it was removed", - Security.getProvider(test.getName()) == null); + Security.getProvider(test.getName())); // Make sure entrust provider not already loaded. Should do nothing // if not already loaded. Index: modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java (working copy) @@ -25,8 +25,8 @@ public void test_Constructor() { // Test for method java.security.SignatureException() SignatureException e = new SignatureException(); - assertTrue("Failed toString test for constructed instance", e - .toString().equals("java.security.SignatureException")); + assertEquals("Failed toString test for constructed instance", "java.security.SignatureException", e + .toString()); } /** @@ -35,8 +35,8 @@ public void test_ConstructorLjava_lang_String() { // Test for method java.security.SignatureException(java.lang.String) SignatureException e = new SignatureException("test message"); - assertTrue("Failed toString test for constructed instance", e - .toString().equals( - "java.security.SignatureException: test message")); + assertEquals("Failed toString test for constructed instance", + "java.security.SignatureException: test message", e + .toString()); } } \ No newline at end of file Index: modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java (working copy) @@ -59,9 +59,9 @@ // Test for method java.security.Permission // java.security.AccessControlException.getPermission() // make sure getPermission returns null when it's not set - assertTrue( + assertNull( "getPermission should have returned null if no permission was set", - acException.getPermission() == null); + acException.getPermission()); assertTrue( "getPermission should have returned the permission we assigned to it", acException1.getPermission() == filePermission); Index: modules/security/src/test/java/common/tests/api/java/security/CodeSourceTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/CodeSourceTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/CodeSourceTest.java (working copy) @@ -62,8 +62,8 @@ public void test_getCertificates() throws Exception { CodeSource cs = new CodeSource(new java.net.URL("file:///test"), (Certificate[]) null); - assertTrue("Should have gotten null certificate list.", cs - .getCertificates() == null); + assertNull("Should have gotten null certificate list.", cs + .getCertificates()); } /** @@ -73,8 +73,8 @@ // Test for method java.net.URL java.security.CodeSource.getLocation() CodeSource cs = new CodeSource(new java.net.URL("file:///test"), (Certificate[]) null); - assertTrue("Did not get expected location!", cs.getLocation() - .toString().equals("file:/test")); + assertEquals("Did not get expected location!", "file:/test", cs.getLocation() + .toString()); } /** Index: modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java =================================================================== --- modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java (revision 396457) +++ modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java (working copy) @@ -52,7 +52,7 @@ // java.security.AlgorithmParameterGenerator.getAlgorithm() String alg = AlgorithmParameterGenerator.getInstance("DSA") .getAlgorithm(); - assertTrue("getAlgorithm ok", alg.equals("DSA")); + assertEquals("getAlgorithm ok", "DSA", alg); } /** Index: modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CRLImplTest.java =================================================================== --- modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CRLImplTest.java (revision 396457) +++ modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CRLImplTest.java (working copy) @@ -280,7 +280,7 @@ * getVersion() method testing. */ public void testGetVersion() { - assertTrue("Incorrect version value", crl.getVersion() == 2); + assertEquals("Incorrect version value", 2, crl.getVersion()); } /** Index: modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImplTest.java =================================================================== --- modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImplTest.java (revision 396457) +++ modules/security/src/test/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImplTest.java (working copy) @@ -98,8 +98,8 @@ new ByteArrayInputStream( CertFactoryTestData.getCertEncoding()); try { - assertTrue("The size of collection is not correct", - certFactory.engineGenerateCertificates(bais).size() == 2); + assertEquals("The size of collection is not correct", + 2, certFactory.engineGenerateCertificates(bais).size()); } catch (CertificateException e) { e.printStackTrace(); fail("Unexpected CertificateException: " + e.getMessage()); @@ -109,8 +109,8 @@ bais = new ByteArrayInputStream( CertFactoryTestData.getBase64CertEncoding()); try { - assertTrue("The size of collection is not correct", - certFactory.engineGenerateCertificates(bais).size() == 2); + assertEquals("The size of collection is not correct", + 2, certFactory.engineGenerateCertificates(bais).size()); } catch (CertificateException e) { e.printStackTrace(); fail("Unexpected CertificateException: " + e.getMessage()); @@ -157,8 +157,8 @@ new ByteArrayInputStream( CertFactoryTestData.getCRLEncoding()); try { - assertTrue("The size of collection is not correct", - certFactory.engineGenerateCRLs(bais).size() == 2); + assertEquals("The size of collection is not correct", + 2, certFactory.engineGenerateCRLs(bais).size()); } catch (CRLException e) { e.printStackTrace(); fail("Unexpected CRLException: " + e.getMessage()); Index: modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerGeneralizedTimeEDTest.java =================================================================== --- modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerGeneralizedTimeEDTest.java (revision 396457) +++ modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerGeneralizedTimeEDTest.java (working copy) @@ -61,21 +61,21 @@ encoded = new DerOutputStream(gTime, myDate).encoded; rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("2 fraction", "20041202093934.18Z".equals(rep)); + assertEquals("2 fraction", "20041202093934.18Z", rep); // 1 digit fractional seconds (last 2 0s must be trimmed out) myDate = getGmtDate(1101980374100L); encoded = new DerOutputStream(gTime, myDate).encoded; rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("1 fraction", "20041202093934.1Z".equals(rep)); + assertEquals("1 fraction", "20041202093934.1Z", rep); // no fractional seconds (last 3 0s and "." must be trimmed out) myDate = getGmtDate(1101980374000L); encoded = new DerOutputStream(gTime, myDate).encoded; rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("no fraction", "20041202093934Z".equals(rep)); + assertEquals("no fraction", "20041202093934Z", rep); // midnight SimpleDateFormat sdf = @@ -85,7 +85,7 @@ encoded = new DerOutputStream(gTime, myDate).encoded; rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("midnight", "20040606000000Z".equals(rep)); + assertEquals("midnight", "20040606000000Z", rep); } /** Index: modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerUTCTimeEDTest.java =================================================================== --- modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerUTCTimeEDTest.java (revision 396457) +++ modules/security/src/test/java/common/org/apache/harmony/security/asn1/der/DerUTCTimeEDTest.java (working copy) @@ -56,7 +56,7 @@ byte[] encoded = new DerOutputStream(uTime, myDate).encoded; String rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("no fraction", "041202093934Z".equals(rep)); + assertEquals("no fraction", "041202093934Z", rep); // midnight SimpleDateFormat sdf = @@ -66,7 +66,7 @@ encoded = new DerOutputStream(uTime, myDate).encoded; rep = new String(encoded, 2, encoded[1] & 0xff); - assertTrue("midnight", "040606000000Z".equals(rep)); + assertEquals("midnight", "040606000000Z", rep); } /** @@ -102,7 +102,7 @@ ? new DerInputStream(new ByteArrayInputStream(encoded)) : new DerInputStream(encoded); // the difference only fractional-seconds - assertTrue((myDate.getTime()-((Date)uTime.decode(dis)).getTime()) == 187); + assertEquals(187, (myDate.getTime()-((Date)uTime.decode(dis)).getTime())); // midnight myDate = new SimpleDateFormat("MM.dd.yyyy HH:mm"). Index: modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java =================================================================== --- modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java (revision 396457) +++ modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java (working copy) @@ -79,12 +79,12 @@ Matcher m = p.matcher("foo1barzfoo2baryfoozbar5"); assertTrue(m.find()); - assertTrue(m.start() == 0); - assertTrue(m.end() == 8); - assertTrue(m.start(1) == 0); - assertTrue(m.end(1) == 4); - assertTrue(m.start(2) == 4); - assertTrue(m.end(2) == 8); + assertEquals(0, m.start()); + assertEquals(8, m.end()); + assertEquals(0, m.start(1)); + assertEquals(4, m.end(1)); + assertEquals(4, m.start(2)); + assertEquals(8, m.end(2)); try { m.start(3); @@ -123,12 +123,12 @@ } assertTrue(m.find()); - assertTrue(m.start() == 8); - assertTrue(m.end() == 16); - assertTrue(m.start(1) == 8); - assertTrue(m.end(1) == 12); - assertTrue(m.start(2) == 12); - assertTrue(m.end(2) == 16); + assertEquals(8, m.start()); + assertEquals(16, m.end()); + assertEquals(8, m.start(1)); + assertEquals(12, m.end(1)); + assertEquals(12, m.start(2)); + assertEquals(16, m.end(2)); try { m.start(3); Index: modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java =================================================================== --- modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java (revision 396457) +++ modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java (working copy) @@ -32,25 +32,25 @@ p = Pattern.compile("([a-z]+)[0-9]+"); m = p.matcher("cAT123#dog345"); assertTrue(m.find()); - assertTrue(m.group(1).equals("dog")); + assertEquals("dog", m.group(1)); assertFalse(m.find()); p = Pattern.compile("([a-z]+)[0-9]+", Pattern.CASE_INSENSITIVE); m = p.matcher("cAt123#doG345"); assertTrue(m.find()); - assertTrue(m.group(1).equals("cAt")); + assertEquals("cAt", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("doG")); + assertEquals("doG", m.group(1)); assertFalse(m.find()); p = Pattern.compile("(?i)([a-z]+)[0-9]+"); m = p.matcher("cAt123#doG345"); assertTrue(m.find()); - assertTrue(m.group(1).equals("cAt")); + assertEquals("cAt", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("doG")); + assertEquals("doG", m.group(1)); assertFalse(m.find()); } @@ -81,35 +81,35 @@ p = Pattern.compile("^foo([0-9]*)", Pattern.MULTILINE); m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4"); assertTrue(m.find()); - assertTrue(m.group(1).equals("1")); + assertEquals("1", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("2")); + assertEquals("2", m.group(1)); assertFalse(m.find()); p = Pattern.compile("foo([0-9]*)$", Pattern.MULTILINE); m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4"); assertTrue(m.find()); - assertTrue(m.group(1).equals("3")); + assertEquals("3", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("4")); + assertEquals("4", m.group(1)); assertFalse(m.find()); p = Pattern.compile("(?m)^foo([0-9]*)"); m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4"); assertTrue(m.find()); - assertTrue(m.group(1).equals("1")); + assertEquals("1", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("2")); + assertEquals("2", m.group(1)); assertFalse(m.find()); p = Pattern.compile("(?m)foo([0-9]*)$"); m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4"); assertTrue(m.find()); - assertTrue(m.group(1).equals("3")); + assertEquals("3", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("4")); + assertEquals("4", m.group(1)); assertFalse(m.find()); } } Index: modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTest.java =================================================================== --- modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTest.java (revision 396457) +++ modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTest.java (working copy) @@ -48,9 +48,9 @@ p = Pattern.compile(pattern); m = p.matcher(target); s = m.replaceFirst(repl); - assertTrue(s.equals("foo[31];bar[42];[99]xyz")); + assertEquals("foo[31];bar[42];[99]xyz", s); s = m.replaceAll(repl); - assertTrue(s.equals("foo[31];bar[42];xyz[99]")); + assertEquals("foo[31];bar[42];xyz[99]", s); target = "[31]foo(42)bar{63}zoo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;"; pattern = "\\[([0-9]+)\\]([a-z]+)\\(([0-9]+)\\)([a-z]+)\\{([0-9]+)\\}([a-z]+)"; @@ -59,12 +59,12 @@ m = p.matcher(target); s = m.replaceFirst(repl); // System.out.println(s); - assertTrue(s - .equals("[63]zoo(42)bar{31}foo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;")); + assertEquals("[63]zoo(42)bar{31}foo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;", s + ); s = m.replaceAll(repl); // System.out.println(s); - assertTrue(s - .equals("[63]zoo(42)bar{31}foo;[56]ghi(34)def{12}abc;{99}xyz[88]xyz(77)xyz;")); + assertEquals("[63]zoo(42)bar{31}foo;[56]ghi(34)def{12}abc;{99}xyz[88]xyz(77)xyz;", s + ); } public void testEscapeReplace() { @@ -74,12 +74,12 @@ pattern = "'"; repl = "\\'"; s = target.replaceAll(pattern, repl); - assertTrue(s.equals("foo'bar''foo")); + assertEquals("foo'bar''foo", s); repl = "\\\\'"; s = target.replaceAll(pattern, repl); - assertTrue(s.equals("foo\\'bar\\'\\'foo")); + assertEquals("foo\\'bar\\'\\'foo", s); repl = "\\$3"; s = target.replaceAll(pattern, repl); - assertTrue(s.equals("foo$3bar$3$3foo")); + assertEquals("foo$3bar$3$3foo", s); } } Index: modules/regex/src/test/java/tests/api/java/util/regex/SplitTest.java =================================================================== --- modules/regex/src/test/java/tests/api/java/util/regex/SplitTest.java (revision 396457) +++ modules/regex/src/test/java/tests/api/java/util/regex/SplitTest.java (working copy) @@ -41,88 +41,88 @@ String tokens[]; tokens = p.split(input, 1); - assertTrue(tokens.length == 1); + assertEquals(1, tokens.length); assertTrue(tokens[0].equals(input)); tokens = p.split(input, 2); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poodle")); - assertTrue(tokens[1].equals("zoo")); + assertEquals(2, tokens.length); + assertEquals("poodle", tokens[0]); + assertEquals("zoo", tokens[1]); tokens = p.split(input, 5); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poodle")); - assertTrue(tokens[1].equals("zoo")); + assertEquals(2, tokens.length); + assertEquals("poodle", tokens[0]); + assertEquals("zoo", tokens[1]); tokens = p.split(input, -2); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poodle")); - assertTrue(tokens[1].equals("zoo")); + assertEquals(2, tokens.length); + assertEquals("poodle", tokens[0]); + assertEquals("zoo", tokens[1]); tokens = p.split(input, 0); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poodle")); - assertTrue(tokens[1].equals("zoo")); + assertEquals(2, tokens.length); + assertEquals("poodle", tokens[0]); + assertEquals("zoo", tokens[1]); tokens = p.split(input); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poodle")); - assertTrue(tokens[1].equals("zoo")); + assertEquals(2, tokens.length); + assertEquals("poodle", tokens[0]); + assertEquals("zoo", tokens[1]); p = Pattern.compile("d"); tokens = p.split(input, 1); - assertTrue(tokens.length == 1); + assertEquals(1, tokens.length); assertTrue(tokens[0].equals(input)); tokens = p.split(input, 2); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poo")); - assertTrue(tokens[1].equals("le zoo")); + assertEquals(2, tokens.length); + assertEquals("poo", tokens[0]); + assertEquals("le zoo", tokens[1]); tokens = p.split(input, 5); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poo")); - assertTrue(tokens[1].equals("le zoo")); + assertEquals(2, tokens.length); + assertEquals("poo", tokens[0]); + assertEquals("le zoo", tokens[1]); tokens = p.split(input, -2); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poo")); - assertTrue(tokens[1].equals("le zoo")); + assertEquals(2, tokens.length); + assertEquals("poo", tokens[0]); + assertEquals("le zoo", tokens[1]); tokens = p.split(input, 0); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poo")); - assertTrue(tokens[1].equals("le zoo")); + assertEquals(2, tokens.length); + assertEquals("poo", tokens[0]); + assertEquals("le zoo", tokens[1]); tokens = p.split(input); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("poo")); - assertTrue(tokens[1].equals("le zoo")); + assertEquals(2, tokens.length); + assertEquals("poo", tokens[0]); + assertEquals("le zoo", tokens[1]); p = Pattern.compile("o"); tokens = p.split(input, 1); - assertTrue(tokens.length == 1); + assertEquals(1, tokens.length); assertTrue(tokens[0].equals(input)); tokens = p.split(input, 2); - assertTrue(tokens.length == 2); - assertTrue(tokens[0].equals("p")); - assertTrue(tokens[1].equals("odle zoo")); + assertEquals(2, tokens.length); + assertEquals("p", tokens[0]); + assertEquals("odle zoo", tokens[1]); tokens = p.split(input, 5); - assertTrue(tokens.length == 5); - assertTrue(tokens[0].equals("p")); + assertEquals(5, tokens.length); + assertEquals("p", tokens[0]); assertTrue(tokens[1].equals("")); - assertTrue(tokens[2].equals("dle z")); + assertEquals("dle z", tokens[2]); assertTrue(tokens[3].equals("")); assertTrue(tokens[4].equals("")); tokens = p.split(input, -2); - assertTrue(tokens.length == 5); - assertTrue(tokens[0].equals("p")); + assertEquals(5, tokens.length); + assertEquals("p", tokens[0]); assertTrue(tokens[1].equals("")); - assertTrue(tokens[2].equals("dle z")); + assertEquals("dle z", tokens[2]); assertTrue(tokens[3].equals("")); assertTrue(tokens[4].equals("")); tokens = p.split(input, 0); - assertTrue(tokens.length == 3); - assertTrue(tokens[0].equals("p")); + assertEquals(3, tokens.length); + assertEquals("p", tokens[0]); assertTrue(tokens[1].equals("")); - assertTrue(tokens[2].equals("dle z")); + assertEquals("dle z", tokens[2]); tokens = p.split(input); - assertTrue(tokens.length == 3); - assertTrue(tokens[0].equals("p")); + assertEquals(3, tokens.length); + assertEquals("p", tokens[0]); assertTrue(tokens[1].equals("")); - assertTrue(tokens[2].equals("dle z")); + assertEquals("dle z", tokens[2]); } public void testSplit2() { Index: modules/regex/src/test/java/tests/api/java/util/regex/PatternTest.java =================================================================== --- modules/regex/src/test/java/tests/api/java/util/regex/PatternTest.java (revision 396457) +++ modules/regex/src/test/java/tests/api/java/util/regex/PatternTest.java (working copy) @@ -56,46 +56,46 @@ m = p.matcher("foobar"); assertTrue(m.find()); - assertTrue(m.start() == 0); - assertTrue(m.end() == 3); + assertEquals(0, m.start()); + assertEquals(3, m.end()); assertFalse(m.find()); // Note: also testing reset here m.reset(); assertTrue(m.find()); - assertTrue(m.start() == 0); - assertTrue(m.end() == 3); + assertEquals(0, m.start()); + assertEquals(3, m.end()); assertFalse(m.find()); m.reset("barfoobar"); assertTrue(m.find()); - assertTrue(m.start() == 3); - assertTrue(m.end() == 6); + assertEquals(3, m.start()); + assertEquals(6, m.end()); assertFalse(m.find()); m.reset("barfoo"); assertTrue(m.find()); - assertTrue(m.start() == 3); - assertTrue(m.end() == 6); + assertEquals(3, m.start()); + assertEquals(6, m.end()); assertFalse(m.find()); m.reset("foobarfoobarfoo"); assertTrue(m.find()); - assertTrue(m.start() == 0); - assertTrue(m.end() == 3); + assertEquals(0, m.start()); + assertEquals(3, m.end()); assertTrue(m.find()); - assertTrue(m.start() == 6); - assertTrue(m.end() == 9); + assertEquals(6, m.start()); + assertEquals(9, m.end()); assertTrue(m.find()); - assertTrue(m.start() == 12); - assertTrue(m.end() == 15); + assertEquals(12, m.start()); + assertEquals(15, m.end()); assertFalse(m.find()); assertTrue(m.find(0)); - assertTrue(m.start() == 0); - assertTrue(m.end() == 3); + assertEquals(0, m.start()); + assertEquals(3, m.end()); assertTrue(m.find(4)); - assertTrue(m.start() == 6); - assertTrue(m.end() == 9); + assertEquals(6, m.start()); + assertEquals(9, m.end()); } catch (PatternSyntaxException e) { System.out.println(e.getMessage()); fail(); @@ -110,48 +110,48 @@ m = p.matcher("p1#q3p2q42p5p71p63#q888"); assertTrue(m.find()); - assertTrue(m.start() == 0); - assertTrue(m.end() == 5); - assertTrue(m.groupCount() == 2); - assertTrue(m.start(0) == 0); - assertTrue(m.end(0) == 5); - assertTrue(m.start(1) == 0); - assertTrue(m.end(1) == 2); - assertTrue(m.start(2) == 3); - assertTrue(m.end(2) == 5); - assertTrue(m.group().equals("p1#q3")); - assertTrue(m.group(0).equals("p1#q3")); - assertTrue(m.group(1).equals("p1")); - assertTrue(m.group(2).equals("q3")); + assertEquals(0, m.start()); + assertEquals(5, m.end()); + assertEquals(2, m.groupCount()); + assertEquals(0, m.start(0)); + assertEquals(5, m.end(0)); + assertEquals(0, m.start(1)); + assertEquals(2, m.end(1)); + assertEquals(3, m.start(2)); + assertEquals(5, m.end(2)); + assertEquals("p1#q3", m.group()); + assertEquals("p1#q3", m.group(0)); + assertEquals("p1", m.group(1)); + assertEquals("q3", m.group(2)); assertTrue(m.find()); - assertTrue(m.start() == 5); - assertTrue(m.end() == 10); - assertTrue(m.groupCount() == 2); - assertTrue(m.end(0) == 10); - assertTrue(m.start(1) == 5); - assertTrue(m.end(1) == 7); - assertTrue(m.start(2) == 7); - assertTrue(m.end(2) == 10); - assertTrue(m.group().equals("p2q42")); - assertTrue(m.group(0).equals("p2q42")); - assertTrue(m.group(1).equals("p2")); - assertTrue(m.group(2).equals("q42")); + assertEquals(5, m.start()); + assertEquals(10, m.end()); + assertEquals(2, m.groupCount()); + assertEquals(10, m.end(0)); + assertEquals(5, m.start(1)); + assertEquals(7, m.end(1)); + assertEquals(7, m.start(2)); + assertEquals(10, m.end(2)); + assertEquals("p2q42", m.group()); + assertEquals("p2q42", m.group(0)); + assertEquals("p2", m.group(1)); + assertEquals("q42", m.group(2)); assertTrue(m.find()); - assertTrue(m.start() == 15); - assertTrue(m.end() == 23); - assertTrue(m.groupCount() == 2); - assertTrue(m.start(0) == 15); - assertTrue(m.end(0) == 23); - assertTrue(m.start(1) == 15); - assertTrue(m.end(1) == 18); - assertTrue(m.start(2) == 19); - assertTrue(m.end(2) == 23); - assertTrue(m.group().equals("p63#q888")); - assertTrue(m.group(0).equals("p63#q888")); - assertTrue(m.group(1).equals("p63")); - assertTrue(m.group(2).equals("q888")); + assertEquals(15, m.start()); + assertEquals(23, m.end()); + assertEquals(2, m.groupCount()); + assertEquals(15, m.start(0)); + assertEquals(23, m.end(0)); + assertEquals(15, m.start(1)); + assertEquals(18, m.end(1)); + assertEquals(19, m.start(2)); + assertEquals(23, m.end(2)); + assertEquals("p63#q888", m.group()); + assertEquals("p63#q888", m.group(0)); + assertEquals("p63", m.group(1)); + assertEquals("q888", m.group(2)); assertFalse(m.find()); } @@ -210,42 +210,42 @@ p = Pattern.compile("([a-z]+)\\\\([a-z]+);"); m = p.matcher("fred\\ginger;abbott\\costello;jekell\\hyde;"); assertTrue(m.find()); - assertTrue(m.group(1).equals("fred")); - assertTrue(m.group(2).equals("ginger")); + assertEquals("fred", m.group(1)); + assertEquals("ginger", m.group(2)); assertTrue(m.find()); - assertTrue(m.group(1).equals("abbott")); - assertTrue(m.group(2).equals("costello")); + assertEquals("abbott", m.group(1)); + assertEquals("costello", m.group(2)); assertTrue(m.find()); - assertTrue(m.group(1).equals("jekell")); - assertTrue(m.group(2).equals("hyde")); + assertEquals("jekell", m.group(1)); + assertEquals("hyde", m.group(2)); assertFalse(m.find()); // Test \n, \t, \r, \f, \e, \a sequences p = Pattern.compile("([a-z]+)[\\n\\t\\r\\f\\e\\a]+([a-z]+)"); m = p.matcher("aa\nbb;cc\u0009\rdd;ee\u000C\u001Bff;gg\n\u0007hh"); assertTrue(m.find()); - assertTrue(m.group(1).equals("aa")); - assertTrue(m.group(2).equals("bb")); + assertEquals("aa", m.group(1)); + assertEquals("bb", m.group(2)); assertTrue(m.find()); - assertTrue(m.group(1).equals("cc")); - assertTrue(m.group(2).equals("dd")); + assertEquals("cc", m.group(1)); + assertEquals("dd", m.group(2)); assertTrue(m.find()); - assertTrue(m.group(1).equals("ee")); - assertTrue(m.group(2).equals("ff")); + assertEquals("ee", m.group(1)); + assertEquals("ff", m.group(2)); assertTrue(m.find()); - assertTrue(m.group(1).equals("gg")); - assertTrue(m.group(2).equals("hh")); + assertEquals("gg", m.group(1)); + assertEquals("hh", m.group(2)); assertFalse(m.find()); // Test \\u and \\x sequences p = Pattern.compile("([0-9]+)[\\u0020:\\x21];"); m = p.matcher("11:;22 ;33-;44!;"); assertTrue(m.find()); - assertTrue(m.group(1).equals("11")); + assertEquals("11", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("22")); + assertEquals("22", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("44")); + assertEquals("44", m.group(1)); assertFalse(m.find()); // Test invalid unicode sequences @@ -302,11 +302,11 @@ p = Pattern.compile("([0-9]+)[\\07\\040\\0160];"); m = p.matcher("11\u0007;22:;33 ;44p;"); assertTrue(m.find()); - assertTrue(m.group(1).equals("11")); + assertEquals("11", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("33")); + assertEquals("33", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("44")); + assertEquals("44", m.group(1)); assertFalse(m.find()); // Test invalid octal sequences @@ -341,13 +341,13 @@ p = Pattern.compile("([0-9]+)[\\cA\\cB\\cC\\cD];"); m = p.matcher("11\u0001;22:;33\u0002;44p;55\u0003;66\u0004;"); assertTrue(m.find()); - assertTrue(m.group(1).equals("11")); + assertEquals("11", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("33")); + assertEquals("33", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("55")); + assertEquals("55", m.group(1)); assertTrue(m.find()); - assertTrue(m.group(1).equals("66")); + assertEquals("66", m.group(1)); assertFalse(m.find()); // More thorough control escape test @@ -361,7 +361,7 @@ for (j = 0; j < 255; j++) { m = p.matcher(Character.toString((char) j)); if (m.matches()) { - assertTrue(match_char == -1); + assertEquals(-1, match_char); match_char = j; } } @@ -1012,7 +1012,7 @@ p = Pattern.compile("[a-z]+;(foo[0-9]-\\Q(...)\\E);[0-9]+"); m = p.matcher("abc;foo5-(...);123"); assertTrue(m.matches()); - assertTrue(m.group(1).equals("foo5-(...)")); + assertEquals("foo5-(...)", m.group(1)); m = p.matcher("abc;foo9-(xxx);789"); assertFalse(m.matches()); @@ -1069,14 +1069,14 @@ p = Pattern.compile("a$"); m = p.matcher("a\n"); assertTrue(m.find()); - assertTrue(m.group().equals("a")); + assertEquals("a", m.group()); assertFalse(m.find()); p = Pattern.compile("(a$)"); m = p.matcher("a\n"); assertTrue(m.find()); - assertTrue(m.group().equals("a")); - assertTrue(m.group(1).equals("a")); + assertEquals("a", m.group()); + assertEquals("a", m.group(1)); assertFalse(m.find()); p = Pattern.compile("^.*$", Pattern.MULTILINE); @@ -1084,24 +1084,24 @@ m = p.matcher("a\n"); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("a")); + assertEquals("a", m.group()); assertFalse(m.find()); m = p.matcher("a\nb\n"); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("a")); + assertEquals("a", m.group()); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("b")); + assertEquals("b", m.group()); assertFalse(m.find()); m = p.matcher("a\nb"); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("a")); + assertEquals("a", m.group()); assertTrue(m.find()); - assertTrue(m.group().equals("b")); + assertEquals("b", m.group()); assertFalse(m.find()); m = p.matcher("\naa\r\nbb\rcc\n\n"); @@ -1110,13 +1110,13 @@ assertTrue(m.group().equals("")); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("aa")); + assertEquals("aa", m.group()); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("bb")); + assertEquals("bb", m.group()); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); - assertTrue(m.group().equals("cc")); + assertEquals("cc", m.group()); assertTrue(m.find()); // System.out.println("["+m.group()+"]"); assertTrue(m.group().equals("")); @@ -1124,7 +1124,7 @@ m = p.matcher("a"); assertTrue(m.find()); - assertTrue(m.group().equals("a")); + assertEquals("a", m.group()); assertFalse(m.find()); m = p.matcher(""); @@ -1152,7 +1152,7 @@ boolean found = matcher.find(); assertTrue(found); - assertTrue(matcher.start() == 4); + assertEquals(4, matcher.start()); if (found) { // modify text text.delete(0, text.length()); Index: support/src/test/java/tests/support/Support_UnmodifiableMapTest.java =================================================================== --- support/src/test/java/tests/support/Support_UnmodifiableMapTest.java (revision 396457) +++ support/src/test/java/tests/support/Support_UnmodifiableMapTest.java (working copy) @@ -63,17 +63,16 @@ map.get(me.getKey()).equals(me.getValue())); myCounter++; } - assertTrue( - "UnmodifiableMapTest - Incorrect number of map entries returned", - myCounter == 100); + assertEquals("UnmodifiableMapTest - Incorrect number of map entries returned", + 100, myCounter); // get assertTrue("UnmodifiableMapTest - getting \"0\" didn't return 0", ((Integer) map.get("0")).intValue() == 0); assertTrue("UnmodifiableMapTest - getting \"50\" didn't return 0", ((Integer) map.get("0")).intValue() == 0); - assertTrue("UnmodifiableMapTest - getting \"100\" didn't return null", - map.get("100") == null); + assertNull("UnmodifiableMapTest - getting \"100\" didn't return null", + map.get("100")); // isEmpty assertTrue( Index: support/src/test/java/tests/support/Support_MapTest2.java =================================================================== --- support/src/test/java/tests/support/Support_MapTest2.java (revision 396457) +++ support/src/test/java/tests/support/Support_MapTest2.java (working copy) @@ -32,9 +32,9 @@ public void runTest() { try { map.put("one", "1"); - assertTrue("size should be one", map.size() == 1); + assertEquals("size should be one", 1, map.size()); map.clear(); - assertTrue("size should be zero", map.size() == 0); + assertEquals("size should be zero", 0, map.size()); assertTrue("Should not have entries", !map.entrySet().iterator() .hasNext()); assertTrue("Should not have keys", !map.keySet().iterator() @@ -46,9 +46,9 @@ try { map.put("one", "1"); - assertTrue("size should be one", map.size() == 1); + assertEquals("size should be one", 1, map.size()); map.remove("one"); - assertTrue("size should be zero", map.size() == 0); + assertEquals("size should be zero", 0, map.size()); assertTrue("Should not have entries", !map.entrySet().iterator() .hasNext()); assertTrue("Should not have keys", !map.keySet().iterator() Index: support/src/test/java/tests/support/Support_HttpTests.java =================================================================== --- support/src/test/java/tests/support/Support_HttpTests.java (revision 396457) +++ support/src/test/java/tests/support/Support_HttpTests.java (working copy) @@ -79,8 +79,8 @@ c = is.read(); is.close(); connector.close(); - TestCase.assertTrue("Error receiving chunked transfer coded data", - c == -1); + TestCase.assertEquals("Error receiving chunked transfer coded data", + -1, c); } catch (Exception e) { e.printStackTrace(); TestCase.fail("Exception during test a: " + e); @@ -375,9 +375,8 @@ connector.close(); c = is.read(); - TestCase.assertTrue( - "Incorrect data returned on redirection to a different port.", - c == 'A'); + TestCase.assertEquals("Incorrect data returned on redirection to a different port.", + 'A', c); while (c > 0) c = is.read(); c = is.read(); @@ -402,8 +401,8 @@ connector.close(); c = is.read(); - TestCase.assertTrue("Incorrect data returned on redirect to relative URI.", - c == 'A'); + TestCase.assertEquals("Incorrect data returned on redirect to relative URI.", + 'A', c); while (c > 0) c = is.read(); c = is.read(); Index: support/src/test/java/tests/support/Support_ListTest.java =================================================================== --- support/src/test/java/tests/support/Support_ListTest.java (revision 396457) +++ support/src/test/java/tests/support/Support_ListTest.java (working copy) @@ -92,7 +92,7 @@ list.get(49).equals(new Integer(49))); List mySubList = list.subList(50, 53); - assertTrue(mySubList.size() == 3); + assertEquals(3, mySubList.size()); assertTrue( "ListTest - a) sublist Failed--does not contain correct elements", mySubList.get(0).equals(new Integer(500))); @@ -106,9 +106,8 @@ t_listIterator(mySubList); mySubList.clear(); - assertTrue( - "ListTest - Clearing the sublist did not remove the appropriate elements from the original list", - list.size() == 100); + assertEquals("ListTest - Clearing the sublist did not remove the appropriate elements from the original list", + 100, list.size()); t_listIterator(list); ListIterator li = list.listIterator(); @@ -182,25 +181,25 @@ Integer add2 = new Integer(601); li.add(add1); assertTrue("list iterator add(), size()", list.size() == (orgSize + 1)); - assertTrue("list iterator add(), nextIndex()", li.nextIndex() == 1); - assertTrue("list iterator add(), previousIndex()", - li.previousIndex() == 0); + assertEquals("list iterator add(), nextIndex()", 1, li.nextIndex()); + assertEquals("list iterator add(), previousIndex()", + 0, li.previousIndex()); Object next = li.next(); assertTrue("list iterator add(), next(): " + next, next == list.get(1)); li.add(add2); Object previous = li.previous(); assertTrue("list iterator add(), previous(): " + previous, previous == add2); - assertTrue("list iterator add(), nextIndex()2", li.nextIndex() == 2); - assertTrue("list iterator add(), previousIndex()2", - li.previousIndex() == 1); + assertEquals("list iterator add(), nextIndex()2", 2, li.nextIndex()); + assertEquals("list iterator add(), previousIndex()2", + 1, li.previousIndex()); li.remove(); assertTrue("list iterator remove(), size()", list.size() == (orgSize + 1)); - assertTrue("list iterator remove(), nextIndex()", li.nextIndex() == 2); - assertTrue("list iterator remove(), previousIndex()", li - .previousIndex() == 1); + assertEquals("list iterator remove(), nextIndex()", 2, li.nextIndex()); + assertEquals("list iterator remove(), previousIndex()", 1, li + .previousIndex()); assertTrue("list iterator previous()2", li.previous() == list.get(1)); assertTrue("list iterator previous()3", li.previous() == list.get(0)); assertTrue("list iterator next()2", li.next() == list.get(0)); @@ -208,7 +207,7 @@ assertTrue("list iterator hasPrevious()3", !li.hasPrevious()); assertTrue("list iterator hasNext()3", li.hasNext()); assertTrue("list iterator size()", list.size() == orgSize); - assertTrue("list iterator nextIndex()3", li.nextIndex() == 0); - assertTrue("list iterator previousIndex()3", li.previousIndex() == -1); + assertEquals("list iterator nextIndex()3", 0, li.nextIndex()); + assertEquals("list iterator previousIndex()3", -1, li.previousIndex()); } }