Skip to content

Commit f26b1d3

Browse files
committed
TestFix: KeyValueCollectionIntegrationTest.recognizesCollectionAfterCreation
Motivation ---------- This test was failing against Community Edition because it used the deprecated createCollection(CollectionSpec) method which sends the enterprise-only `maxTTL` parameter regardless of whether the caller specified it. Modifications ------------- Update the deprecation warning to indicate the method is not compatible with Community Edition. Update the test to use the non-deprecated version of `createCollection`, which works with CE. Rejected Alternatives --------------------- We _could_ change the deprecated method to convert a zero TTL into null so it wouldn't get sent to the server. However, this would ignore a zero TTL explicitly set by the user, breaking the behavior if the server's default TTL ever changes to something other than zero. Change-Id: I3fac794436b71254b68bcf39ec444702493a2a87 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/228634 Reviewed-by: Will Broadbelt <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 634808b commit f26b1d3

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

java-client/src/integrationTest/java/com/couchbase/client/java/KeyValueCollectionIntegrationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ static void afterAll() {
6060
@Test
6161
@IgnoreWhen(isProtostellarWillWorkLater = true) // Fails as CNG is not yet waiting for the collection to be ready before continuing
6262
void recognizesCollectionAfterCreation() {
63-
String collId = UUID.randomUUID().toString().substring(0, 10);
64-
CollectionSpec collectionSpec = CollectionSpec.create(collId, DEFAULT_SCOPE);
65-
bucket.collections().createCollection(collectionSpec);
66-
if (!config().isProtostellar()) ConsistencyUtil.waitUntilCollectionPresent(cluster.core(), bucket.name(), collectionSpec.scopeName(), collectionSpec.name());
63+
String collectionName = UUID.randomUUID().toString().substring(0, 10);
64+
String scopeName = DEFAULT_SCOPE;
65+
bucket.collections().createCollection(scopeName, collectionName);
66+
if (!config().isProtostellar()) ConsistencyUtil.waitUntilCollectionPresent(cluster.core(), bucket.name(), scopeName, collectionName);
6767

68-
Collection collection = bucket.collection(collId);
68+
Collection collection = bucket.collection(collectionName);
6969

7070
String id = UUID.randomUUID().toString();
7171
String content = "bar";
@@ -75,7 +75,7 @@ void recognizesCollectionAfterCreation() {
7575
assertEquals(upsertResult.cas(), getResult.cas());
7676
assertEquals(content, getResult.contentAs(String.class));
7777

78-
checkCachesScopesAndCollections(bucket.async(), collId);
78+
checkCachesScopesAndCollections(bucket.async(), collectionName);
7979
}
8080

8181
private void checkCachesScopesAndCollections(AsyncBucket bucket, String collId) {

java-client/src/main/java/com/couchbase/client/java/manager/collection/AsyncCollectionManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public AsyncCollectionManager(
8585
* @throws ScopeNotFoundException (async) if the specified scope does not exist.
8686
* @throws CouchbaseException (async) if any other generic unhandled/unexpected errors.
8787
* @deprecated This method cannot be used to set the collection's "history" property.
88+
* This method is not compatible with Couchbase Server Community Edition.
8889
* Please use {@link #createCollection(String, String, CreateCollectionSettings)} instead.
8990
*/
9091
@Deprecated
@@ -104,6 +105,7 @@ public CompletableFuture<Void> createCollection(final CollectionSpec collectionS
104105
* @throws ScopeNotFoundException (async) if the specified scope does not exist.
105106
* @throws CouchbaseException (async) if any other generic unhandled/unexpected errors.
106107
* @deprecated This method cannot be used to set the collection's "history" property.
108+
* This method is not compatible with Couchbase Server Community Edition.
107109
* Please use {@link #createCollection(String, String, CreateCollectionSettings, CreateCollectionOptions)} instead.
108110
*/
109111
@Deprecated

java-client/src/main/java/com/couchbase/client/java/manager/collection/CollectionManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public CollectionManager(final AsyncCollectionManager async) {
7070
* @throws ScopeNotFoundException if the specified scope does not exist.
7171
* @throws CouchbaseException if any other generic unhandled/unexpected errors.
7272
* @deprecated This method cannot be used to set the collection's "history" property.
73+
* This method is not compatible with Couchbase Server Community Edition.
7374
* Please use {@link #createCollection(String, String, CreateCollectionSettings)} instead.
7475
*/
7576
@Deprecated
@@ -89,6 +90,7 @@ public void createCollection(final CollectionSpec collectionSpec) {
8990
* @throws CouchbaseException if any other generic unhandled/unexpected errors.
9091
*
9192
* @deprecated This method cannot be used to set the collection's "history" property.
93+
* This method is not compatible with Couchbase Server Community Edition.
9294
* Please use {@link #createCollection(String, String, CreateCollectionSettings, CreateCollectionOptions)} instead.
9395
*/
9496
@Deprecated

java-client/src/main/java/com/couchbase/client/java/manager/collection/ReactiveCollectionManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public ReactiveCollectionManager(final ReactorOps reactor, final AsyncCollection
7474
* @throws ScopeNotFoundException (async) if the specified scope does not exist.
7575
* @throws CouchbaseException (async) if any other generic unhandled/unexpected errors.
7676
* @deprecated This method cannot be used to set the collection's "history" property.
77+
* This method is not compatible with Couchbase Server Community Edition.
7778
* Please use {@link #createCollection(String, String, CreateCollectionSettings)} instead.
7879
*/
7980
@Deprecated
@@ -93,6 +94,7 @@ public Mono<Void> createCollection(final CollectionSpec collectionSpec) {
9394
* @throws ScopeNotFoundException (async) if the specified scope does not exist.
9495
* @throws CouchbaseException (async) if any other generic unhandled/unexpected errors.
9596
* @deprecated This method cannot be used to set the collection's "history" property.
97+
* This method is not compatible with Couchbase Server Community Edition.
9698
* Please use {@link #createCollection(String, String, CreateCollectionSettings, CreateCollectionOptions)} instead.
9799
*/
98100
@Deprecated

0 commit comments

Comments
 (0)