Example usage for io.netty.util CharsetUtil UTF_8

List of usage examples for io.netty.util CharsetUtil UTF_8

Introduction

In this page you can find the example usage for io.netty.util CharsetUtil UTF_8.

Prototype

Charset UTF_8

To view the source code for io.netty.util CharsetUtil UTF_8.

Click Source Link

Document

8-bit UTF (UCS Transformation Format)

Usage

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReplaceEntryInArray() {
    String path = "sub.array[0]";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubReplaceRequest request = new SubReplaceRequest(testSubKey, path, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();
    ReferenceCountUtil.releaseLater(response.content());

    assertTrue(response.status().isSuccess());
    assertEquals(0, response.content().readableBytes());
    assertEquals(ResponseStatus.SUCCESS, response.status());

    assertMutation(testSubKey,//from  w w  w . j  a  v  a  2s.  c o m
            "{\"value\":\"stringValue\", \"sub\": {\"value\": \"subStringValue\",\"array\": [\"mutated\", 2, true]}}");
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathNotFoundOnReplaceNonExistingPath() {
    String path = "sub.value2";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubReplaceRequest request = new SubReplaceRequest(testSubKey, path, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();
    ReferenceCountUtil.releaseLater(response.content());

    assertFalse(response.status().isSuccess());
    assertEquals(0, response.content().readableBytes());
    assertEquals(ResponseStatus.SUBDOC_PATH_NOT_FOUND, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldAllowArrayOperationOnDocumentRootIfArray() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_FIRST;

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testArrayRoot, "", arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUCCESS, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldNotAllowArrayOperationOnDocumentRootIfNotArray() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_LAST;

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, "", arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUBDOC_PATH_MISMATCH, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathMismatchForArrayOperationOnNonArrayFinalElement() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_FIRST;
    String path = "sub";

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUBDOC_PATH_MISMATCH, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldPushLastInArray() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_LAST;
    String path = "sub.array";

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUCCESS, response.status());
    assertMutation(testSubKey, jsonContent.replace("]", ", \"arrayElement\"]"));
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathNotFoundOnPushLastOnNonExistingPath() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_LAST;
    String path = "sub.array2";

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUBDOC_PATH_NOT_FOUND, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldPushFirstInArray() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_FIRST;
    String path = "sub.array";

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUCCESS, response.status());
    assertMutation(testSubKey, jsonContent.replace("[", "[\"arrayElement\", "));
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathNotFoundOnPushFirstOnNonExistingPath() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.PUSH_FIRST;
    String path = "sub.array2";

    ByteBuf fragment = Unpooled.copiedBuffer("\"arrayElement\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUBDOC_PATH_NOT_FOUND, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldShiftArrayByOneOnArrayInsert() {
    SubArrayRequest.ArrayOperation arrayOp = SubArrayRequest.ArrayOperation.INSERT;
    String path = "sub.array[1]";

    ByteBuf fragment = Unpooled.copiedBuffer("99", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubArrayRequest request = new SubArrayRequest(testSubKey, path, arrayOp, fragment, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(request).toBlocking().single();

    assertEquals(ResponseStatus.SUCCESS, response.status());
    assertMutation(testSubKey, jsonContent.replace("2", "99, 2"));
}