1 32 package net.sf.retrotranslator.runtime.java.lang; 33 34 import java.io.*; 35 import java.nio.CharBuffer ; 36 import java.util.*; 37 import junit.framework.TestCase; 38 39 42 public class _ReadableTestCase extends TestCase { 43 44 private static class MyReadable implements Readable { 45 public int read(CharBuffer cb) throws IOException { 46 cb.put("123"); 47 return 3; 48 } 49 } 50 51 public void testRead() throws Exception { 52 List<Readable > list = Arrays.asList(new Readable [] { 53 new StringReader("abc"), 54 CharBuffer.wrap("xyz"), 55 new MyReadable() 56 }); 57 CharBuffer buffer = CharBuffer.allocate(10); 58 for (Readable readable : list) { 59 assertEquals(3, readable.read(buffer)); 60 } 61 buffer.limit(buffer.position()); 62 buffer.position(0); 63 assertEquals("abcxyz123", buffer.toString()); 64 } 65 66 } | Popular Tags |