harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r589692 [4/7] - in /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common: org/apache/harmony/luni/tests/java/lang/ org/apache/harmony/luni/tests/java/net/ tests/api/java/io/ tests/api/java/lang/ tests/api/java/lang/ref/ tests/ap...
Date Mon, 29 Oct 2007 15:45:46 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/FieldTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/FieldTest.java?rev=589692&r1=589691&r2=589692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/FieldTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/FieldTest.java Mon Oct 29 08:45:41 2007
@@ -83,25 +83,18 @@
 	/**
 	 * @tests java.lang.reflect.Field#equals(java.lang.Object)
 	 */
-	public void test_equalsLjava_lang_Object() {
+	public void test_equalsLjava_lang_Object() throws Exception {
 		// Test for method boolean
 		// java.lang.reflect.Field.equals(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
-		try {
-			f = x.getClass().getDeclaredField("shortField");
-		} catch (Exception e) {
-			fail("Exception during getType test : " + e.getMessage());
-		}
-		try {
-			assertTrue("Same Field returned false", f.equals(f));
-			assertTrue("Inherited Field returned false", f.equals(x.getClass()
-					.getDeclaredField("shortField")));
-			assertTrue("Identical Field from different class returned true", !f
-					.equals(A.class.getDeclaredField("shortField")));
-		} catch (Exception e) {
-			fail("Exception during getType test : " + e.getMessage());
-		}
+		f = x.getClass().getDeclaredField("shortField");
+
+                assertTrue("Same Field returned false", f.equals(f));
+                assertTrue("Inherited Field returned false", f.equals(x.getClass()
+                                .getDeclaredField("shortField")));
+                assertTrue("Identical Field from different class returned true", !f
+                                .equals(A.class.getDeclaredField("shortField")));
 	}
 
 	/**
@@ -463,96 +456,77 @@
 	/**
 	 * @tests java.lang.reflect.Field#getBoolean(java.lang.Object)
 	 */
-	public void test_getBooleanLjava_lang_Object() {
+	public void test_getBooleanLjava_lang_Object() throws Exception {
 		// Test for method boolean
 		// java.lang.reflect.Field.getBoolean(java.lang.Object)
 
 		TestField x = new TestField();
 		Field f = null;
 		boolean val = false;
-		try {
-			f = x.getClass().getDeclaredField("booleanField");
-			val = f.getBoolean(x);
+                f = x.getClass().getDeclaredField("booleanField");
+                val = f.getBoolean(x);
 
-		} catch (Exception e) {
-			fail("Exception during getBoolean test: " + e.toString());
-		}
-		assertTrue("Returned incorrect boolean field value", val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("doubleField");
-				f.getBoolean(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since doubleField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getBoolean test: " + e.toString());
-		}
+                assertTrue("Returned incorrect boolean field value", val);
+
+                try {
+                        f = x.getClass().getDeclaredField("doubleField");
+                        f.getBoolean(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since doubleField is not a
+                        // boolean type
+                        return;
+                }
 		fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getByte(java.lang.Object)
 	 */
-	public void test_getByteLjava_lang_Object() {
+	public void test_getByteLjava_lang_Object() throws Exception {
 		// Test for method byte
 		// java.lang.reflect.Field.getByte(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		byte val = 0;
-		try {
-			f = x.getClass().getDeclaredField("byteField");
-			val = f.getByte(x);
-		} catch (Exception e) {
-			fail("Exception during getbyte test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect byte field value", val == Byte.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getByte(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since byteField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getbyte test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("byteField");
+                val = f.getByte(x);
+
+                assertTrue("Returned incorrect byte field value", val == Byte.MAX_VALUE);
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getByte(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since byteField is not a
+                        // boolean type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getChar(java.lang.Object)
 	 */
-	public void test_getCharLjava_lang_Object() {
+	public void test_getCharLjava_lang_Object() throws Exception {
 		// Test for method char
 		// java.lang.reflect.Field.getChar(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		char val = 0;
-		try {
-			f = x.getClass().getDeclaredField("charField");
-			val = f.getChar(x);
-		} catch (Exception e) {
-			fail("Exception during getCharacter test: " + e.toString());
-		}
-		assertEquals("Returned incorrect char field value", 'T', val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getChar(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since charField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getchar test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("charField");
+                val = f.getChar(x);
+
+                assertEquals("Returned incorrect char field value", 'T', val);
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getChar(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since charField is not a
+                        // boolean type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
@@ -563,160 +537,130 @@
 		// java.lang.reflect.Field.getDeclaringClass()
 		Field[] fields;
 
-		try {
-			fields = new TestField().getClass().getFields();
-			assertTrue("Returned incorrect declaring class", fields[0]
-					.getDeclaringClass().equals(new TestField().getClass()));
-
-			// Check the case where the field is inherited to be sure the parent
-			// is returned as the declarator
-			fields = new TestFieldSub1().getClass().getFields();
-			assertTrue("Returned incorrect declaring class", fields[0]
-					.getDeclaringClass().equals(new TestField().getClass()));
-		} catch (Exception e) {
-			fail("Exception : " + e.getMessage());
-		}
+                fields = new TestField().getClass().getFields();
+                assertTrue("Returned incorrect declaring class", fields[0]
+                                .getDeclaringClass().equals(new TestField().getClass()));
+
+                // Check the case where the field is inherited to be sure the parent
+                // is returned as the declarator
+                fields = new TestFieldSub1().getClass().getFields();
+                assertTrue("Returned incorrect declaring class", fields[0]
+                                .getDeclaringClass().equals(new TestField().getClass()));
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getDouble(java.lang.Object)
 	 */
-	public void test_getDoubleLjava_lang_Object() {
+	public void test_getDoubleLjava_lang_Object() throws Exception {
 		// Test for method double
 		// java.lang.reflect.Field.getDouble(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		double val = 0.0;
-		try {
-			f = x.getClass().getDeclaredField("doubleField");
-			val = f.getDouble(x);
-		} catch (Exception e) {
-			fail("Exception during getDouble test: " + e.toString());
-		}
-		assertTrue("Returned incorrect double field value",
+                f = x.getClass().getDeclaredField("doubleField");
+                val = f.getDouble(x);
+
+                assertTrue("Returned incorrect double field value",
 				val == Double.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getDouble(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since doubleField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getDouble test: " + e.toString());
-		}
-		fail("Accessed field of invalid type");
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getDouble(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since doubleField is not a
+                        // boolean type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getFloat(java.lang.Object)
 	 */
-	public void test_getFloatLjava_lang_Object() {
+	public void test_getFloatLjava_lang_Object() throws Exception {
 		// Test for method float
 		// java.lang.reflect.Field.getFloat(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		float val = 0;
-		try {
-			f = x.getClass().getDeclaredField("floatField");
-			val = f.getFloat(x);
-		} catch (Exception e) {
-			fail("Exception during getFloat test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect float field value",
+                f = x.getClass().getDeclaredField("floatField");
+                val = f.getFloat(x);
+
+                assertTrue("Returned incorrect float field value",
 				val == Float.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getFloat(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since floatField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getfloat test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getFloat(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since floatField is not a
+                        // boolean type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getInt(java.lang.Object)
 	 */
-	public void test_getIntLjava_lang_Object() {
+	public void test_getIntLjava_lang_Object() throws Exception {
 		// Test for method int java.lang.reflect.Field.getInt(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		int val = 0;
-		try {
-			f = x.getClass().getDeclaredField("intField");
-			val = f.getInt(x);
-		} catch (Exception e) {
-			fail("Exception during getInt test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect Int field value",
+                f = x.getClass().getDeclaredField("intField");
+                val = f.getInt(x);
+
+                assertTrue("Returned incorrect Int field value",
 				val == Integer.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getInt(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since IntField is not a
-				// boolean type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getInt test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getInt(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since IntField is not a
+                        // boolean type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getLong(java.lang.Object)
 	 */
-	public void test_getLongLjava_lang_Object() {
+	public void test_getLongLjava_lang_Object() throws Exception {
 		// Test for method long
 		// java.lang.reflect.Field.getLong(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		long val = 0;
-		try {
-			f = x.getClass().getDeclaredField("longField");
-			val = f.getLong(x);
-		} catch (Exception e) {
-			fail("Exception during getLong test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect long field value", val == Long.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getLong(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// long type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getlong test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("longField");
+                val = f.getLong(x);
+
+                assertTrue("Returned incorrect long field value", val == Long.MAX_VALUE);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getLong(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // long type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getModifiers()
 	 */
-	public void test_getModifiers() {
+	public void test_getModifiers() throws Exception {
 		// Test for method int java.lang.reflect.Field.getModifiers()
 		TestField x = new TestField();
 		Field f = null;
-		try {
-			f = x.getClass().getDeclaredField("prsttrvol");
-		} catch (Exception e) {
-			fail("Exception during getModifiers test: " + e.toString());
-		}
-		int mod = f.getModifiers();
+		f = x.getClass().getDeclaredField("prsttrvol");
+
+                int mod = f.getModifiers();
 		int mask = (Modifier.PROTECTED | Modifier.STATIC)
 				| (Modifier.TRANSIENT | Modifier.VOLATILE);
 		int nmask = (Modifier.PUBLIC | Modifier.NATIVE);
@@ -727,450 +671,387 @@
 	/**
 	 * @tests java.lang.reflect.Field#getName()
 	 */
-	public void test_getName() {
+	public void test_getName() throws Exception {
 		// Test for method java.lang.String java.lang.reflect.Field.getName()
 		TestField x = new TestField();
 		Field f = null;
-		try {
-			f = x.getClass().getDeclaredField("shortField");
-		} catch (Exception e) {
-			fail("Exception during getType test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect field name", 
+		f = x.getClass().getDeclaredField("shortField");
+
+                assertEquals("Returned incorrect field name", 
 				"shortField", f.getName());
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getShort(java.lang.Object)
 	 */
-	public void test_getShortLjava_lang_Object() {
+	public void test_getShortLjava_lang_Object() throws Exception {
 		// Test for method short
 		// java.lang.reflect.Field.getShort(java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		short val = 0;
-		;
-		try {
-			f = x.getClass().getDeclaredField("shortField");
-			val = f.getShort(x);
-		} catch (Exception e) {
-			fail("Exception during getShort test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect short field value",
+
+                f = x.getClass().getDeclaredField("shortField");
+                val = f.getShort(x);
+
+                assertTrue("Returned incorrect short field value",
 				val == Short.MAX_VALUE);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.getShort(x);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// short type
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during getshort test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.getShort(x);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // short type
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#getType()
 	 */
-	public void test_getType() {
+	public void test_getType() throws Exception {
 		// Test for method java.lang.Class java.lang.reflect.Field.getType()
 		TestField x = new TestField();
 		Field f = null;
-		try {
-			f = x.getClass().getDeclaredField("shortField");
-		} catch (Exception e) {
-			fail("Exception during getType test : " + e.getMessage());
-		}
-		assertTrue("Returned incorrect field type: " + f.getType().toString(),
+		f = x.getClass().getDeclaredField("shortField");
+
+                assertTrue("Returned incorrect field type: " + f.getType().toString(),
 				f.getType().equals(short.class));
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#set(java.lang.Object, java.lang.Object)
 	 */
-	public void test_setLjava_lang_ObjectLjava_lang_Object() {
+	public void test_setLjava_lang_ObjectLjava_lang_Object() throws Exception {
 		// Test for method void java.lang.reflect.Field.set(java.lang.Object,
 		// java.lang.Object)
 		TestField x = new TestField();
 		Field f = null;
 		double val = 0.0;
-		try {
-			f = x.getClass().getDeclaredField("doubleField");
-			f.set(x, new Double(1.0));
-			val = f.getDouble(x);
-		} catch (Exception e) {
-			fail("Exception during set test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect double field value", 1.0, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.set(x, new Double(1.0));
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// double type
-				return;
-			}
-			try {
-				f = x.getClass().getDeclaredField("doubleFField");
-				f.set(x, new Double(1.0));
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since doubleFField is
-				// declared as final
-				return;
-			}
-			// Test setting a static field;
-			f = x.getClass().getDeclaredField("doubleSField");
-			f.set(x, new Double(1.0));
-			val = f.getDouble(x);
-			assertEquals("Returned incorrect double field value", 1.0, val);
-		} catch (Exception e) {
-			fail("Exception during setDouble test: " + e.toString());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("doubleField");
+                f.set(x, new Double(1.0));
+                val = f.getDouble(x);
+
+                assertEquals("Returned incorrect double field value", 1.0, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.set(x, new Double(1.0));
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // double type
+                        return;
+                }
+                try {
+                        f = x.getClass().getDeclaredField("doubleFField");
+                        f.set(x, new Double(1.0));
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since doubleFField is
+                        // declared as final
+                        return;
+                }
+                // Test setting a static field;
+                f = x.getClass().getDeclaredField("doubleSField");
+                f.set(x, new Double(1.0));
+                val = f.getDouble(x);
+                assertEquals("Returned incorrect double field value", 1.0, val);
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setBoolean(java.lang.Object, boolean)
 	 */
-	public void test_setBooleanLjava_lang_ObjectZ() {
+	public void test_setBooleanLjava_lang_ObjectZ() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setBoolean(java.lang.Object, boolean)
 		TestField x = new TestField();
 		Field f = null;
 		boolean val = false;
-		try {
-			f = x.getClass().getDeclaredField("booleanField");
-			f.setBoolean(x, false);
-			val = f.getBoolean(x);
-		} catch (Exception e) {
-			fail("Exception during setboolean test: " + e.toString());
-		}
-		assertTrue("Returned incorrect float field value", !val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setBoolean(x, true);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// boolean type
-				return;
-			}
+                f = x.getClass().getDeclaredField("booleanField");
+                f.setBoolean(x, false);
+                val = f.getBoolean(x);
+
+                assertTrue("Returned incorrect float field value", !val);
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setBoolean(x, true);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // boolean type
+                        return;
+                }
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanFField");
+                        f.setBoolean(x, true);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since booleanField is
+                        // declared as final
+                        return;
+                }
 
-			try {
-				f = x.getClass().getDeclaredField("booleanFField");
-				f.setBoolean(x, true);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since booleanField is
-				// declared as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setboolean test: " + e.toString());
-		}
-		fail("Accessed field of invalid type");
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setByte(java.lang.Object, byte)
 	 */
-	public void test_setByteLjava_lang_ObjectB() {
+	public void test_setByteLjava_lang_ObjectB() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setByte(java.lang.Object, byte)
 		TestField x = new TestField();
 		Field f = null;
 		byte val = 0;
-		try {
-			f = x.getClass().getDeclaredField("byteField");
-			f.setByte(x, (byte) 1);
-			val = f.getByte(x);
-		} catch (Exception e) {
-			fail("Exception during setByte test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect float field value", 1, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setByte(x, (byte) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// byte type
-				return;
-			}
+                f = x.getClass().getDeclaredField("byteField");
+                f.setByte(x, (byte) 1);
+                val = f.getByte(x);
+
+                assertEquals("Returned incorrect float field value", 1, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setByte(x, (byte) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // byte type
+                        return;
+                }
+
+                try {
+                        f = x.getClass().getDeclaredField("byteFField");
+                        f.setByte(x, (byte) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since byteFField is declared
+                        // as final
+                        return;
+                }
 
-			try {
-				f = x.getClass().getDeclaredField("byteFField");
-				f.setByte(x, (byte) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since byteFField is declared
-				// as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setByte test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setChar(java.lang.Object, char)
 	 */
-	public void test_setCharLjava_lang_ObjectC() {
+	public void test_setCharLjava_lang_ObjectC() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setChar(java.lang.Object, char)
 		TestField x = new TestField();
 		Field f = null;
 		char val = 0;
-		try {
-			f = x.getClass().getDeclaredField("charField");
-			f.setChar(x, (char) 1);
-			val = f.getChar(x);
-		} catch (Exception e) {
-			fail("Exception during setChar test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect float field value", 1, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setChar(x, (char) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// char type
-				return;
-			}
+                f = x.getClass().getDeclaredField("charField");
+                f.setChar(x, (char) 1);
+                val = f.getChar(x);
+
+                assertEquals("Returned incorrect float field value", 1, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setChar(x, (char) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // char type
+                        return;
+                }
+
+                try {
+                        f = x.getClass().getDeclaredField("charFField");
+                        f.setChar(x, (char) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since charFField is declared
+                        // as final
+                        return;
+                }
 
-			try {
-				f = x.getClass().getDeclaredField("charFField");
-				f.setChar(x, (char) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since charFField is declared
-				// as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setChar test : " + e.getMessage());
-		}
 		fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setDouble(java.lang.Object, double)
 	 */
-	public void test_setDoubleLjava_lang_ObjectD() {
+	public void test_setDoubleLjava_lang_ObjectD() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setDouble(java.lang.Object, double)
 		TestField x = new TestField();
 		Field f = null;
 		double val = 0.0;
-		try {
-			f = x.getClass().getDeclaredField("doubleField");
-			f.setDouble(x, 1.0);
-			val = f.getDouble(x);
-		} catch (Exception e) {
-			fail("Exception during setDouble test: " + e.toString());
-		}
-		assertEquals("Returned incorrect double field value", 1.0, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setDouble(x, 1.0);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// double type
-				return;
-			}
+                f = x.getClass().getDeclaredField("doubleField");
+                f.setDouble(x, 1.0);
+                val = f.getDouble(x);
+
+                assertEquals("Returned incorrect double field value", 1.0, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setDouble(x, 1.0);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // double type
+                        return;
+                }
+
+                try {
+                        f = x.getClass().getDeclaredField("doubleFField");
+                        f.setDouble(x, 1.0);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since doubleFField is
+                        // declared as final
+                        return;
+                }
 
-			try {
-				f = x.getClass().getDeclaredField("doubleFField");
-				f.setDouble(x, 1.0);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since doubleFField is
-				// declared as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setDouble test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setFloat(java.lang.Object, float)
 	 */
-	public void test_setFloatLjava_lang_ObjectF() {
+	public void test_setFloatLjava_lang_ObjectF() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setFloat(java.lang.Object, float)
 		TestField x = new TestField();
 		Field f = null;
 		float val = 0.0F;
-		try {
-			f = x.getClass().getDeclaredField("floatField");
-			f.setFloat(x, (float) 1);
-			val = f.getFloat(x);
-		} catch (Exception e) {
-			fail("Exception during setFloat test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect float field value", 1.0, val, 0.0);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setFloat(x, (float) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// float type
-				return;
-			}
-			try {
-				f = x.getClass().getDeclaredField("floatFField");
-				f.setFloat(x, (float) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since floatFField is
-				// declared as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setFloat test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("floatField");
+                f.setFloat(x, (float) 1);
+                val = f.getFloat(x);
+
+                assertEquals("Returned incorrect float field value", 1.0, val, 0.0);
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setFloat(x, (float) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // float type
+                        return;
+                }
+                try {
+                        f = x.getClass().getDeclaredField("floatFField");
+                        f.setFloat(x, (float) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since floatFField is
+                        // declared as final
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setInt(java.lang.Object, int)
 	 */
-	public void test_setIntLjava_lang_ObjectI() {
+	public void test_setIntLjava_lang_ObjectI() throws Exception {
 		// Test for method void java.lang.reflect.Field.setInt(java.lang.Object,
 		// int)
 		TestField x = new TestField();
 		Field f = null;
 		int val = 0;
-		try {
-			f = x.getClass().getDeclaredField("intField");
-			f.setInt(x, (int) 1);
-			val = f.getInt(x);
-		} catch (Exception e) {
-			fail("Exception during setInteger test: " + e.toString());
-		}
-		assertEquals("Returned incorrect int field value", 1, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setInt(x, (int) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// int type
-				return;
-			}
-			try {
-				f = x.getClass().getDeclaredField("intFField");
-				f.setInt(x, (int) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since intFField is declared
-				// as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setInteger test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("intField");
+                f.setInt(x, (int) 1);
+                val = f.getInt(x);
+
+                assertEquals("Returned incorrect int field value", 1, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setInt(x, (int) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // int type
+                        return;
+                }
+                try {
+                        f = x.getClass().getDeclaredField("intFField");
+                        f.setInt(x, (int) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since intFField is declared
+                        // as final
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setLong(java.lang.Object, long)
 	 */
-	public void test_setLongLjava_lang_ObjectJ() {
+	public void test_setLongLjava_lang_ObjectJ() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setLong(java.lang.Object, long)
 		TestField x = new TestField();
 		Field f = null;
 		long val = 0L;
-		try {
-			f = x.getClass().getDeclaredField("longField");
-			f.setLong(x, (long) 1);
-			val = f.getLong(x);
-		} catch (Exception e) {
-			fail("Exception during setLong test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect long field value", 1, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setLong(x, (long) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// long type
-				return;
-			}
-			try {
-				f = x.getClass().getDeclaredField("longFField");
-				f.setLong(x, (long) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since longFField is declared
-				// as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setLong test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("longField");
+                f.setLong(x, (long) 1);
+                val = f.getLong(x);
+
+                assertEquals("Returned incorrect long field value", 1, val);
+
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setLong(x, (long) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // long type
+                        return;
+                }
+                try {
+                        f = x.getClass().getDeclaredField("longFField");
+                        f.setLong(x, (long) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since longFField is declared
+                        // as final
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#setShort(java.lang.Object, short)
 	 */
-	public void test_setShortLjava_lang_ObjectS() {
+	public void test_setShortLjava_lang_ObjectS() throws Exception {
 		// Test for method void
 		// java.lang.reflect.Field.setShort(java.lang.Object, short)
 		TestField x = new TestField();
 		Field f = null;
 		short val = 0;
-		try {
-			f = x.getClass().getDeclaredField("shortField");
-			f.setShort(x, (short) 1);
-			val = f.getShort(x);
-		} catch (Exception e) {
-			fail("Exception during setShort test : " + e.getMessage());
-		}
-		assertEquals("Returned incorrect short field value", 1, val);
-		try {
-			try {
-				f = x.getClass().getDeclaredField("booleanField");
-				f.setShort(x, (short) 1);
-			} catch (IllegalArgumentException ex) {
-				// Good, Exception should be thrown since booleanField is not a
-				// short type
-				return;
-			}
-			try {
-				f = x.getClass().getDeclaredField("shortFField");
-				f.setShort(x, (short) 1);
-			} catch (IllegalAccessException ex) {
-				// Good, Exception should be thrown since shortFField is
-				// declared as final
-				return;
-			}
-		} catch (Exception e) {
-			fail("Exception during setShort test : " + e.getMessage());
-		}
-		fail("Accessed field of invalid type");
+                f = x.getClass().getDeclaredField("shortField");
+                f.setShort(x, (short) 1);
+                val = f.getShort(x);
+
+                assertEquals("Returned incorrect short field value", 1, val);
+                try {
+                        f = x.getClass().getDeclaredField("booleanField");
+                        f.setShort(x, (short) 1);
+                } catch (IllegalArgumentException ex) {
+                        // Good, Exception should be thrown since booleanField is not a
+                        // short type
+                        return;
+                }
+                try {
+                        f = x.getClass().getDeclaredField("shortFField");
+                        f.setShort(x, (short) 1);
+                } catch (IllegalAccessException ex) {
+                        // Good, Exception should be thrown since shortFField is
+                        // declared as final
+                        return;
+                }
+
+                fail("Accessed field of invalid type");
 	}
 
 	/**
 	 * @tests java.lang.reflect.Field#toString()
 	 */
-	public void test_toString() {
+	public void test_toString() throws Exception {
 		// Test for method java.lang.String java.lang.reflect.Field.toString()
 		Field f = null;
 
-		try {
-			f = TestField.class.getDeclaredField("x");
-		} catch (Exception e) {
-			fail("Exception getting field : " + e.getMessage());
-		}
-		assertEquals("Field returned incorrect string",
+		f = TestField.class.getDeclaredField("x");
+
+                assertEquals("Field returned incorrect string",
 				"private static final int tests.api.java.lang.reflect.FieldTest$TestField.x",
 						f.toString());
 	}

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/InvocationTargetExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/InvocationTargetExceptionTest.java?rev=589692&r1=589691&r2=589692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/InvocationTargetExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/InvocationTargetExceptionTest.java Mon Oct 29 08:45:41 2007
@@ -153,7 +153,7 @@
 	/**
 	 * @tests java.lang.reflect.InvocationTargetException#getTargetException()
 	 */
-	public void test_getTargetException() {
+	public void test_getTargetException() throws Exception {
 		// Test for method java.lang.Throwable
 		// java.lang.reflect.InvocationTargetException.getTargetException()
 		try {
@@ -166,9 +166,8 @@
 			assertTrue("Returned incorrect target exception", e
 					.getTargetException() instanceof NullPointerException);
 			return;
-		} catch (Exception e) {
-			fail("Exception during constructor test : " + e.getMessage());
-		}
+		} 
+
 		fail("Failed to throw exception");
 	}
 
@@ -178,22 +177,18 @@
 	public void test_printStackTrace() {
 		// Test for method void
 		// java.lang.reflect.InvocationTargetException.printStackTrace()
-		try {
-			ByteArrayOutputStream bao = new ByteArrayOutputStream();
-			PrintStream ps = new PrintStream(bao);
-			PrintStream oldErr = System.err;
-			System.setErr(ps);
-			InvocationTargetException ite = new InvocationTargetException(null);
-			ite.printStackTrace();
-			System.setErr(oldErr);
-
-			String s = new String(bao.toByteArray());
-
-			assertTrue("Incorrect Stack trace: " + s, s != null
-					&& s.length() > 300);
-		} catch (Exception e) {
-			fail("printStackTrace() caused exception : " + e.getMessage());
-		}
+                ByteArrayOutputStream bao = new ByteArrayOutputStream();
+                PrintStream ps = new PrintStream(bao);
+                PrintStream oldErr = System.err;
+                System.setErr(ps);
+                InvocationTargetException ite = new InvocationTargetException(null);
+                ite.printStackTrace();
+                System.setErr(oldErr);
+
+                String s = new String(bao.toByteArray());
+
+                assertTrue("Incorrect Stack trace: " + s, s != null
+                                && s.length() > 300);
 	}
 
 	/**
@@ -219,35 +214,30 @@
 	public void test_printStackTraceLjava_io_PrintWriter() {
 		// Test for method void
 		// java.lang.reflect.InvocationTargetException.printStackTrace(java.io.PrintWriter)
-		try {
-			PrintWriter pw;
-			InvocationTargetException ite;
-			String s;
-			CharArrayWriter caw = new CharArrayWriter();
-			pw = new PrintWriter(caw);
-			ite = new InvocationTargetException(new InvocationTargetException(
-					null));
-			ite.printStackTrace(pw);
-
-			s = caw.toString();
-			assertTrue("printStackTrace failed." + s.length(), s != null
-					&& s.length() > 400);
-			pw.close();
-
-			ByteArrayOutputStream bao = new ByteArrayOutputStream();
-			pw = new PrintWriter(bao);
-			ite = new InvocationTargetException(new InvocationTargetException(
-					null));
-			ite.printStackTrace(pw);
-
-			pw.flush(); // Test will fail if this line removed.
-			s = bao.toString();
-			assertTrue("printStackTrace failed." + s.length(), s != null
-					&& s.length() > 400);
-
-		} catch (Exception e) {
-			fail("Exception during test : " + e.getMessage());
-		}
+                PrintWriter pw;
+                InvocationTargetException ite;
+                String s;
+                CharArrayWriter caw = new CharArrayWriter();
+                pw = new PrintWriter(caw);
+                ite = new InvocationTargetException(new InvocationTargetException(
+                                null));
+                ite.printStackTrace(pw);
+
+                s = caw.toString();
+                assertTrue("printStackTrace failed." + s.length(), s != null
+                                && s.length() > 400);
+                pw.close();
+
+                ByteArrayOutputStream bao = new ByteArrayOutputStream();
+                pw = new PrintWriter(bao);
+                ite = new InvocationTargetException(new InvocationTargetException(
+                                null));
+                ite.printStackTrace(pw);
+
+                pw.flush(); // Test will fail if this line removed.
+                s = bao.toString();
+                assertTrue("printStackTrace failed." + s.length(), s != null
+                                && s.length() > 400);
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/MethodTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/MethodTest.java?rev=589692&r1=589691&r2=589692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/MethodTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/MethodTest.java Mon Oct 29 08:45:41 2007
@@ -136,28 +136,22 @@
 	/**
 	 * @tests java.lang.reflect.Method#equals(java.lang.Object)
 	 */
-	public void test_equalsLjava_lang_Object() {
+	public void test_equalsLjava_lang_Object() throws Exception {
 		// Test for method boolean
 		// java.lang.reflect.Method.equals(java.lang.Object)
 
 		Method m1 = null, m2 = null;
-		try {
-			m1 = TestMethod.class.getMethod("invokeInstanceTest", new Class[0]);
-			m2 = TestMethodSub.class.getMethod("invokeInstanceTest",
-					new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during equals test : " + e.getMessage());
-		}
+		m1 = TestMethod.class.getMethod("invokeInstanceTest", new Class[0]);
+		m2 = TestMethodSub.class.getMethod("invokeInstanceTest",
+				new Class[0]);
+
 		assertTrue("Overriden method returned equal", !m1.equals(m2));
 		assertTrue("Same method returned not-equal", m1.equals(m1));
-		try {
-			m1 = TestMethod.class.getMethod("invokeStaticTest", new Class[0]);
-			m2 = TestMethodSub.class
-					.getMethod("invokeStaticTest", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during equals test : " + e.getMessage());
-		}
-		assertTrue("Inherited method returned not-equal", m1.equals(m2));
+                m1 = TestMethod.class.getMethod("invokeStaticTest", new Class[0]);
+                m2 = TestMethodSub.class
+                                .getMethod("invokeStaticTest", new Class[0]);
+
+                assertTrue("Inherited method returned not-equal", m1.equals(m2));
 	}
 
 	/**
@@ -169,114 +163,86 @@
 
 		Method[] mths;
 
-		try {
-			mths = TestMethod.class.getDeclaredMethods();
-			assertTrue("Returned incorrect declaring class: "
-					+ mths[0].getDeclaringClass().toString(), mths[0]
-					.getDeclaringClass().equals(TestMethod.class));
-		} catch (Exception e) {
-			fail("Exception during getDeclaringClass test: "
-					+ e.toString());
-		}
+                mths = TestMethod.class.getDeclaredMethods();
+                assertTrue("Returned incorrect declaring class: "
+                                + mths[0].getDeclaringClass().toString(), mths[0]
+                                .getDeclaringClass().equals(TestMethod.class));
 	}
 
 	/**
 	 * @tests java.lang.reflect.Method#getExceptionTypes()
 	 */
-	public void test_getExceptionTypes() {
+	public void test_getExceptionTypes() throws Exception {
 		// Test for method java.lang.Class []
 		// java.lang.reflect.Method.getExceptionTypes()
 
-		try {
-			Method mth = TestMethod.class.getMethod("voidMethod", new Class[0]);
-			Class[] ex = mth.getExceptionTypes();
-			assertEquals("Returned incorrect number of exceptions",
-					1, ex.length);
-			assertTrue("Returned incorrect exception type", ex[0]
-					.equals(IllegalArgumentException.class));
-			mth = TestMethod.class.getMethod("intMethod", new Class[0]);
-			ex = mth.getExceptionTypes();
-			assertEquals("Returned incorrect number of exceptions",
-					0, ex.length);
-		} catch (Exception e) {
-			fail("Exception during getExceptionTypes: " + e.toString());
-		}
-
+                Method mth = TestMethod.class.getMethod("voidMethod", new Class[0]);
+                Class[] ex = mth.getExceptionTypes();
+                assertEquals("Returned incorrect number of exceptions",
+                                1, ex.length);
+                assertTrue("Returned incorrect exception type", ex[0]
+                                .equals(IllegalArgumentException.class));
+                mth = TestMethod.class.getMethod("intMethod", new Class[0]);
+                ex = mth.getExceptionTypes();
+                assertEquals("Returned incorrect number of exceptions",
+                                0, ex.length);
 	}
 
 	/**
 	 * @tests java.lang.reflect.Method#getModifiers()
 	 */
-	public void test_getModifiers() {
+	public void test_getModifiers() throws Exception {
 		// Test for method int java.lang.reflect.Method.getModifiers()
 
 		Class cl = TestMethod.class;
 		int mods = 0;
 		Method mth = null;
 		int mask = 0;
-		try {
-			mth = cl.getMethod("pustatic", new Class[0]);
-			mods = mth.getModifiers();
-		} catch (Exception e) {
-			fail("Exception during getModfiers test: " + e.toString());
-		}
-		mask = Modifier.PUBLIC | Modifier.STATIC;
+                mth = cl.getMethod("pustatic", new Class[0]);
+                mods = mth.getModifiers();
+
+                mask = Modifier.PUBLIC | Modifier.STATIC;
 		assertTrue("Incorrect modifiers returned", (mods | mask) == mask);
-		try {
-			mth = cl.getDeclaredMethod("prstatic", new Class[0]);
-			mods = mth.getModifiers();
-		} catch (Exception e) {
-			fail("Exception during getModfiers test: " + e.toString());
-		}
-		mask = Modifier.PRIVATE | Modifier.STATIC;
+                mth = cl.getDeclaredMethod("prstatic", new Class[0]);
+                mods = mth.getModifiers();
+
+                mask = Modifier.PRIVATE | Modifier.STATIC;
 		assertTrue("Incorrect modifiers returned", (mods | mask) == mask);
-		try {
-			mth = cl.getDeclaredMethod("pustatsynch", new Class[0]);
-			mods = mth.getModifiers();
-		} catch (Exception e) {
-			fail("Exception during getModfiers test: " + e.toString());
-		}
-		mask = (Modifier.PUBLIC | Modifier.STATIC) | Modifier.SYNCHRONIZED;
+		mth = cl.getDeclaredMethod("pustatsynch", new Class[0]);
+		mods = mth.getModifiers();
+
+                mask = (Modifier.PUBLIC | Modifier.STATIC) | Modifier.SYNCHRONIZED;
 		assertTrue("Incorrect modifiers returned", (mods | mask) == mask);
-		try {
-			mth = cl.getDeclaredMethod("pustatsynchnat", new Class[0]);
-			mods = mth.getModifiers();
-		} catch (Exception e) {
-			fail("Exception during getModfiers test: " + e.toString());
-		}
-		mask = ((Modifier.PUBLIC | Modifier.STATIC) | Modifier.SYNCHRONIZED)
+		mth = cl.getDeclaredMethod("pustatsynchnat", new Class[0]);
+		mods = mth.getModifiers();
+
+                mask = ((Modifier.PUBLIC | Modifier.STATIC) | Modifier.SYNCHRONIZED)
 				| Modifier.NATIVE;
 		assertTrue("Incorrect modifiers returned", (mods | mask) == mask);
 		cl = AbstractTestMethod.class;
-		try {
-			mth = cl.getDeclaredMethod("puabs", new Class[0]);
-			mods = mth.getModifiers();
-		} catch (Exception e) {
-			fail("Exception during getModfiers test: " + e.toString());
-		}
-		mask = Modifier.PUBLIC | Modifier.ABSTRACT;
+                mth = cl.getDeclaredMethod("puabs", new Class[0]);
+                mods = mth.getModifiers();
+
+                mask = Modifier.PUBLIC | Modifier.ABSTRACT;
 		assertTrue("Incorrect modifiers returned", (mods | mask) == mask);
 	}
 
 	/**
 	 * @tests java.lang.reflect.Method#getName()
 	 */
-	public void test_getName() {
+	public void test_getName() throws Exception {
 		// Test for method java.lang.String java.lang.reflect.Method.getName()
 		Method mth = null;
-		try {
-			mth = TestMethod.class.getMethod("voidMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getMethodName(): " + e.toString());
-		}
-		assertEquals("Returned incorrect method name", 
+		mth = TestMethod.class.getMethod("voidMethod", new Class[0]);
+
+                assertEquals("Returned incorrect method name", 
 				"voidMethod", mth.getName());
 	}
 
 	/**
 	 * @tests java.lang.reflect.Method#getParameterTypes()
 	 */
-	public void test_getParameterTypes() {
+	public void test_getParameterTypes() throws Exception {
 		// Test for method java.lang.Class []
 		// java.lang.reflect.Method.getParameterTypes()
 		Class cl = TestMethod.class;
@@ -286,22 +252,14 @@
 		Class[] plist = { int.class, short.class, String.class, boolean.class,
 				Object.class, long.class, byte.class, char.class, double.class,
 				float.class };
-		try {
-			mth = cl.getMethod("voidMethod", new Class[0]);
-			parms = mth.getParameterTypes();
-		} catch (Exception e) {
-			fail("Exception during getParameterTypes test: "
-					+ e.toString());
-		}
-		assertEquals("Returned incorrect parameterTypes", 0, parms.length);
-		try {
-			mth = cl.getMethod("parmTest", plist);
-			parms = mth.getParameterTypes();
-		} catch (Exception e) {
-			fail("Exception during getParameterTypes test: "
-					+ e.toString());
-		}
-		assertTrue("Invalid number of parameters returned",
+		mth = cl.getMethod("voidMethod", new Class[0]);
+		parms = mth.getParameterTypes();
+
+                assertEquals("Returned incorrect parameterTypes", 0, parms.length);
+		mth = cl.getMethod("parmTest", plist);
+		parms = mth.getParameterTypes();
+
+                assertTrue("Invalid number of parameters returned",
 				plist.length == parms.length);
 		for (int i = 0; i < plist.length; i++)
 			assertTrue("Incorrect parameter returned", plist[i]
@@ -330,74 +288,47 @@
 	/**
 	 * @tests java.lang.reflect.Method#getReturnType()
 	 */
-	public void test_getReturnType() {
+	public void test_getReturnType() throws Exception {
 		// Test for method java.lang.Class
 		// java.lang.reflect.Method.getReturnType()
 		Class cl = TestMethod.class;
 		Method mth = null;
-		try {
-			mth = cl.getMethod("charMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted char", mth
+		mth = cl.getMethod("charMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted char", mth
 				.getReturnType().equals(char.class));
-		try {
-			mth = cl.getMethod("longMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted long", mth
+		mth = cl.getMethod("longMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted long", mth
 				.getReturnType().equals(long.class));
-		try {
-			mth = cl.getMethod("shortMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted short", mth
+		mth = cl.getMethod("shortMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted short", mth
 				.getReturnType().equals(short.class));
-		try {
-			mth = cl.getMethod("intMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted int: "
+		mth = cl.getMethod("intMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted int: "
 				+ mth.getReturnType(), mth.getReturnType().equals(int.class));
-		try {
-			mth = cl.getMethod("doubleMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted double", mth
+		mth = cl.getMethod("doubleMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted double", mth
 				.getReturnType().equals(double.class));
-		try {
-			mth = cl.getMethod("byteMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted byte", mth
+		mth = cl.getMethod("byteMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted byte", mth
 				.getReturnType().equals(byte.class));
-		try {
-			mth = cl.getMethod("byteMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test:" + e.toString());
-		}
-		assertTrue("Gave incorrect returne type, wanted byte", mth
+		mth = cl.getMethod("byteMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted byte", mth
 				.getReturnType().equals(byte.class));
-		try {
-			mth = cl.getMethod("objectMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted Object", mth
+		mth = cl.getMethod("objectMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted Object", mth
 				.getReturnType().equals(Object.class));
 
-		try {
-			mth = cl.getMethod("voidMethod", new Class[0]);
-		} catch (Exception e) {
-			fail("Exception during getReturnType test : " + e.getMessage());
-		}
-		assertTrue("Gave incorrect returne type, wanted void", mth
+		mth = cl.getMethod("voidMethod", new Class[0]);
+
+                assertTrue("Gave incorrect returne type, wanted void", mth
 				.getReturnType().equals(void.class));
 	}
 
@@ -405,7 +336,7 @@
 	 * @tests java.lang.reflect.Method#invoke(java.lang.Object,
 	 *        java.lang.Object[])
 	 */
-	public void test_invokeLjava_lang_Object$Ljava_lang_Object() {
+	public void test_invokeLjava_lang_Object$Ljava_lang_Object() throws Exception {
 		// Test for method java.lang.Object
 		// java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object
 		// [])
@@ -416,94 +347,54 @@
 		Class[] dcl = new Class[0];
 
 		// Get and invoke a static method
-		try {
-			mth = cl.getDeclaredMethod("invokeStaticTest", dcl);
-		} catch (Exception e) {
-			fail(
-					"Unable to obtain method for invoke test: invokeStaticTest");
-		}
-		try {
-			ret = mth.invoke(null, new Object[0]);
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
-		}
-		assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
+		mth = cl.getDeclaredMethod("invokeStaticTest", dcl);
+                ret = mth.invoke(null, new Object[0]);
+
+                assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
 				.intValue());
 
 		// Get and invoke an instance method
-		try {
-			mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
-		} catch (Exception e) {
-			fail(
-					"Unable to obtain method for invoke test: invokeInstanceTest");
-		}
-		try {
-			ret = mth.invoke(new TestMethod(), new Object[0]);
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
-		}
-		assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
+		mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
+                ret = mth.invoke(new TestMethod(), new Object[0]);
+
+                assertEquals("Invoke returned incorrect value", 1, ((Integer) ret)
 				.intValue());
 
 		// Get and attempt to invoke a private method
-		try {
-			mth = cl.getDeclaredMethod("privateInvokeTest", dcl);
-		} catch (Exception e) {
-			fail(
-					"Unable to obtain method for invoke test: privateInvokeTest");
-		}
+		mth = cl.getDeclaredMethod("privateInvokeTest", dcl);
+
 		try {
 			ret = mth.invoke(new TestMethod(), new Object[0]);
 		} catch (IllegalAccessException e) {
 			// Correct behaviour
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
-		}
+		} 
+
 		// Generate an IllegalArgumentException
-		try {
-			mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
-		} catch (Exception e) {
-			fail(
-					"Unable to obtain method for invoke test: invokeInstanceTest");
-		}
-		try {
+		mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
+
+                try {
 			Object[] args = { Object.class };
 			ret = mth.invoke(new TestMethod(), args);
 		} catch (IllegalArgumentException e) {
 			// Correct behaviour
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
 		}
 
 		// Generate a NullPointerException
-		try {
-			mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
-		} catch (Exception e) {
-			fail("Unable to obtain method invokeInstanceTest for invoke test : "
-					+ e.getMessage());
-		}
-		try {
+		mth = cl.getDeclaredMethod("invokeInstanceTest", dcl);
+
+                try {
 			ret = mth.invoke(null, new Object[0]);
 		} catch (NullPointerException e) {
 			// Correct behaviour
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
 		}
 
 		// Generate an InvocationTargetException
-		try {
-			mth = cl.getDeclaredMethod("invokeExceptionTest", dcl);
-		} catch (Exception e) {
-			fail("Unable to obtain method invokeExceptionTest for invoke test: "
-					+ e.getMessage());
-		}
+		mth = cl.getDeclaredMethod("invokeExceptionTest", dcl);
 		try {
 			ret = mth.invoke(new TestMethod(), new Object[0]);
 		} catch (InvocationTargetException e) {
 			// Correct behaviour
-		} catch (Exception e) {
-			fail("Exception during invoke test : " + e.getMessage());
-		}
+		} 
 
 		TestMethod testMethod = new TestMethod();
 		Method methods[] = cl.getMethods();
@@ -646,18 +537,13 @@
 	/**
 	 * @tests java.lang.reflect.Method#toString()
 	 */
-	public void test_toString() {
+	public void test_toString() throws Exception {
 		// Test for method java.lang.String java.lang.reflect.Method.toString()
 		Method mth = null;
 		Class[] parms = { int.class, short.class, String.class, boolean.class,
 				Object.class, long.class, byte.class, char.class, double.class,
 				float.class };
-		try {
-
-			mth = TestMethod.class.getDeclaredMethod("printTest", parms);
-		} catch (Exception e) {
-			fail("Exception during toString test : " + e.getMessage());
-		}
+		mth = TestMethod.class.getDeclaredMethod("printTest", parms);
 
 		assertTrue(
 				"Returned incorrect string for method: " + mth.toString(),

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ProxyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ProxyTest.java?rev=589692&r1=589691&r2=589692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ProxyTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ProxyTest.java Mon Oct 29 08:45:41 2007
@@ -153,16 +153,11 @@
 		}
 		assertTrue("Problem converting exception ", worked);
 
-		Broken1 proxyObject = null;
-		try {
-			proxyObject = (Broken1) Proxy.newProxyInstance(Broken1.class
-					.getClassLoader(), new Class[] { Broken1.class },
-					new Broken1Invoke());
-		} catch (Throwable e) {
-			fail("Failed to create proxy for class: " + Broken1.class + " - "
-					+ e);
-		}
-		float brokenResult = proxyObject.method(2.1f, 5.8f);
+		Broken1 proxyObject = (Broken1) Proxy.newProxyInstance(Broken1.class
+				.getClassLoader(), new Class[] { Broken1.class },
+				new Broken1Invoke());
+
+                float brokenResult = proxyObject.method(2.1f, 5.8f);
 		assertTrue("Invalid invoke result", brokenResult == 5.8f);
 	}
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/DatagramPacketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/DatagramPacketTest.java?rev=589692&r1=589691&r2=589692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/DatagramPacketTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/DatagramPacketTest.java Mon Oct 29 08:45:41 2007
@@ -39,91 +39,72 @@
 	 */
 	public void test_Constructor$BI() {
 		// Test for method java.net.DatagramPacket(byte [], int)
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 5);
-			assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
-					dp.getData().length));
-			assertEquals("Wrong length", 5, dp.getLength());
-		} catch (Exception e) {
-			fail("Exception during Constructor test: " + e.toString());
-		}
-        //regression for Harmony-890
-        dp = new DatagramPacket(new byte[942],4);
-        assertEquals(-1, dp.getPort());
-        try{
-            dp.getSocketAddress();
-            fail("Should throw IllegalArgumentException");            
-        }catch(IllegalArgumentException e){
-            //expected
-        }
+                dp = new DatagramPacket("Hello".getBytes(), 5);
+                assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
+                                dp.getData().length));
+                assertEquals("Wrong length", 5, dp.getLength());
+
+                //regression for Harmony-890
+                dp = new DatagramPacket(new byte[942],4);
+                assertEquals(-1, dp.getPort());
+                try{
+                    dp.getSocketAddress();
+                    fail("Should throw IllegalArgumentException");            
+                }catch(IllegalArgumentException e){
+                    //expected
+                }
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, int)
 	 */
 	public void test_Constructor$BII() {
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 2, 3);
-			assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
-					dp.getData().length));
-			assertEquals("Wrong length", 3, dp.getLength());
-			assertEquals("Wrong offset", 2, dp.getOffset());
-		} catch (Exception e) {
-			fail("Exception during Constructor test: " + e.toString());
-		}
+                dp = new DatagramPacket("Hello".getBytes(), 2, 3);
+                assertEquals("Created incorrect packet", "Hello", new String(dp.getData(), 0,
+                                dp.getData().length));
+                assertEquals("Wrong length", 3, dp.getLength());
+                assertEquals("Wrong offset", 2, dp.getOffset());
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, int,
 	 *        java.net.InetAddress, int)
 	 */
-	public void test_Constructor$BIILjava_net_InetAddressI() {
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 2, 3, InetAddress
-					.getLocalHost(), 0);
-			assertTrue("Created incorrect packet", dp.getAddress().equals(
-					InetAddress.getLocalHost())
-					&& dp.getPort() == 0);
-			assertEquals("Wrong length", 3, dp.getLength());
-			assertEquals("Wrong offset", 2, dp.getOffset());
-		} catch (Exception e) {
-			fail("Exception during Constructor test: " + e.toString());
-		}
+	public void test_Constructor$BIILjava_net_InetAddressI() throws Exception {
+                dp = new DatagramPacket("Hello".getBytes(), 2, 3, InetAddress
+                                .getLocalHost(), 0);
+                assertTrue("Created incorrect packet", dp.getAddress().equals(
+                                InetAddress.getLocalHost())
+                                && dp.getPort() == 0);
+                assertEquals("Wrong length", 3, dp.getLength());
+                assertEquals("Wrong offset", 2, dp.getOffset());
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#DatagramPacket(byte[], int,
 	 *        java.net.InetAddress, int)
 	 */
-	public void test_Constructor$BILjava_net_InetAddressI() {
+	public void test_Constructor$BILjava_net_InetAddressI() throws Exception {
 		// Test for method java.net.DatagramPacket(byte [], int,
 		// java.net.InetAddress, int)
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
-					.getLocalHost(), 0);
-			assertTrue("Created incorrect packet", dp.getAddress().equals(
-					InetAddress.getLocalHost())
-					&& dp.getPort() == 0);
-			assertEquals("Wrong length", 5, dp.getLength());
-		} catch (Exception e) {
-			fail("Exception during Constructor test: " + e.toString());
-		}
+                dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
+                                .getLocalHost(), 0);
+                assertTrue("Created incorrect packet", dp.getAddress().equals(
+                                InetAddress.getLocalHost())
+                                && dp.getPort() == 0);
+                assertEquals("Wrong length", 5, dp.getLength());
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#getAddress()
 	 */
-	public void test_getAddress() {
+	public void test_getAddress() throws Exception {
 		// Test for method java.net.InetAddress
 		// java.net.DatagramPacket.getAddress()
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
-					.getLocalHost(), 0);
-			assertTrue("Incorrect address returned", dp.getAddress().equals(
-					InetAddress.getLocalHost()));
-		} catch (Exception e) {
-			fail("Exception during getAddress test:" + e.toString());
-		}
+                dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
+                                .getLocalHost(), 0);
+                assertTrue("Incorrect address returned", dp.getAddress().equals(
+                                InetAddress.getLocalHost()));
 	}
 
 	/**
@@ -158,23 +139,16 @@
 	/**
 	 * @tests java.net.DatagramPacket#getPort()
 	 */
-	public void test_getPort() {
+	public void test_getPort() throws Exception {
 		// Test for method int java.net.DatagramPacket.getPort()
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
-					.getLocalHost(), 1000);
-			assertEquals("Incorrect port returned", 1000, dp.getPort());
-		} catch (Exception e) {
-			fail("Exception during getPort test : " + e.getMessage());
-		}
+                dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
+                                .getLocalHost(), 1000);
+                assertEquals("Incorrect port returned", 1000, dp.getPort());
 
 		InetAddress localhost = null;
-		try {
-			localhost = InetAddress.getByName("localhost");
-		} catch (UnknownHostException e) {
-			fail("Unexpected UnknownHostException : " + e.getMessage());
-		}
-		int[] ports = Support_PortManager.getNextPortsForUDP(2);
+		localhost = InetAddress.getByName("localhost");
+
+                int[] ports = Support_PortManager.getNextPortsForUDP(2);
 		final int port = ports[0];
 		final Object lock = new Object();
 
@@ -234,19 +208,15 @@
 	/**
 	 * @tests java.net.DatagramPacket#setAddress(java.net.InetAddress)
 	 */
-	public void test_setAddressLjava_net_InetAddress() {
+	public void test_setAddressLjava_net_InetAddress() throws Exception {
 		// Test for method void
 		// java.net.DatagramPacket.setAddress(java.net.InetAddress)
-		try {
-			InetAddress ia = InetAddress
-					.getByName(Support_Configuration.InetTestIP);
-			dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
-					.getLocalHost(), 0);
-			dp.setAddress(ia);
-			assertTrue("Incorrect address returned", dp.getAddress().equals(ia));
-		} catch (Exception e) {
-			fail("Exception during getAddress test:" + e.toString());
-		}
+                InetAddress ia = InetAddress
+                                .getByName(Support_Configuration.InetTestIP);
+                dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
+                                .getLocalHost(), 0);
+                dp.setAddress(ia);
+                assertTrue("Incorrect address returned", dp.getAddress().equals(ia));
 	}
 
 	/**
@@ -283,132 +253,115 @@
 	/**
 	 * @tests java.net.DatagramPacket#setPort(int)
 	 */
-	public void test_setPortI() {
+	public void test_setPortI() throws Exception {
 		// Test for method void java.net.DatagramPacket.setPort(int)
-		try {
-			dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
-					.getLocalHost(), 1000);
-			dp.setPort(2000);
-			assertEquals("Port not set", 2000, dp.getPort());
-		} catch (Exception e) {
-			fail("Exception during setPort test : " + e.getMessage());
-		}
+                dp = new DatagramPacket("Hello".getBytes(), 5, InetAddress
+                                .getLocalHost(), 1000);
+                dp.setPort(2000);
+                assertEquals("Port not set", 2000, dp.getPort());
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#DatagramPacket(byte[], int,
 	 *        java.net.SocketAddress)
 	 */
-	public void test_Constructor$BILjava_net_SocketAddress() {
+	public void test_Constructor$BILjava_net_SocketAddress() throws Exception {
 		class mySocketAddress extends SocketAddress {
 
 			public mySocketAddress() {
 			}
 		}
 
-		try {
-			// unsupported SocketAddress subclass
-			byte buf[] = new byte[1];
-			try {
-				DatagramPacket thePacket = new DatagramPacket(buf, 1,
-						new mySocketAddress());
-				fail("No exception when constructing using unsupported SocketAddress subclass");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// case were we try to pass in null
-			// unsupported SocketAddress subclass
-
-			try {
-				DatagramPacket thePacket = new DatagramPacket(buf, 1, null);
-				fail("No exception when constructing address using null");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// now validate we can construct
-			InetSocketAddress theAddress = new InetSocketAddress(InetAddress
-					.getLocalHost(), Support_PortManager.getNextPortForUDP());
-			DatagramPacket thePacket = new DatagramPacket(buf, 1, theAddress);
-			assertTrue("Socket address not set correctly (1)", theAddress
-					.equals(thePacket.getSocketAddress()));
-			assertTrue("Socket address not set correctly (2)", theAddress
-					.equals(new InetSocketAddress(thePacket.getAddress(),
-							thePacket.getPort())));
-		} catch (Exception e) {
-			fail("Exception during constructor test(1):" + e.toString());
-		}
+                // unsupported SocketAddress subclass
+                byte buf[] = new byte[1];
+                try {
+                        DatagramPacket thePacket = new DatagramPacket(buf, 1,
+                                        new mySocketAddress());
+                        fail("No exception when constructing using unsupported SocketAddress subclass");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // case were we try to pass in null
+                // unsupported SocketAddress subclass
+
+                try {
+                        DatagramPacket thePacket = new DatagramPacket(buf, 1, null);
+                        fail("No exception when constructing address using null");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // now validate we can construct
+                InetSocketAddress theAddress = new InetSocketAddress(InetAddress
+                                .getLocalHost(), Support_PortManager.getNextPortForUDP());
+                DatagramPacket thePacket = new DatagramPacket(buf, 1, theAddress);
+                assertTrue("Socket address not set correctly (1)", theAddress
+                                .equals(thePacket.getSocketAddress()));
+                assertTrue("Socket address not set correctly (2)", theAddress
+                                .equals(new InetSocketAddress(thePacket.getAddress(),
+                                                thePacket.getPort())));
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, int,
 	 *        java.net.SocketAddress)
 	 */
-	public void test_Constructor$BIILjava_net_SocketAddress() {
+	public void test_Constructor$BIILjava_net_SocketAddress() throws Exception {
 		class mySocketAddress extends SocketAddress {
 
 			public mySocketAddress() {
 			}
 		}
 
-		try {
-			// unsupported SocketAddress subclass
-			byte buf[] = new byte[2];
-			try {
-				DatagramPacket thePacket = new DatagramPacket(buf, 1, 1,
-						new mySocketAddress());
-				fail("No exception when constructing using unsupported SocketAddress subclass");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// case were we try to pass in null
-			// unsupported SocketAddress subclass
-
-			try {
-				DatagramPacket thePacket = new DatagramPacket(buf, 1, 1, null);
-				fail("No exception when constructing address using null");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// now validate we can construct
-			InetSocketAddress theAddress = new InetSocketAddress(InetAddress
-					.getLocalHost(), Support_PortManager.getNextPortForUDP());
-			DatagramPacket thePacket = new DatagramPacket(buf, 1, 1, theAddress);
-			assertTrue("Socket address not set correctly (1)", theAddress
-					.equals(thePacket.getSocketAddress()));
-			assertTrue("Socket address not set correctly (2)", theAddress
-					.equals(new InetSocketAddress(thePacket.getAddress(),
-							thePacket.getPort())));
-			assertEquals("Offset not set correctly", 1, thePacket.getOffset());
-		} catch (Exception e) {
-			fail("Exception during constructor test(2):" + e.toString());
-		}
+                // unsupported SocketAddress subclass
+                byte buf[] = new byte[2];
+                try {
+                        DatagramPacket thePacket = new DatagramPacket(buf, 1, 1,
+                                        new mySocketAddress());
+                        fail("No exception when constructing using unsupported SocketAddress subclass");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // case were we try to pass in null
+                // unsupported SocketAddress subclass
+
+                try {
+                        DatagramPacket thePacket = new DatagramPacket(buf, 1, 1, null);
+                        fail("No exception when constructing address using null");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // now validate we can construct
+                InetSocketAddress theAddress = new InetSocketAddress(InetAddress
+                                .getLocalHost(), Support_PortManager.getNextPortForUDP());
+                DatagramPacket thePacket = new DatagramPacket(buf, 1, 1, theAddress);
+                assertTrue("Socket address not set correctly (1)", theAddress
+                                .equals(thePacket.getSocketAddress()));
+                assertTrue("Socket address not set correctly (2)", theAddress
+                                .equals(new InetSocketAddress(thePacket.getAddress(),
+                                                thePacket.getPort())));
+                assertEquals("Offset not set correctly", 1, thePacket.getOffset());
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#getSocketAddress()
 	 */
-	public void test_getSocketAddress() {
-		try {
-			byte buf[] = new byte[1];
-			DatagramPacket thePacket = new DatagramPacket(buf, 1);
-
-			// validate get returns the value we set
-			InetSocketAddress theAddress = new InetSocketAddress(InetAddress
-					.getLocalHost(), Support_PortManager.getNextPortForUDP());
-			thePacket = new DatagramPacket(buf, 1);
-			thePacket.setSocketAddress(theAddress);
-			assertTrue("Socket address not set correctly (1)", theAddress
-					.equals(thePacket.getSocketAddress()));
-		} catch (Exception e) {
-			fail(
-					"Exception during getSocketAddress test:" + e.toString());
-		}
+	public void test_getSocketAddress() throws Exception {
+                byte buf[] = new byte[1];
+                DatagramPacket thePacket = new DatagramPacket(buf, 1);
+
+                // validate get returns the value we set
+                InetSocketAddress theAddress = new InetSocketAddress(InetAddress
+                                .getLocalHost(), Support_PortManager.getNextPortForUDP());
+                thePacket = new DatagramPacket(buf, 1);
+                thePacket.setSocketAddress(theAddress);
+                assertTrue("Socket address not set correctly (1)", theAddress
+                                .equals(thePacket.getSocketAddress()));
 	}
 
 	/**
 	 * @tests java.net.DatagramPacket#setSocketAddress(java.net.SocketAddress)
 	 */
-	public void test_setSocketAddressLjava_net_SocketAddress() {
+	public void test_setSocketAddressLjava_net_SocketAddress() throws Exception {
 
 		class mySocketAddress extends SocketAddress {
 
@@ -416,39 +369,34 @@
 			}
 		}
 
-		try {
-			// unsupported SocketAddress subclass
-			byte buf[] = new byte[1];
-			DatagramPacket thePacket = new DatagramPacket(buf, 1);
-			try {
-				thePacket.setSocketAddress(new mySocketAddress());
-				fail("No exception when setting address using unsupported SocketAddress subclass");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// case were we try to pass in null
-			// unsupported SocketAddress subclass
-			thePacket = new DatagramPacket(buf, 1);
-			try {
-				thePacket.setSocketAddress(null);
-				fail("No exception when setting address using null");
-			} catch (IllegalArgumentException ex) {
-			}
-
-			// now validate we can set it correctly
-			InetSocketAddress theAddress = new InetSocketAddress(InetAddress
-					.getLocalHost(), Support_PortManager.getNextPortForUDP());
-			thePacket = new DatagramPacket(buf, 1);
-			thePacket.setSocketAddress(theAddress);
-			assertTrue("Socket address not set correctly (1)", theAddress
-					.equals(thePacket.getSocketAddress()));
-			assertTrue("Socket address not set correctly (2)", theAddress
-					.equals(new InetSocketAddress(thePacket.getAddress(),
-							thePacket.getPort())));
-		} catch (Exception e) {
-			fail(
-					"Exception during setSocketAddress test:" + e.toString());
-		}
+                // unsupported SocketAddress subclass
+                byte buf[] = new byte[1];
+                DatagramPacket thePacket = new DatagramPacket(buf, 1);
+                try {
+                        thePacket.setSocketAddress(new mySocketAddress());
+                        fail("No exception when setting address using unsupported SocketAddress subclass");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // case were we try to pass in null
+                // unsupported SocketAddress subclass
+                thePacket = new DatagramPacket(buf, 1);
+                try {
+                        thePacket.setSocketAddress(null);
+                        fail("No exception when setting address using null");
+                } catch (IllegalArgumentException ex) {
+                }
+
+                // now validate we can set it correctly
+                InetSocketAddress theAddress = new InetSocketAddress(InetAddress
+                                .getLocalHost(), Support_PortManager.getNextPortForUDP());
+                thePacket = new DatagramPacket(buf, 1);
+                thePacket.setSocketAddress(theAddress);
+                assertTrue("Socket address not set correctly (1)", theAddress
+                                .equals(thePacket.getSocketAddress()));
+                assertTrue("Socket address not set correctly (2)", theAddress
+                                .equals(new InetSocketAddress(thePacket.getAddress(),
+                                                thePacket.getPort())));
 	}
 
 	/**



Mime
View raw message