Package java.io

Examples of java.io.ByteArrayInputStream.markSupported()


  @Test
  public void testMarkSupported() throws IOException
  {
    InputStream data = new ByteArrayInputStream(DATA);
    CountingInputStream in = new CountingInputStream(data);
    assertEquals(data.markSupported(), in.markSupported());
  }

  @Test
  public void testMarkAndReset() throws IOException
  {


     */
    public void test_markSupported() {
        InputStream is = new ByteArrayInputStream(new byte[10]);
        InflaterInputStream iis = new InflaterInputStream(is);
        assertFalse(iis.markSupported());
        assertTrue(is.markSupported());
    }

  /**
     * @tests java.util.zip.InflaterInputStream#read()
     */
 

  @Test
  public void testMarkSupported() throws IOException
  {
    InputStream data = new ByteArrayInputStream(DATA);
    InputStream in = new LimitInputStream(data, 10);
    assertEquals(data.markSupported(), in.markSupported());
  }

  @Test
  public void testMarkAndReset() throws IOException
  {

             * @see java.io.InputStream#markSupported()
             */
            @Override
            public boolean markSupported()
            {
                return proxy.markSupported();
            }

            /* (non-Javadoc)
             * @see java.io.InputStream#read(byte[], int, int)
             */
 

     */
    public void test_markSupported() {
        InputStream is = new ByteArrayInputStream(new byte[10]);
        InflaterInputStream iis = new InflaterInputStream(is);
        assertFalse(iis.markSupported());
        assertTrue(is.markSupported());
    }

  /**
     * @tests java.util.zip.InflaterInputStream#read()
     */
 

     */
    public void test_markSupported() {
        InputStream is = new ByteArrayInputStream(new byte[10]);
        InflaterInputStream iis = new InflaterInputStream(is);
        assertFalse(iis.markSupported());
        assertTrue(is.markSupported());
    }

  /**
     * @tests java.util.zip.InflaterInputStream#read()
     */
 

        // frame
        byte[] length = new byte[4];
        transport.read( length, 0, 4 );

        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        // magic
        Assert.assertEquals( ThriftCodec.MAGIC, protocol.readI16() );

        Assert.assertEquals( Demo.Iface.class.getName(), protocol.readString() );
        // dubbo request id
        Assert.assertEquals( request.getId(), protocol.readI64() );

        // test message header length
        if ( bis.markSupported() ) {
            bis.reset();
            bis.skip( headerLength );
        }

        TMessage message = protocol.readMessageBegin();

        byte[] buf = new byte[bos.writerIndex() - 4];
        System.arraycopy( bos.array(), 4, buf, 0, bos.writerIndex() - 4 );

        ByteArrayInputStream bis = new ByteArrayInputStream( buf );

        if ( bis.markSupported() ) {
            bis.mark( 0 );
        }

        TIOStreamTransport transport = new TIOStreamTransport( bis );
        TBinaryProtocol protocol = new TBinaryProtocol( transport );

        Assert.assertEquals( ThriftCodec.VERSION, protocol.readByte() );
        Assert.assertEquals( Demo.Iface.class.getName(), protocol.readString() );
        Assert.assertEquals( request.getId(), protocol.readI64() );

        if ( bis.markSupported() ) {
            bis.reset();
            bis.skip( headerLength );
        }

        TMessage message = protocol.readMessageBegin();

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.