Package java.io

Examples of java.io.ByteArrayInputStream.available()


        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);

        int count = CopyUtils.copy(in, out);
       
        assertEquals("Not all bytes were read", 0, in.available());
        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
        assertEquals(inData.length, count);
    }
View Full Code Here


        Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII");
       
        CopyUtils.copy(in, writer);
        writer.flush();

        assertEquals("Not all bytes were read", 0, in.available());
        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
    }

    public void testCopy_inputStreamToWriterWithEncoding() throws Exception {
View Full Code Here

    long[] result = new PopulationCodec(codec,codec,codec).decode(expectedResult.length,in);
    assertEquals(expectedResult.length,result.length);
    for(int i=0;i<expectedResult.length;i++) {
      assertEquals(expectedResult[i],result[i]);
    }
    assertEquals(0,in.available());
  }

}
View Full Code Here

        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);

        int count = IOUtils.copy(in, out);
       
        assertEquals("Not all bytes were read", 0, in.available());
        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
        assertEquals(inData.length,count);
    }
View Full Code Here

       
        IOUtils.copy(in, writer);
        out.off();
        writer.flush();

        assertEquals("Not all bytes were read", 0, in.available());
        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
    }

    public void testCopy_inputStreamToWriter_nullIn() throws Exception {
View Full Code Here

       
        IOUtils.copy(in, writer, "UTF8");
        out.off();
        writer.flush();

        assertEquals("Not all bytes were read", 0, in.available());
        byte[] bytes = baout.toByteArray();
        bytes = new String(bytes, "UTF8").getBytes("US-ASCII");
        assertTrue("Content differs", Arrays.equals(inData, bytes));
    }
View Full Code Here

       
        IOUtils.copy(in, writer, null);
        out.off();
        writer.flush();

        assertEquals("Not all bytes were read", 0, in.available());
        assertEquals("Sizes differ", inData.length, baout.size());
        assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
    }

    //-----------------------------------------------------------------------
View Full Code Here

    RunCodec runCodec = new RunCodec(1,Codec.UNSIGNED5,Codec.BYTE1);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(0,bais.available());
    runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
    bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
View Full Code Here

    runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
    bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,bais.available());
  }
  public void testUnsigned5() throws Exception {
    decode(Codec.UNSIGNED5, new byte[] { 1 }, 1, 0);
    decode(Codec.UNSIGNED5, new byte[] { (byte) 191 }, 191, 0);
    decode(Codec.UNSIGNED5, new byte[] { (byte) 192, 0 }, 192, 0);
View Full Code Here

    private void verifyReceivedMessage(Message message) {
        ByteArrayInputStream bis = (ByteArrayInputStream)message.getContent(InputStream.class);
        String response = "<not found>";
        if (bis != null) {
            byte bytes[] = new byte[bis.available()];
            try {
                bis.read(bytes);
            } catch (IOException ex) {
                assertFalse("Read the Destination recieved Message error ", false);
                ex.printStackTrace();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.