You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/06/23 12:09:40 UTC
svn commit: r416658 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni: build.xml
src/test/java/tests/api/java/net/InetAddressTest.java
Author: gharley
Date: Fri Jun 23 03:09:34 2006
New Revision: 416658
URL: http://svn.apache.org/viewvc?rev=416658&view=rev
Log:
Tentative return of InetAddressTest.java to the net tests. May well get excluded if Linux failures seen again.
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml?rev=416658&r1=416657&r2=416658&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/build.xml Fri Jun 23 03:09:34 2006
@@ -220,8 +220,7 @@
<exclude name="tests/api/java/net/URLClassLoaderTest.java" />
<exclude name="tests/api/java/net/URLConnectionTest.java" />
<exclude name="tests/api/java/net/URLTest.java" />
- <exclude name="tests/api/java/net/ServerSocketTest.java" />
- <exclude name="tests/api/java/net/InetAddressTest.java" />
+ <exclude name="tests/api/java/net/SocketPermissionTest.java" />
</fileset>
</batchtest>
</junit>
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java?rev=416658&r1=416657&r2=416658&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/InetAddressTest.java Fri Jun 23 03:09:34 2006
@@ -155,60 +155,54 @@
/**
* @tests java.net.InetAddress#getAllByName(java.lang.String)
*/
- public void test_getAllByNameLjava_lang_String() {
+ public void test_getAllByNameLjava_lang_String() throws Exception {
// Test for method java.net.InetAddress []
- // java.net.InetAddress.getAllByName(java.lang.String)
-
- try {
- InetAddress[] ia = InetAddress
- .getAllByName(Support_Configuration.SpecialInetTestAddress);
- assertTrue(
- "Incorrect number of aliases returned: "
- + ia.length
- + " should be "
- + Support_Configuration.SpecialInetTestAddressNumber,
- ia.length == Support_Configuration.SpecialInetTestAddressNumber);
- } catch (Exception e) {
- fail("Exception during getAllByName : " + e.getMessage());
- }
-
- // check the getByName if there is a security manager.
+ // java.net.InetAddress.getAllByName(java.lang.String)
+ InetAddress[] all = InetAddress
+ .getAllByName(Support_Configuration.SpecialInetTestAddress);
+ assertNotNull(all);
+ // Number of aliases depends on individual test machine
+ assertTrue(all.length >= 1);
+ for (InetAddress alias : all) {
+ // Check that each alias has the same hostname. Intentionally not
+ // checking for exact string match.
+ assertTrue(alias.getHostName().startsWith(
+ Support_Configuration.SpecialInetTestAddress));
+ }// end for all aliases
+
+ // check the getByName if there is a security manager.
SecurityManager oldman = System.getSecurityManager();
- System.setSecurityManager(new MockSecurityManager());
- try {
- boolean exception = false;
- try {
- InetAddress.getByName("3d.com");
- } catch (SecurityException ex) {
- exception = true;
- } catch (Exception ex) {
- fail("getByName threw wrong exception : " + ex.getMessage());
- }
- assertTrue("expected SecurityException", exception);
- } finally {
- System.setSecurityManager(oldman);
- }
+ System.setSecurityManager(new MockSecurityManager());
+ try {
+ boolean exception = false;
+ try {
+ InetAddress.getByName("3d.com");
+ } catch (SecurityException ex) {
+ exception = true;
+ } catch (Exception ex) {
+ fail("getByName threw wrong exception : " + ex.getMessage());
+ }
+ assertTrue("expected SecurityException", exception);
+ } finally {
+ System.setSecurityManager(oldman);
+ }
}
/**
* @tests java.net.InetAddress#getByName(java.lang.String)
*/
- public void test_getByNameLjava_lang_String() {
- // Test for method java.net.InetAddress
- // java.net.InetAddress.getByName(java.lang.String)
- try {
- InetAddress ia2 = InetAddress
- .getByName(Support_Configuration.InetTestIP);
- assertTrue("Equals returned incorrect result: " + ia2.getHostName()
- + " != " + Support_Configuration.InetTestAddress, ia2
- .getHostName()
- .equals(Support_Configuration.InetTestAddress));
- } catch (Exception e) {
- fail("Exception during equals test : " + e.getMessage());
- }
+ public void test_getByNameLjava_lang_String() throws Exception {
+ // Test for method java.net.InetAddress
+ // java.net.InetAddress.getByName(java.lang.String)
+ InetAddress ia2 = InetAddress
+ .getByName(Support_Configuration.InetTestIP);
+
+ // Intentionally not testing for exact string match
+ assertTrue(ia2.getHostName().startsWith(
+ Support_Configuration.InetTestAddress));
- // TODO : Test to ensure all the address formats are recognized
- }
+ // TODO : Test to ensure all the address formats are recognized
+ }
/**
* @tests java.net.InetAddress#getHostAddress()
@@ -235,9 +229,10 @@
// Test for method java.lang.String java.net.InetAddress.getHostName()
InetAddress ia = InetAddress
.getByName(Support_Configuration.InetTestIP);
- assertTrue("Incorrect host name returned: " + ia.getHostName() + " != "
- + Support_Configuration.InetTestAddress, ia.getHostName()
- .equals(Support_Configuration.InetTestAddress));
+
+ // Intentionally not testing for exact string match
+ assertTrue(ia.getHostName().startsWith(
+ Support_Configuration.InetTestAddress));
// Test for any of the host lookups, where the default SecurityManager
// is installed.
@@ -398,36 +393,22 @@
/**
* @tests java.net.InetAddress#getCanonicalHostName()
*/
- public void test_getCanonicalHostName() {
-
- try {
- InetAddress theAddress = null;
- theAddress = InetAddress.getLocalHost();
- assertTrue("getCanonicalHostName returned a zero length string ",
- theAddress.getCanonicalHostName().length() != 0);
- assertTrue("getCanonicalHostName returned an empty string ",
- !theAddress.equals(""));
- } catch (Exception e) {
- fail("Unexcepted exception testing getCanonicalHostName:"
- + e.toString());
- }
- ;
+ public void test_getCanonicalHostName() throws Exception {
+ InetAddress theAddress = null;
+ theAddress = InetAddress.getLocalHost();
+ assertTrue("getCanonicalHostName returned a zero length string ",
+ theAddress.getCanonicalHostName().length() != 0);
+ assertTrue("getCanonicalHostName returned an empty string ",
+ !theAddress.equals(""));
- // test against an expected value
- try {
- InetAddress ia = InetAddress
- .getByName(Support_Configuration.InetTestIP);
- assertTrue("Incorrect host name returned by getCanonicalHostHame: "
- + ia.getCanonicalHostName() + " != "
- + Support_Configuration.InetTestAddress, ia.getHostName()
- .equals(Support_Configuration.InetTestAddress));
- } catch (Exception e) {
- fail(
- "Exception during getCanonicalHostName - InetAddress.getByName: "
- + e);
- }
-
- }
+ // test against an expected value
+ InetAddress ia = InetAddress
+ .getByName(Support_Configuration.InetTestIP);
+
+ // Intentionally not testing for exact string match
+ assertTrue(ia.getCanonicalHostName().startsWith(
+ Support_Configuration.InetTestAddress));
+ }
/**
* @tests java.net.InetAddress#isReachableI