harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r721077 [4/12] - in /harmony/enhanced/classlib/branches/java6: ./ depends/files/ depends/jars/ depends/manifests/asm-3.1/ depends/manifests/asm-3.1/META-INF/ depends/manifests/bcel-5.2/ make/ modules/accessibility/ modules/accessibility/src...
Date Thu, 27 Nov 2008 05:10:42 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java Wed Nov 26 21:10:32 2008
@@ -181,57 +181,52 @@
                                         && (preferIPv6AddressesValue != null)
                                         && (preferIPv6AddressesValue.equals("true"))) {
                                 // we expect an IPv6 ANY in this case
-                                assertTrue("inet Address returned when not set:"
-                                                + mss.getInterface().toString(), InetAddress
-                                                .getByName("::0").equals(mss.getInterface()));
+                                assertEquals("inet Address returned when not set",
+                                             InetAddress.getByName("::0"),
+                                             mss.getInterface());
                         } else {
                                 // we expect an IPv4 ANY in this case
-                                assertTrue("inet Address returned when not set:"
-                                                + mss.getInterface().toString(), InetAddress
-                                                .getByName("0.0.0.0").equals(mss.getInterface()));
+                                assertEquals("inet Address returned when not set",
+                                             InetAddress.getByName("0.0.0.0"),
+                                             mss.getInterface());
                         }
 
                         // validate that we get the expected response when we set via
                         // setInterface
                         Enumeration addresses = networkInterface1.getInetAddresses();
-                        if (addresses != null) {
+                        if (addresses.hasMoreElements()) {
                                 InetAddress firstAddress = (InetAddress) addresses
                                                 .nextElement();
                                 mss.setInterface(firstAddress);
-                                assertTrue(
-                                                "getNetworkInterface did not return interface set by setInterface.  Expected:"
-                                                                + firstAddress + " Got:"
-                                                                + mss.getInterface(), firstAddress
-                                                                .equals(mss.getInterface()));
+                                assertEquals("getNetworkInterface did not return interface set by setInterface",
+                                             firstAddress, mss.getInterface());
 
                                 groupPort = Support_PortManager.getNextPortForUDP();
                                 mss = new MulticastSocket(groupPort);
                                 mss.setNetworkInterface(networkInterface1);
-                                assertTrue(
-                                                "getInterface did not return interface set by setNeworkInterface Expected: "
-                                                                + firstAddress + "Got:"
-                                                                + mss.getInterface(), NetworkInterface
-                                                                .getByInetAddress(mss.getInterface())
-                                                                .equals(networkInterface1));
+                                assertEquals("getInterface did not return interface set by setNetworkInterface",
+                                             networkInterface1,
+                                             NetworkInterface.getByInetAddress(mss.getInterface()));
                         }
 
                 }
 	}
 
 	/**
-	 * @throws IOException 
+	 * @throws IOException
 	 * @tests java.net.MulticastSocket#getNetworkInterface()
 	 */
 	public void test_getNetworkInterface() throws IOException {
-		int groupPort = Support_PortManager.getNextPortForUDP();
-		if (atLeastOneInterface) {
+        int groupPort = Support_PortManager.getNextPortForUDP();
+        if (atLeastOneInterface) {
             // validate that we get the expected response when one was not
             // set
             mss = new MulticastSocket(groupPort);
             NetworkInterface theInterface = mss.getNetworkInterface();
-            assertNotNull(
+            assertTrue(
                     "network interface returned wrong network interface when not set:"
-                            + theInterface, theInterface.getInetAddresses());
+                            + theInterface, theInterface.getInetAddresses()
+                            .hasMoreElements());
             InetAddress firstAddress = (InetAddress) theInterface
                     .getInetAddresses().nextElement();
             // validate we the first address in the network interface is the
@@ -244,37 +239,34 @@
                     .equalsIgnoreCase("false"))
                     && (preferIPv6AddressesValue != null)
                     && (preferIPv6AddressesValue.equals("true"))) {
-                assertTrue(
-                        "network interface returned wrong network interface when not set:"
-                                + theInterface, InetAddress.getByName("::0")
-                                .equals(firstAddress));
+                assertEquals("network interface returned wrong network interface when not set:"
+                             + theInterface,
+                             firstAddress, InetAddress.getByName("::0"));
 
             } else {
-                assertTrue(
-                        "network interface returned wrong network interface when not set:"
-                                + theInterface, InetAddress
-                                .getByName("0.0.0.0").equals(firstAddress));
+                assertEquals("network interface returned wrong network interface when not set:"
+                             + theInterface,
+                             InetAddress.getByName("0.0.0.0"),
+                             firstAddress);
             }
 
             mss.setNetworkInterface(networkInterface1);
-            assertTrue(
-                    "getNetworkInterface did not return interface set by setNeworkInterface",
-                    networkInterface1.equals(mss.getNetworkInterface()));
+            assertEquals("getNetworkInterface did not return interface set by setNeworkInterface",
+                         networkInterface1, mss.getNetworkInterface());
 
             if (atLeastTwoInterfaces) {
                 mss.setNetworkInterface(networkInterface2);
-                assertTrue(
-                        "getNetworkInterface did not return network interface set by second setNetworkInterface call",
-                        networkInterface2.equals(mss.getNetworkInterface()));
+                assertEquals("getNetworkInterface did not return network interface set by second setNetworkInterface call",
+                             networkInterface2, mss.getNetworkInterface());
             }
 
             groupPort = Support_PortManager.getNextPortForUDP();
             mss = new MulticastSocket(groupPort);
             if (IPV6networkInterface1 != null) {
                 mss.setNetworkInterface(IPV6networkInterface1);
-                assertTrue(
-                        "getNetworkInterface did not return interface set by setNeworkInterface",
-                        IPV6networkInterface1.equals(mss.getNetworkInterface()));
+                assertEquals("getNetworkInterface did not return interface set by setNeworkInterface",
+                             IPV6networkInterface1,
+                             mss.getNetworkInterface());
             }
 
             // validate that we get the expected response when we set via
@@ -282,15 +274,15 @@
             groupPort = Support_PortManager.getNextPortForUDP();
             mss = new MulticastSocket(groupPort);
             Enumeration addresses = networkInterface1.getInetAddresses();
-            if (addresses != null) {
+            if (addresses.hasMoreElements()) {
                 firstAddress = (InetAddress) addresses.nextElement();
                 mss.setInterface(firstAddress);
-                assertTrue(
-                        "getNetworkInterface did not return interface set by setInterface",
-                        networkInterface1.equals(mss.getNetworkInterface()));
+                assertEquals("getNetworkInterface did not return interface set by setInterface",
+                             networkInterface1,
+                             mss.getNetworkInterface());
             }
         }
-	}
+    }
 
 	/**
 	 * @tests java.net.MulticastSocket#getTimeToLive()
@@ -299,11 +291,11 @@
 		try {
 			mss = new MulticastSocket();
 			mss.setTimeToLive(120);
-			assertTrue("Returned incorrect 1st TTL: " + mss.getTimeToLive(),
-					mss.getTimeToLive() == 120);
+			assertEquals("Returned incorrect 1st TTL",
+                                     120, mss.getTimeToLive());
 			mss.setTimeToLive(220);
-			assertTrue("Returned incorrect 2nd TTL: " + mss.getTimeToLive(),
-					mss.getTimeToLive() == 220);
+			assertEquals("Returned incorrect 2nd TTL",
+                                     220, mss.getTimeToLive());
 			ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_MULTICAST);
 		} catch (Exception e) {
 			handleException(e, SO_MULTICAST);
@@ -319,8 +311,8 @@
 		try {
 			mss = new MulticastSocket();
 			mss.setTTL((byte) 120);
-			assertTrue("Returned incorrect TTL: " + mss.getTTL(),
-					mss.getTTL() == 120);
+			assertEquals("Returned incorrect TTL",
+                                     120, mss.getTTL());
 			ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_MULTICAST);
 		} catch (Exception e) {
 			handleException(e, SO_MULTICAST);
@@ -348,8 +340,9 @@
                 mss.send(sdp, (byte) 10);
                 Thread.sleep(1000);
 
-                assertTrue("Group member did not recv data: ", new String(server.rdp
-				.getData(), 0, server.rdp.getLength()).equals(msg));
+                assertEquals("Group member did not recv data",
+                             msg,
+                             new String(server.rdp.getData(), 0, server.rdp.getLength()));
 	}
 
 	/**
@@ -374,7 +367,7 @@
 		int groupPort = ports[0];
 		int serverPort = ports[1];
 
-			Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
+                Enumeration theInterfaces = NetworkInterface.getNetworkInterfaces();
 
         // first validate that we handle a null group ok
         mss = new MulticastSocket(groupPort);
@@ -432,9 +425,9 @@
             mss.send(sdp);
             Thread.sleep(1000);
             // now vaildate that we received the data as expected
-            assertTrue("Group member did not recv data: ", new String(
-                    server.rdp.getData(), 0, server.rdp.getLength())
-                    .equals(msg));
+            assertEquals("Group member did not recv data",
+                         msg,
+                         new String(server.rdp.getData(), 0, server.rdp.getLength()));
             server.stopServer();
 
             // now validate that we handled the case were we join a
@@ -475,8 +468,7 @@
 
                     NetworkInterface thisInterface = (NetworkInterface) theInterfaces
                             .nextElement();
-                    if ((thisInterface.getInetAddresses() != null && thisInterface
-                            .getInetAddresses().hasMoreElements())
+                    if (thisInterface.getInetAddresses().hasMoreElements()
                             && (Support_NetworkInterface
                                     .useInterface(thisInterface) == true)) {
                         // get the first address on the interface
@@ -488,7 +480,7 @@
 
                         NetworkInterface sendingInterface = null;
                         boolean isLoopback = false;
-                        if (addresses != null) {
+                        if (addresses.hasMoreElements()) {
                             InetAddress firstAddress = (InetAddress) addresses
                                     .nextElement();
                             if (firstAddress.isLoopbackAddress()) {
@@ -514,8 +506,7 @@
 
                         InetAddress useAddress = null;
                         addresses = sendingInterface.getInetAddresses();
-                        if ((addresses != null)
-                                && (addresses.hasMoreElements())) {
+                        if (addresses.hasMoreElements()) {
                             useAddress = (InetAddress) addresses.nextElement();
                         }
 
@@ -541,10 +532,9 @@
                         mss.send(sdp);
                         Thread.sleep(1000);
                         if (thisInterface.equals(sendingInterface)) {
-                            assertTrue(
-                                    "Group member did not recv data when bound on specific interface: ",
-                                    new String(server.rdp.getData(), 0,
-                                            server.rdp.getLength()).equals(msg));
+                            assertEquals("Group member did not recv data when bound on specific interface",
+                                         msg,
+                                         new String(server.rdp.getData(), 0, server.rdp.getLength()));
                         } else {
                             assertFalse(
                                     "Group member received data on other interface when only asked for it on one interface: ",
@@ -735,14 +725,14 @@
 		mss.close();
 		byte[] data = server.rdp.getData();
 		int length = server.rdp.getLength();
-		assertTrue("Failed to send data. Received " + length, new String(data,
-				0, length).equals(msg));
+		assertEquals("Failed to send data. Received " + length,
+                             msg, new String(data, 0, length));
 	}
 
 	/**
 	 * @tests java.net.MulticastSocket#setInterface(java.net.InetAddress)
 	 */
