Esempio n. 1
0
 @Test
 public void testDrainTo_none() throws Exception {
   Message m = new Message();
   byte[] bytes = IoUtils.toByteArray(marshaller.stream(m));
   InputStream is = marshaller.stream(m);
   byte[] unused = IoUtils.toByteArray(is);
   Drainable d = (Drainable) is;
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   assertEquals(0, d.drainTo(baos));
   assertArrayEquals(new byte[0], baos.toByteArray());
   assertEquals(0, is.available());
 }
Esempio n. 2
0
 @Test
 public void testDrainTo_all() throws Exception {
   Message m = new Message();
   byte[] bytes = IoUtils.toByteArray(marshaller.stream(m));
   InputStream is = marshaller.stream(m);
   Drainable d = (Drainable) is;
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   int drained = d.drainTo(baos);
   assertEquals(baos.size(), drained);
   assertArrayEquals(bytes, baos.toByteArray());
   assertEquals(0, is.available());
 }