Example usage for io.netty.buffer ByteBuf maxCapacity

List of usage examples for io.netty.buffer ByteBuf maxCapacity

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf maxCapacity.

Prototype

public abstract int maxCapacity();

Source Link

Document

Returns the maximum allowed capacity of this buffer.

Usage

From source file:io.vertx.proton.impl.ProtonWritableBufferImplTest.java

License:Apache License

@Test
public void testRemaining() {
    ByteBuf buffer = Unpooled.buffer(1024);
    ProtonWritableBufferImpl writable = new ProtonWritableBufferImpl(buffer);

    assertEquals(buffer.maxCapacity(), writable.remaining());
    writable.put((byte) 0);
    assertEquals(buffer.maxCapacity() - 1, writable.remaining());
}

From source file:io.vertx.proton.impl.ProtonWritableBufferImplTest.java

License:Apache License

@Test
public void testHasRemaining() {
    ByteBuf buffer = Unpooled.buffer(100, 100);
    ProtonWritableBufferImpl writable = new ProtonWritableBufferImpl(buffer);

    assertTrue(writable.hasRemaining());
    writable.put((byte) 0);
    assertTrue(writable.hasRemaining());
    buffer.writerIndex(buffer.maxCapacity());
    assertFalse(writable.hasRemaining());
}

From source file:org.apache.activemq.artemis.protocol.amqp.util.NettyWritableTest.java

License:Apache License

@Test
public void testRemaining() {
    ByteBuf buffer = Unpooled.buffer(1024);
    NettyWritable writable = new NettyWritable(buffer);

    assertEquals(buffer.maxCapacity(), writable.remaining());
    writable.put((byte) 0);
    assertEquals(buffer.maxCapacity() - 1, writable.remaining());
}

From source file:org.apache.activemq.artemis.protocol.amqp.util.NettyWritableTest.java

License:Apache License

@Test
public void testHasRemaining() {
    ByteBuf buffer = Unpooled.buffer(100, 100);
    NettyWritable writable = new NettyWritable(buffer);

    assertTrue(writable.hasRemaining());
    writable.put((byte) 0);
    assertTrue(writable.hasRemaining());
    buffer.writerIndex(buffer.maxCapacity());
    assertFalse(writable.hasRemaining());
}

From source file:org.apache.qpid.jms.provider.amqp.message.AmqpWritableBufferTest.java

License:Apache License

@Test
public void testRemaining() {
    ByteBuf buffer = Unpooled.buffer(1024);
    AmqpWritableBuffer writable = new AmqpWritableBuffer(buffer);

    assertEquals(buffer.maxCapacity(), writable.remaining());
    writable.put((byte) 0);
    assertEquals(buffer.maxCapacity() - 1, writable.remaining());
}

From source file:org.apache.qpid.jms.provider.amqp.message.AmqpWritableBufferTest.java

License:Apache License

@Test
public void testHasRemaining() {
    ByteBuf buffer = Unpooled.buffer(100, 100);
    AmqpWritableBuffer writable = new AmqpWritableBuffer(buffer);

    assertTrue(writable.hasRemaining());
    writable.put((byte) 0);
    assertTrue(writable.hasRemaining());
    buffer.writerIndex(buffer.maxCapacity());
    assertFalse(writable.hasRemaining());
}

From source file:reactor.io.net.impl.netty.NettyChannelHandlerBridge.java

License:Apache License

private static boolean bufferHasSufficientCapacity(ByteBuf receiver, ByteBuf provider) {
    return receiver.writerIndex() <= receiver.maxCapacity() - provider.readableBytes();
}

From source file:reactor.io.net.impl.netty.NettyNetChannelInboundHandler.java

License:Apache License

private boolean bufferHasSufficientCapacity(ByteBuf receiver, ByteBuf provider) {
    return receiver.writerIndex() <= receiver.maxCapacity() - provider.readableBytes();
}