1 32 package net.sf.retrotranslator.runtime.java.io; 33 34 import java.io.*; 35 import java.util.*; 36 import junit.framework.TestCase; 37 38 41 public class _CloseableTestCase extends TestCase { 42 43 public void testClose() throws Exception { 44 File tempFile = File.createTempFile("closeable", "test"); 45 tempFile.deleteOnExit(); 46 RandomAccessFile randomAccessFile = new RandomAccessFile(tempFile, "r"); 47 48 List<Closeable> closeables = Arrays.asList(new Closeable[] { 49 new ByteArrayInputStream("abc".getBytes()), 50 new ByteArrayOutputStream(), 51 new StringReader("abc"), 52 new StringWriter(), 53 randomAccessFile, 54 randomAccessFile.getChannel(), 55 new Closeable() { 56 public void close() throws IOException { 57 } 58 } 59 }); 60 61 for (Closeable closeable : closeables) { 62 closeable.close(); 63 } 64 } 65 } | Popular Tags |