Example usage for io.netty.util ReferenceCountUtil releaseLater

List of usage examples for io.netty.util ReferenceCountUtil releaseLater

Introduction

In this page you can find the example usage for io.netty.util ReferenceCountUtil releaseLater.

Prototype

@Deprecated
public static <T> T releaseLater(T msg) 

Source Link

Document

Schedules the specified object to be released when the caller thread terminates.

Usage

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

License:Apache License

@Test
public void shouldReturnPathNotFoundOnDictAddForNewDeepPath() {
    String subPath = "sub2.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"insertedPath\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate//from   ww w .ja v a 2  s.com
    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    assertFalse(insertRequest.createIntermediaryPath());

    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(insertResponse.content());
    assertFalse(insertResponse.status().isSuccess());
    assertEquals(0, insertResponse.content().readableBytes());
    assertEquals(ResponseStatus.SUBDOC_PATH_NOT_FOUND, insertResponse.status());
}

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

License:Apache License

@Test
public void shouldReturnPathInvalidOnDictAddForArrayPath() {
    String subPath = "sub.array[1]";
    ByteBuf fragment = Unpooled.copiedBuffer("\"insertedPath\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate/*from www  .  java  2  s.  co m*/
    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    assertFalse(insertRequest.createIntermediaryPath());

    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(insertResponse.content());
    assertFalse(insertResponse.status().isSuccess());
    assertEquals(0, insertResponse.content().readableBytes());
    assertEquals(ResponseStatus.SUBDOC_PATH_INVALID, insertResponse.status());
}

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

License:Apache License

@Test
public void shouldCreateIntermediaryNodesOnDictAddForNewDeepPathIfForced() {
    String subPath = "sub2.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"insertedPath\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate//from w w  w  .  java  2s .com
    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    insertRequest.createIntermediaryPath(true);

    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(insertResponse.content());
    assertTrue(insertResponse.status().isSuccess());
    assertEquals(0, insertResponse.content().readableBytes());
}

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

License:Apache License

@Test
public void shouldNotCreateIntermediaryNodesOnDictAddForNewDeepPathByDefault() {
    String subPath = "sub2.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"insertedPath\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();/*from   w w  w  . ja  v a  2  s  .co  m*/
    ReferenceCountUtil.releaseLater(insertResponse.content());

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

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

License:Apache License

@Test
public void shouldDeleteExistingObjectPath() {
    String path = "sub.value";

    SubDeleteRequest request = new SubDeleteRequest(testSubKey, path, 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());

    //assert the mutation
    String expected = "{\"value\":\"stringValue\", \"sub\": {\"array\": [\"array1\", 2, true]}}";
    assertMutation(testSubKey, expected);
}

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

License:Apache License

@Test
public void shouldDeleteExistingArrayIndexPath() {
    String path = "sub.array[1]";
    SubDeleteRequest request = new SubDeleteRequest(testSubKey, path, 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,// w w w .j a va  2 s .  c o  m
            "{\"value\":\"stringValue\", \"sub\": {\"value\": \"subStringValue\",\"array\": [\"array1\", true]}}");
}

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

License:Apache License

@Test
public void shouldDeleteExistingWholeArrayPath() {
    String path = "sub.array";
    SubDeleteRequest request = new SubDeleteRequest(testSubKey, path, 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());

    //assert the mutation
    String expected = "{\"value\":\"stringValue\", \"sub\": {\"value\": \"subStringValue\"}}";
    assertMutation(testSubKey, expected);
}

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

License:Apache License

@Test
public void shouldReturnPathNotFoundOnDeleteNonexistingPath() {
    String path = "sub.bad";
    SubDeleteRequest request = new SubDeleteRequest(testSubKey, path, 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 shouldReplaceValueInSubObject() {
    String path = "sub.value";
    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());

    //assert the mutation
    String expected = "{\"value\":\"stringValue\", \"sub\": {\"value\": \"mutated\",\"array\": [\"array1\", 2, true]}}";
    assertMutation(testSubKey, expected);
}

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,/* www . java2  s. c o  m*/
            "{\"value\":\"stringValue\", \"sub\": {\"value\": \"subStringValue\",\"array\": [\"mutated\", 2, true]}}");
}