You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/02/07 17:40:30 UTC

svn commit: r619493 [7/7] - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java?rev=619493&r1=619492&r2=619493&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownHostExceptionTest.java Thu Feb  7 08:40:26 2008
@@ -17,45 +17,52 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-public class UnknownHostExceptionTest extends junit.framework.TestCase {
+import java.net.UnknownHostException;
 
-	/**
-	 * @tests java.net.UnknownHostException#UnknownHostException()
-	 */
-	public void test_Constructor() {
-		// Test for method java.net.UnknownHostException()
-                try {
-                        java.net.InetAddress.getByName("a.b.c.x.y.z.com");
-                } catch (java.net.UnknownHostException e) {
-                        return;
-                }
-                fail("Failed to generate Exception");
-	}
-
-	/**
-	 * @tests java.net.UnknownHostException#UnknownHostException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.net.UnknownHostException(java.lang.String)
-                try {
-                        java.net.InetAddress.getByName("a.b.c.x.y.z.com");
-                } catch (java.net.UnknownHostException e) {
-                        return;
-                }
-                fail("Failed to generate Exception");
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+import junit.framework.TestCase;
+
+public class UnknownHostExceptionTest extends TestCase {
+
+    /**
+     * @tests java.net.UnknownHostException#UnknownHostException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new UnknownHostException();
+            }
+            fail("Failed to generate Exception");
+        } catch (UnknownHostException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.net.UnknownHostException#UnknownHostException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        try {
+            if (true) {
+                throw new UnknownHostException("test");
+            }
+            fail("Failed to generate Exception");
+        } catch (UnknownHostException e) {
+            assertEquals("Threw exception with incorrect message", "test", e
+                    .getMessage());
+        }
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
+    protected void setUp() {
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    protected void tearDown() {
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java?rev=619493&r1=619492&r2=619493&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/UnknownServiceExceptionTest.java Thu Feb  7 08:40:26 2008
@@ -17,53 +17,51 @@
 
 package org.apache.harmony.luni.tests.java.net;
 
-import java.net.URL;
 import java.net.UnknownServiceException;
 
-public class UnknownServiceExceptionTest extends junit.framework.TestCase {
+import junit.framework.TestCase;
 
-	/**
-	 * @tests java.net.UnknownServiceException#UnknownServiceException()
-	 */
-	public void test_Constructor() throws Exception {
-		// Test for method java.net.UnknownServiceException()
-		try {
-			new URL("file://moo.txt").openConnection().getOutputStream();
-		} catch (UnknownServiceException e) {
-			// correct
-			return;
-		} 
-
-		fail("Exception not thrown");
-	}
-
-	/**
-	 * @tests java.net.UnknownServiceException#UnknownServiceException(java.lang.String)
-	 */
-	public void test_ConstructorLjava_lang_String() {
-		// Test for method java.net.UnknownServiceException(java.lang.String)
-		try {
-			if (true)
-				throw new UnknownServiceException("HelloWorld");
-		} catch (UnknownServiceException e) {
-			assertTrue("Wrong exception message: " + e.toString(), e
-					.getMessage().equals("HelloWorld"));
-			return;
-		}
-		fail("Constructor failed");
-	}
-
-	/**
-	 * Sets up the fixture, for example, open a network connection. This method
-	 * is called before a test is executed.
-	 */
-	protected void setUp() {
-	}
-
-	/**
-	 * Tears down the fixture, for example, close a network connection. This
-	 * method is called after a test is executed.
-	 */
-	protected void tearDown() {
-	}
+public class UnknownServiceExceptionTest extends TestCase {
+
+    /**
+     * @tests java.net.UnknownServiceException#UnknownServiceException()
+     */
+    public void test_Constructor() {
+        try {
+            if (true) {
+                throw new UnknownServiceException();
+            }
+            fail("Exception not thrown");
+        } catch (UnknownServiceException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.net.UnknownServiceException#UnknownServiceException(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String() {
+        try {
+            if (true) {
+                throw new UnknownServiceException("test");
+            }
+            fail("Constructor failed");
+        } catch (UnknownServiceException e) {
+            assertEquals("Wrong exception message", "test", e.getMessage());
+        }
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection. This method
+     * is called before a test is executed.
+     */
+    protected void setUp() {
+    }
+
+    /**
+     * Tears down the fixture, for example, close a network connection. This
+     * method is called after a test is executed.
+     */
+    protected void tearDown() {
+    }
 }