Search in sources :

Example 46 with IgnoreWhen

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

the class QueryErrorIntegrationTest method includesHttpStatusCodeInErrorContext.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void includesHttpStatusCodeInErrorContext() {
    ParsingFailureException ex = assertThrows(ParsingFailureException.class, () -> cluster.query("select 1="));
    assertTrue(ex.getMessage().contains("\"httpStatus\":400"));
}
Also used : ParsingFailureException(com.couchbase.client.core.error.ParsingFailureException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 47 with IgnoreWhen

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

the class CollectionManagerErrorIntegrationTest method failsUnderMemcachedBuckets.

@Test
@IgnoreWhen(missesCapabilities = Capabilities.COLLECTIONS)
void failsUnderMemcachedBuckets() {
    String bucketName = UUID.randomUUID().toString();
    cluster.buckets().createBucket(BucketSettings.create(bucketName).bucketType(BucketType.MEMCACHED));
    try {
        Bucket bucket = cluster.bucket(bucketName);
        bucket.waitUntilReady(Duration.ofSeconds(10));
        CollectionManager mgr = bucket.collections();
        assertThrows(FeatureNotAvailableException.class, () -> mgr.createScope("a"));
        assertThrows(FeatureNotAvailableException.class, () -> mgr.createCollection(CollectionSpec.create("a", "b")));
        assertThrows(FeatureNotAvailableException.class, () -> mgr.dropScope("a"));
        assertThrows(FeatureNotAvailableException.class, () -> mgr.dropCollection(CollectionSpec.create("a", "b")));
    } finally {
        cluster.buckets().dropBucket(bucketName);
    }
}
Also used : Bucket(com.couchbase.client.java.Bucket) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 48 with IgnoreWhen

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

the class SubdocMutateIntegrationTest method counterMinusCreatePath.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterMinusCreatePath() {
    JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(MutateInSpec.decrement("foo", 3).createPath()));
    assertEquals(-3, (int) updatedContent.getInt("foo"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 49 with IgnoreWhen

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

the class WaitUntilReadyIntegrationTest method handlesCreatingBucketDuringWaitUntilReady.

@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED, ClusterType.CAVES })
void handlesCreatingBucketDuringWaitUntilReady() {
    ExecutorService es = Executors.newFixedThreadPool(1);
    String bucketName = UUID.randomUUID().toString();
    if (!config().capabilities().contains(Capabilities.GLOBAL_CONFIG)) {
        // We need to open the "other" bucket to make sure the test passes in clusters pre 6.5
        Bucket b = cluster.bucket(config().bucketname());
        b.waitUntilReady(Duration.ofSeconds(30));
    }
    long creationDelay = 2000;
    try {
        Bucket bucket = cluster.bucket(bucketName);
        es.submit(() -> {
            try {
                Thread.sleep(creationDelay);
            } catch (InterruptedException e) {
                fail();
            }
            cluster.buckets().createBucket(BucketSettings.create(bucketName));
        });
        long start = System.nanoTime();
        bucket.waitUntilReady(Duration.ofSeconds(30));
        long end = System.nanoTime();
        Collection collection = bucket.defaultCollection();
        collection.upsert("my-doc", JsonObject.create());
        assertEquals(JsonObject.create(), collection.get("my-doc").contentAsObject());
        assertTrue(TimeUnit.NANOSECONDS.toMillis(end - start) > creationDelay);
    } finally {
        es.shutdownNow();
        try {
            cluster.buckets().dropBucket(bucketName);
        } catch (BucketNotFoundException ex) {
        // ignore
        }
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) BucketNotFoundException(com.couchbase.client.core.error.BucketNotFoundException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 50 with IgnoreWhen

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

the class AnalyticsErrorIntegrationTest method includesHttpStatusCodeInErrorContext.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void includesHttpStatusCodeInErrorContext() {
    ParsingFailureException ex = assertThrows(ParsingFailureException.class, () -> cluster.analyticsQuery("select 1="));
    assertTrue(ex.getMessage().contains("\"httpStatus\":400"));
}
Also used : ParsingFailureException(com.couchbase.client.core.error.ParsingFailureException) 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