diff options
author | alanb <none@none> | 2010-06-23 20:19:29 +0100 |
---|---|---|
committer | alanb <none@none> | 2010-06-23 20:19:29 +0100 |
commit | 9758b5d9166376b2e71397e101758ab5611f09ff (patch) | |
tree | cc4f40b066572d73030b2563f02871b4cc1e85ca /test/sun/nio | |
parent | 138ad052a7487d5e2fe7b95be32db6729eefbd06 (diff) |
6963027: TEST_BUG: channels and buffer tests need to run in samevm mode
Reviewed-by: ohair, sherman, chegar
Diffstat (limited to 'test/sun/nio')
-rw-r--r-- | test/sun/nio/ch/Basic.java | 2 | ||||
-rw-r--r-- | test/sun/nio/ch/TempBuffer.java | 23 | ||||
-rw-r--r-- | test/sun/nio/cs/ReadZero.java | 19 | ||||
-rw-r--r-- | test/sun/nio/cs/Test4206507.java | 9 | ||||
-rw-r--r-- | test/sun/nio/cs/TestStringCoding.java | 2 |
5 files changed, 38 insertions, 17 deletions
diff --git a/test/sun/nio/ch/Basic.java b/test/sun/nio/ch/Basic.java index a5f028b10..5d13d08ee 100644 --- a/test/sun/nio/ch/Basic.java +++ b/test/sun/nio/ch/Basic.java @@ -32,5 +32,7 @@ import java.nio.channels.Pipe; public class Basic { public static void main(String[] args) throws Exception { Pipe p = Pipe.open(); + p.source().close(); + p.sink().close(); } } diff --git a/test/sun/nio/ch/TempBuffer.java b/test/sun/nio/ch/TempBuffer.java index 53c71d507..e71ce7d60 100644 --- a/test/sun/nio/ch/TempBuffer.java +++ b/test/sun/nio/ch/TempBuffer.java @@ -54,8 +54,12 @@ public class TempBuffer { blah.deleteOnExit(); TempBuffer.initTestFile(blah); RandomAccessFile raf = new RandomAccessFile(blah, "rw"); - FileChannel fs = raf.getChannel(); - fs.transferTo(0, SIZE, Channels.newChannel(out)); + FileChannel fc = raf.getChannel(); + try { + fc.transferTo(0, SIZE, Channels.newChannel(out)); + } finally { + fc.close(); + } out.flush(); } catch (IOException ioe) { throw new RuntimeException(ioe); @@ -69,10 +73,17 @@ public class TempBuffer { File blah = File.createTempFile("blah2", null); blah.deleteOnExit(); RandomAccessFile raf = new RandomAccessFile(blah, "rw"); - FileChannel fs = raf.getChannel(); - raf.setLength(SIZE); - fs.transferFrom(Channels.newChannel(in), 0, SIZE); - fs.close(); + FileChannel fc = raf.getChannel(); + try { + raf.setLength(SIZE); + fc.transferFrom(Channels.newChannel(in), 0, SIZE); + } finally { + fc.close(); + } + + sourceChannel.close(); + sinkChannel.close(); + blah.delete(); } private static void initTestFile(File blah) throws IOException { diff --git a/test/sun/nio/cs/ReadZero.java b/test/sun/nio/cs/ReadZero.java index 06741dcfa..05b58194a 100644 --- a/test/sun/nio/cs/ReadZero.java +++ b/test/sun/nio/cs/ReadZero.java @@ -43,15 +43,18 @@ public class ReadZero { return 0; } }; - - is.read(new byte[1], 0, 1); // ok - InputStreamReader isr = new InputStreamReader(is); - try { - int res = isr.read(new char[1], 0, 1); - } catch (IOException x) { - System.out.println("IOException caught"); - return; + is.read(new byte[1], 0, 1); // ok + InputStreamReader isr = new InputStreamReader(is); + + try { + int res = isr.read(new char[1], 0, 1); + } catch (IOException x) { + System.out.println("IOException caught"); + return; + } + } finally { + is.close(); } throw new RuntimeException("IOException not thrown"); } diff --git a/test/sun/nio/cs/Test4206507.java b/test/sun/nio/cs/Test4206507.java index 61e7ce444..3b6f9f61f 100644 --- a/test/sun/nio/cs/Test4206507.java +++ b/test/sun/nio/cs/Test4206507.java @@ -32,7 +32,12 @@ import java.io.UnsupportedEncodingException; public class Test4206507 { public static void main(String[] args) throws UnsupportedEncodingException { - Locale.setDefault(new Locale("tr", "TR")); - byte[] b = "".getBytes("ISO8859-9"); + Locale l = Locale.getDefault(); + try { + Locale.setDefault(new Locale("tr", "TR")); + byte[] b = "".getBytes("ISO8859-9"); + } finally { + Locale.setDefault(l); + } } } diff --git a/test/sun/nio/cs/TestStringCoding.java b/test/sun/nio/cs/TestStringCoding.java index 6acbad9fa..61b1c37e7 100644 --- a/test/sun/nio/cs/TestStringCoding.java +++ b/test/sun/nio/cs/TestStringCoding.java @@ -26,7 +26,7 @@ /* @test @bug 6636323 6636319 @summary Test if StringCoding and NIO result have the same de/encoding result - * @run main/timeout=2000 TestStringCoding + * @run main/othervm/timeout=2000 TestStringCoding */ import java.util.*; |