Search in sources :

Example 21 with ByteBuf

use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.

the class CompressionTest method doesNotCompressIfTooShortReplace.

@Test
void doesNotCompressIfTooShortReplace() {
    ReplaceRequest request = new ReplaceRequest(key, shortContent, expiry, preserveExpiry, flags, timeout, cas, coreContext, cid, retryStrategy, durability, null);
    ByteBuf encoded = request.encode(allocator, 0, ctx(true));
    assertEquals(0, datatype(encoded));
    assertEquals(Unpooled.wrappedBuffer(shortContent), body(encoded).get());
    ReferenceCountUtil.release(encoded);
}
Also used : ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Example 22 with ByteBuf

use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.

the class CompressionTest method doesCompressLongUpsert.

@Test
void doesCompressLongUpsert() {
    UpsertRequest request = new UpsertRequest(key, longContent, expiry, preserveExpiry, flags, timeout, coreContext, cid, retryStrategy, Optional.empty(), null);
    ByteBuf encoded = request.encode(allocator, 0, ctx(true));
    assertEquals(MemcacheProtocol.Datatype.SNAPPY.datatype(), datatype(encoded));
    assertTrue(body(encoded).get().readableBytes() < longContent.length);
    ReferenceCountUtil.release(encoded);
}
Also used : ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Example 23 with ByteBuf

use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.

the class CompressionTest method doesNotCompressIfTooShortPrepend.

@Test
void doesNotCompressIfTooShortPrepend() {
    PrependRequest request = new PrependRequest(timeout, coreContext, cid, retryStrategy, key, shortContent, cas, durability, null);
    ByteBuf encoded = request.encode(allocator, 0, ctx(true));
    assertEquals(0, datatype(encoded));
    assertEquals(Unpooled.wrappedBuffer(shortContent), body(encoded).get());
    ReferenceCountUtil.release(encoded);
}
Also used : ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Example 24 with ByteBuf

use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.

the class CompressionTest method doesCompressLongInsert.

@Test
void doesCompressLongInsert() {
    InsertRequest request = new InsertRequest(key, longContent, expiry, flags, timeout, coreContext, cid, retryStrategy, durability, null);
    ByteBuf encoded = request.encode(allocator, 0, ctx(true));
    assertEquals(MemcacheProtocol.Datatype.SNAPPY.datatype(), datatype(encoded));
    assertTrue(body(encoded).get().readableBytes() < longContent.length);
    ReferenceCountUtil.release(encoded);
}
Also used : ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Example 25 with ByteBuf

use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.

the class CompressionTest method doesNotCompressIfDisabledInsert.

@Test
void doesNotCompressIfDisabledInsert() {
    InsertRequest request = new InsertRequest(key, longContent, expiry, flags, timeout, coreContext, cid, retryStrategy, durability, null);
    ByteBuf encoded = request.encode(allocator, 0, ctx(false));
    assertEquals(0, datatype(encoded));
    assertEquals(Unpooled.wrappedBuffer(longContent), body(encoded).get());
    ReferenceCountUtil.release(encoded);
}
Also used : ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Aggregations

ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)107 Test (org.junit.jupiter.api.Test)54 InetSocketAddress (java.net.InetSocketAddress)17 EmbeddedChannel (com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel)12 ChannelFuture (com.couchbase.client.core.deps.io.netty.channel.ChannelFuture)11 Duration (java.time.Duration)10 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)9 CoreContext (com.couchbase.client.core.CoreContext)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 CompressionConfig (com.couchbase.client.core.env.CompressionConfig)6 ResponseStatus (com.couchbase.client.core.msg.ResponseStatus)6 GetRequest (com.couchbase.client.core.msg.kv.GetRequest)6 ChannelHandlerContext (com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext)5 AuthenticationFailureException (com.couchbase.client.core.error.AuthenticationFailureException)5 ArrayList (java.util.ArrayList)5 DurabilityTimeoutCoercedEvent (com.couchbase.client.core.cnc.events.io.DurabilityTimeoutCoercedEvent)4 FeaturesNegotiatedEvent (com.couchbase.client.core.cnc.events.io.FeaturesNegotiatedEvent)4 CompositeByteBuf (com.couchbase.client.core.deps.io.netty.buffer.CompositeByteBuf)4 FullHttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest)4 BaseEndpoint (com.couchbase.client.core.endpoint.BaseEndpoint)4