Search in sources :

Example 36 with ByteBuf

use of com.firenio.buffer.ByteBuf in project baseio by generallycloud.

the class TestBytebufPut method testput0.

@Test
public void testput0() {
    ByteBuf src = ByteBuf.direct(1024);
    src.writeBytes(data.getBytes());
    ByteBuf dst = ByteBuf.direct(1024);
    dst.writeBytes(src);
    v(dst);
}
Also used : ByteBuf(com.firenio.buffer.ByteBuf) Test(org.junit.Test)

Example 37 with ByteBuf

use of com.firenio.buffer.ByteBuf in project baseio by generallycloud.

the class TestExpansion method directUnPool.

@Test
public void directUnPool() {
    ByteBuf buf = ByteBuf.direct(2);
    for (int i = 0; i < 10; i++) {
        buf.writeBytes(data);
        buf.writeByte(a);
    }
    Assert.assertTrue(v(buf));
}
Also used : ByteBuf(com.firenio.buffer.ByteBuf) Test(org.junit.Test)

Example 38 with ByteBuf

use of com.firenio.buffer.ByteBuf in project baseio by generallycloud.

the class TestExpansion method arrayUnPool.

@Test
public void arrayUnPool() {
    ByteBuf buf = ByteBuf.heap(2);
    buf.clear();
    for (int i = 0; i < 10; i++) {
        buf.writeBytes(data);
        buf.writeByte(a);
    }
    Assert.assertTrue(v(buf));
}
Also used : ByteBuf(com.firenio.buffer.ByteBuf) Test(org.junit.Test)

Example 39 with ByteBuf

use of com.firenio.buffer.ByteBuf in project baseio by generallycloud.

the class TestByteBufPool method main.

public static void main(String[] args) throws Exception {
    ChannelConnector context = new ChannelConnector("192.168.1.102", 6500);
    context.addChannelEventListener(new LoggerChannelOpenListener());
    context.addProtocolCodec(new LengthValueCodec());
    Channel ch = context.connect(3000);
    ByteBuf buf = ch.allocate();
    ch.close();
    buf.release();
}
Also used : LengthValueCodec(com.firenio.codec.lengthvalue.LengthValueCodec) ChannelConnector(com.firenio.component.ChannelConnector) Channel(com.firenio.component.Channel) ByteBuf(com.firenio.buffer.ByteBuf) LoggerChannelOpenListener(com.firenio.component.LoggerChannelOpenListener)

Example 40 with ByteBuf

use of com.firenio.buffer.ByteBuf in project baseio by generallycloud.

the class TestByteBufCopy method arrayPutDirect.

Object arrayPutDirect() {
    ByteBuf buf = _array();
    buf.writeBytes(directData());
    return buf;
}
Also used : ByteBuf(com.firenio.buffer.ByteBuf)

Aggregations

ByteBuf (com.firenio.buffer.ByteBuf)58 Test (org.junit.Test)18 ByteBufAllocator (com.firenio.buffer.ByteBufAllocator)5 Channel (com.firenio.component.Channel)5 PooledByteBufAllocator (com.firenio.buffer.PooledByteBufAllocator)4 Frame (com.firenio.component.Frame)3 IoEventHandle (com.firenio.component.IoEventHandle)3 NioEventLoopGroup (com.firenio.component.NioEventLoopGroup)3 LengthValueCodec (com.firenio.codec.lengthvalue.LengthValueCodec)2 ChannelAcceptor (com.firenio.component.ChannelAcceptor)2 ChannelConnector (com.firenio.component.ChannelConnector)2 LoggerChannelOpenListener (com.firenio.component.LoggerChannelOpenListener)2 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 SSLEngine (javax.net.ssl.SSLEngine)2 SSLEngineResult (javax.net.ssl.SSLEngineResult)2 HandshakeStatus (javax.net.ssl.SSLEngineResult.HandshakeStatus)2 ByteBufAllocatorGroup (com.firenio.buffer.ByteBufAllocatorGroup)1 PoolState (com.firenio.buffer.PooledByteBufAllocator.PoolState)1