You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/10/31 09:42:35 UTC
svn commit: r590591 [5/12] - in /harmony/enhanced/classlib/branches/java6:
depends/build/platform/ depends/files/ depends/jars/icu4j_3.8/
depends/libs/freebsd.x86/ depends/manifests/icu4j_3.4.4/
depends/manifests/icu4j_3.8/ depends/manifests/icu4j_3.8/...
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -40,57 +40,42 @@
/**
* @tests java.io.FileInputStream#FileInputStream(java.io.File)
*/
- public void test_ConstructorLjava_io_File() {
+ public void test_ConstructorLjava_io_File() throws Exception {
// Test for method java.io.FileInputStream(java.io.File)
- try {
- java.io.File f = new java.io.File(fileName);
- is = new java.io.FileInputStream(f);
- is.close();
- } catch (Exception e) {
- fail("Failed to create FileInputStream : " + e.getMessage());
- }
-
+ java.io.File f = new java.io.File(fileName);
+ is = new java.io.FileInputStream(f);
+ is.close();
}
/**
* @tests java.io.FileInputStream#FileInputStream(java.io.FileDescriptor)
*/
- public void test_ConstructorLjava_io_FileDescriptor() {
+ public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
// Test for method java.io.FileInputStream(java.io.FileDescriptor)
- try {
- FileOutputStream fos = new FileOutputStream(fileName);
- FileInputStream fis = new FileInputStream(fos.getFD());
- fos.close();
- fis.close();
- } catch (Exception e) {
- fail("Exception during constrcutor test: " + e.toString());
- }
+ FileOutputStream fos = new FileOutputStream(fileName);
+ FileInputStream fis = new FileInputStream(fos.getFD());
+ fos.close();
+ fis.close();
}
/**
* @tests java.io.FileInputStream#FileInputStream(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.FileInputStream(java.lang.String)
- try {
- is = new java.io.FileInputStream(fileName);
- is.close();
- } catch (Exception e) {
- fail("Failed to create FileInputStream : " + e.getMessage());
- }
+ is = new java.io.FileInputStream(fileName);
+ is.close();
}
/**
* @tests java.io.FileInputStream#available()
*/
- public void test_available() {
+ public void test_available() throws Exception {
// Test for method int java.io.FileInputStream.available()
try {
is = new java.io.FileInputStream(fileName);
assertTrue("Returned incorrect number of available bytes", is
.available() == fileString.length());
- } catch (Exception e) {
- fail("Exception during available test : " + e.getMessage());
} finally {
try {
is.close();
@@ -145,55 +130,41 @@
/**
* @tests java.io.FileInputStream#read()
*/
- public void test_read() {
+ public void test_read() throws Exception {
// Test for method int java.io.FileInputStream.read()
- try {
- is = new java.io.FileInputStream(fileName);
- int c = is.read();
- is.close();
- assertTrue("read returned incorrect char", c == fileString
- .charAt(0));
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ is = new java.io.FileInputStream(fileName);
+ int c = is.read();
+ is.close();
+ assertTrue("read returned incorrect char", c == fileString
+ .charAt(0));
}
/**
* @tests java.io.FileInputStream#read(byte[])
*/
- public void test_read$B() {
+ public void test_read$B() throws Exception {
// Test for method int java.io.FileInputStream.read(byte [])
byte[] buf1 = new byte[100];
- try {
- is = new java.io.FileInputStream(fileName);
- is.skip(3000);
- is.read(buf1);
- is.close();
- assertTrue("Failed to read correct data", new String(buf1, 0,
- buf1.length).equals(fileString.substring(3000, 3100)));
-
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ is = new java.io.FileInputStream(fileName);
+ is.skip(3000);
+ is.read(buf1);
+ is.close();
+ assertTrue("Failed to read correct data", new String(buf1, 0,
+ buf1.length).equals(fileString.substring(3000, 3100)));
}
/**
* @tests java.io.FileInputStream#read(byte[], int, int)
*/
- public void test_read$BII() {
+ public void test_read$BII() throws Exception {
// Test for method int java.io.FileInputStream.read(byte [], int, int)
byte[] buf1 = new byte[100];
- try {
- is = new java.io.FileInputStream(fileName);
- is.skip(3000);
- is.read(buf1, 0, buf1.length);
- is.close();
- assertTrue("Failed to read correct data", new String(buf1, 0,
- buf1.length).equals(fileString.substring(3000, 3100)));
-
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ is = new java.io.FileInputStream(fileName);
+ is.skip(3000);
+ is.read(buf1, 0, buf1.length);
+ is.close();
+ assertTrue("Failed to read correct data", new String(buf1, 0,
+ buf1.length).equals(fileString.substring(3000, 3100)));
}
/**
@@ -317,19 +288,15 @@
/**
* @tests java.io.FileInputStream#skip(long)
*/
- public void test_skipJ() {
+ public void test_skipJ() throws Exception {
// Test for method long java.io.FileInputStream.skip(long)
byte[] buf1 = new byte[10];
- try {
- is = new java.io.FileInputStream(fileName);
- is.skip(1000);
- is.read(buf1, 0, buf1.length);
- is.close();
- assertTrue("Failed to skip to correct position", new String(buf1,
- 0, buf1.length).equals(fileString.substring(1000, 1010)));
- } catch (Exception e) {
- fail("Exception during skip test " + e.getMessage());
- }
+ is = new java.io.FileInputStream(fileName);
+ is.skip(1000);
+ is.read(buf1, 0, buf1.length);
+ is.close();
+ assertTrue("Failed to skip to correct position", new String(buf1,
+ 0, buf1.length).equals(fileString.substring(1000, 1010)));
}
/**
@@ -395,8 +362,6 @@
fail("IOException must be thrown if number of bytes to skip <0");
} catch (IOException e) {
// Expected IOException
- } catch (Exception e) {
- fail("IOException expected, but found: " + e.getMessage());
}
fis.close();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileReaderTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileReaderTest.java Wed Oct 31 01:42:07 2007
@@ -36,63 +36,48 @@
/**
* @tests java.io.FileReader#FileReader(java.io.File)
*/
- public void test_ConstructorLjava_io_File() {
+ public void test_ConstructorLjava_io_File() throws Exception {
// Test for method java.io.FileReader(java.io.File)
- try {
- bw = new BufferedWriter(new FileWriter(f.getPath()));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new FileReader(f);
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ bw = new BufferedWriter(new FileWriter(f.getPath()));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new FileReader(f);
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r));
}
/**
* @tests java.io.FileReader#FileReader(java.io.FileDescriptor)
*/
- public void test_ConstructorLjava_io_FileDescriptor() {
+ public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
// Test for method java.io.FileReader(java.io.FileDescriptor)
- try {
- bw = new BufferedWriter(new FileWriter(f.getPath()));
- bw.write(" After test string", 0, 18);
- bw.close();
- FileInputStream fis = new FileInputStream(f.getPath());
- br = new FileReader(fis.getFD());
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- fis.close();
- assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ bw = new BufferedWriter(new FileWriter(f.getPath()));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ FileInputStream fis = new FileInputStream(f.getPath());
+ br = new FileReader(fis.getFD());
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ fis.close();
+ assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r));
}
/**
* @tests java.io.FileReader#FileReader(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.FileReader(java.lang.String)
- try {
- bw = new BufferedWriter(new FileWriter(f.getPath()));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new FileReader(f.getPath());
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ bw = new BufferedWriter(new FileWriter(f.getPath()));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new FileReader(f.getPath());
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ assertEquals("Failed to read correct chars", " After test string", new String(buf, 0, r));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileTest.java Wed Oct 31 01:42:07 2007
@@ -957,11 +957,7 @@
f = new File(System.getProperty("user.home"), "p.tst");
assertTrue("Incorrect path returned", f.getParent().equals(
System.getProperty("user.home")));
- try {
- f.delete();
- } catch (Exception e) {
- fail("Unexpected exception during tests : " + e.getMessage());
- }
+ f.delete();
File f1 = new File("/directory");
assertTrue("Wrong parent test 1", f1.getParent().equals(slash));
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileWriterTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FileWriterTest.java Wed Oct 31 01:42:07 2007
@@ -42,24 +42,19 @@
/**
* @tests java.io.FileWriter#FileWriter(java.io.File)
*/
- public void test_ConstructorLjava_io_File() {
+ public void test_ConstructorLjava_io_File() throws Exception {
// Test for method java.io.FileWriter(java.io.File)
- try {
- fos = new FileOutputStream(f.getPath());
- fos.write("Test String".getBytes());
- fos.close();
- bw = new BufferedWriter(new FileWriter(f));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new BufferedReader(new FileReader(f.getPath()));
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ fos = new FileOutputStream(f.getPath());
+ fos.write("Test String".getBytes());
+ fos.close();
+ bw = new BufferedWriter(new FileWriter(f));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new BufferedReader(new FileReader(f.getPath()));
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r));
}
/**
@@ -109,85 +104,69 @@
/**
* @tests java.io.FileWriter#FileWriter(java.io.FileDescriptor)
*/
- public void test_ConstructorLjava_io_FileDescriptor() {
+ public void test_ConstructorLjava_io_FileDescriptor() throws Exception {
// Test for method java.io.FileWriter(java.io.FileDescriptor)
- try {
- fos = new FileOutputStream(f.getPath());
- fos.write("Test String".getBytes());
- fos.close();
- fis = new FileInputStream(f.getPath());
- br = new BufferedReader(new FileReader(fis.getFD()));
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- fis.close();
- assertTrue("Failed to write correct chars: "
- + new String(buf, 0, r), new String(buf, 0, r)
- .equals("Test String"));
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ fos = new FileOutputStream(f.getPath());
+ fos.write("Test String".getBytes());
+ fos.close();
+ fis = new FileInputStream(f.getPath());
+ br = new BufferedReader(new FileReader(fis.getFD()));
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ fis.close();
+ assertTrue("Failed to write correct chars: "
+ + new String(buf, 0, r), new String(buf, 0, r)
+ .equals("Test String"));
}
/**
* @tests java.io.FileWriter#FileWriter(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.FileWriter(java.lang.String)
- try {
- fos = new FileOutputStream(f.getPath());
- fos.write("Test String".getBytes());
- fos.close();
- bw = new BufferedWriter(new FileWriter(f.getPath()));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new BufferedReader(new FileReader(f.getPath()));
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
+ fos = new FileOutputStream(f.getPath());
+ fos.write("Test String".getBytes());
+ fos.close();
+ bw = new BufferedWriter(new FileWriter(f.getPath()));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new BufferedReader(new FileReader(f.getPath()));
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ assertEquals("Failed to write correct chars", " After test string", new String(buf, 0, r));
}
/**
* @tests java.io.FileWriter#FileWriter(java.lang.String, boolean)
*/
- public void test_ConstructorLjava_lang_StringZ() {
+ public void test_ConstructorLjava_lang_StringZ() throws Exception {
// Test for method java.io.FileWriter(java.lang.String, boolean)
-
- try {
- fos = new FileOutputStream(f.getPath());
- fos.write("Test String".getBytes());
- fos.close();
- bw = new BufferedWriter(new FileWriter(f.getPath(), true));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new BufferedReader(new FileReader(f.getPath()));
- char[] buf = new char[100];
- int r = br.read(buf);
- br.close();
- assertEquals("Failed to append to file", "Test String After test string", new String(buf, 0, r)
- );
-
- fos = new FileOutputStream(f.getPath());
- fos.write("Test String".getBytes());
- fos.close();
- bw = new BufferedWriter(new FileWriter(f.getPath(), false));
- bw.write(" After test string", 0, 18);
- bw.close();
- br = new BufferedReader(new FileReader(f.getPath()));
- buf = new char[100];
- r = br.read(buf);
- br.close();
- assertEquals("Failed to overwrite file", " After test string", new String(buf, 0, r)
- );
- } catch (Exception e) {
- fail("Exception during Constructor test " + e.toString());
- }
-
+ fos = new FileOutputStream(f.getPath());
+ fos.write("Test String".getBytes());
+ fos.close();
+ bw = new BufferedWriter(new FileWriter(f.getPath(), true));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new BufferedReader(new FileReader(f.getPath()));
+ char[] buf = new char[100];
+ int r = br.read(buf);
+ br.close();
+ assertEquals("Failed to append to file", "Test String After test string", new String(buf, 0, r)
+ );
+
+ fos = new FileOutputStream(f.getPath());
+ fos.write("Test String".getBytes());
+ fos.close();
+ bw = new BufferedWriter(new FileWriter(f.getPath(), false));
+ bw.write(" After test string", 0, 18);
+ bw.close();
+ br = new BufferedReader(new FileReader(f.getPath()));
+ buf = new char[100];
+ r = br.read(buf);
+ br.close();
+ assertEquals("Failed to overwrite file", " After test string", new String(buf, 0, r));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FilterInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FilterInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FilterInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/FilterInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -40,14 +40,10 @@
/**
* @tests java.io.FilterInputStream#available()
*/
- public void test_available() {
+ public void test_available() throws Exception {
// Test for method int java.io.FilterInputStream.available()
- try {
- assertTrue("Returned incorrect number of available bytes", is
- .available() == fileString.length());
- } catch (Exception e) {
- fail("Exception during available test : " + e.getMessage());
- }
+ assertTrue("Returned incorrect number of available bytes", is
+ .available() == fileString.length());
}
/**
@@ -88,47 +84,35 @@
/**
* @tests java.io.FilterInputStream#read()
*/
- public void test_read() {
+ public void test_read() throws Exception {
// Test for method int java.io.FilterInputStream.read()
- try {
- int c = is.read();
- assertTrue("read returned incorrect char", c == fileString
- .charAt(0));
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ int c = is.read();
+ assertTrue("read returned incorrect char", c == fileString
+ .charAt(0));
}
/**
* @tests java.io.FilterInputStream#read(byte[])
*/
- public void test_read$B() {
+ public void test_read$B() throws Exception {
// Test for method int java.io.FilterInputStream.read(byte [])
byte[] buf1 = new byte[100];
- try {
- is.read(buf1);
- assertTrue("Failed to read correct data", new String(buf1, 0,
- buf1.length).equals(fileString.substring(0, 100)));
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ is.read(buf1);
+ assertTrue("Failed to read correct data", new String(buf1, 0,
+ buf1.length).equals(fileString.substring(0, 100)));
}
/**
* @tests java.io.FilterInputStream#read(byte[], int, int)
*/
- public void test_read$BII() {
+ public void test_read$BII() throws Exception {
// Test for method int java.io.FilterInputStream.read(byte [], int, int)
byte[] buf1 = new byte[100];
- try {
- is.skip(3000);
- is.mark(1000);
- is.read(buf1, 0, buf1.length);
- assertTrue("Failed to read correct data", new String(buf1, 0,
- buf1.length).equals(fileString.substring(3000, 3100)));
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ is.skip(3000);
+ is.mark(1000);
+ is.read(buf1, 0, buf1.length);
+ assertTrue("Failed to read correct data", new String(buf1, 0,
+ buf1.length).equals(fileString.substring(3000, 3100)));
}
/**
@@ -147,17 +131,14 @@
/**
* @tests java.io.FilterInputStream#skip(long)
*/
- public void test_skipJ() {
+ public void test_skipJ() throws Exception {
// Test for method long java.io.FilterInputStream.skip(long)
byte[] buf1 = new byte[10];
- try {
- is.skip(1000);
- is.read(buf1, 0, buf1.length);
- assertTrue("Failed to skip to correct position", new String(buf1,
- 0, buf1.length).equals(fileString.substring(1000, 1010)));
- } catch (Exception e) {
- fail("Exception during skip test");
- }
+
+ is.skip(1000);
+ is.read(buf1, 0, buf1.length);
+ assertTrue("Failed to skip to correct position", new String(buf1,
+ 0, buf1.length).equals(fileString.substring(1000, 1010)));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InputStreamReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InputStreamReaderTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InputStreamReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InputStreamReaderTest.java Wed Oct 31 01:42:07 2007
@@ -515,10 +515,11 @@
reader = new InputStreamReader(in, "UTF-16");
assertEquals("Incorrect byte UTF-16BE", '\u7261', reader.read());
+ /* Temporarily commented out due to lack of ISO2022 support in ICU4J 3.8
in = new LimitedByteArrayInputStream(2);
reader = new InputStreamReader(in, "ISO2022JP");
assertEquals("Incorrect byte ISO2022JP 1", '\u4e5d', reader.read());
- assertEquals("Incorrect byte ISO2022JP 2", '\u7b2c', reader.read());
+ assertEquals("Incorrect byte ISO2022JP 2", '\u7b2c', reader.read());*/
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InterruptedIOExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InterruptedIOExceptionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InterruptedIOExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/InterruptedIOExceptionTest.java Wed Oct 31 01:42:07 2007
@@ -30,11 +30,7 @@
throw new InterruptedIOException();
} catch (InterruptedIOException e) {
return;
- } catch (Exception e) {
- fail("Exception during InterruptedIOException test"
- + e.toString());
- }
- fail("Failed to generate exception");
+ }
}
/**
@@ -46,11 +42,7 @@
throw new InterruptedIOException("Some error message");
} catch (InterruptedIOException e) {
return;
- } catch (Exception e) {
- fail("Exception during InterruptedIOException test"
- + e.toString());
}
- fail("Failed to generate exception");
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/OutputStreamWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/OutputStreamWriterTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/OutputStreamWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/OutputStreamWriterTest.java Wed Oct 31 01:42:07 2007
@@ -625,20 +625,16 @@
/**
* @tests java.io.OutputStreamWriter#flush()
*/
- public void test_flush() {
+ public void test_flush() throws Exception {
// Test for method void java.io.OutputStreamWriter.flush()
- try {
- char[] buf = new char[testString.length()];
- osw.write(testString, 0, testString.length());
- osw.flush();
- openInputStream();
- isr.read(buf, 0, buf.length);
- assertTrue("Chars not flushed", new String(buf, 0, buf.length)
- .equals(testString));
- } catch (Exception e) {
- fail("Exception during write test : " + e.getMessage());
- }
- }
+ char[] buf = new char[testString.length()];
+ osw.write(testString, 0, testString.length());
+ osw.flush();
+ openInputStream();
+ isr.read(buf, 0, buf.length);
+ assertTrue("Chars not flushed", new String(buf, 0, buf.length)
+ .equals(testString));
+ }
/**
* @tests java.io.OutputStreamWriter#getEncoding()
@@ -657,56 +653,44 @@
/**
* @tests java.io.OutputStreamWriter#write(char[], int, int)
*/
- public void test_write$CII() {
+ public void test_write$CII() throws Exception {
// Test for method void java.io.OutputStreamWriter.write(char [], int,
// int)
- try {
- char[] buf = new char[testString.length()];
- osw.write(testString, 0, testString.length());
- osw.close();
- openInputStream();
- isr.read(buf, 0, buf.length);
- assertTrue("Incorrect chars returned", new String(buf, 0,
- buf.length).equals(testString));
- } catch (Exception e) {
- fail("Exception during write test : " + e.getMessage());
- }
+ char[] buf = new char[testString.length()];
+ osw.write(testString, 0, testString.length());
+ osw.close();
+ openInputStream();
+ isr.read(buf, 0, buf.length);
+ assertTrue("Incorrect chars returned", new String(buf, 0,
+ buf.length).equals(testString));
}
/**
* @tests java.io.OutputStreamWriter#write(int)
*/
- public void test_writeI() {
+ public void test_writeI() throws Exception {
// Test for method void java.io.OutputStreamWriter.write(int)
- try {
- osw.write('T');
- osw.close();
- openInputStream();
- int c = isr.read();
- assertEquals("Incorrect char returned", 'T', (char) c);
- } catch (Exception e) {
- fail("Exception during write test : " + e.getMessage());
- }
+ osw.write('T');
+ osw.close();
+ openInputStream();
+ int c = isr.read();
+ assertEquals("Incorrect char returned", 'T', (char) c);
}
/**
* @tests java.io.OutputStreamWriter#write(java.lang.String, int, int)
*/
- public void test_writeLjava_lang_StringII() {
+ public void test_writeLjava_lang_StringII() throws Exception {
// Test for method void
// java.io.OutputStreamWriter.write(java.lang.String, int, int)
- try {
- char[] buf = new char[testString.length()];
- osw.write(testString, 0, testString.length());
- osw.close();
- openInputStream();
- isr.read(buf);
- assertTrue("Incorrect chars returned", new String(buf, 0,
- buf.length).equals(testString));
- } catch (Exception e) {
- fail("Exception during write test : " + e.getMessage());
- }
+ char[] buf = new char[testString.length()];
+ osw.write(testString, 0, testString.length());
+ osw.close();
+ openInputStream();
+ isr.read(buf);
+ assertTrue("Incorrect chars returned", new String(buf, 0,
+ buf.length).equals(testString));
}
private void openInputStream() {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PipedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PipedOutputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PipedOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PipedOutputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -85,30 +85,22 @@
/**
* @tests java.io.PipedOutputStream#PipedOutputStream(java.io.PipedInputStream)
*/
- public void test_ConstructorLjava_io_PipedInputStream() {
+ public void test_ConstructorLjava_io_PipedInputStream() throws Exception {
// Test for method java.io.PipedOutputStream(java.io.PipedInputStream)
- try {
- out = new PipedOutputStream(new PipedInputStream());
- out.write('b');
- } catch (Exception e) {
- fail("Exception during constructor test : " + e.getMessage());
- }
+ out = new PipedOutputStream(new PipedInputStream());
+ out.write('b');
}
/**
* @tests java.io.PipedOutputStream#close()
*/
- public void test_close() {
+ public void test_close() throws Exception {
// Test for method void java.io.PipedOutputStream.close()
- try {
- out = new PipedOutputStream();
- rt = new Thread(reader = new PReader(out));
- rt.start();
- out.close();
- } catch (IOException e) {
- fail("Exception during close : " + e.getMessage());
- }
+ out = new PipedOutputStream();
+ rt = new Thread(reader = new PReader(out));
+ rt.start();
+ out.close();
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PushbackInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PushbackInputStreamTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PushbackInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/PushbackInputStreamTest.java Wed Oct 31 01:42:07 2007
@@ -117,23 +117,19 @@
/**
* @tests java.io.PushbackInputStream#skip(long)
*/
- public void test_skipJ() {
+ public void test_skipJ() throws Exception {
// Test for method long java.io.PushbackInputStream.skip(long)
- try {
- byte[] buf = new byte[50];
- pis.skip(50);
- pis.read(buf, 0, buf.length);
- assertTrue("a) Incorrect bytes read", new String(buf)
- .equals(fileString.substring(50, 100)));
- pis.unread(buf);
- pis.skip(25);
- byte[] buf2 = new byte[25];
- pis.read(buf2, 0, buf2.length);
- assertTrue("b) Incorrect bytes read", new String(buf2)
- .equals(fileString.substring(75, 100)));
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ byte[] buf = new byte[50];
+ pis.skip(50);
+ pis.read(buf, 0, buf.length);
+ assertTrue("a) Incorrect bytes read", new String(buf)
+ .equals(fileString.substring(50, 100)));
+ pis.unread(buf);
+ pis.skip(25);
+ byte[] buf2 = new byte[25];
+ pis.read(buf2, 0, buf2.length);
+ assertTrue("b) Incorrect bytes read", new String(buf2)
+ .equals(fileString.substring(75, 100)));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest.java Wed Oct 31 01:42:07 2007
@@ -275,16 +275,11 @@
}
}
- public void test_1_Constructor() {
+ public void test_1_Constructor() throws Exception {
// Test for method java.io.ObjectOutputStream(java.io.OutputStream)
-
- try {
- oos.close();
- oos = new ObjectOutputStream(new ByteArrayOutputStream());
- oos.close();
- } catch (Exception e) {
- fail("Failed to create ObjectOutputStream : " + e.getMessage());
- }
+ oos.close();
+ oos = new ObjectOutputStream(new ByteArrayOutputStream());
+ oos.close();
}
public void test_2_close() {
@@ -691,14 +686,10 @@
}
}
- public void test_serialVersionUID(Class clazz, long svUID) {
+ public void test_serialVersionUID(Class clazz, long svUID) throws Exception {
final String idWrong = "serialVersionUID is wrong for: ";
long reflectedSvUID = 0L;
- try {
- reflectedSvUID = clazz.getField("serialVersionUID").getLong(null);
- } catch (Exception e) {
- fail("Unable to determine serialVersionUID of " + clazz);
- }
+ reflectedSvUID = clazz.getField("serialVersionUID").getLong(null);
assertTrue(idWrong + clazz + ": " + reflectedSvUID + " does not equal "
+ svUID, reflectedSvUID == svUID);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest4.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest4.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest4.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SerializationStressTest4.java Wed Oct 31 01:42:07 2007
@@ -2084,14 +2084,11 @@
try {
objToSave = null;
- try {
- objToSave = new java.security.CodeSource(new java.net.URL(
- "http://localhost/a.txt"),
- (Certificate[])null);
- } catch (Exception e) {
- fail("Exception creating object : " + e.getMessage());
- }
- if (DEBUG)
+ objToSave = new java.security.CodeSource(new java.net.URL(
+ "http://localhost/a.txt"),
+ (Certificate[])null);
+
+ if (DEBUG)
System.out.println("Obj = " + objToSave);
objLoaded = dumpAndReload(objToSave);
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StreamCorruptedExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StreamCorruptedExceptionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StreamCorruptedExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StreamCorruptedExceptionTest.java Wed Oct 31 01:42:07 2007
@@ -26,7 +26,7 @@
/**
* @tests java.io.StreamCorruptedException#StreamCorruptedException()
*/
- public void test_Constructor() {
+ public void test_Constructor() throws Exception {
// Test for method java.io.StreamCorruptedException()
try {
@@ -38,16 +38,15 @@
} catch (StreamCorruptedException e) {
// Correct
return;
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
}
- fail("Failed to throw exception for non serialized stream");
+
+ fail("Failed to throw StreamCorruptedException for non serialized stream");
}
/**
* @tests java.io.StreamCorruptedException#StreamCorruptedException(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.StreamCorruptedException(java.lang.String)
try {
ObjectInputStream ois = new ObjectInputStream(
@@ -58,10 +57,9 @@
} catch (StreamCorruptedException e) {
// Correct
return;
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- fail("Failed to throw exception for non serialized stream");
+ }
+
+ fail("Failed to throw StreamCorruptedException for non serialized stream");
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StringReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StringReaderTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StringReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/StringReaderTest.java Wed Oct 31 01:42:07 2007
@@ -37,7 +37,7 @@
/**
* @tests java.io.StringReader#close()
*/
- public void test_close() {
+ public void test_close() throws Exception {
// Test for method void java.io.StringReader.close()
try {
sr = new StringReader(testString);
@@ -53,21 +53,17 @@
/**
* @tests java.io.StringReader#mark(int)
*/
- public void test_markI() {
+ public void test_markI() throws Exception {
// Test for method void java.io.StringReader.mark(int)
- try {
- sr = new StringReader(testString);
- sr.skip(5);
- sr.mark(0);
- sr.skip(5);
- sr.reset();
- char[] buf = new char[10];
- sr.read(buf, 0, 2);
- assertTrue("Failed to return to mark", new String(buf, 0, 2)
- .equals(testString.substring(5, 7)));
- } catch (Exception e) {
- fail("Exception during mark test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ sr.skip(5);
+ sr.mark(0);
+ sr.skip(5);
+ sr.reset();
+ char[] buf = new char[10];
+ sr.read(buf, 0, 2);
+ assertTrue("Failed to return to mark", new String(buf, 0, 2)
+ .equals(testString.substring(5, 7)));
}
/**
@@ -83,92 +79,72 @@
/**
* @tests java.io.StringReader#read()
*/
- public void test_read() {
+ public void test_read() throws Exception {
// Test for method int java.io.StringReader.read()
- try {
- sr = new StringReader(testString);
- int r = sr.read();
- assertEquals("Failed to read char", 'T', r);
- sr = new StringReader(new String(new char[] { '\u8765' }));
- assertTrue("Wrong double byte char", sr.read() == '\u8765');
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ int r = sr.read();
+ assertEquals("Failed to read char", 'T', r);
+ sr = new StringReader(new String(new char[] { '\u8765' }));
+ assertTrue("Wrong double byte char", sr.read() == '\u8765');
}
/**
* @tests java.io.StringReader#read(char[], int, int)
*/
- public void test_read$CII() {
+ public void test_read$CII() throws Exception {
// Test for method int java.io.StringReader.read(char [], int, int)
- try {
- sr = new StringReader(testString);
- char[] buf = new char[testString.length()];
- int r = sr.read(buf, 0, testString.length());
- assertTrue("Failed to read chars", r == testString.length());
- assertTrue("Read chars incorrectly", new String(buf, 0, r)
- .equals(testString));
- } catch (Exception e) {
- fail("Exception during read test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ char[] buf = new char[testString.length()];
+ int r = sr.read(buf, 0, testString.length());
+ assertTrue("Failed to read chars", r == testString.length());
+ assertTrue("Read chars incorrectly", new String(buf, 0, r)
+ .equals(testString));
}
/**
* @tests java.io.StringReader#ready()
*/
- public void test_ready() {
+ public void test_ready() throws Exception {
// Test for method boolean java.io.StringReader.ready()
- try {
- sr = new StringReader(testString);
- assertTrue("Steam not ready", sr.ready());
- sr.close();
- int r = 0;
- try {
- sr.ready();
- } catch (IOException e) {
- r = 1;
- }
- assertEquals("Expected IOException not thrown in read()", 1, r);
- } catch (IOException e) {
- fail("IOException during ready test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ assertTrue("Steam not ready", sr.ready());
+ sr.close();
+ int r = 0;
+ try {
+ sr.ready();
+ } catch (IOException e) {
+ r = 1;
+ }
+ assertEquals("Expected IOException not thrown in read()", 1, r);
}
/**
* @tests java.io.StringReader#reset()
*/
- public void test_reset() {
+ public void test_reset() throws Exception {
// Test for method void java.io.StringReader.reset()
- try {
- sr = new StringReader(testString);
- sr.skip(5);
- sr.mark(0);
- sr.skip(5);
- sr.reset();
- char[] buf = new char[10];
- sr.read(buf, 0, 2);
- assertTrue("Failed to reset properly", new String(buf, 0, 2)
- .equals(testString.substring(5, 7)));
- } catch (Exception e) {
- fail("Exception during reset test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ sr.skip(5);
+ sr.mark(0);
+ sr.skip(5);
+ sr.reset();
+ char[] buf = new char[10];
+ sr.read(buf, 0, 2);
+ assertTrue("Failed to reset properly", new String(buf, 0, 2)
+ .equals(testString.substring(5, 7)));
}
/**
* @tests java.io.StringReader#skip(long)
*/
- public void test_skipJ() {
+ public void test_skipJ() throws Exception {
// Test for method long java.io.StringReader.skip(long)
- try {
- sr = new StringReader(testString);
- sr.skip(5);
- char[] buf = new char[10];
- sr.read(buf, 0, 2);
- assertTrue("Failed to skip properly", new String(buf, 0, 2)
- .equals(testString.substring(5, 7)));
- } catch (Exception e) {
- fail("Exception during skip test : " + e.getMessage());
- }
+ sr = new StringReader(testString);
+ sr.skip(5);
+ char[] buf = new char[10];
+ sr.read(buf, 0, 2);
+ assertTrue("Failed to skip properly", new String(buf, 0, 2)
+ .equals(testString.substring(5, 7)));
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SyncFailedExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SyncFailedExceptionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SyncFailedExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/SyncFailedExceptionTest.java Wed Oct 31 01:42:07 2007
@@ -27,21 +27,20 @@
/**
* @tests java.io.SyncFailedException#SyncFailedException(java.lang.String)
*/
- public void test_ConstructorLjava_lang_String() {
+ public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.SyncFailedException(java.lang.String)
- File f = null;
- try {
- f = new File(System.getProperty("user.dir"), "synfail.tst");
- FileOutputStream fos = new FileOutputStream(f.getPath());
- FileDescriptor fd = fos.getFD();
- fos.close();
- fd.sync();
+ File f = null;
+ try {
+ f = new File(System.getProperty("user.dir"), "synfail.tst");
+ FileOutputStream fos = new FileOutputStream(f.getPath());
+ FileDescriptor fd = fos.getFD();
+ fos.close();
+ fd.sync();
} catch (SyncFailedException e) {
f.delete();
return;
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ }
+
fail("Failed to generate expected Exception");
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/UnsupportedEncodingExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/UnsupportedEncodingExceptionTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/UnsupportedEncodingExceptionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/UnsupportedEncodingExceptionTest.java Wed Oct 31 01:42:07 2007
@@ -32,10 +32,8 @@
new OutputStreamWriter(new ByteArrayOutputStream(), "BogusEncoding");
} catch (UnsupportedEncodingException e) {
return;
- } catch (Exception e) {
- fail("Exception during UnsupportedEncodingException test"
- + e.toString());
}
+
fail("Failed to generate expected exception");
}
@@ -49,10 +47,8 @@
new OutputStreamWriter(new ByteArrayOutputStream(), "BogusEncoding");
} catch (UnsupportedEncodingException e) {
return;
- } catch (Exception e) {
- fail("Exception during UnsupportedEncodingException test"
- + e.toString());
}
+
fail("Failed to generate expected exception");
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/Process2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/Process2Test.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/Process2Test.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/Process2Test.java Wed Oct 31 01:42:07 2007
@@ -32,22 +32,18 @@
* java.lang.Process#getOutputStream()
* Tests if these methods return buffered streams.
*/
- public void test_isBufferedStreams() {
+ public void test_isBufferedStreams() throws Exception {
// Regression test for HARMONY-2735.
- try {
- Object[] execArgs = Support_Exec.execJava2(new String[0], null, true);
- Process p = (Process) execArgs[0];
- InputStream in = p.getInputStream();
- assertTrue("getInputStream() returned non-buffered stream: " + in, (in instanceof BufferedInputStream));
- in = p.getErrorStream();
- assertTrue("getErrorStream() returned non-buffered stream: " + in, (in instanceof BufferedInputStream));
- OutputStream out = p.getOutputStream();
- assertTrue("getOutputStream() returned non-buffered stream: " + out, (out instanceof BufferedOutputStream));
- in.close();
- out.close();
- p.destroy();
- } catch (Exception ex) {
- fail("Unexpected exception got: " + ex);
- }
+ Object[] execArgs = Support_Exec.execJava2(new String[0], null, true);
+ Process p = (Process) execArgs[0];
+ InputStream in = p.getInputStream();
+ assertTrue("getInputStream() returned non-buffered stream: " + in, (in instanceof BufferedInputStream));
+ in = p.getErrorStream();
+ assertTrue("getErrorStream() returned non-buffered stream: " + in, (in instanceof BufferedInputStream));
+ OutputStream out = p.getOutputStream();
+ assertTrue("getOutputStream() returned non-buffered stream: " + out, (out instanceof BufferedOutputStream));
+ in.close();
+ out.close();
+ p.destroy();
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/PhantomReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/PhantomReferenceTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/PhantomReferenceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/PhantomReferenceTest.java Wed Oct 31 01:42:07 2007
@@ -41,18 +41,15 @@
* @tests java.lang.ref.PhantomReference#PhantomReference(java.lang.Object,
* java.lang.ref.ReferenceQueue)
*/
- public void test_ConstructorLjava_lang_ObjectLjava_lang_ref_ReferenceQueue() {
+ public void test_ConstructorLjava_lang_ObjectLjava_lang_ref_ReferenceQueue() throws Exception {
ReferenceQueue rq = new ReferenceQueue();
bool = new Boolean(true);
- try {
- PhantomReference pr = new PhantomReference(bool, rq);
- // Allow the finalizer to run to potentially enqueue
- Thread.sleep(1000);
- assertTrue("Initialization failed.", !pr.isEnqueued());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- // need a reference to bool so the jit does not optimize it away
+ PhantomReference pr = new PhantomReference(bool, rq);
+ // Allow the finalizer to run to potentially enqueue
+ Thread.sleep(1000);
+ assertTrue("Initialization failed.", !pr.isEnqueued());
+
+ // need a reference to bool so the jit does not optimize it away
assertTrue("should always pass", bool.booleanValue());
boolean exception = false;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceQueueTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceQueueTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceQueueTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceQueueTest.java Wed Oct 31 01:42:07 2007
@@ -62,48 +62,33 @@
b = new Boolean(true);
SoftReference sr = new SoftReference(b, rq);
sr.enqueue();
- try {
- assertTrue("Remove failed.", ((Boolean) rq.poll().get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during the test : " + e.getMessage());
- }
+ assertTrue("Remove failed.", ((Boolean) rq.poll().get())
+ .booleanValue());
}
/**
* @tests java.lang.ref.ReferenceQueue#remove()
*/
- public void test_remove() {
+ public void test_remove() throws Exception {
// store in a static so it won't be gc'ed because the jit
// optimized it out
b = new Boolean(true);
SoftReference sr = new SoftReference(b, rq);
sr.enqueue();
- try {
- assertTrue("Remove failed.", ((Boolean) rq.remove().get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during the test : " + e.getMessage());
- }
+ assertTrue("Remove failed.", ((Boolean) rq.remove().get())
+ .booleanValue());
}
/**
* @tests java.lang.ref.ReferenceQueue#remove(long)
*/
- public void test_removeJ() {
- try {
- assertNull("Queue is empty.", rq.poll());
- assertNull("Queue is empty.", rq.remove((long) 1));
- Thread ct = new Thread(new ChildThread());
- ct.start();
- Reference ret = rq.remove(0L);
- assertNotNull("Delayed remove failed.", ret);
- } catch (InterruptedException e) {
- fail("InterruptedExeException during test : " + e.getMessage());
- }
- catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ public void test_removeJ() throws Exception {
+ assertNull("Queue is empty.", rq.poll());
+ assertNull("Queue is empty.", rq.remove((long) 1));
+ Thread ct = new Thread(new ChildThread());
+ ct.start();
+ Reference ret = rq.remove(0L);
+ assertNotNull("Delayed remove failed.", ret);
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/ReferenceTest.java Wed Oct 31 01:42:07 2007
@@ -78,7 +78,7 @@
/**
* @tests java.lang.ref.Reference#enqueue()
*/
- public void test_general() {
+ public void test_general() throws Exception {
// Test the general/overall functionality of Reference.
class TestObject {
@@ -107,35 +107,27 @@
Reference ref;
- try {
- Thread t = new TestThread();
- t.start();
- t.join();
- System.gc();
- System.runFinalization();
- ref = rq.remove();
- assertTrue("Unexpected ref1", ref == wr);
- assertNotNull("Object not garbage collected1.", ref);
- assertNull("Object could not be reclaimed1.", wr.get());
- } catch (InterruptedException e) {
- fail("InterruptedException : " + e.getMessage());
- }
-
- try {
- Thread t = new TestThread();
- t.start();
- t.join();
- System.gc();
- System.runFinalization();
- ref = rq.poll();
- assertTrue("Unexpected ref2", ref == wr);
- assertNotNull("Object not garbage collected.", ref);
- assertNull("Object could not be reclaimed.", ref.get());
- // Reference wr so it does not get collected
- assertNull("Object could not be reclaimed.", wr.get());
- } catch (Exception e) {
- fail("Exception : " + e.getMessage());
- }
+ Thread t = new TestThread();
+ t.start();
+ t.join();
+ System.gc();
+ System.runFinalization();
+ ref = rq.remove();
+ assertTrue("Unexpected ref1", ref == wr);
+ assertNotNull("Object not garbage collected1.", ref);
+ assertNull("Object could not be reclaimed1.", wr.get());
+
+ t = new TestThread();
+ t.start();
+ t.join();
+ System.gc();
+ System.runFinalization();
+ ref = rq.poll();
+ assertTrue("Unexpected ref2", ref == wr);
+ assertNotNull("Object not garbage collected.", ref);
+ assertNull("Object could not be reclaimed.", ref.get());
+ // Reference wr so it does not get collected
+ assertNull("Object could not be reclaimed.", wr.get());
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/SoftReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/SoftReferenceTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/SoftReferenceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/SoftReferenceTest.java Wed Oct 31 01:42:07 2007
@@ -33,13 +33,9 @@
public void test_ConstructorLjava_lang_ObjectLjava_lang_ref_ReferenceQueue() {
ReferenceQueue rq = new ReferenceQueue();
bool = new Boolean(true);
- try {
- SoftReference sr = new SoftReference(bool, rq);
- assertTrue("Initialization failed.", ((Boolean) sr.get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ SoftReference sr = new SoftReference(bool, rq);
+ assertTrue("Initialization failed.", ((Boolean) sr.get())
+ .booleanValue());
boolean exception = false;
try {
@@ -55,13 +51,9 @@
*/
public void test_ConstructorLjava_lang_Object() {
bool = new Boolean(true);
- try {
- SoftReference sr = new SoftReference(bool);
- assertTrue("Initialization failed.", ((Boolean) sr.get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ SoftReference sr = new SoftReference(bool);
+ assertTrue("Initialization failed.", ((Boolean) sr.get())
+ .booleanValue());
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/WeakReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/WeakReferenceTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/WeakReferenceTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/ref/WeakReferenceTest.java Wed Oct 31 01:42:07 2007
@@ -34,15 +34,12 @@
public void test_ConstructorLjava_lang_ObjectLjava_lang_ref_ReferenceQueue() {
ReferenceQueue rq = new ReferenceQueue();
bool = new Boolean(true);
- try {
- // Allow the finalizer to run to potentially enqueue
- WeakReference wr = new WeakReference(bool, rq);
- assertTrue("Initialization failed.", ((Boolean) wr.get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- // need a reference to bool so the jit does not optimize it away
+ // Allow the finalizer to run to potentially enqueue
+ WeakReference wr = new WeakReference(bool, rq);
+ assertTrue("Initialization failed.", ((Boolean) wr.get())
+ .booleanValue());
+
+ // need a reference to bool so the jit does not optimize it away
assertTrue("should always pass", bool.booleanValue());
boolean exception = false;
@@ -57,18 +54,15 @@
/**
* @tests java.lang.ref.WeakReference#WeakReference(java.lang.Object)
*/
- public void test_ConstructorLjava_lang_Object() {
+ public void test_ConstructorLjava_lang_Object() throws Exception {
bool = new Boolean(true);
- try {
- WeakReference wr = new WeakReference(bool);
- // Allow the finalizer to run to potentially enqueue
- Thread.sleep(1000);
- assertTrue("Initialization failed.", ((Boolean) wr.get())
- .booleanValue());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- // need a reference to bool so the jit does not optimize it away
+ WeakReference wr = new WeakReference(bool);
+ // Allow the finalizer to run to potentially enqueue
+ Thread.sleep(1000);
+ assertTrue("Initialization failed.", ((Boolean) wr.get())
+ .booleanValue());
+
+ // need a reference to bool so the jit does not optimize it away
assertTrue("should always pass", bool.booleanValue());
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/AccessibleObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/AccessibleObjectTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/AccessibleObjectTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/AccessibleObjectTest.java Wed Oct 31 01:42:07 2007
@@ -28,38 +28,30 @@
/**
* @tests java.lang.reflect.AccessibleObject#isAccessible()
*/
- public void test_isAccessible() {
+ public void test_isAccessible() throws Exception {
// Test for method boolean
// java.lang.reflect.AccessibleObject.isAccessible()
- try {
- AccessibleObject ao = TestClass.class.getField("aField");
- ao.setAccessible(true);
- assertTrue("Returned false to isAccessible", ao.isAccessible());
- ao.setAccessible(false);
- assertTrue("Returned true to isAccessible", !ao.isAccessible());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ AccessibleObject ao = TestClass.class.getField("aField");
+ ao.setAccessible(true);
+ assertTrue("Returned false to isAccessible", ao.isAccessible());
+ ao.setAccessible(false);
+ assertTrue("Returned true to isAccessible", !ao.isAccessible());
}
/**
* @tests java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[],
* boolean)
*/
- public void test_setAccessible$Ljava_lang_reflect_AccessibleObjectZ() {
+ public void test_setAccessible$Ljava_lang_reflect_AccessibleObjectZ() throws Exception {
// Test for method void
// java.lang.reflect.AccessibleObject.setAccessible(java.lang.reflect.AccessibleObject
// [], boolean)
- try {
- AccessibleObject ao = TestClass.class.getField("aField");
- AccessibleObject[] aoa = new AccessibleObject[] { ao };
- AccessibleObject.setAccessible(aoa, true);
- assertTrue("Returned false to isAccessible", ao.isAccessible());
- AccessibleObject.setAccessible(aoa, false);
- assertTrue("Returned true to isAccessible", !ao.isAccessible());
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
+ AccessibleObject ao = TestClass.class.getField("aField");
+ AccessibleObject[] aoa = new AccessibleObject[] { ao };
+ AccessibleObject.setAccessible(aoa, true);
+ assertTrue("Returned false to isAccessible", ao.isAccessible());
+ AccessibleObject.setAccessible(aoa, false);
+ assertTrue("Returned true to isAccessible", !ao.isAccessible());
}
/**
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ArrayTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ArrayTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ArrayTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ArrayTest.java Wed Oct 31 01:42:07 2007
@@ -31,12 +31,9 @@
int[] x = { 1 };
Object ret = null;
boolean thrown = false;
- try {
- ret = Array.get(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value",
+ ret = Array.get(x, 0);
+
+ assertEquals("Get returned incorrect value",
1, ((Integer) ret).intValue());
try {
ret = Array.get(new Object(), 0);
@@ -68,12 +65,9 @@
boolean[] x = { true };
boolean ret = false;
boolean thrown = false;
- try {
- ret = Array.getBoolean(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertTrue("Get returned incorrect value", ret);
+ ret = Array.getBoolean(x, 0);
+
+ assertTrue("Get returned incorrect value", ret);
try {
ret = Array.getBoolean(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -104,12 +98,9 @@
byte[] x = { 1 };
byte ret = 0;
boolean thrown = false;
- try {
- ret = Array.getByte(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret);
+ ret = Array.getByte(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getByte(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -140,12 +131,9 @@
char[] x = { 1 };
char ret = 0;
boolean thrown = false;
- try {
- ret = Array.getChar(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret);
+ ret = Array.getChar(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getChar(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -176,12 +164,9 @@
double[] x = { 1 };
double ret = 0;
boolean thrown = false;
- try {
- ret = Array.getDouble(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret, 0.0);
+ ret = Array.getDouble(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret, 0.0);
try {
ret = Array.getDouble(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -213,12 +198,9 @@
float[] x = { 1 };
float ret = 0;
boolean thrown = false;
- try {
- ret = Array.getFloat(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret, 0.0);
+ ret = Array.getFloat(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret, 0.0);
try {
ret = Array.getFloat(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -249,12 +231,9 @@
int[] x = { 1 };
int ret = 0;
boolean thrown = false;
- try {
- ret = Array.getInt(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret);
+ ret = Array.getInt(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getInt(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -305,12 +284,9 @@
long[] x = { 1 };
long ret = 0;
boolean thrown = false;
- try {
- ret = Array.getLong(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret);
+ ret = Array.getLong(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getLong(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -341,12 +317,9 @@
short[] x = { 1 };
short ret = 0;
boolean thrown = false;
- try {
- ret = Array.getShort(x, 0);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ret);
+ ret = Array.getShort(x, 0);
+
+ assertEquals("Get returned incorrect value", 1, ret);
try {
ret = Array.getShort(new Object(), 0);
} catch (IllegalArgumentException e) {
@@ -403,12 +376,9 @@
// int, java.lang.Object)
int[] x = { 0 };
boolean thrown = false;
- try {
- Array.set(x, 0, new Integer(1));
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, ((Integer) Array.get(x, 0))
+ Array.set(x, 0, new Integer(1));
+
+ assertEquals("Get returned incorrect value", 1, ((Integer) Array.get(x, 0))
.intValue());
try {
Array.set(new Object(), 0, new Object());
@@ -449,12 +419,9 @@
// java.lang.reflect.Array.setBoolean(java.lang.Object, int, boolean)
boolean[] x = { false };
boolean thrown = false;
- try {
- Array.setBoolean(x, 0, true);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertTrue("Failed to set correct value", Array.getBoolean(x, 0));
+ Array.setBoolean(x, 0, true);
+
+ assertTrue("Failed to set correct value", Array.getBoolean(x, 0));
try {
Array.setBoolean(new Object(), 0, false);
} catch (IllegalArgumentException e) {
@@ -484,12 +451,9 @@
// java.lang.reflect.Array.setByte(java.lang.Object, int, byte)
byte[] x = { 0 };
boolean thrown = false;
- try {
- Array.setByte(x, 0, (byte) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getByte(x, 0));
+ Array.setByte(x, 0, (byte) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getByte(x, 0));
try {
Array.setByte(new Object(), 0, (byte) 9);
} catch (IllegalArgumentException e) {
@@ -519,12 +483,9 @@
// java.lang.reflect.Array.setChar(java.lang.Object, int, char)
char[] x = { 0 };
boolean thrown = false;
- try {
- Array.setChar(x, 0, (char) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getChar(x, 0));
+ Array.setChar(x, 0, (char) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getChar(x, 0));
try {
Array.setChar(new Object(), 0, (char) 9);
} catch (IllegalArgumentException e) {
@@ -554,12 +515,9 @@
// java.lang.reflect.Array.setDouble(java.lang.Object, int, double)
double[] x = { 0 };
boolean thrown = false;
- try {
- Array.setDouble(x, 0, (double) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getDouble(x, 0), 0.0);
+ Array.setDouble(x, 0, (double) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getDouble(x, 0), 0.0);
try {
Array.setDouble(new Object(), 0, (double) 9);
} catch (IllegalArgumentException e) {
@@ -589,12 +547,9 @@
// java.lang.reflect.Array.setFloat(java.lang.Object, int, float)
float[] x = { 0.0f };
boolean thrown = false;
- try {
- Array.setFloat(x, 0, (float) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getFloat(x, 0), 0.0);
+ Array.setFloat(x, 0, (float) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getFloat(x, 0), 0.0);
try {
Array.setFloat(new Object(), 0, (float) 9);
} catch (IllegalArgumentException e) {
@@ -624,12 +579,9 @@
// int, int)
int[] x = { 0 };
boolean thrown = false;
- try {
- Array.setInt(x, 0, (int) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getInt(x, 0));
+ Array.setInt(x, 0, (int) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getInt(x, 0));
try {
Array.setInt(new Object(), 0, (int) 9);
} catch (IllegalArgumentException e) {
@@ -659,12 +611,9 @@
// java.lang.reflect.Array.setLong(java.lang.Object, int, long)
long[] x = { 0 };
boolean thrown = false;
- try {
- Array.setLong(x, 0, (long) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getLong(x, 0));
+ Array.setLong(x, 0, (long) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getLong(x, 0));
try {
Array.setLong(new Object(), 0, (long) 9);
} catch (IllegalArgumentException e) {
@@ -694,12 +643,9 @@
// java.lang.reflect.Array.setShort(java.lang.Object, int, short)
short[] x = { 0 };
boolean thrown = false;
- try {
- Array.setShort(x, 0, (short) 1);
- } catch (Exception e) {
- fail("Exception during get test : " + e.getMessage());
- }
- assertEquals("Get returned incorrect value", 1, Array.getShort(x, 0));
+ Array.setShort(x, 0, (short) 1);
+
+ assertEquals("Get returned incorrect value", 1, Array.getShort(x, 0));
try {
Array.setShort(new Object(), 0, (short) 9);
} catch (IllegalArgumentException e) {
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ConstructorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ConstructorTest.java?rev=590591&r1=590590&r2=590591&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ConstructorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/lang/reflect/ConstructorTest.java Wed Oct 31 01:42:07 2007
@@ -46,60 +46,51 @@
/**
* @tests java.lang.reflect.Constructor#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.Constructor.equals(java.lang.Object)
Class[] types = null;
Constructor ctor1 = null, ctor2 = null;
- try {
- ctor1 = new ConstructorTestHelper().getClass().getConstructor(
- new Class[0]);
+ ctor1 = new ConstructorTestHelper().getClass().getConstructor(
+ new Class[0]);
- Class[] parms = null;
- parms = new Class[1];
- parms[0] = new Object().getClass();
- ctor2 = new ConstructorTestHelper().getClass()
- .getConstructor(parms);
- } catch (Exception e) {
- fail("Exception during equals test : " + e.getMessage());
- }
- assertTrue("Different Constructors returned equal", !ctor1.equals(ctor2));
+ Class[] parms = null;
+ parms = new Class[1];
+ parms[0] = new Object().getClass();
+ ctor2 = new ConstructorTestHelper().getClass()
+ .getConstructor(parms);
+
+ assertTrue("Different Constructors returned equal", !ctor1.equals(ctor2));
}
/**
* @tests java.lang.reflect.Constructor#getDeclaringClass()
*/
- public void test_getDeclaringClass() {
+ public void test_getDeclaringClass() throws Exception {
// Test for method java.lang.Class
// java.lang.reflect.Constructor.getDeclaringClass()
boolean val = false;
- try {
- Class pclass = new ConstructorTestHelper().getClass();
- Constructor ctor = pclass.getConstructor(new Class[0]);
- val = ctor.getDeclaringClass().equals(pclass);
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- assertTrue("Returned incorrect declaring class", val);
+ Class pclass = new ConstructorTestHelper().getClass();
+ Constructor ctor = pclass.getConstructor(new Class[0]);
+ val = ctor.getDeclaringClass().equals(pclass);
+
+ assertTrue("Returned incorrect declaring class", val);
}
/**
* @tests java.lang.reflect.Constructor#getExceptionTypes()
*/
- public void test_getExceptionTypes() {
+ public void test_getExceptionTypes() throws Exception {
// Test for method java.lang.Class []
// java.lang.reflect.Constructor.getExceptionTypes()
Class[] exceptions = null;
Class ex = null;
- try {
- Constructor ctor = new ConstructorTestHelper().getClass()
- .getConstructor(new Class[0]);
- exceptions = ctor.getExceptionTypes();
- ex = new IndexOutOfBoundsException().getClass();
- } catch (Exception e) {
- fail("Exception during test : " + e.getMessage());
- }
- assertEquals("Returned exception list of incorrect length",
+ Constructor ctor = new ConstructorTestHelper().getClass()
+ .getConstructor(new Class[0]);
+ exceptions = ctor.getExceptionTypes();
+ ex = new IndexOutOfBoundsException().getClass();
+
+ assertEquals("Returned exception list of incorrect length",
1, exceptions.length);
assertTrue("Returned incorrect exception", exceptions[0].equals(ex));
}
@@ -147,89 +138,69 @@
/**
* @tests java.lang.reflect.Constructor#getName()
*/
- public void test_getName() {
+ public void test_getName() throws Exception {
// Test for method java.lang.String
// java.lang.reflect.Constructor.getName()
- try {
- Constructor ctor = new ConstructorTestHelper().getClass()
- .getConstructor(new Class[0]);
- assertTrue(
- "Returned incorrect name: " + ctor.getName(),
- ctor
- .getName()
- .equals(
- "tests.api.java.lang.reflect.ConstructorTest$ConstructorTestHelper"));
- } catch (Exception e) {
- fail("Exception obtaining constructor : " + e.getMessage());
- }
+ Constructor ctor = new ConstructorTestHelper().getClass()
+ .getConstructor(new Class[0]);
+ assertTrue(
+ "Returned incorrect name: " + ctor.getName(),
+ ctor
+ .getName()
+ .equals(
+ "tests.api.java.lang.reflect.ConstructorTest$ConstructorTestHelper"));
}
/**
* @tests java.lang.reflect.Constructor#getParameterTypes()
*/
- public void test_getParameterTypes() {
+ public void test_getParameterTypes() throws Exception {
// Test for method java.lang.Class []
// java.lang.reflect.Constructor.getParameterTypes()
Class[] types = null;
- try {
- Constructor ctor = new ConstructorTestHelper().getClass()
- .getConstructor(new Class[0]);
- types = ctor.getParameterTypes();
- } catch (Exception e) {
- fail("Exception during getParameterTypes test:"
- + e.toString());
- }
- assertEquals("Incorrect parameter returned", 0, types.length);
+ Constructor ctor = new ConstructorTestHelper().getClass()
+ .getConstructor(new Class[0]);
+ types = ctor.getParameterTypes();
+
+ assertEquals("Incorrect parameter returned", 0, types.length);
Class[] parms = null;
- try {
- parms = new Class[1];
- parms[0] = new Object().getClass();
- Constructor ctor = new ConstructorTestHelper().getClass()
- .getConstructor(parms);
- types = ctor.getParameterTypes();
- } catch (Exception e) {
- fail("Exception during getParameterTypes test:"
- + e.toString());
- }
- assertTrue("Incorrect parameter returned", types[0].equals(parms[0]));
+ parms = new Class[1];
+ parms[0] = new Object().getClass();
+ ctor = new ConstructorTestHelper().getClass().getConstructor(parms);
+ types = ctor.getParameterTypes();
+
+ assertTrue("Incorrect parameter returned", types[0].equals(parms[0]));
}
/**
* @tests java.lang.reflect.Constructor#newInstance(java.lang.Object[])
*/
- public void test_newInstance$Ljava_lang_Object() {
+ public void test_newInstance$Ljava_lang_Object() throws Exception {
// Test for method java.lang.Object
// java.lang.reflect.Constructor.newInstance(java.lang.Object [])
ConstructorTestHelper test = null;
- try {
- Constructor ctor = new ConstructorTestHelper().getClass()
- .getConstructor(new Class[0]);
- test = (ConstructorTestHelper) ctor.newInstance((Object[])null);
- } catch (Exception e) {
- fail("Failed to create instance : " + e.getMessage());
- }
- assertEquals("improper instance created", 99, test.check());
+ Constructor ctor = new ConstructorTestHelper().getClass()
+ .getConstructor(new Class[0]);
+ test = (ConstructorTestHelper) ctor.newInstance((Object[])null);
+
+ assertEquals("improper instance created", 99, test.check());
}
/**
* @tests java.lang.reflect.Constructor#toString()
*/
- public void test_toString() {
+ public void test_toString() throws Exception {
// Test for method java.lang.String
// java.lang.reflect.Constructor.toString()
Class[] parms = null;
Constructor ctor = null;
- try {
- parms = new Class[1];
- parms[0] = new Object().getClass();
- ctor = new ConstructorTestHelper().getClass().getConstructor(parms);
- } catch (Exception e) {
- fail("Exception during getParameterTypes test:"
- + e.toString());
- }
- assertTrue(
+ parms = new Class[1];
+ parms[0] = new Object().getClass();
+ ctor = new ConstructorTestHelper().getClass().getConstructor(parms);
+
+ assertTrue(
"Returned incorrect string representation: " + ctor.toString(),
ctor
.toString()