Code example for CountingOutputStream

Methods: getCount

0
  public static final Log LOG = LogFactory.getLog(TestCellMessageCodec.class);
 
  @Test
  public void testEmptyWorks() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CountingOutputStream cos = new CountingOutputStream(baos);
    DataOutputStream dos = new DataOutputStream(cos);
    MessageCodec cmc = new MessageCodec();
    Codec.Encoder encoder = cmc.getEncoder(dos);
    encoder.flush(); 
    dos.close();
    long offset = cos.getCount();
    assertEquals(0, offset);
    CountingInputStream cis = new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
    DataInputStream dis = new DataInputStream(cis);
    Codec.Decoder decoder = cmc.getDecoder(dis);
    assertFalse(decoder.advance()); 
    dis.close();
    assertEquals(0, cis.getCount());
  } 
Contextual code suggestions in your IDE  Get Codota for Java