-	public void test_setInterfaceLjava_net_InetAddress() {
+	public void test_setInterfaceLjava_net_InetAddress() throws UnknownHostException {
 		// Test for method void
 		// java.net.MulticastSocket.setInterface(java.net.InetAddress)
 		// Note that the machine is not multi-homed
@@ -777,16 +767,12 @@
 			ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_MULTICAST);
 		} catch (SocketException e) {
 			handleException(e, SO_MULTICAST);
-		} catch (UnknownHostException e) {
-			fail("Exception during setInterface test: " + e.toString());
 		}
 
 		// Regression test for Harmony-2410
 		try {
 			mss = new MulticastSocket();
 			mss.setInterface(InetAddress.getByName("224.0.0.5"));
-		} catch (UnknownHostException uhe) {
-			fail("Unable to get InetAddress by name from '224.0.0.5' addr: " + uhe.toString());
 		} catch (SocketException se) {
 			// expected
 		} catch (IOException ioe) {
@@ -821,9 +807,8 @@
             groupPort = Support_PortManager.getNextPortForUDP();
             mss = new MulticastSocket(groupPort);
             mss.setNetworkInterface(networkInterface1);
-            assertTrue(
-                    "Interface did not seem to be set by setNeworkInterface",
-                    networkInterface1.equals(mss.getNetworkInterface()));
+            assertEquals("Interface did not seem to be set by setNeworkInterface",
+                         networkInterface1, mss.getNetworkInterface());
 
             // set up the server and join the group
             group = InetAddress.getByName("224.0.0.3");
@@ -832,8 +817,7 @@
             while (theInterfaces.hasMoreElements()) {
                 NetworkInterface thisInterface = (NetworkInterface) theInterfaces
                         .nextElement();
-                if (thisInterface.getInetAddresses() != null
-                        && thisInterface.getInetAddresses().hasMoreElements()) {
+                if (thisInterface.getInetAddresses().hasMoreElements()) {
                     if ((!((InetAddress) thisInterface.getInetAddresses()
                             .nextElement()).isLoopbackAddress())
                             &&
@@ -865,9 +849,8 @@
                         Thread.sleep(1000);
                         String receivedMessage = new String(server.rdp
                                 .getData(), 0, server.rdp.getLength());
-                        assertTrue(
-                                "Group member did not recv data when send on a specific interface: ",
-                                receivedMessage.equals(msg));
+                        assertEquals("Group member did not recv data sent on a specific interface",
+                                     msg, receivedMessage);
                         // stop the server
                         server.stopServer();
                     }
@@ -883,11 +866,11 @@
 		try {
 			mss = new MulticastSocket();
 			mss.setTimeToLive(120);
-			assertTrue("Returned incorrect 1st TTL: " + mss.getTimeToLive(),
-					mss.getTimeToLive() == 120);
+			assertEquals("Returned incorrect 1st TTL",
+                                     120, mss.getTimeToLive());
 			mss.setTimeToLive(220);
-			assertTrue("Returned incorrect 2nd TTL: " + mss.getTimeToLive(),
-					mss.getTimeToLive() == 220);
+			assertEquals("Returned incorrect 2nd TTL",
+                                     220, mss.getTimeToLive());
 			ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_MULTICAST);
 		} catch (Exception e) {
 			handleException(e, SO_MULTICAST);
@@ -902,8 +885,7 @@
 		try {
 			mss = new MulticastSocket();
 			mss.setTTL((byte) 120);
-			assertTrue("Failed to set TTL: " + mss.getTTL(),
-					mss.getTTL() == 120);
+			assertEquals("Failed to set TTL", 120, mss.getTTL());
 			ensureExceptionThrownIfOptionIsUnsupportedOnOS(SO_MULTICAST);
 		} catch (Exception e) {
 			handleException(e, SO_MULTICAST);
@@ -1071,20 +1053,16 @@
 			if (theSocket2 != null)
 				theSocket2.close();
 
-			// test the default case which we expect to be the same on all
-			// platforms
-			try {
-				theAddress = new InetSocketAddress(
-					InetAddress.getLocalHost(), Support_PortManager
-							.getNextPortForUDP());
-				theSocket1 = new MulticastSocket(null);
-				theSocket2 = new MulticastSocket(null);
-				theSocket1.bind(theAddress);
-				theSocket2.bind(theAddress);
-			} catch (BindException e) {
-				fail(
-						"unexpected exception when trying to connect to do duplicate socket bind with re-useaddr left as default");
-			}
+			// test the default case which we expect to be
+			// the same on all platforms
+                        theAddress =
+                            new InetSocketAddress(
+                                    InetAddress.getLocalHost(),
+                                    Support_PortManager.getNextPortForUDP());
+                        theSocket1 = new MulticastSocket(null);
+                        theSocket2 = new MulticastSocket(null);
+                        theSocket1.bind(theAddress);
+                        theSocket2.bind(theAddress);
 			if (theSocket1 != null)
 				theSocket1.close();
 			if (theSocket2 != null)
@@ -1116,9 +1094,7 @@
                     && (atLeastOneInterface == false)) {
                 networkInterface1 = (NetworkInterface) theInterfaces
                         .nextElement();
-                if ((networkInterface1.getInetAddresses() != null)
-                        && networkInterface1.getInetAddresses()
-                                .hasMoreElements() &&
+                if (networkInterface1.getInetAddresses().hasMoreElements() &&
                         // we only want real interfaces
                         (Support_NetworkInterface
                                 .useInterface(networkInterface1) == true)) {
@@ -1132,9 +1108,8 @@
                         && (atLeastTwoInterfaces == false)) {
                     networkInterface2 = (NetworkInterface) theInterfaces
                             .nextElement();
-                    if ((networkInterface2.getInetAddresses() != null)
-                            && networkInterface2.getInetAddresses()
-                                    .hasMoreElements() &&
+                    if (networkInterface2.getInetAddresses().hasMoreElements()
+                            &&
                             // we only want real interfaces
                             (Support_NetworkInterface
                                     .useInterface(networkInterface2) == true)) {
@@ -1155,7 +1130,7 @@
 				NetworkInterface nextInterface = (NetworkInterface) theInterfaces
 						.nextElement();
 				addresses = nextInterface.getInetAddresses();
-				if (addresses != null) {
+				if (addresses.hasMoreElements()) {
 					while (addresses.hasMoreElements()) {
 						InetAddress nextAddress = (InetAddress) addresses
 								.nextElement();

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetworkInterfaceTest.java Wed Nov 26 21:10:32 2008
@@ -95,27 +95,21 @@
 		}
 
 		if (atLeastOneInterface) {
-			Enumeration theAddresses = networkInterface1.getInetAddresses();
-			if (theAddresses != null) {
-				while (theAddresses.hasMoreElements()) {
-					InetAddress theAddress = (InetAddress) theAddresses
-							.nextElement();
-					assertTrue("validate that address is not null",
-							null != theAddress);
-				}
-			}
-		}
+            Enumeration theAddresses = networkInterface1.getInetAddresses();
+            while (theAddresses.hasMoreElements()) {
+                InetAddress theAddress = (InetAddress) theAddresses
+                        .nextElement();
+                assertNotNull("validate that address is not null", theAddress);
+            }
+        }
 
 		if (atLeastTwoInterfaces) {
 			Enumeration theAddresses = networkInterface2.getInetAddresses();
-			if (theAddresses != null) {
-				while (theAddresses.hasMoreElements()) {
-					InetAddress theAddress = (InetAddress) theAddresses
-							.nextElement();
-					assertTrue("validate that address is not null",
-							null != theAddress);
-				}
-			}
+			while (theAddresses.hasMoreElements()) {
+                InetAddress theAddress = (InetAddress) theAddresses
+                        .nextElement();
+                assertNotNull("validate that address is not null", theAddress);
+            }
 		}
 
 		// create the list of ok and not ok addresses to return
@@ -124,7 +118,20 @@
 			Enumeration addresses = networkInterface1.getInetAddresses();
 			int index = 0;
 			ArrayList notOkAddresses = new ArrayList();
-			if (addresses != null) {
+			while (addresses.hasMoreElements()) {
+                InetAddress theAddress = (InetAddress) addresses.nextElement();
+                if (index != 0) {
+                    okAddresses.add(theAddress);
+                } else {
+                    notOkAddresses.add(theAddress);
+                }
+                index++;
+            }
+
+			// do the same for network interface 2 if it exists
+			if (atLeastTwoInterfaces) {
+				addresses = networkInterface2.getInetAddresses();
+				index = 0;
 				while (addresses.hasMoreElements()) {
 					InetAddress theAddress = (InetAddress) addresses
 							.nextElement();
@@ -137,24 +144,6 @@
 				}
 			}
 
-			// do the same for network interface 2 it it exists
-			if (atLeastTwoInterfaces) {
-				addresses = networkInterface2.getInetAddresses();
-				index = 0;
-				if (addresses != null) {
-					while (addresses.hasMoreElements()) {
-						InetAddress theAddress = (InetAddress) addresses
-								.nextElement();
-						if (index != 0) {
-							okAddresses.add(theAddress);
-						} else {
-							notOkAddresses.add(theAddress);
-						}
-						index++;
-					}
-				}
-			}
-
 			// set the security manager that will make the first address not
 			// visible
 			System.setSecurityManager(new mySecurityManager(notOkAddresses));
@@ -163,7 +152,15 @@
 			for (int i = 0; i < notOkAddresses.size(); i++) {
 				Enumeration reducedAddresses = networkInterface1
 						.getInetAddresses();
-				if (reducedAddresses != null) {
+				while (reducedAddresses.hasMoreElements()) {
+                    InetAddress nextAddress = (InetAddress) reducedAddresses
+                            .nextElement();
+                    assertTrue(
+                            "validate that address without permission is not returned",
+                            !nextAddress.equals(notOkAddresses.get(i)));
+                }
+				if (atLeastTwoInterfaces) {
+                    reducedAddresses = networkInterface2.getInetAddresses();
 					while (reducedAddresses.hasMoreElements()) {
 						InetAddress nextAddress = (InetAddress) reducedAddresses
 								.nextElement();
@@ -172,18 +169,6 @@
 								!nextAddress.equals(notOkAddresses.get(i)));
 					}
 				}
-				if (atLeastTwoInterfaces) {
-					reducedAddresses = networkInterface2.getInetAddresses();
-					if (reducedAddresses != null) {
-						while (reducedAddresses.hasMoreElements()) {
-							InetAddress nextAddress = (InetAddress) reducedAddresses
-									.nextElement();
-							assertTrue(
-									"validate that address without permission is not returned",
-									!nextAddress.equals(notOkAddresses.get(i)));
-						}
-					}
-				}
 			}
 
 			// validate that ok addresses are returned
@@ -191,7 +176,15 @@
 				boolean addressReturned = false;
 				Enumeration reducedAddresses = networkInterface1
 						.getInetAddresses();
-				if (reducedAddresses != null) {
+				while (reducedAddresses.hasMoreElements()) {
+                    InetAddress nextAddress = (InetAddress) reducedAddresses
+                            .nextElement();
+                    if (nextAddress.equals(okAddresses.get(i))) {
+                        addressReturned = true;
+                    }
+                }
+				if (atLeastTwoInterfaces) {
+					reducedAddresses = networkInterface2.getInetAddresses();
 					while (reducedAddresses.hasMoreElements()) {
 						InetAddress nextAddress = (InetAddress) reducedAddresses
 								.nextElement();
@@ -200,18 +193,6 @@
 						}
 					}
 				}
-				if (atLeastTwoInterfaces) {
-					reducedAddresses = networkInterface2.getInetAddresses();
-					if (reducedAddresses != null) {
-						while (reducedAddresses.hasMoreElements()) {
-							InetAddress nextAddress = (InetAddress) reducedAddresses
-									.nextElement();
-							if (nextAddress.equals(okAddresses.get(i))) {
-								addressReturned = true;
-							}
-						}
-					}
-				}
 				assertTrue("validate that address with permission is returned",
 						addressReturned);
 			}
@@ -219,22 +200,22 @@
 			// validate that we can get the interface by specifying the address.
 			// This is to be compatible
 			for (int i = 0; i < notOkAddresses.size(); i++) {
-                                assertNotNull(
-                                                "validate we cannot get the NetworkInterface with an address for which we have no privs",
-                                                NetworkInterface
-                                                                .getByInetAddress((InetAddress) notOkAddresses
-                                                                                .get(i)));
-			}
+                assertNotNull(
+                        "validate we cannot get the NetworkInterface with an address for which we have no privs",
+                        NetworkInterface
+                                .getByInetAddress((InetAddress) notOkAddresses
+                                        .get(i)));
+            }
 
 			// validate that we can get the network interface for the good
 			// addresses
-                        for (int i = 0; i < okAddresses.size(); i++) {
-                                assertNotNull(
-                                                "validate we cannot get the NetworkInterface with an address fro which we have no privs",
-                                                NetworkInterface
-                                                                .getByInetAddress((InetAddress) okAddresses
-                                                                                .get(i)));
-                        }
+			for (int i = 0; i < okAddresses.size(); i++) {
+                assertNotNull(
+                        "validate we cannot get the NetworkInterface with an address fro which we have no privs",
+                        NetworkInterface
+                                .getByInetAddress((InetAddress) okAddresses
+                                        .get(i)));
+            }
 
 			System.setSecurityManager(null);
 		}
@@ -278,10 +259,10 @@
 		if (atLeastOneInterface) {
 			String theName = networkInterface1.getName();
 			if (theName != null) {
-                                assertTrue("validate that Interface can be obtained with its name",
-                                                NetworkInterface.getByName(theName).equals(
-                                                                networkInterface1));
-			}
+                assertEquals(
+                        "validate that Interface can be obtained with its name",
+                        networkInterface1, NetworkInterface.getByName(theName));
+            }
 		}
 
 		// validate that we get the right interface with the second interface as
@@ -289,10 +270,10 @@
 		if (atLeastTwoInterfaces) {
 			String theName = networkInterface2.getName();
 			if (theName != null) {
-				assertTrue("validate that Interface can be obtained with its name",
-                                                NetworkInterface.getByName(theName).equals(
-                                                                networkInterface2));
-			}
+                assertEquals(
+                        "validate that Interface can be obtained with its name",
+                        networkInterface2, NetworkInterface.getByName(theName));
+            }
 		}
 	}
 
@@ -323,30 +304,26 @@
 		// interface for that address
 		if (atLeastOneInterface) {
 			Enumeration addresses = networkInterface1.getInetAddresses();
-			if (addresses != null) {
-				while (addresses.hasMoreElements()) {
-					InetAddress theAddress = (InetAddress) addresses
-							.nextElement();
-                                        assertTrue("validate that Interface can be obtained with any one of its addresses",
-                                                        NetworkInterface.getByInetAddress(theAddress)
-                                                                        .equals(networkInterface1));
-				}
-			}
+			while (addresses.hasMoreElements()) {
+                InetAddress theAddress = (InetAddress) addresses.nextElement();
+                assertEquals(
+                        "validate that Interface can be obtained with any one of its addresses",
+                        networkInterface1, NetworkInterface
+                                .getByInetAddress(theAddress));
+            }
 		}
 
 		// validate that we get the right interface with the second interface as
 		// well (ie we just don't always get the first interface
 		if (atLeastTwoInterfaces) {
 			Enumeration addresses = networkInterface2.getInetAddresses();
-			if (addresses != null) {
-				while (addresses.hasMoreElements()) {
-					InetAddress theAddress = (InetAddress) addresses
-							.nextElement();
-                                        assertTrue("validate that Interface can be obtained with any one of its addresses",
-                                                        NetworkInterface.getByInetAddress(theAddress)
-                                                                        .equals(networkInterface2));
-				}
-			}
+			while (addresses.hasMoreElements()) {
+                InetAddress theAddress = (InetAddress) addresses.nextElement();
+                assertEquals(
+                        "validate that Interface can be obtained with any one of its addresses",
+                        networkInterface2, NetworkInterface
+                                .getByInetAddress(theAddress));
+            }
 		}
 	}
 
@@ -367,11 +344,10 @@
 		// Test for method boolean
 		// java.net.SocketPermission.equals(java.lang.Object)
 		if (atLeastOneInterface) {
-			assertTrue("If objects are the same true is returned",
-					networkInterface1.equals(sameAsNetworkInterface1));
-			assertFalse("Validate Null handled ok", networkInterface1
-					.equals(null));
-		}
+            assertEquals("If objects are the same true is returned",
+                    sameAsNetworkInterface1, networkInterface1);
+            assertNotNull("Validate Null handled ok", networkInterface1);
+        }
 		if (atLeastTwoInterfaces) {
 			assertFalse("If objects are different false is returned",
 					networkInterface1.equals(networkInterface2));
@@ -533,7 +509,7 @@
 					&& (atLeastOneInterface == false)) {
 				NetworkInterface theInterface = (NetworkInterface) theInterfaces
 						.nextElement();
-				if (theInterface.getInetAddresses() != null) {
+				if (theInterface.getInetAddresses().hasMoreElements()) {
 					// Ensure that the current NetworkInterface has at least
 					// one InetAddress bound to it.  
 					Enumeration addrs = theInterface.getInetAddresses();
@@ -548,7 +524,7 @@
 					&& (atLeastTwoInterfaces == false)) {
 				NetworkInterface theInterface = (NetworkInterface) theInterfaces
 						.nextElement();
-				if (theInterface.getInetAddresses() != null) {
+				if (theInterface.getInetAddresses().hasMoreElements()) {
 					// Ensure that the current NetworkInterface has at least
 					// one InetAddress bound to it.  
 					Enumeration addrs = theInterface.getInetAddresses();
@@ -563,7 +539,7 @@
 			// at least one good NetworkInterface
 			if (atLeastOneInterface) {
 				Enumeration addresses = networkInterface1.getInetAddresses();
-				if (addresses != null) {
+				if (addresses.hasMoreElements()) {
 					try {
 						if (addresses.hasMoreElements()) {
 							sameAsNetworkInterface1 = NetworkInterface

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java Wed Nov 26 21:10:32 2008
@@ -518,6 +518,16 @@
     }
 
     /**
+     * @tests java.util.AbstractCollection#toString()
+     */
+    public void test_toString() {
+        ArrayList l = new ArrayList(1);
+        l.add(l);
+        String result = l.toString();
+        assertTrue("should contain self ref", result.indexOf("(this") > -1);
+    }
+
+    /**
      * @tests java.util.ArrayList#toArray()
      */
     public void test_toArray() {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/BitSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/BitSetTest.java?rev=721077&r1=721076&r2=721077&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/BitSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/BitSetTest.java Wed Nov 26 21:10:32 2008
@@ -47,8 +47,8 @@
         // Default size for a BitSet should be 64 elements;
 
         assertEquals("Created BitSet of incorrect size", 128, bs.size());
-        assertTrue("New BitSet had invalid string representation: "
-                + bs.toString(), bs.toString().equals("{}"));
+        assertEquals("New BitSet had invalid string representation: "
+                + bs.toString(), "{}", bs.toString());
 
         // All BitSets are created with elements of multiples of 64
 
@@ -77,7 +77,7 @@
         // Test for method java.lang.Object java.util.BitSet.clone()
         BitSet bs;
         bs = (BitSet) eightbs.clone();
-        assertTrue("Clone failed to return equal BitSet", eightbs.equals(bs));
+        assertEquals("clone failed to return equal BitSet", bs, eightbs);
 
     }
 
@@ -89,15 +89,15 @@
         BitSet bs;
 
         bs = (BitSet) eightbs.clone();
-        assertTrue("Same BitSet returned false", eightbs.equals(eightbs));
-        assertTrue("Identical BitSets returned false", eightbs.equals(bs));
+        assertEquals("Same BitSet returned false", eightbs, eightbs);
+        assertEquals("Identical BitSet returned false", bs, eightbs);
         bs.clear(6);
-        assertTrue("Different BitSets returned true", !eightbs.equals(bs));
+        assertFalse("Different BitSets returned true", eightbs.equals(bs));
         // Grow the BitSet
         bs = (BitSet) eightbs.clone();
         bs.set(128);
-        assertTrue("Different sized BitSet with higher bit set returned true",
-                !eightbs.equals(bs));
+        assertFalse("Different sized BitSet with higher bit set returned true",
+                eightbs.equals(bs));
         bs.clear(128);
         assertTrue(
                 "Different sized BitSet with higher bits not set returned false",
@@ -112,12 +112,10 @@
         BitSet bs = (BitSet) eightbs.clone();
         bs.clear(2);
         bs.clear(6);
-        assertTrue("BitSet returns wrong hash value: " + bs.hashCode(), bs
-                .hashCode() == 1129);
+        assertEquals("BitSet returns wrong hash value", 1129, bs.hashCode());
         bs.set(10);
         bs.clear(3);
-        assertTrue("BitSet returns wrong hash value: " + bs.hashCode(), bs
-                .hashCode() == 97);
+        assertEquals("BitSet returns wrong hash value", 97, bs.hashCode());
     }
 
     /**
@@ -147,7 +145,7 @@
         // Test for method void java.util.BitSet.clear(int)
 
         eightbs.clear(7);
-        assertTrue("Failed to clear bit", !eightbs.get(7));
+        assertFalse("Failed to clear bit", eightbs.get(7));
 
         // Check to see all other bits are still set
         for (int i = 0; i < 7; i++) {
@@ -155,7 +153,7 @@
         }
 
         eightbs.clear(165);
-        assertTrue("Failed to clear bit", !eightbs.get(165));
+        assertFalse("Failed to clear bit", eightbs.get(165));
         // Try out of range
         try {
             eightbs.clear(-1);
@@ -165,9 +163,31 @@
         }
 
         BitSet bs = new BitSet(0);
-        assertTrue("Test1: Wrong length, " + bs.size(), bs.length() == 0);
+        assertEquals("Test1: Wrong length,", 0, bs.length());
+        assertEquals("Test1: Wrong size,", 0, bs.size());
         bs.clear(0);
-        assertTrue("Test2: Wrong length" + bs.size(), bs.length() == 0);
+        assertEquals("Test2: Wrong length,", 0, bs.length());
+        assertEquals("Test2: Wrong size,", 0, bs.size());
+
+        bs.clear(60);
+        assertEquals("Test3: Wrong length,", 0, bs.length());
+        assertEquals("Test3: Wrong size,", 0, bs.size());
+
+        bs.clear(120);
+        assertEquals("Test4: Wrong size,", 0, bs.size());
+        assertEquals("Test4: Wrong length,", 0, bs.length());
+
+        bs.set(25);
+        assertEquals("Test5: Wrong size,", 64, bs.size());
+        assertEquals("Test5: Wrong length,", 26, bs.length());
+
+        bs.clear(80);
+        assertEquals("Test6: Wrong size,", 64, bs.size());
+        assertEquals("Test6: Wrong length,", 26, bs.length());
+
+        bs.clear(25);
+        assertEquals("Test7: Wrong size,", 64, bs.size());
+        assertEquals("Test7: Wrong length,", 0, bs.length());
 
         bs = new BitSet();
         try {
@@ -181,7 +201,14 @@
     /**
      * @tests java.util.BitSet#clear(int, int)
      */
-    public void test_clearII() {
+    public void test_clearII() throws IndexOutOfBoundsException {
+        // Regression for HARMONY-98
+        BitSet bitset = new BitSet();
+        for (int i = 0; i < 20; i++) {
+            bitset.set(i);
+        }
+        bitset.clear(10, 10);
+
         // Test for method void java.util.BitSet.clear(int, int)
         // pos1 and pos2 are in the same bitset element
         BitSet bs = new BitSet(16);
@@ -192,25 +219,25 @@
         bs.clear(7, 11);
         for (int i = 0; i < 7; i++) {
             if (i == 5) {
-                assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+                assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
             } else {
                 assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
             }
         }
         for (int i = 7; i < 11; i++) {
-            assertTrue("Failed to clear bit " + i, !bs.get(i));
+            assertFalse("Failed to clear bit " + i, bs.get(i));
         }
 
         for (int i = 11; i < initialSize; i++) {
             if (i == 15) {
-                assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+                assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
             } else {
                 assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
             }
         }
 
         for (int i = initialSize; i < bs.size(); i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
 
         // pos1 and pos2 is in the same bitset element, boundary testing
@@ -223,7 +250,7 @@
             assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
         }
         for (int i = 7; i < 64; i++) {
-            assertTrue("Failed to clear bit " + i, !bs.get(i));
+            assertFalse("Failed to clear bit " + i, bs.get(i));
         }
         for (int i = 64; i < bs.size(); i++) {
             assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
@@ -234,10 +261,10 @@
         bs.set(0, initialSize);
         bs.clear(0, 64);
         for (int i = 0; i < 64; i++) {
-            assertTrue("Failed to clear bit " + i, !bs.get(i));
+            assertFalse("Failed to clear bit " + i, bs.get(i));
         }
         for (int i = 64; i < bs.size(); i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
 
         bs = new BitSet(32);
@@ -245,7 +272,7 @@
         bs.set(0, initialSize);
         bs.clear(0, 65);
         for (int i = 0; i < 65; i++) {
-            assertTrue("Failed to clear bit " + i, !bs.get(i));
+            assertFalse("Failed to clear bit " + i, bs.get(i));
         }
         for (int i = 65; i < bs.size(); i++) {
             assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
@@ -260,23 +287,23 @@
         bs.clear(9, 74);
         for (int i = 0; i < 9; i++) {
             if (i == 7) {
-                assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+                assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
             } else {
                 assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
             }
         }
         for (int i = 9; i < 74; i++) {
-            assertTrue("Failed to clear bit " + i, !bs.get(i));
+            assertFalse("Failed to clear bit " + i, bs.get(i));
         }
         for (int i = 74; i < initialSize; i++) {
             if (i == 110) {
-                assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+                assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
             } else {
                 assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
             }
         }
         for (int i = initialSize; i < bs.size(); i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
 
         // pos1 and pos2 are in two non-sequential bitset elements
@@ -287,14 +314,14 @@
         bs.clear(9, 219);
         for (int i = 0; i < 9; i++) {
             if (i == 7) {
-                assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+                assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
             } else {
                 assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
             }
         }
 
         for (int i = 9; i < 219; i++) {
-            assertTrue("failed to clear bit " + i, !bs.get(i));
+            assertFalse("failed to clear bit " + i, bs.get(i));
         }
 
         for (int i = 219; i < 255; i++) {
@@ -311,19 +338,61 @@
             bs.clear(-1, 3);
             fail("Test1: Attempt to flip with  negative index failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // excepted
         }
 
         try {
             bs.clear(2, -1);
             fail("Test2: Attempt to flip with negative index failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // excepted
         }
 
+        bs.set(2, 4);
+        bs.clear(2, 2);
+        assertTrue("Bit got cleared incorrectly ", bs.get(2));
         try {
             bs.clear(4, 2);
             fail("Test4: Attempt to flip with illegal args failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // excepted
         }
+
+        bs = new BitSet(0);
+        assertEquals("Test1: Wrong length,", 0, bs.length());
+        assertEquals("Test1: Wrong size,", 0, bs.size());
+
+        bs.clear(0, 2);
+        assertEquals("Test2: Wrong length,", 0, bs.length());
+        assertEquals("Test2: Wrong size,", 0, bs.size());
+
+        bs.clear(60, 64);
+        assertEquals("Test3: Wrong length,", 0, bs.length());
+        assertEquals("Test3: Wrong size,", 0, bs.size());
+
+        bs.clear(64, 120);
+        assertEquals("Test4: Wrong length,", 0, bs.length());
+        assertEquals("Test4: Wrong size,", 0, bs.size());
+
+        bs.set(25);
+        assertEquals("Test5: Wrong length,", 26, bs.length());
+        assertEquals("Test5: Wrong size,", 64, bs.size());
+
+        bs.clear(60, 64);
+        assertEquals("Test6: Wrong length,", 26, bs.length());
+        assertEquals("Test6: Wrong size,", 64, bs.size());
+
+        bs.clear(64, 120);
+        assertEquals("Test7: Wrong size,", 64, bs.size());
+        assertEquals("Test7: Wrong length,", 26, bs.length());
+
+        bs.clear(80);
+        assertEquals("Test8: Wrong size,", 64, bs.size());
+        assertEquals("Test8: Wrong length,", 26, bs.length());
+
+        bs.clear(25);
+        assertEquals("Test9: Wrong size,", 64, bs.size());
+        assertEquals("Test9: Wrong length,", 0, bs.length());
     }
 
     /**
@@ -334,9 +403,9 @@
 
         BitSet bs = new BitSet();
         bs.set(8);
-        assertTrue("Get returned true for index out of range", !eightbs.get(99));
+        assertFalse("Get returned true for index out of range", eightbs.get(99));
         assertTrue("Get returned false for set value", eightbs.get(3));
-        assertTrue("Get returned true for a non set value", !bs.get(0));
+        assertFalse("Get returned true for a non set value", bs.get(0));
 
         try {
             bs.get(-1);
@@ -353,6 +422,18 @@
         assertTrue("Test highest bit", bs.get(63));
 
         bs = new BitSet();
+        assertEquals("Test1: Wrong length,", 0, bs.length());
+        assertEquals("Test1: Wrong size,", 0, bs.size());
+
+        bs.get(2);
+        assertEquals("Test2: Wrong length,", 0, bs.length());
+        assertEquals("Test2: Wrong size,", 0, bs.size());
+
+        bs.get(70);
+        assertEquals("Test3: Wrong length,", 0, bs.length());
+        assertEquals("Test3: Wrong size,", 0, bs.size());
+
+        bs = new BitSet();
         try {
             bs.get(Integer.MIN_VALUE);
             fail("Should throw IndexOutOfBoundsException");
@@ -365,6 +446,8 @@
      * @tests java.util.BitSet#get(int, int)
      */
     public void test_getII() {
+        BitSet bitset = new BitSet(30);
+        bitset.get(3, 3);
         // Test for method boolean java.util.BitSet.get(int, int)
         BitSet bs, resultbs, correctbs;
         bs = new BitSet(512);
@@ -378,15 +461,13 @@
         resultbs = bs.get(3, 6);
         correctbs = new BitSet(3);
         correctbs.set(0, 3);
-        assertTrue("Test1: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test1: Returned incorrect BitSet", correctbs, resultbs);
 
         // pos1 and pos2 are in the same bitset element, at index 1
         resultbs = bs.get(100, 125);
         correctbs = new BitSet(25);
         correctbs.set(21);
-        assertTrue("Test2: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test2: Returned incorrect BitSet", correctbs, resultbs);
 
         // pos1 in bitset element at index 0, and pos2 in bitset element at
         // index 1
@@ -395,8 +476,7 @@
         correctbs.set(0, 5);
         correctbs.set(45, 60);
         correctbs.set(121 - 15);
-        assertTrue("Test3: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test3: Returned incorrect BitSet", correctbs, resultbs);
 
         // pos1 in bitset element at index 1, and pos2 in bitset element at
         // index 2
@@ -405,8 +485,7 @@
         correctbs.set(0, 5);
         correctbs.set(51);
         correctbs.set(60, 70);
-        assertTrue("Test4: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test4: Returned incorrect BitSet", correctbs, resultbs);
 
         // pos1 in bitset element at index 0, and pos2 in bitset element at
         // index 2
@@ -417,8 +496,7 @@
         correctbs.set(55, 70);
         correctbs.set(116);
         correctbs.set(125, 135);
-        assertTrue("Test5: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test5: Returned incorrect BitSet", correctbs, resultbs);
 
         // pos1 in bitset element at index 0, and pos2 in bitset element at
         // index 3
@@ -429,10 +507,9 @@
         correctbs.set(55, 70);
         correctbs.set(116);
         correctbs.set(125, 135);
-        assertTrue("Test6: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test6: Returned incorrect BitSet", correctbs, resultbs);
 
-        assertTrue("equality principle", bs.equals(bs.get(0, bs.size())));
+        assertEquals("equality principle 1 ", bs.get(0, bs.size()), bs);
 
         // more tests
         BitSet bs2 = new BitSet(129);
@@ -444,8 +521,7 @@
         correctbs.set(0, 19);
         correctbs.set(61, 64);
         correctbs.set(120, 122);
-        assertTrue("Test6: Returned incorrect BitSet", resultbs
-                .equals(correctbs));
+        assertEquals("Test7: Returned incorrect BitSet", correctbs, resultbs);
 
         // equality principle with some boundary conditions
         bs2 = new BitSet(128);
@@ -463,205 +539,43 @@
         bs2.set(127);
         bs2.flip(0, 128);
         resultbs = bs2.get(0, bs.size());
-        assertTrue("equality principle", bs2.equals(resultbs));
-    }
-
-    /**
-     * @tests java.util.BitSet#set(int)
-     */
-    public void test_setI() {
-        // Test for method void java.util.BitSet.set(int)
-
-        BitSet bs = new BitSet();
-        bs.set(8);
-        assertTrue("Failed to set bit", bs.get(8));
-
-        try {
-            bs.set(-1);
-            fail("Attempt to set at negative index failed to generate exception");
-        } catch (IndexOutOfBoundsException e) {
-            // Correct behaviour
-        }
-
-        // Try setting a bit on a 64 boundary
-        bs.set(128);
-        assertEquals("Failed to grow BitSet", 192, bs.size());
-        assertTrue("Failed to set bit", bs.get(128));
-
-        bs = new BitSet(64);
-        for (int i = bs.size(); --i >= 0;) {
-            bs.set(i);
-            assertTrue("Incorrectly set", bs.get(i));
-            assertTrue("Incorrect length", bs.length() == (i + 1));
-            for (int j = bs.size(); --j > i;) {
-                assertTrue("Incorrectly set bit " + j, !bs.get(j));
-            }
-            for (int j = i; --j >= 0;) {
-                assertTrue("Incorrectly set bit " + j, !bs.get(j));
-            }
-            bs.clear(i);
-        }
+        assertEquals("equality principle 3 ", resultbs, bs2);
 
         bs = new BitSet(0);
-        assertTrue("Test1: Wrong length, " + bs.size(), bs.length() == 0);
-        bs.set(0);
-        assertTrue("Test2: Wrong length" + bs.size(), bs.length() == 1);
-    }
-
-    /**
-     * @tests java.util.BitSet#set(int, boolean)
-     */
-    public void test_setIZ() {
-        // Test for method void java.util.BitSet.set(int, boolean)
-        eightbs.set(5, false);
-        assertTrue("Should have set bit 5 to true", !eightbs.get(5));
-
-        eightbs.set(5, true);
-        assertTrue("Should have set bit 5 to false", eightbs.get(5));
-
-        try {
-            BitSet bs = new BitSet();
-            bs.set(-2147483648, false);
-            fail("Should throw IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException e) {
-            // expected
-        }
-    }
-
-    /**
-     * @tests java.util.BitSet#set(int, int)
-     */
-    public void test_setII() {
-        // Test for method void java.util.BitSet.set(int, int)
-        // pos1 and pos2 are in the same bitset element
-        BitSet bs = new BitSet(16);
-        bs.set(5);
-        bs.set(15);
-        bs.set(7, 11);
-        for (int i = 0; i < 7; i++) {
-            if (i == 5) {
-                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
-            } else {
-                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-            }
-        }
-        for (int i = 7; i < 11; i++) {
-            assertTrue("Failed to set bit " + i, bs.get(i));
-        }
-        for (int i = 11; i < bs.size(); i++) {
-            if (i == 15) {
-                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
-            } else {
-                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-            }
-        }
-
-        // pos1 and pos2 is in the same bitset element, boundary testing
-        bs = new BitSet(16);
-        bs.set(7, 64);
-        assertEquals("Failed to grow BitSet", 64, 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++) {
-            assertTrue("Failed to set bit " + i, bs.get(i));
-        }
-        assertTrue("Shouldn't have set bit 64", !bs.get(64));
-
-        // more boundary testing
-        bs = new BitSet(32);
-        bs.set(0, 64);
-        for (int i = 0; i < 64; i++) {
-            assertTrue("Failed to set bit " + i, bs.get(i));
-        }
-        assertTrue("Shouldn't have set bit 64", !bs.get(64));
-
-        bs = new BitSet(32);
-        bs.set(0, 65);
-        for (int i = 0; i < 65; i++) {
-            assertTrue("Failed to set bit " + i, bs.get(i));
-        }
-        assertTrue("Shouldn't have set bit 65", !bs.get(65));
-
-        // pos1 and pos2 are in two sequential bitset elements
-        bs = new BitSet(128);
-        bs.set(7);
-        bs.set(110);
-        bs.set(9, 74);
-        for (int i = 0; i < 9; i++) {
-            if (i == 7) {
-                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
-            } else {
-                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-            }
-        }
-        for (int i = 9; i < 74; i++) {
-            assertTrue("Failed to set bit " + i, bs.get(i));
-        }
-        for (int i = 74; i < bs.size(); i++) {
-            if (i == 110) {
-                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
-            } else {
-                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-            }
-        }
-
-        // pos1 and pos2 are in two non-sequential bitset elements
-        bs = new BitSet(256);
-        bs.set(7);
-        bs.set(255);
-        bs.set(9, 219);
-        for (int i = 0; i < 9; i++) {
-            if (i == 7) {
-                assertTrue("Shouldn't have set flipped " + i, bs.get(i));
-            } else {
-                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-            }
-        }
-
-        for (int i = 9; i < 219; i++) {
-            assertTrue("failed to set bit " + i, bs.get(i));
-        }
-
-        for (int i = 219; i < 255; i++) {
-            assertTrue("Shouldn't have set bit " + i, !bs.get(i));
-        }
-
-        assertTrue("Shouldn't have flipped bit 255", bs.get(255));
-
-        // test illegal args
-        bs = new BitSet(10);
-        try {
-            bs.set(-1, 3);
-            fail("Test1: Attempt to flip with  negative index failed to generate exception");
-        } catch (IndexOutOfBoundsException e) {
-        }
-
-        try {
-            bs.set(2, -1);
-            fail("Test2: Attempt to flip with negative index failed to generate exception");
-        } catch (IndexOutOfBoundsException e) {
-        }
-
-        try {
-            bs.set(4, 2);
-            fail("Test4: Attempt to flip with illegal args failed to generate exception");
-        } catch (IndexOutOfBoundsException e) {
-        }
-    }
-
-    /**
-     * @tests java.util.BitSet#set(int, int, boolean)
-     */
-    public void test_setIIZ() {
-        // Test for method void java.util.BitSet.set(int, int, boolean)
-        eightbs.set(3, 6, false);
-        assertTrue("Should have set bits 3, 4, and 5 to false", !eightbs.get(3)
-                && !eightbs.get(4) && !eightbs.get(5));
+        assertEquals("Test1: Wrong length,", 0, bs.length());
+        assertEquals("Test1: Wrong size,", 0, bs.size());
 
-        eightbs.set(3, 6, true);
-        assertTrue("Should have set bits 3, 4, and 5 to true", eightbs.get(3)
-                && eightbs.get(4) && eightbs.get(5));
+        bs.get(0, 2);
+        assertEquals("Test2: Wrong length,", 0, bs.length());
+        assertEquals("Test2: Wrong size,", 0, bs.size());
+
+        bs.get(60, 64);
+        assertEquals("Test3: Wrong length,", 0, bs.length());
+        assertEquals("Test3: Wrong size,", 0, bs.size());
+
+        bs.get(64, 120);
+        assertEquals("Test4: Wrong length,", 0, bs.length());
+        assertEquals("Test4: Wrong size,", 0, bs.size());
+
+        bs.set(25);
+        assertEquals("Test5: Wrong length,", 26, bs.length());
+        assertEquals("Test5: Wrong size,", 64, bs.size());
+
+        bs.get(60, 64);
+        assertEquals("Test6: Wrong length,", 26, bs.length());
+        assertEquals("Test6: Wrong size,", 64, bs.size());
+
+        bs.get(64, 120);
+        assertEquals("Test7: Wrong size,", 64, bs.size());
+        assertEquals("Test7: Wrong length,", 26, bs.length());
+
+        bs.get(80);
+        assertEquals("Test8: Wrong size,", 64, bs.size());
+        assertEquals("Test8: Wrong length,", 26, bs.length());
+
+        bs.get(25);
+        assertEquals("Test9: Wrong size,", 64, bs.size());
+        assertEquals("Test9: Wrong length,", 26, bs.length());
 
     }
 
@@ -675,7 +589,7 @@
         bs.clear(9);
         bs.set(10);
         bs.flip(9);
-        assertTrue("Failed to flip bit", !bs.get(8));
+        assertFalse("Failed to flip bit", bs.get(8));
         assertTrue("Failed to flip bit", bs.get(9));
         assertTrue("Failed to flip bit", bs.get(10));
 
@@ -684,8 +598,8 @@
         bs.clear(10);
         bs.flip(9);
         assertTrue("Failed to flip bit", bs.get(8));
-        assertTrue("Failed to flip bit", !bs.get(9));
-        assertTrue("Failed to flip bit", !bs.get(10));
+        assertFalse("Failed to flip bit", bs.get(9));
+        assertFalse("Failed to flip bit", bs.get(10));
 
         try {
             bs.flip(-1);
@@ -703,7 +617,7 @@
         for (int i = bs.size(); --i >= 0;) {
             bs.flip(i);
             assertTrue("Test1: Incorrectly flipped bit" + i, bs.get(i));
-            assertTrue("Incorrect length", bs.length() == (i + 1));
+            assertEquals("Incorrect length", i+1, bs.length());
             for (int j = bs.size(); --j > i;) {
                 assertTrue("Test2: Incorrectly flipped bit" + j, !bs.get(j));
             }
@@ -729,9 +643,8 @@
         assertTrue("Failed to flip bit 7", !eightbs.get(7));
 
         // Check to see all other bits are still set
-        for (int i = 0; i < 7; i++) {
+        for (int i = 0; i < 7; i++)
             assertTrue("Flip flipped incorrect bits", eightbs.get(i));
-        }
 
         eightbs.flip(127);
         assertTrue("Failed to flip bit 127", eightbs.get(127));
@@ -741,9 +654,15 @@
     }
 
     /**
-     * @tests java.util.BitSet#flip(int, int)
+     * @tests java.util.BitSet#clear(int, int)
      */
     public void test_flipII() {
+        BitSet bitset = new BitSet();
+        for (int i = 0; i < 20; i++) {
+            bitset.set(i);
+        }
+        bitset.flip(10, 10);
+               
         // Test for method void java.util.BitSet.flip(int, int)
         // pos1 and pos2 are in the same bitset element
         BitSet bs = new BitSet(16);
@@ -753,15 +672,15 @@
         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));
+        assertFalse("Failed to flip bit 7", bs.get(7));
         assertTrue("Failed to flip bit 8", bs.get(8));
         assertTrue("Failed to flip bit 9", bs.get(9));
-        assertTrue("Failed to flip bit 10", !bs.get(10));
+        assertFalse("Failed to flip bit 10", bs.get(10));
         for (int i = 11; i < bs.size(); i++) {
             assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
         }
 
-        // pos1 and pos2 is in the same bitset element, boundary testing
+        // pos1 and pos2 is in the same bitset element, boundry testing
         bs = new BitSet(16);
         bs.set(7);
         bs.set(10);
@@ -770,14 +689,14 @@
         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));
+        assertFalse("Failed to flip bit 7", bs.get(7));
         assertTrue("Failed to flip bit 8", bs.get(8));
         assertTrue("Failed to flip bit 9", bs.get(9));
-        assertTrue("Failed to flip bit 10", !bs.get(10));
+        assertFalse("Failed to flip bit 10", bs.get(10));
         for (int i = 11; i < 64; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Shouldn't have flipped bit 64", !bs.get(64));
+        assertFalse("Shouldn't have flipped bit 64", bs.get(64));
 
         // more boundary testing
         bs = new BitSet(32);
@@ -785,14 +704,14 @@
         for (int i = 0; i < 64; i++) {
             assertTrue("Failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Shouldn't have flipped bit 64", !bs.get(64));
+        assertFalse("Shouldn't have flipped bit 64", bs.get(64));
 
         bs = new BitSet(32);
         bs.flip(0, 65);
         for (int i = 0; i < 65; i++) {
             assertTrue("Failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Shouldn't have flipped bit 65", !bs.get(65));
+        assertFalse("Shouldn't have flipped bit 65", bs.get(65));
 
         // pos1 and pos2 are in two sequential bitset elements
         bs = new BitSet(128);
@@ -802,23 +721,23 @@
         bs.set(110);
         bs.flip(9, 74);
         for (int i = 0; i < 7; i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
         assertTrue("Shouldn't have flipped bit 7", bs.get(7));
-        assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
+        assertFalse("Shouldn't have flipped bit 8", bs.get(8));
         assertTrue("Failed to flip bit 9", bs.get(9));
-        assertTrue("Failed to flip bit 10", !bs.get(10));
+        assertFalse("Failed to flip bit 10", bs.get(10));
         for (int i = 11; i < 72; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Failed to flip bit 72", !bs.get(72));
+        assertFalse("Failed to flip bit 72", bs.get(72));
         assertTrue("Failed to flip bit 73", bs.get(73));
         for (int i = 74; i < 110; i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
         assertTrue("Shouldn't have flipped bit 110", bs.get(110));
         for (int i = 111; i < bs.size(); i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
 
         // pos1 and pos2 are in two non-sequential bitset elements
@@ -831,28 +750,28 @@
         bs.set(220);
         bs.flip(9, 219);
         for (int i = 0; i < 7; i++) {
-            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+            assertFalse("Shouldn't have flipped bit " + i, bs.get(i));
         }
         assertTrue("Shouldn't have flipped bit 7", bs.get(7));
-        assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
+        assertFalse("Shouldn't have flipped bit 8", bs.get(8));
         assertTrue("Failed to flip bit 9", bs.get(9));
-        assertTrue("Failed to flip bit 10", !bs.get(10));
+        assertFalse("Failed to flip bit 10", bs.get(10));
         for (int i = 11; i < 72; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Failed to flip bit 72", !bs.get(72));
+        assertFalse("Failed to flip bit 72", bs.get(72));
         for (int i = 73; i < 110; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Failed to flip bit 110", !bs.get(110));
+        assertFalse("Failed to flip bit 110", bs.get(110));
         for (int i = 111; i < 181; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Failed to flip bit 181", !bs.get(181));
+        assertFalse("Failed to flip bit 181", bs.get(181));
         for (int i = 182; i < 219; i++) {
             assertTrue("failed to flip bit " + i, bs.get(i));
         }
-        assertTrue("Shouldn't have flipped bit 219", !bs.get(219));
+        assertFalse("Shouldn't have flipped bit 219", bs.get(219));
         assertTrue("Shouldn't have flipped bit 220", bs.get(220));
         for (int i = 221; i < bs.size(); i++) {
             assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
@@ -864,22 +783,230 @@
             bs.flip(-1, 3);
             fail("Test1: Attempt to flip with  negative index failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // correct behavior
         }
 
         try {
             bs.flip(2, -1);
             fail("Test2: Attempt to flip with negative index failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // correct behavior
         }
 
         try {
             bs.flip(4, 2);
             fail("Test4: Attempt to flip with illegal args failed to generate exception");
         } catch (IndexOutOfBoundsException e) {
+            // correct behavior
+        }
+    }
+
+    /**
+     * @tests java.util.BitSet#set(int)
+     */
+    public void test_setI() {
+        // Test for method void java.util.BitSet.set(int)
+
+        BitSet bs = new BitSet();
+        bs.set(8);
+        assertTrue("Failed to set bit", bs.get(8));
+
+        try {
+            bs.set(-1);
+            fail("Attempt to set at negative index failed to generate exception");
+        } catch (IndexOutOfBoundsException e) {
+            // Correct behaviour
+        }
+
+        // Try setting a bit on a 64 boundary
+        bs.set(128);
+        assertEquals("Failed to grow BitSet", 192, bs.size());
+        assertTrue("Failed to set bit", bs.get(128));
+
+        bs = new BitSet(64);
+        for (int i = bs.size(); --i >= 0;) {
+            bs.set(i);
+            assertTrue("Incorrectly set", bs.get(i));
+            assertEquals("Incorrect length", i+1, bs.length());
+            for (int j = bs.size(); --j > i;)
+                assertFalse("Incorrectly set bit " + j, bs.get(j));
+            for (int j = i; --j >= 0;)
+                assertFalse("Incorrectly set bit " + j, bs.get(j));
+            bs.clear(i);
+        }
+
+        bs = new BitSet(0);
+        assertEquals("Test1: Wrong length", 0, bs.length());
+        bs.set(0);
+        assertEquals("Test2: Wrong length", 1, bs.length());
+    }
+
+    /**
+     * @tests java.util.BitSet#set(int, boolean)
+     */
+    public void test_setIZ() {
+        // Test for method void java.util.BitSet.set(int, boolean)
+        eightbs.set(5, false);
+        assertFalse("Should have set bit 5 to true", eightbs.get(5));
+
+        eightbs.set(5, true);
+        assertTrue("Should have set bit 5 to false", eightbs.get(5));
+
+        try {
+            BitSet bs = new BitSet();
+            bs.set(-2147483648, false);
+            fail("Should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+    }
+
+    /**
+     * @tests java.util.BitSet#set(int, int)
+     */
+    public void test_setII() throws IndexOutOfBoundsException {
+        BitSet bitset = new BitSet(30);
+        bitset.set(29, 29);
+        
+        // Test for method void java.util.BitSet.set(int, int)
+        // pos1 and pos2 are in the same bitset element
+        BitSet bs = new BitSet(16);
+        bs.set(5);
+        bs.set(15);
+        bs.set(7, 11);
+        for (int i = 0; i < 7; i++) {
+            if (i == 5)
+                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+            else
+                assertFalse("Shouldn't have set bit " + i, bs.get(i));
+        }
+        for (int i = 7; i < 11; i++) {
+            assertTrue("Failed to set bit " + i, bs.get(i));
+        }
+        for (int i = 11; i < bs.size(); i++) {
+            if (i == 15) {
+                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+            } else {
+                assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+            }
+        }
+
+        // pos1 and pos2 is in the same bitset element, boundary testing
+        bs = new BitSet(16);
+        bs.set(7, 64);
+        assertEquals("Failed to grow BitSet", 64, bs.size());
+        for (int i = 0; i < 7; i++) {
+            assertFalse("Shouldn't have set bit " + i, bs.get(i));
+        }
+        for (int i = 7; i < 64; i++) {
+            assertTrue("Failed to set bit " + i, bs.get(i));
+        }
+        assertFalse("Shouldn't have set bit 64", bs.get(64));
+
+        // more boundary testing
+        bs = new BitSet(32);
+        bs.set(0, 64);
+        for (int i = 0; i < 64; i++) {
+            assertTrue("Failed to set bit " + i, bs.get(i));
+        }
+        assertTrue("Shouldn't have set bit 64", !bs.get(64));
+
+        bs = new BitSet(32);
+        bs.set(0, 65);
+        for (int i = 0; i < 65; i++) {
+            assertTrue("Failed to set bit " + i, bs.get(i));
+        }
+        assertTrue("Shouldn't have set bit 65", !bs.get(65));
+
+        // pos1 and pos2 are in two sequential bitset elements
+        bs = new BitSet(128);
+        bs.set(7);
+        bs.set(110);
+        bs.set(9, 74);
+        for (int i = 0; i < 9; i++) {
+            if (i == 7) {
+                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+            } else {
+                assertFalse("Shouldn't have set bit " + i, bs.get(i));
+            }
+        }
+        for (int i = 9; i < 74; i++) {
+            assertTrue("Failed to set bit " + i, bs.get(i));
+        }
+        for (int i = 74; i < bs.size(); i++) {
+            if (i == 110) {
+                assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+            } else {
+                assertFalse("Shouldn't have set bit " + i, bs.get(i));
+            }
+        }
+
+        // pos1 and pos2 are in two non-sequential bitset elements
+        bs = new BitSet(256);
+        bs.set(7);
+        bs.set(255);
+        bs.set(9, 219);
+        for (int i = 0; i < 9; i++) {
+            if (i == 7) {
+                assertTrue("Shouldn't have set flipped " + i, bs.get(i));
+            } else {
+                assertFalse("Shouldn't have set bit " + i, bs.get(i));
+            }
+        }
+
+        for (int i = 9; i < 219; i++) {
+            assertTrue("failed to set bit " + i, bs.get(i));
+        }
+
+        for (int i = 219; i < 255; i++) {
+            assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+        }
+
+        assertTrue("Shouldn't have flipped bit 255", bs.get(255));
+
+        // test illegal args
+        bs = new BitSet(10);
+        try {
+            bs.set(-1, 3);
+            fail("Test1: Attempt to flip with  negative index failed to generate exception");
+        } catch (IndexOutOfBoundsException e) {
+            // Correct behavior
+        }
+
+        try {
+            bs.set(2, -1);
+            fail("Test2: Attempt to flip with negative index failed to generate exception");
+        } catch (IndexOutOfBoundsException e) {
+            // Correct behavior
+        }
+
+        bs.set(2, 2);
+        assertFalse("Bit got set incorrectly ", bs.get(2));
+
+        try {
+            bs.set(4, 2);
+            fail("Test4: Attempt to flip with illegal args failed to generate exception");
+        } catch (IndexOutOfBoundsException e) {
+            // Correct behavior
         }
     }
 
     /**
+     * @tests java.util.BitSet#set(int, int, boolean)
+     */
+    public void test_setIIZ() {
+        // Test for method void java.util.BitSet.set(int, int, boolean)
+        eightbs.set(3, 6, false);
+        assertTrue("Should have set bits 3, 4, and 5 to false", !eightbs.get(3)
+                && !eightbs.get(4) && !eightbs.get(5));
+
+        eightbs.set(3, 6, true);
+        assertTrue("Should have set bits 3, 4, and 5 to true", eightbs.get(3)
+                && eightbs.get(4) && eightbs.get(5));
+
+    }
+
+    /**
      * @tests java.util.BitSet#set(int, int)
      * @tests java.util.BitSet#cardinality()
      * @tests java.util.BitSet#get(int)
@@ -997,14 +1124,14 @@
             bs.set(i);
         }
         eightbs.and(bs);
-        assertTrue("AND failed to clear bits", !eightbs.equals(bs));
+        assertFalse("AND failed to clear bits", eightbs.equals(bs));
         eightbs.set(3);
         bs.set(3);
         eightbs.and(bs);
         assertTrue("AND failed to maintain set bits", bs.get(3));
         bs.and(eightbs);
         for (int i = 64; i < 128; i++) {
-            assertTrue("Failed to clear extra bits in the receiver BitSet", !bs
+            assertFalse("Failed to clear extra bits in the receiver BitSet", bs
                     .get(i));
         }
 
@@ -1027,8 +1154,8 @@
         bs2.set(2);
         bs2.set(3);
         bs.andNot(bs2);
-        assertEquals("Incorrect bitset after andNot", "{0, 1, 4, 6, 7}", bs
-                .toString());
+        assertEquals("Incorrect bitset after andNot",
+                     "{0, 1, 4, 6, 7}", bs.toString());
 
         bs = new BitSet(0);
         bs.andNot(bs2);
@@ -1083,7 +1210,7 @@
         BitSet bs = (BitSet) eightbs.clone();
         bs.xor(eightbs);
         for (int i = 0; i < 8; i++) {
-            assertTrue("XOR failed to clear bits", !bs.get(i));
+            assertFalse("XOR failed to clear bits", bs.get(i));
         }
 
         bs.xor(eightbs);
@@ -1130,20 +1257,15 @@
      */
     public void test_length() {
         BitSet bs = new BitSet();
-        assertTrue("BitSet returned wrong length--wanted 0, got: "
-                + bs.length(), bs.length() == 0);
+        assertEquals("BitSet returned wrong length", 0, bs.length());
         bs.set(5);
-        assertTrue("BitSet returned wrong length--wanted 6, got: "
-                + bs.length(), bs.length() == 6);
+        assertEquals("BitSet returned wrong length", 6, bs.length());
         bs.set(10);
-        assertTrue("BitSet returned wrong length--wanted 11, got: "
-                + bs.length(), bs.length() == 11);
+        assertEquals("BitSet returned wrong length", 11, bs.length());
         bs.set(432);
-        assertTrue("BitSet returned wrong length--wanted 433, got: "
-                + bs.length(), bs.length() == 433);
+        assertEquals("BitSet returned wrong length", 433, bs.length());
         bs.set(300);
-        assertTrue("BitSet returned wrong length--wanted 433 (again), got: "
-                + bs.length(), bs.length() == 433);
+        assertEquals("BitSet returned wrong length", 433, bs.length());
     }
 
     /**
@@ -1164,6 +1286,7 @@
             bs.nextSetBit(-1);
             fail("Expected IndexOutOfBoundsException for negative index");
         } catch (IndexOutOfBoundsException e) {
+            // correct behavior
         }
         assertEquals("nextSetBit() returned the wrong value", 5, bs
                 .nextSetBit(0));
@@ -1248,6 +1371,7 @@
             bs.nextClearBit(-1);
             fail("Expected IndexOutOfBoundsException for negative index");
         } catch (IndexOutOfBoundsException e) {
+            // correct behavior
         }
         assertEquals("nextClearBit() returned the wrong value", 5, bs
                 .nextClearBit(0));



Mime
View raw message