Search in sources :

Example 1 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueIntegrationTest method shortCircuitCollectionsIfNotAvailable.

@Test
@IgnoreWhen(hasCapabilities = { Capabilities.COLLECTIONS })
void shortCircuitCollectionsIfNotAvailable() {
    String id = UUID.randomUUID().toString();
    byte[] content = "hello, world".getBytes(UTF_8);
    InsertRequest insertRequest = new InsertRequest(id, content, 0, 0, kvTimeout, core.context(), new CollectionIdentifier(config().bucketname(), Optional.of(CollectionIdentifier.DEFAULT_SCOPE), Optional.of("my_collection_name")), env.retryStrategy(), Optional.empty(), null);
    core.send(insertRequest);
    ExecutionException exception = assertThrows(ExecutionException.class, () -> insertRequest.response().get());
    assertTrue(exception.getCause() instanceof FeatureNotAvailableException);
    InsertRequest insertRequest2 = new InsertRequest(id, content, 0, 0, kvTimeout, core.context(), new CollectionIdentifier(config().bucketname(), Optional.of("my_custom_scope"), Optional.of(CollectionIdentifier.DEFAULT_COLLECTION)), env.retryStrategy(), Optional.empty(), null);
    core.send(insertRequest2);
    exception = assertThrows(ExecutionException.class, () -> insertRequest2.response().get());
    assertTrue(exception.getCause() instanceof FeatureNotAvailableException);
}
Also used : FeatureNotAvailableException(com.couchbase.client.core.error.FeatureNotAvailableException) InsertRequest(com.couchbase.client.core.msg.kv.InsertRequest) ExecutionException(java.util.concurrent.ExecutionException) CollectionIdentifier(com.couchbase.client.core.io.CollectionIdentifier) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class ViewEndpointIntegrationTest method dispatchGenericRequest.

/**
 * Makes sure that we can execute a generic view management request.
 *
 * <p>The mock does not support hitting the / path for views, so this test is ignored there.</p>
 */
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void dispatchGenericRequest() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    ViewEndpoint endpoint = new ViewEndpoint(serviceContext, node.hostname(), node.ports().get(Services.VIEW));
    endpoint.connect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
    CoreHttpRequest request = CoreHttpRequest.builder(CoreCommonOptions.of(Duration.ofSeconds(5), null, null), serviceContext, HttpMethod.GET, CoreHttpPath.path("/"), RequestTarget.views(config().bucketname())).build();
    endpoint.send(request);
    CoreHttpResponse response = request.response().get();
    assertEquals(ResponseStatus.SUCCESS, response.status());
    assertNotNull(response.content());
    assertTrue(response.content().length > 0);
    endpoint.disconnect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
Also used : CoreHttpRequest(com.couchbase.client.core.endpoint.http.CoreHttpRequest) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method failWithInvalidPasswordCredential.

@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidPasswordCredential() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), PasswordAuthenticator.create(config().adminUsername(), "djslkfsdfsoufhoshfoishgs")).init(null, ch.pipeline());
        }
    });
    assertAuthenticationFailure(bootstrap, "Authentication Failure");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueErrorIntegrationTest method verifyUnlockCasMismatch.

/**
 * Ignored for the mock because it still returns TMPFAIL (like the old servers)
 */
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void verifyUnlockCasMismatch() {
    String id = UUID.randomUUID().toString();
    collection.upsert(id, "foo");
    GetResult result = collection.getAndLock(id, Duration.ofSeconds(5));
    CasMismatchException thrown = assertThrows(CasMismatchException.class, () -> collection.unlock(id, result.cas() + 1));
    assertNotNull(thrown.context());
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) CasMismatchException(com.couchbase.client.core.error.CasMismatchException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class QueryIntegrationTest method preserveExpiry.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.QUERY_PRESERVE_EXPIRY)
void preserveExpiry() {
    String id = UUID.randomUUID().toString();
    collection.insert(id, FOO_CONTENT, InsertOptions.insertOptions().expiry(Duration.ofDays(1L)));
    Instant expectedExpiry = collection.get(id, GetOptions.getOptions().withExpiry(true)).expiryTime().get();
    cluster.query("UPDATE " + bucketName + " AS content USE KEYS '" + id + "' SET content.foo = 'updated'", queryOptions().preserveExpiry(true));
    GetResult result = collection.get(id, GetOptions.getOptions().withExpiry(true));
    assertEquals("updated", result.contentAsObject().get("foo"));
    assertEquals(expectedExpiry, result.expiryTime().get());
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) Instant(java.time.Instant) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

IgnoreWhen (com.couchbase.client.test.IgnoreWhen)79 Test (org.junit.jupiter.api.Test)78 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)70 JsonObject (com.couchbase.client.java.json.JsonObject)41 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)13 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)9 RateLimitedException (com.couchbase.client.core.error.RateLimitedException)8 TimeoutException (com.couchbase.client.core.error.TimeoutException)7 LookupInResult (com.couchbase.client.java.kv.LookupInResult)7 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 SearchIndex (com.couchbase.client.java.manager.search.SearchIndex)5 CasMismatchException (com.couchbase.client.core.error.CasMismatchException)4 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)4 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)3 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)3 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)3 Core (com.couchbase.client.core.Core)2