You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/10/31 09:42:35 UTC
svn commit: r590591 [4/12] - in /harmony/enhanced/classlib/branches/java6:
depends/build/platform/ depends/files/ depends/jars/icu4j_3.8/
depends/libs/freebsd.x86/ depends/manifests/icu4j_3.4.4/
depends/manifests/icu4j_3.8/ depends/manifests/icu4j_3.8/...
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.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/Inet6AddressTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/Inet6AddressTest.java Wed Oct 31 01:42:07 2007
@@ -31,744 +31,686 @@
/**
* @tests java.net.Inet6Address#isMulticastAddress()
*/
- public void test_isMulticastAddress() {
+ public void test_isMulticastAddress() throws Exception {
String addrName = "";
InetAddress addr = null;
- try {
-
- // IP V6 regular multicast and non-multicast tests
- //
- // Create 2 IP v6 addresses and call "isMulticastAddress()"
- // A prefix of "11111111" means that the address is multicast
- // The first one will be one with the prefix the second without
-
- addrName = "FFFF::42:42"; // 11111111 = FFFF
- addr = InetAddress.getByName(addrName);
- assertTrue("Multicast address " + addrName + " not detected.", addr
- .isMulticastAddress());
-
- addrName = "42::42:42"; // an non-multicast address
- addr = InetAddress.getByName(addrName);
- assertTrue("Non multicast address " + addrName
- + " reporting as a multicast address.", !addr
- .isMulticastAddress());
-
- // IPv4-compatible IPv6 address tests
- //
- // Now create 2 IP v6 addresses that are IP v4 compatable
- // to IP v6 addresses. The address prefix for a multicast ip v4
- // address is 1110 for the last 16 bits ::d.d.d.d
- // We expect these to be false
-
- addrName = "::224.42.42.42"; // an ipv4 multicast addr 1110 = 224
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 compatable address " + addrName
- + " reported incorrectly as multicast.", !addr
- .isMulticastAddress());
-
- addrName = "::42.42.42.42"; // an ipv4 non-multicast address
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 compatable address " + addrName
- + " reported incorrectly as multicast.", !addr
- .isMulticastAddress());
-
- // IPv4-mapped IPv6 address tests
- //
- // Now create 2 IP v6 addresses that are IP v4 compatable
- // to IP v6 addresses. The address prefix for a multicast ip v4
- // address is 1110 for the last 16 bits ::FFFF:d.d.d.d
-
- addrName = "::FFFF:224.42.42.42"; // an ipv4 multicast addr 1110 =
- // 224
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-mapped IPv6 multicast address " + addrName
- + " not detected.", addr.isMulticastAddress());
-
- addrName = "::FFFF:42.42.42.42"; // an ipv4 non-multicast address
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-mapped IPv6 non-multicast address " + addrName
- + " reporting as a multicast address.", !addr
- .isMulticastAddress());
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular multicast and non-multicast tests
+ //
+ // Create 2 IP v6 addresses and call "isMulticastAddress()"
+ // A prefix of "11111111" means that the address is multicast
+ // The first one will be one with the prefix the second without
+
+ addrName = "FFFF::42:42"; // 11111111 = FFFF
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Multicast address " + addrName + " not detected.", addr
+ .isMulticastAddress());
+
+ addrName = "42::42:42"; // an non-multicast address
+ addr = InetAddress.getByName(addrName);
+ assertTrue("Non multicast address " + addrName
+ + " reporting as a multicast address.", !addr
+ .isMulticastAddress());
+
+ // IPv4-compatible IPv6 address tests
+ //
+ // Now create 2 IP v6 addresses that are IP v4 compatable
+ // to IP v6 addresses. The address prefix for a multicast ip v4
+ // address is 1110 for the last 16 bits ::d.d.d.d
+ // We expect these to be false
+
+ addrName = "::224.42.42.42"; // an ipv4 multicast addr 1110 = 224
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 compatable address " + addrName
+ + " reported incorrectly as multicast.", !addr
+ .isMulticastAddress());
+
+ addrName = "::42.42.42.42"; // an ipv4 non-multicast address
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 compatable address " + addrName
+ + " reported incorrectly as multicast.", !addr
+ .isMulticastAddress());
+
+ // IPv4-mapped IPv6 address tests
+ //
+ // Now create 2 IP v6 addresses that are IP v4 compatable
+ // to IP v6 addresses. The address prefix for a multicast ip v4
+ // address is 1110 for the last 16 bits ::FFFF:d.d.d.d
+
+ addrName = "::FFFF:224.42.42.42"; // an ipv4 multicast addr 1110 =
+ // 224
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-mapped IPv6 multicast address " + addrName
+ + " not detected.", addr.isMulticastAddress());
+
+ addrName = "::FFFF:42.42.42.42"; // an ipv4 non-multicast address
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-mapped IPv6 non-multicast address " + addrName
+ + " reporting as a multicast address.", !addr
+ .isMulticastAddress());
}
/**
* @tests java.net.Inet6Address#isAnyLocalAddress()
*/
- public void test_isAnyLocalAddress() {
+ public void test_isAnyLocalAddress() throws Exception {
String addrName = "";
InetAddress addr = null;
- try {
-
- // test to ensure that the unspecified address returns tru
- addrName = "::0"; // The unspecified address
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "The unspecified (also known as wildcard and any local address) "
- + addrName + " not detected.", addr
- .isAnyLocalAddress());
-
- addrName = "::"; // another form of the unspecified address
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "The unspecified (also known as wildcard and any local address) "
- + addrName + " not detected.", addr
- .isAnyLocalAddress());
-
- addrName = "::1"; // The loopback address
- addr = InetAddress.getByName(addrName);
- assertTrue("The addresses " + addrName
- + " incorrectly reporting an the unspecified address.",
- !addr.isAnyLocalAddress());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // test to ensure that the unspecified address returns tru
+ addrName = "::0"; // The unspecified address
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "The unspecified (also known as wildcard and any local address) "
+ + addrName + " not detected.", addr
+ .isAnyLocalAddress());
+
+ addrName = "::"; // another form of the unspecified address
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "The unspecified (also known as wildcard and any local address) "
+ + addrName + " not detected.", addr
+ .isAnyLocalAddress());
+
+ addrName = "::1"; // The loopback address
+ addr = InetAddress.getByName(addrName);
+ assertTrue("The addresses " + addrName
+ + " incorrectly reporting an the unspecified address.",
+ !addr.isAnyLocalAddress());
}
/**
* @tests java.net.Inet6Address#isLoopbackAddress()
*/
- public void test_isLoopbackAddress() {
+ public void test_isLoopbackAddress() throws Exception {
String addrName = "";
- try {
-
- // IP V6 regular address tests for loopback
- // The loopback address for IPv6 is ::1
+ // IP V6 regular address tests for loopback
+ // The loopback address for IPv6 is ::1
- addrName = "::1";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 loopback address " + addrName + " not detected.",
- addr.isLoopbackAddress());
-
- addrName = "::2";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address incorrectly " + addrName
- + " detected as a loopback address.", !addr
- .isLoopbackAddress());
-
- // a loopback address should be 127.d.d.d
- addrName = "42:42::42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address incorrectly " + addrName
- + " detected as a loopback address.", !addr
- .isLoopbackAddress());
-
- // IPv4-compatible IPv6 address tests
- //
- // Now create 2 IP v6 addresses that are IP v4 compatable
- // to IP v6 addresses. The address prefix for a multicast ip v4
- // address is 1110 for the last 16 bits ::d.d.d.d
- // We expect these to be false, as they are not IPv4 addresses
-
- // a loopback address should be 127.d.d.d
- addrName = "::127.0.0.0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 address " + addrName
- + " detected incorrectly as a loopback.", !addr
- .isLoopbackAddress());
-
- addrName = "::127.42.42.42"; // a loopback address should be
- // 127.d.d.d
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 address " + addrName
- + " detected incorrectly as a loopback.", !addr
- .isLoopbackAddress());
-
- // a loopback address should be 127.d.d.d
- addrName = "::42.42.42.42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 address " + addrName
- + " detected incorrectly as a loopback.", !addr
- .isLoopbackAddress());
-
- // IPv4-mapped IPv6 address tests
- //
- // Now create 2 IP v6 addresses that are IP v4 compatable
- // to IP v6 addresses. The address prefix for a multicast ip v4
- // address is 1110 for the last 16 bits ::FFFF:d.d.d.d
-
- // a loopback address should be 127.d.d.d
- addrName = "::FFFF:127.0.0.0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 loopback address " + addrName
- + " not detected.", addr.isLoopbackAddress());
-
- // a loopback address should be 127.d.d.d
- addrName = "::FFFF:127.42.42.42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 loopback address " + addrName
- + " not detected.", addr.isLoopbackAddress());
-
- // a loopback address should be 127.d.d.d
- addrName = "::FFFF:42.42.42.42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4-compatible IPv6 address incorrectly " + addrName
- + " detected as a loopback address.", !addr
- .isLoopbackAddress());
-
- } catch (UnknownHostException e) {
- fail("Unknown address : " + addrName);
- }
+ addrName = "::1";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 loopback address " + addrName + " not detected.",
+ addr.isLoopbackAddress());
+
+ addrName = "::2";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address incorrectly " + addrName
+ + " detected as a loopback address.", !addr
+ .isLoopbackAddress());
+
+ // a loopback address should be 127.d.d.d
+ addrName = "42:42::42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address incorrectly " + addrName
+ + " detected as a loopback address.", !addr
+ .isLoopbackAddress());
+
+ // IPv4-compatible IPv6 address tests
+ //
+ // Now create 2 IP v6 addresses that are IP v4 compatable
+ // to IP v6 addresses. The address prefix for a multicast ip v4
+ // address is 1110 for the last 16 bits ::d.d.d.d
+ // We expect these to be false, as they are not IPv4 addresses
+
+ // a loopback address should be 127.d.d.d
+ addrName = "::127.0.0.0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 address " + addrName
+ + " detected incorrectly as a loopback.", !addr
+ .isLoopbackAddress());
+
+ addrName = "::127.42.42.42"; // a loopback address should be
+ // 127.d.d.d
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 address " + addrName
+ + " detected incorrectly as a loopback.", !addr
+ .isLoopbackAddress());
+
+ // a loopback address should be 127.d.d.d
+ addrName = "::42.42.42.42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 address " + addrName
+ + " detected incorrectly as a loopback.", !addr
+ .isLoopbackAddress());
+
+ // IPv4-mapped IPv6 address tests
+ //
+ // Now create 2 IP v6 addresses that are IP v4 compatable
+ // to IP v6 addresses. The address prefix for a multicast ip v4
+ // address is 1110 for the last 16 bits ::FFFF:d.d.d.d
+
+ // a loopback address should be 127.d.d.d
+ addrName = "::FFFF:127.0.0.0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 loopback address " + addrName
+ + " not detected.", addr.isLoopbackAddress());
+
+ // a loopback address should be 127.d.d.d
+ addrName = "::FFFF:127.42.42.42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 loopback address " + addrName
+ + " not detected.", addr.isLoopbackAddress());
+
+ // a loopback address should be 127.d.d.d
+ addrName = "::FFFF:42.42.42.42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4-compatible IPv6 address incorrectly " + addrName
+ + " detected as a loopback address.", !addr
+ .isLoopbackAddress());
}
/**
* @tests java.net.Inet6Address#isLinkLocalAddress()
*/
- public void test_isLinkLocalAddress() {
+ public void test_isLinkLocalAddress() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for link local addresses
- //
- // Link local addresses are FE80:: -
- // FEBF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
-
- addrName = "FE80::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 link local address " + addrName + " not detected.",
- addr.isLinkLocalAddress());
-
- addrName = "FEBF::FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 link local address " + addrName + " not detected.",
- addr.isLinkLocalAddress());
-
- addrName = "FEC0::1";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address " + addrName
- + " detected incorrectly as a link local address.", !addr
- .isLinkLocalAddress());
-
- addrName = "FD80::1:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address " + addrName
- + " detected incorrectly as a link local address.", !addr
- .isLinkLocalAddress());
-
- addrName = "FE7F::FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address " + addrName
- + " detected incorrectly as a link local address.", !addr
- .isLinkLocalAddress());
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
-
+ // IP V6 regular address tests for link local addresses
+ //
+ // Link local addresses are FE80:: -
+ // FEBF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
+
+ addrName = "FE80::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 link local address " + addrName + " not detected.",
+ addr.isLinkLocalAddress());
+
+ addrName = "FEBF::FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 link local address " + addrName + " not detected.",
+ addr.isLinkLocalAddress());
+
+ addrName = "FEC0::1";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address " + addrName
+ + " detected incorrectly as a link local address.", !addr
+ .isLinkLocalAddress());
+
+ addrName = "FD80::1:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address " + addrName
+ + " detected incorrectly as a link local address.", !addr
+ .isLinkLocalAddress());
+
+ addrName = "FE7F::FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address " + addrName
+ + " detected incorrectly as a link local address.", !addr
+ .isLinkLocalAddress());
}
/**
* @tests java.net.Inet6Address#isSiteLocalAddress()
*/
- public void test_isSiteLocalAddress() {
+ public void test_isSiteLocalAddress() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for link local addresses
- //
- // Link local addresses are FEC0::0 through to
- // FEFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
-
- addrName = "FEC0::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 site local address " + addrName + " not detected.",
- addr.isSiteLocalAddress());
-
- addrName = "FEFF::FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 site local address " + addrName + " not detected.",
- addr.isSiteLocalAddress());
-
- addrName = "FEBF::FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address " + addrName
- + " detected incorrectly as a site local address.", !addr
- .isSiteLocalAddress());
-
- addrName = "FFC0::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 address " + addrName
- + " detected incorrectly as a site local address.", !addr
- .isSiteLocalAddress());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+
+ // IP V6 regular address tests for link local addresses
+ //
+ // Link local addresses are FEC0::0 through to
+ // FEFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
+
+ addrName = "FEC0::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 site local address " + addrName + " not detected.",
+ addr.isSiteLocalAddress());
+
+ addrName = "FEFF::FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 site local address " + addrName + " not detected.",
+ addr.isSiteLocalAddress());
+
+ addrName = "FEBF::FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address " + addrName
+ + " detected incorrectly as a site local address.", !addr
+ .isSiteLocalAddress());
+
+ addrName = "FFC0::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 address " + addrName
+ + " detected incorrectly as a site local address.", !addr
+ .isSiteLocalAddress());
}
/**
* @tests java.net.Inet6Address#isMCGlobal()
*/
- public void test_isMCGlobal() {
+ public void test_isMCGlobal() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for Mulitcase Global addresses
- //
- // Multicast global addresses are FFxE:/112 where x is
- // a set of flags, and the addition 112 bits make up
- // the global address space
-
- addrName = "FF0E::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 global mutlicast address " + addrName
- + " not detected.", addr.isMCGlobal());
-
- addrName = "FF0E:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 global multicast address " + addrName
- + " not detected.", addr.isMCGlobal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFFE::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 global mutlicast address " + addrName
- + " not detected.", addr.isMCGlobal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFFE:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 global multicast address " + addrName
- + " not detected.", addr.isMCGlobal());
-
- // a sample MC organizational address
- addrName = "FF08:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast organizational " + addrName
- + " incorrectly indicated as a global address.", !addr
- .isMCGlobal());
-
- // a sample MC site address
- addrName = "FF05:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast site address " + addrName
- + " incorrectly indicated as a global address.", !addr
- .isMCGlobal());
-
- // a sample MC link address
- addrName = "FF02:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast link address " + addrName
- + " incorrectly indicated as a global address.", !addr
- .isMCGlobal());
-
- // a sample MC Node
- addrName = "FF01:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast node address " + addrName
- + " incorrectly indicated as a global address.", !addr
- .isMCGlobal());
-
- // IPv4-mapped IPv6 address tests
- addrName = "::FFFF:224.0.1.0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 global multicast address " + addrName
- + " not identified as a global multicast address.", addr
- .isMCGlobal());
-
- addrName = "::FFFF:238.255.255.255";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 global multicast address " + addrName
- + " not identified as a global multicast address.", addr
- .isMCGlobal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular address tests for Mulitcase Global addresses
+ //
+ // Multicast global addresses are FFxE:/112 where x is
+ // a set of flags, and the addition 112 bits make up
+ // the global address space
+
+ addrName = "FF0E::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 global mutlicast address " + addrName
+ + " not detected.", addr.isMCGlobal());
+
+ addrName = "FF0E:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 global multicast address " + addrName
+ + " not detected.", addr.isMCGlobal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFFE::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 global mutlicast address " + addrName
+ + " not detected.", addr.isMCGlobal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFFE:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 global multicast address " + addrName
+ + " not detected.", addr.isMCGlobal());
+
+ // a sample MC organizational address
+ addrName = "FF08:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast organizational " + addrName
+ + " incorrectly indicated as a global address.", !addr
+ .isMCGlobal());
+
+ // a sample MC site address
+ addrName = "FF05:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast site address " + addrName
+ + " incorrectly indicated as a global address.", !addr
+ .isMCGlobal());
+
+ // a sample MC link address
+ addrName = "FF02:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast link address " + addrName
+ + " incorrectly indicated as a global address.", !addr
+ .isMCGlobal());
+
+ // a sample MC Node
+ addrName = "FF01:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast node address " + addrName
+ + " incorrectly indicated as a global address.", !addr
+ .isMCGlobal());
+
+ // IPv4-mapped IPv6 address tests
+ addrName = "::FFFF:224.0.1.0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 global multicast address " + addrName
+ + " not identified as a global multicast address.", addr
+ .isMCGlobal());
+
+ addrName = "::FFFF:238.255.255.255";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 global multicast address " + addrName
+ + " not identified as a global multicast address.", addr
+ .isMCGlobal());
}
/**
* @tests java.net.Inet6Address#isMCNodeLocal()
*/
- public void test_isMCNodeLocal() {
+ public void test_isMCNodeLocal() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for Mulitcase node local addresses
- //
- // Multicast node local addresses are FFx1:/112 where x is
- // a set of flags, and the addition 112 bits make up
- // the global address space
-
- addrName = "FF01::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 node-local mutlicast address " + addrName
- + " not detected.", addr.isMCNodeLocal());
-
- addrName = "FF01:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 node-local multicast address " + addrName
- + " not detected.", addr.isMCNodeLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF1::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 node-local mutlicast address " + addrName
- + " not detected.", addr.isMCNodeLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF1:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 node-local multicast address " + addrName
- + " not detected.", addr.isMCNodeLocal());
-
- // a sample MC organizational address
- addrName = "FF08:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast organizational address " + addrName
- + " incorrectly indicated as a node-local address.", !addr
- .isMCNodeLocal());
-
- // a sample MC site address
- addrName = "FF05:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast site address " + addrName
- + " incorrectly indicated as a node-local address.", !addr
- .isMCNodeLocal());
-
- // a sample MC link address
- addrName = "FF02:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast link address " + addrName
- + " incorrectly indicated as a node-local address.", !addr
- .isMCNodeLocal());
-
- // a sample MC global address
- addrName = "FF0E:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 mulitcast node address " + addrName
- + " incorrectly indicated as a node-local address.", !addr
- .isMCNodeLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular address tests for Mulitcase node local addresses
+ //
+ // Multicast node local addresses are FFx1:/112 where x is
+ // a set of flags, and the addition 112 bits make up
+ // the global address space
+
+ addrName = "FF01::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 node-local mutlicast address " + addrName
+ + " not detected.", addr.isMCNodeLocal());
+
+ addrName = "FF01:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 node-local multicast address " + addrName
+ + " not detected.", addr.isMCNodeLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF1::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 node-local mutlicast address " + addrName
+ + " not detected.", addr.isMCNodeLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF1:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 node-local multicast address " + addrName
+ + " not detected.", addr.isMCNodeLocal());
+
+ // a sample MC organizational address
+ addrName = "FF08:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast organizational address " + addrName
+ + " incorrectly indicated as a node-local address.", !addr
+ .isMCNodeLocal());
+
+ // a sample MC site address
+ addrName = "FF05:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast site address " + addrName
+ + " incorrectly indicated as a node-local address.", !addr
+ .isMCNodeLocal());
+
+ // a sample MC link address
+ addrName = "FF02:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast link address " + addrName
+ + " incorrectly indicated as a node-local address.", !addr
+ .isMCNodeLocal());
+
+ // a sample MC global address
+ addrName = "FF0E:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 mulitcast node address " + addrName
+ + " incorrectly indicated as a node-local address.", !addr
+ .isMCNodeLocal());
}
/**
* @tests java.net.Inet6Address#isMCLinkLocal()
*/
- public void test_isMCLinkLocal() {
+ public void test_isMCLinkLocal() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for Mulitcase link local addresses
- //
- // Multicast link local addresses are FFx2:/112 where x is
- // a set of flags, and the addition 112 bits make up
- // the global address space
-
- addrName = "FF02::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 link local multicast address " + addrName
- + " not detected.", addr.isMCLinkLocal());
-
- addrName = "FF02:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 link local multicast address " + addrName
- + " not detected.", addr.isMCLinkLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF2::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 link local multicast address " + addrName
- + " not detected.", addr.isMCLinkLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF2:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 link local multicast address " + addrName
- + " not detected.", addr.isMCLinkLocal());
-
- // a sample MC organizational address
- addrName = "FF08:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 organization multicast address "
- + addrName
- + " incorrectly indicated as a link-local mulitcast address.",
- !addr.isMCLinkLocal());
-
- // a sample MC site address
- addrName = "FF05:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 site-local mulitcast address "
- + addrName
- + " incorrectly indicated as a link-local mulitcast address.",
- !addr.isMCLinkLocal());
-
- // a sample MC global address
- addrName = "FF0E:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 global multicast address "
- + addrName
- + " incorrectly indicated as a link-local mulitcast address.",
- !addr.isMCLinkLocal());
-
- // a sample MC Node
- addrName = "FF01:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 mulitcast node address "
- + addrName
- + " incorrectly indicated as a link-local mulitcast address.",
- !addr.isMCLinkLocal());
-
- // Ipv4-mapped IPv6 addresses
-
- addrName = "::FFFF:224.0.0.0"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " not identified as a link-local multicast address.",
- addr.isMCLinkLocal());
-
- addrName = "::FFFF:224.0.0.255"; // a multicast addr 1110
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 link-local multicast address " + addrName
- + " not identified as a link-local multicast address.",
- addr.isMCLinkLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular address tests for Mulitcase link local addresses
+ //
+ // Multicast link local addresses are FFx2:/112 where x is
+ // a set of flags, and the addition 112 bits make up
+ // the global address space
+
+ addrName = "FF02::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 link local multicast address " + addrName
+ + " not detected.", addr.isMCLinkLocal());
+
+ addrName = "FF02:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 link local multicast address " + addrName
+ + " not detected.", addr.isMCLinkLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF2::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 link local multicast address " + addrName
+ + " not detected.", addr.isMCLinkLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF2:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 link local multicast address " + addrName
+ + " not detected.", addr.isMCLinkLocal());
+
+ // a sample MC organizational address
+ addrName = "FF08:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 organization multicast address "
+ + addrName
+ + " incorrectly indicated as a link-local mulitcast address.",
+ !addr.isMCLinkLocal());
+
+ // a sample MC site address
+ addrName = "FF05:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 site-local mulitcast address "
+ + addrName
+ + " incorrectly indicated as a link-local mulitcast address.",
+ !addr.isMCLinkLocal());
+
+ // a sample MC global address
+ addrName = "FF0E:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 global multicast address "
+ + addrName
+ + " incorrectly indicated as a link-local mulitcast address.",
+ !addr.isMCLinkLocal());
+
+ // a sample MC Node
+ addrName = "FF01:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 mulitcast node address "
+ + addrName
+ + " incorrectly indicated as a link-local mulitcast address.",
+ !addr.isMCLinkLocal());
+
+ // Ipv4-mapped IPv6 addresses
+
+ addrName = "::FFFF:224.0.0.0"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " not identified as a link-local multicast address.",
+ addr.isMCLinkLocal());
+
+ addrName = "::FFFF:224.0.0.255"; // a multicast addr 1110
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 link-local multicast address " + addrName
+ + " not identified as a link-local multicast address.",
+ addr.isMCLinkLocal());
}
/**
* @tests java.net.Inet6Address#isMCSiteLocal()
*/
- public void test_isMCSiteLocal() {
+ public void test_isMCSiteLocal() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for Multicast site-local addresses
- //
- // Multicast global addresses are FFx5:/112 where x is
- // a set of flags, and the addition 112 bits make up
- // the global address space
-
- addrName = "FF05::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 site-local mutlicast address " + addrName
- + " not detected.", addr.isMCSiteLocal());
-
- addrName = "FF05:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 site-local multicast address " + addrName
- + " not detected.", addr.isMCSiteLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF5::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 site-local mutlicast address " + addrName
- + " not detected.", addr.isMCSiteLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF5:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 site-local multicast address " + addrName
- + " not detected.", addr.isMCSiteLocal());
-
- // a sample MC organizational address
- addrName = "FF08:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 organization multicast address "
- + addrName
- + " incorrectly indicated as a site-local mulitcast address.",
- !addr.isMCSiteLocal());
-
- // a sample MC global address
- addrName = "FF0E:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 global mulitcast address "
- + addrName
- + " incorrectly indicated as a site-local mulitcast address.",
- !addr.isMCSiteLocal());
-
- // a sample MC link address
- addrName = "FF02:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 link-local multicast address "
- + addrName
- + " incorrectly indicated as a site-local mulitcast address.",
- !addr.isMCSiteLocal());
-
- // a sample MC Node
- addrName = "FF01:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 mulitcast node address "
- + addrName
- + " incorrectly indicated as a site-local mulitcast address.",
- !addr.isMCSiteLocal());
-
- // IPv4-mapped IPv6 addresses
- addrName = "::FFFF:239.255.0.0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 site-local multicast address " + addrName
- + " not identified as a site-local multicast address.",
- addr.isMCSiteLocal());
-
- addrName = "::FFFF:239.255.255.255";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 site-local multicast address " + addrName
- + " not identified as a site-local multicast address.",
- addr.isMCSiteLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular address tests for Multicast site-local addresses
+ //
+ // Multicast global addresses are FFx5:/112 where x is
+ // a set of flags, and the addition 112 bits make up
+ // the global address space
+
+ addrName = "FF05::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 site-local mutlicast address " + addrName
+ + " not detected.", addr.isMCSiteLocal());
+
+ addrName = "FF05:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 site-local multicast address " + addrName
+ + " not detected.", addr.isMCSiteLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF5::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 site-local mutlicast address " + addrName
+ + " not detected.", addr.isMCSiteLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF5:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 site-local multicast address " + addrName
+ + " not detected.", addr.isMCSiteLocal());
+
+ // a sample MC organizational address
+ addrName = "FF08:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 organization multicast address "
+ + addrName
+ + " incorrectly indicated as a site-local mulitcast address.",
+ !addr.isMCSiteLocal());
+
+ // a sample MC global address
+ addrName = "FF0E:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 global mulitcast address "
+ + addrName
+ + " incorrectly indicated as a site-local mulitcast address.",
+ !addr.isMCSiteLocal());
+
+ // a sample MC link address
+ addrName = "FF02:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 link-local multicast address "
+ + addrName
+ + " incorrectly indicated as a site-local mulitcast address.",
+ !addr.isMCSiteLocal());
+
+ // a sample MC Node
+ addrName = "FF01:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 mulitcast node address "
+ + addrName
+ + " incorrectly indicated as a site-local mulitcast address.",
+ !addr.isMCSiteLocal());
+
+ // IPv4-mapped IPv6 addresses
+ addrName = "::FFFF:239.255.0.0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 site-local multicast address " + addrName
+ + " not identified as a site-local multicast address.",
+ addr.isMCSiteLocal());
+
+ addrName = "::FFFF:239.255.255.255";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 site-local multicast address " + addrName
+ + " not identified as a site-local multicast address.",
+ addr.isMCSiteLocal());
}
/**
* @tests java.net.Inet6Address#isMCOrgLocal()
*/
- public void test_isMCOrgLocal() {
+ public void test_isMCOrgLocal() throws Exception {
String addrName = "";
- try {
- // IP V6 regular address tests for Mulitcase organization-local
- // addresses
- //
- // Multicast global addresses are FFxE:/112 where x is
- // a set of flags, and the addition 112 bits make up
- // the global address space
-
- addrName = "FF08::0";
- InetAddress addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 organization-local mutlicast address " + addrName
- + " not detected.", addr.isMCOrgLocal());
-
- addrName = "FF08:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 organization-local multicast address " + addrName
- + " not detected.", addr.isMCOrgLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF8::0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 organization-local mutlicast address " + addrName
- + " not detected.", addr.isMCOrgLocal());
-
- // a currently invalid address as the prefix FFxE
- // is only valid for x = {1,0} as the rest are reserved
- addrName = "FFF8:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv6 organization-local multicast address " + addrName
- + " not detected.", addr.isMCOrgLocal());
-
- // a sample MC global address
- addrName = "FF0E:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 global multicast address "
- + addrName
- + " incorrectly indicated as an organization-local mulitcast address.",
- !addr.isMCOrgLocal());
-
- // a sample MC site address
- addrName = "FF05:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 site-local mulitcast address "
- + addrName
- + " incorrectly indicated as an organization-local mulitcast address.",
- !addr.isMCOrgLocal());
-
- // a sample MC link address
- addrName = "FF02:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 link-local multicast address "
- + addrName
- + " incorrectly indicated as an organization-local mulitcast address.",
- !addr.isMCOrgLocal());
-
- // a sample MC Node
- addrName = "FF01:42:42:42:42:42:42:42";
- addr = InetAddress.getByName(addrName);
- assertTrue(
- "IPv6 mulitcast node address "
- + addrName
- + " incorrectly indicated as an organization-local mulitcast address.",
- !addr.isMCOrgLocal());
-
- // IPv4-mapped IPv6 addresses
-
- addrName = "::FFFF:239.192.0.0";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 org-local multicast address " + addrName
- + " not identified as a org-local multicast address.", addr
- .isMCOrgLocal());
-
- addrName = "::FFFF:239.195.255.255";
- addr = InetAddress.getByName(addrName);
- assertTrue("IPv4 org-local multicast address " + addrName
- + " not identified as a org-local multicast address.", addr
- .isMCOrgLocal());
-
- } catch (Exception e) {
- fail("Unknown address : " + addrName);
- }
+ // IP V6 regular address tests for Mulitcase organization-local
+ // addresses
+ //
+ // Multicast global addresses are FFxE:/112 where x is
+ // a set of flags, and the addition 112 bits make up
+ // the global address space
+
+ addrName = "FF08::0";
+ InetAddress addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 organization-local mutlicast address " + addrName
+ + " not detected.", addr.isMCOrgLocal());
+
+ addrName = "FF08:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 organization-local multicast address " + addrName
+ + " not detected.", addr.isMCOrgLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF8::0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 organization-local mutlicast address " + addrName
+ + " not detected.", addr.isMCOrgLocal());
+
+ // a currently invalid address as the prefix FFxE
+ // is only valid for x = {1,0} as the rest are reserved
+ addrName = "FFF8:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv6 organization-local multicast address " + addrName
+ + " not detected.", addr.isMCOrgLocal());
+
+ // a sample MC global address
+ addrName = "FF0E:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 global multicast address "
+ + addrName
+ + " incorrectly indicated as an organization-local mulitcast address.",
+ !addr.isMCOrgLocal());
+
+ // a sample MC site address
+ addrName = "FF05:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 site-local mulitcast address "
+ + addrName
+ + " incorrectly indicated as an organization-local mulitcast address.",
+ !addr.isMCOrgLocal());
+
+ // a sample MC link address
+ addrName = "FF02:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 link-local multicast address "
+ + addrName
+ + " incorrectly indicated as an organization-local mulitcast address.",
+ !addr.isMCOrgLocal());
+
+ // a sample MC Node
+ addrName = "FF01:42:42:42:42:42:42:42";
+ addr = InetAddress.getByName(addrName);
+ assertTrue(
+ "IPv6 mulitcast node address "
+ + addrName
+ + " incorrectly indicated as an organization-local mulitcast address.",
+ !addr.isMCOrgLocal());
+
+ // IPv4-mapped IPv6 addresses
+
+ addrName = "::FFFF:239.192.0.0";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 org-local multicast address " + addrName
+ + " not identified as a org-local multicast address.", addr
+ .isMCOrgLocal());
+
+ addrName = "::FFFF:239.195.255.255";
+ addr = InetAddress.getByName(addrName);
+ assertTrue("IPv4 org-local multicast address " + addrName
+ + " not identified as a org-local multicast address.", addr
+ .isMCOrgLocal());
}
/**
* @tests java.net.Inet6Address#isIPv4CompatibleAddress()
*/
- public void test_isIPv4CompatibleAddress() {
+ public void test_isIPv4CompatibleAddress() throws Exception {
String addrName = "";
Inet6Address addr = null;
- try {
-
- // Tests a number of addresses to see if they are compatable with
- // IPv6 addresses
+ // Tests a number of addresses to see if they are compatable with
+ // IPv6 addresses
- addrName = "FFFF::42:42"; // 11111111 = FFFF
- addr = (Inet6Address) InetAddress.getByName(addrName);
- assertTrue("A non-compatable IPv6 address " + addrName
- + " incorrectly identified as a IPv4 compatable address.",
- !addr.isIPv4CompatibleAddress());
-
- // IPv4-compatible IPv6 address tests
- //
- // Now create 2 IP v6 addresses that are IP v4 compatable
- // to IP v6 addresses.
-
- addrName = "::0.0.0.0";
- addr = (Inet6Address) InetAddress.getByName(addrName);
- assertTrue("IPv4 compatable address " + addrName
- + " not detected correctly.", addr
- .isIPv4CompatibleAddress());
-
- addrName = "::255.255.255.255"; // an ipv4 non-multicast address
- addr = (Inet6Address) InetAddress.getByName(addrName);
- assertTrue("IPv4 compatable address " + addrName
- + " not detected correctly.", addr
- .isIPv4CompatibleAddress());
-
- } catch (Exception e) {
- e.printStackTrace();
- fail("Unknown address : " + addrName);
- }
+ addrName = "FFFF::42:42"; // 11111111 = FFFF
+ addr = (Inet6Address) InetAddress.getByName(addrName);
+ assertTrue("A non-compatable IPv6 address " + addrName
+ + " incorrectly identified as a IPv4 compatable address.",
+ !addr.isIPv4CompatibleAddress());
+
+ // IPv4-compatible IPv6 address tests
+ //
+ // Now create 2 IP v6 addresses that are IP v4 compatable
+ // to IP v6 addresses.
+
+ addrName = "::0.0.0.0";
+ addr = (Inet6Address) InetAddress.getByName(addrName);
+ assertTrue("IPv4 compatable address " + addrName
+ + " not detected correctly.", addr
+ .isIPv4CompatibleAddress());
+
+ addrName = "::255.255.255.255"; // an ipv4 non-multicast address
+ addr = (Inet6Address) InetAddress.getByName(addrName);
+ assertTrue("IPv4 compatable address " + addrName
+ + " not detected correctly.", addr
+ .isIPv4CompatibleAddress());
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.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/InetAddressTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/InetAddressTest.java Wed Oct 31 01:42:07 2007
@@ -133,18 +133,14 @@
/**
* @tests java.net.InetAddress#equals(java.lang.Object)
*/
- public void test_equalsLjava_lang_Object() {
+ public void test_equalsLjava_lang_Object() throws Exception {
// Test for method boolean java.net.InetAddress.equals(java.lang.Object)
- try {
- InetAddress ia1 = InetAddress
- .getByName(Support_Configuration.InetTestAddress);
- InetAddress ia2 = InetAddress
- .getByName(Support_Configuration.InetTestIP);
- assertTrue("Equals returned incorrect result - " + ia1 + " != "
- + ia2, ia1.equals(ia2));
- } catch (Exception e) {
- fail("Exception during equals test : " + e.getMessage());
- }
+ InetAddress ia1 = InetAddress
+ .getByName(Support_Configuration.InetTestAddress);
+ InetAddress ia2 = InetAddress
+ .getByName(Support_Configuration.InetTestIP);
+ assertTrue("Equals returned incorrect result - " + ia1 + " != "
+ + ia2, ia1.equals(ia2));
}
/**
@@ -196,8 +192,6 @@
InetAddress.getByName("3d.com");
} catch (SecurityException ex) {
exception = true;
- } catch (Exception ex) {
- fail("getByName threw wrong exception : " + ex.getMessage());
}
assertTrue("expected SecurityException", exception);
} finally {
@@ -249,19 +243,15 @@
/**
* @tests java.net.InetAddress#getHostAddress()
*/
- public void test_getHostAddress() {
+ public void test_getHostAddress() throws Exception {
// Test for method java.lang.String
// java.net.InetAddress.getHostAddress()
- try {
- InetAddress ia2 = InetAddress
- .getByName(Support_Configuration.InetTestAddress);
- assertTrue("getHostAddress returned incorrect result: "
- + ia2.getHostAddress() + " != "
- + Support_Configuration.InetTestIP, ia2.getHostAddress()
- .equals(Support_Configuration.InetTestIP));
- } catch (Exception e) {
- fail("Exception during getHostAddress test : " + e.getMessage());
- }
+ InetAddress ia2 = InetAddress
+ .getByName(Support_Configuration.InetTestAddress);
+ assertTrue("getHostAddress returned incorrect result: "
+ + ia2.getHostAddress() + " != "
+ + Support_Configuration.InetTestIP, ia2.getHostAddress()
+ .equals(Support_Configuration.InetTestIP));
}
/**
@@ -359,20 +349,17 @@
/**
* @tests java.net.InetAddress#getLocalHost()
*/
- public void test_getLocalHost() {
+ public void test_getLocalHost() throws Exception {
// Test for method java.net.InetAddress
// java.net.InetAddress.getLocalHost()
- try {
- // We don't know the host name or ip of the machine
- // running the test, so we can't build our own address
- DatagramSocket dg = new DatagramSocket(0, InetAddress
- .getLocalHost());
- assertTrue("Incorrect host returned", InetAddress.getLocalHost()
- .equals(dg.getLocalAddress()));
- dg.close();
- } catch (Exception e) {
- fail("Exception during getLocalHost test : " + e.getMessage());
- }
+
+ // We don't know the host name or ip of the machine
+ // running the test, so we can't build our own address
+ DatagramSocket dg = new DatagramSocket(0, InetAddress
+ .getLocalHost());
+ assertTrue("Incorrect host returned", InetAddress.getLocalHost()
+ .equals(dg.getLocalAddress()));
+ dg.close();
}
/**
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=590591&r1=590590&r2=590591&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 Oct 31 01:42:07 2007
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.harmony.luni.tests.java.util;
import java.util.ArrayList;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -126,10 +126,7 @@
fail("Expected test to throw IOE.");
} catch (IOException ex) {
// expected
- } catch (Throwable ex) {
- fail("Expected test to throw IOE not "
- + ex.getClass().getName());
- }
+ }
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedReaderTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedReaderTest.java Wed Oct 31 01:42:07 2007
@@ -61,8 +61,6 @@
fail("Read on closed stream");
} catch (IOException x) {
return;
- } catch (Exception e) {
- fail("Exception during close test " + e.toString());
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedWriterTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/BufferedWriterTest.java Wed Oct 31 01:42:07 2007
@@ -111,51 +111,39 @@
/**
* @tests java.io.BufferedWriter#flush()
*/
- public void test_flush() {
+ public void test_flush() throws Exception {
// Test for method void java.io.BufferedWriter.flush()
- try {
- bw.write("This should not cause a flush");
- assertTrue("Bytes written without flush", sw.toString().equals(""));
- bw.flush();
- assertEquals("Bytes not flushed",
- "This should not cause a flush", sw.toString());
- } catch (Exception e) {
- fail("Exception during flush test");
- }
+ bw.write("This should not cause a flush");
+ assertTrue("Bytes written without flush", sw.toString().equals(""));
+ bw.flush();
+ assertEquals("Bytes not flushed",
+ "This should not cause a flush", sw.toString());
}
/**
* @tests java.io.BufferedWriter#newLine()
*/
- public void test_newLine() {
+ public void test_newLine() throws Exception {
// Test for method void java.io.BufferedWriter.newLine()
- try {
- String separator = System.getProperty("line.separator");
- bw.write("Hello");
- bw.newLine();
- bw.write("World");
- bw.flush();
- assertTrue("Incorrect string written: " + sw.toString(), sw
- .toString().equals("Hello" + separator + "World"));
- } catch (Exception e) {
- fail("Exception during write test");
- }
+ String separator = System.getProperty("line.separator");
+ bw.write("Hello");
+ bw.newLine();
+ bw.write("World");
+ bw.flush();
+ assertTrue("Incorrect string written: " + sw.toString(), sw
+ .toString().equals("Hello" + separator + "World"));
}
/**
* @tests java.io.BufferedWriter#write(char[], int, int)
*/
- public void test_write$CII() {
+ public void test_write$CII() throws Exception {
// Test for method void java.io.BufferedWriter.write(char [], int, int)
- try {
- char[] testCharArray = testString.toCharArray();
- bw.write(testCharArray, 500, 1000);
- bw.flush();
- assertTrue("Incorrect string written", sw.toString().equals(
- testString.substring(500, 1500)));
- } catch (Exception e) {
- fail("Exception during write test");
- }
+ char[] testCharArray = testString.toCharArray();
+ bw.write(testCharArray, 500, 1000);
+ bw.flush();
+ assertTrue("Incorrect string written", sw.toString().equals(
+ testString.substring(500, 1500)));
}
/**
@@ -219,32 +207,24 @@
/**
* @tests java.io.BufferedWriter#write(int)
*/
- public void test_writeI() {
+ public void test_writeI() throws Exception {
// Test for method void java.io.BufferedWriter.write(int)
- try {
- bw.write('T');
- assertTrue("Char written without flush", sw.toString().equals(""));
- bw.flush();
- assertEquals("Incorrect char written", "T", sw.toString());
- } catch (Exception e) {
- fail("Exception during write test");
- }
+ bw.write('T');
+ assertTrue("Char written without flush", sw.toString().equals(""));
+ bw.flush();
+ assertEquals("Incorrect char written", "T", sw.toString());
}
/**
* @tests java.io.BufferedWriter#write(java.lang.String, int, int)
*/
- public void test_writeLjava_lang_StringII() {
+ public void test_writeLjava_lang_StringII() throws Exception {
// Test for method void java.io.BufferedWriter.write(java.lang.String,
// int, int)
- try {
- bw.write(testString);
- bw.flush();
- assertTrue("Incorrect string written", sw.toString().equals(
- testString));
- } catch (Exception e) {
- fail("Exception during write test");
- }
+ bw.write(testString);
+ bw.flush();
+ assertTrue("Incorrect string written", sw.toString().equals(
+ testString));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ByteArrayInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ByteArrayInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ByteArrayInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ByteArrayInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -29,18 +29,13 @@
/**
* @tests java.io.ByteArrayInputStream#ByteArrayInputStream(byte[])
*/
- public void test_Constructor$B() {
+ public void test_Constructor$B() throws Exception {
// Test for method java.io.ByteArrayInputStream(byte [])
-
java.io.InputStream bis = new java.io.ByteArrayInputStream(fileString
.getBytes());
- try {
- assertTrue("Unable to create ByteArrayInputStream",
- bis.available() == fileString.length());
- } catch (Exception e) {
- System.out.println("Exception during Constructor test");
- }
+ assertTrue("Unable to create ByteArrayInputStream",
+ bis.available() == fileString.length());
}
/**
@@ -54,12 +49,8 @@
byte[] zz = fileString.getBytes();
java.io.InputStream bis = new java.io.ByteArrayInputStream(zz, 0, 100);
- try {
- assertEquals("Unable to create ByteArrayInputStream",
- 100, bis.available());
- } catch (Exception e) {
- fail("Exception during Constructor test");
- }
+ assertEquals("Unable to create ByteArrayInputStream",
+ 100, bis.available());
// Regression test for Harmony-2405
new SubByteArrayInputStream(new byte[] { 1, 2 }, 444, 13);
@@ -86,14 +77,10 @@
/**
* @tests java.io.ByteArrayInputStream#available()
*/
- public void test_available() {
+ public void test_available() throws Exception {
// Test for method int java.io.ByteArrayInputStream.available()
- try {
- assertTrue("Returned incorrect number of available bytes", is
- .available() == fileString.length());
- } catch (Exception e) {
- fail("Exception during available test");
- }
+ assertTrue("Returned incorrect number of available bytes", is
+ .available() == fileString.length());
}
/**
@@ -121,24 +108,18 @@
/**
* @tests java.io.ByteArrayInputStream#mark(int)
*/
- public void test_markI() {
+ public void test_markI() throws Exception {
// Test for method void java.io.ByteArrayInputStream.mark(int)
byte[] buf1 = new byte[100];
byte[] buf2 = new byte[100];
- try {
- is.skip(3000);
- is.mark(1000);
- is.read(buf1, 0, buf1.length);
- is.reset();
- is.read(buf2, 0, buf2.length);
- is.reset();
- assertTrue("Failed to mark correct position", new String(buf1, 0,
- buf1.length).equals(new String(buf2, 0, buf2.length)));
-
- } catch (Exception e) {
- fail("Exception during mark test");
- }
-
+ is.skip(3000);
+ is.mark(1000);
+ is.read(buf1, 0, buf1.length);
+ is.reset();
+ is.read(buf2, 0, buf2.length);
+ is.reset();
+ assertTrue("Failed to mark correct position", new String(buf1, 0,
+ buf1.length).equals(new String(buf2, 0, buf2.length)));
}
/**
@@ -152,72 +133,54 @@
/**
* @tests java.io.ByteArrayInputStream#read()
*/
- public void test_read() {
+ public void test_read() throws Exception {
// Test for method int java.io.ByteArrayInputStream.read()
- try {
-
- int c = is.read();
- is.reset();
- assertTrue("read returned incorrect char", c == fileString
- .charAt(0));
- } catch (Exception e) {
- fail("Exception during read test");
- }
+ int c = is.read();
+ is.reset();
+ assertTrue("read returned incorrect char", c == fileString
+ .charAt(0));
}
/**
* @tests java.io.ByteArrayInputStream#read(byte[], int, int)
*/
- public void test_read$BII() {
+ public void test_read$BII() throws Exception {
// Test for method int java.io.ByteArrayInputStream.read(byte [], int,
// int)
byte[] buf1 = new byte[20];
- try {
- is.skip(50);
- is.mark(100);
- is.read(buf1, 0, buf1.length);
- assertTrue("Failed to read correct data", new String(buf1, 0,
- buf1.length).equals(fileString.substring(50, 70)));
-
- } catch (Exception e) {
- fail("Exception during read test: " + e);
- }
+ is.skip(50);
+ is.mark(100);
+ is.read(buf1, 0, buf1.length);
+ assertTrue("Failed to read correct data", new String(buf1, 0,
+ buf1.length).equals(fileString.substring(50, 70)));
}
/**
* @tests java.io.ByteArrayInputStream#reset()
*/
- public void test_reset() {
+ public void test_reset() throws Exception {
// Test for method void java.io.ByteArrayInputStream.reset()
byte[] buf1 = new byte[10];
byte[] buf2 = new byte[10];
- try {
- is.mark(200);
- is.read(buf1, 0, 10);
- is.reset();
- is.read(buf2, 0, 10);
- is.reset();
- assertTrue("Reset failed", new String(buf1, 0, buf1.length)
- .equals(new String(buf2, 0, buf2.length)));
- } catch (Exception e) {
- fail("Exception during reset test : " + e.getMessage());
- }
+ is.mark(200);
+ is.read(buf1, 0, 10);
+ is.reset();
+ is.read(buf2, 0, 10);
+ is.reset();
+ assertTrue("Reset failed", new String(buf1, 0, buf1.length)
+ .equals(new String(buf2, 0, buf2.length)));
}
/**
* @tests java.io.ByteArrayInputStream#skip(long)
*/
- public void test_skipJ() {
+ public void test_skipJ() throws Exception {
// Test for method long java.io.ByteArrayInputStream.skip(long)
byte[] buf1 = new byte[10];
- try {
- is.skip(100);
- is.read(buf1, 0, buf1.length);
- assertTrue("Failed to skip to correct position", new String(buf1,
- 0, buf1.length).equals(fileString.substring(100, 110)));
- } catch (Exception e) {
- fail("Exception during skip test : " + e.getMessage());
- }
+ is.skip(100);
+ is.read(buf1, 0, buf1.length);
+ assertTrue("Failed to skip to correct position", new String(buf1,
+ 0, buf1.length).equals(fileString.substring(100, 110)));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -519,52 +519,40 @@
/**
* @tests java.io.DataInputStream#readUnsignedShort()
*/
- public void test_readUnsignedShort() {
+ public void test_readUnsignedShort() throws Exception {
// Test for method int java.io.DataInputStream.readUnsignedShort()
- try {
- os.writeShort(9875);
- os.close();
- openDataInputStream();
- assertEquals("Incorrect short read", 9875, dis.readUnsignedShort());
- } catch (IOException e) {
- fail("Exception during readShort test : " + e.getMessage());
- }
+ os.writeShort(9875);
+ os.close();
+ openDataInputStream();
+ assertEquals("Incorrect short read", 9875, dis.readUnsignedShort());
}
/**
* @tests java.io.DataInputStream#readUTF()
*/
- public void test_readUTF() {
+ public void test_readUTF() throws Exception {
// Test for method java.lang.String java.io.DataInputStream.readUTF()
- try {
- os.writeUTF(unihw);
- os.close();
- openDataInputStream();
- assertTrue("Failed to write string in UTF format",
- dis.available() == unihw.length() + 2);
- assertTrue("Incorrect string read", dis.readUTF().equals(unihw));
- } catch (Exception e) {
- fail("Exception during readUTF : " + e.getMessage());
- }
+ os.writeUTF(unihw);
+ os.close();
+ openDataInputStream();
+ assertTrue("Failed to write string in UTF format",
+ dis.available() == unihw.length() + 2);
+ assertTrue("Incorrect string read", dis.readUTF().equals(unihw));
}
/**
* @tests java.io.DataInputStream#readUTF(java.io.DataInput)
*/
- public void test_readUTFLjava_io_DataInput() {
+ public void test_readUTFLjava_io_DataInput() throws Exception {
// Test for method java.lang.String
// java.io.DataInputStream.readUTF(java.io.DataInput)
- try {
- os.writeUTF(unihw);
- os.close();
- openDataInputStream();
- assertTrue("Failed to write string in UTF format",
- dis.available() == unihw.length() + 2);
- assertTrue("Incorrect string read", DataInputStream.readUTF(dis)
- .equals(unihw));
- } catch (Exception e) {
- fail("Exception during readUTF : " + e.getMessage());
- }
+ os.writeUTF(unihw);
+ os.close();
+ openDataInputStream();
+ assertTrue("Failed to write string in UTF format",
+ dis.available() == unihw.length() + 2);
+ assertTrue("Incorrect string read", DataInputStream.readUTF(dis)
+ .equals(unihw));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataOutputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/DataOutputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -298,19 +298,15 @@
/**
* @tests java.io.DataOutputStream#writeUTF(java.lang.String)
*/
- public void test_writeUTFLjava_lang_String() {
+ public void test_writeUTFLjava_lang_String() throws Exception {
// Test for method void
// java.io.DataOutputStream.writeUTF(java.lang.String)
- try {
- os.writeUTF(unihw);
- os.close();
- openDataInputStream();
- assertTrue("Failed to write string in UTF format",
- dis.available() == unihw.length() + 2);
- assertTrue("Incorrect string returned", dis.readUTF().equals(unihw));
- } catch (Exception e) {
- fail("Exception during writeUTF" + e.getMessage());
- }
+ os.writeUTF(unihw);
+ os.close();
+ openDataInputStream();
+ assertTrue("Failed to write string in UTF format",
+ dis.available() == unihw.length() + 2);
+ assertTrue("Incorrect string returned", dis.readUTF().equals(unihw));
}
private void openDataInputStream() throws IOException {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/EOFExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/EOFExceptionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/EOFExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/EOFExceptionTest.java Wed Oct 31 01:42:07 2007
@@ -26,33 +26,29 @@
/**
* @tests java.io.EOFException#EOFException()
*/
- public void test_Constructor() {
+ public void test_Constructor() throws Exception {
// Test for method java.io.EOFException()
try {
new DataInputStream(new ByteArrayInputStream(new byte[1]))
.readShort();
} catch (EOFException e) {
return;
- } catch (Exception e) {
- fail("Exception during EOFException test" + e.toString());
}
- fail("Failed to generate exception");
+ fail("Failed to generate EOFException");
}
/**
* @tests java.io.EOFException#EOFException(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.EOFException(java.lang.String)
try {
new DataInputStream(new ByteArrayInputStream(new byte[1]))
.readShort();
} catch (EOFException e) {
return;
- } catch (Exception e) {
- fail("Exception during EOFException test" + e.toString());
}
- fail("Failed to generate exception");
+ fail("Failed to generate EOFException");
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileDescriptorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileDescriptorTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileDescriptorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileDescriptorTest.java Wed Oct 31 01:42:07 2007
@@ -78,21 +78,16 @@
/**
* @tests java.io.FileDescriptor#valid()
*/
- public void test_valid() {
+ public void test_valid() throws Exception {
// Test for method boolean java.io.FileDescriptor.valid()
- try {
- f = new File(System.getProperty("user.dir"), "fd.tst");
- f.delete();
- os = new BufferedOutputStream(fos = new FileOutputStream(f
- .getPath()), 4096);
- FileDescriptor fd = fos.getFD();
- assertTrue("Valid fd returned false", fd.valid());
- os.close();
- assertTrue("Invalid fd returned true", !fd.valid());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
-
+ f = new File(System.getProperty("user.dir"), "fd.tst");
+ f.delete();
+ os = new BufferedOutputStream(fos = new FileOutputStream(f
+ .getPath()), 4096);
+ FileDescriptor fd = fos.getFD();
+ assertTrue("Valid fd returned false", fd.valid());
+ os.close();
+ assertTrue("Invalid fd returned true", !fd.valid());
}
/**