Skip to content

Commit 7f2fba3

Browse files
committed
Bump Couchase SDK to 324 on 50x.
Closes #1284.
1 parent 7d0deb4 commit 7f2fba3

File tree

4 files changed

+47
-10
lines changed

4 files changed

+47
-10
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
</parent>
2020

2121
<properties>
22-
<couchbase>3.2.3</couchbase>
23-
<couchbase.osgi>3.2.3</couchbase.osgi>
22+
<couchbase>3.2.4</couchbase>
23+
<couchbase.osgi>3.2.4</couchbase.osgi>
2424
<springdata.commons>3.0.0-SNAPSHOT</springdata.commons>
2525
<java-module-name>spring.data.couchbase</java-module-name>
2626
<jodatime>2.10.13</jodatime>

src/test/java/org/springframework/data/couchbase/domain/AirportRepository.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2021 the original author or authors.
2+
* Copyright 2017-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -130,15 +130,15 @@ Long countFancyExpression(@Param("projectIds") List<String> projectIds, @Param("
130130
Page<Airport> getAllByIataNot(String iata, Pageable pageable);
131131

132132
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
133-
@Query("SELECT iata, \"\" as __id, 0 as __cas from #{#n1ql.bucket} WHERE #{#n1ql.filter} order by meta().id")
133+
@Query("SELECT iata, \"\" as __id, 0 as __cas from `#{#n1ql.bucket}` WHERE #{#n1ql.filter} order by meta().id")
134134
List<String> getStrings();
135135

136136
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
137-
@Query("SELECT length(iata), \"\" as __id, 0 as __cas from #{#n1ql.bucket} WHERE #{#n1ql.filter} order by meta().id")
137+
@Query("SELECT length(iata), \"\" as __id, 0 as __cas from `#{#n1ql.bucket}` WHERE #{#n1ql.filter} order by meta().id")
138138
List<Long> getLongs();
139139

140140
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
141-
@Query("SELECT iata, icao, \"\" as __id, 0 as __cas from #{#n1ql.bucket} WHERE #{#n1ql.filter} order by meta().id")
141+
@Query("SELECT iata, icao, \"\" as __id, 0 as __cas from `#{#n1ql.bucket}` WHERE #{#n1ql.filter} order by meta().id")
142142
List<String[]> getStringArrays();
143143

144144
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)

src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2021 the original author or authors.
2+
* Copyright 2017-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import static org.junit.jupiter.api.Assertions.assertTrue;
3030
import static org.springframework.data.couchbase.config.BeanNames.COUCHBASE_TEMPLATE;
3131

32+
import com.couchbase.client.java.kv.RemoveOptions;
3233
import jakarta.validation.ConstraintViolationException;
3334
import junit.framework.AssertionFailedError;
3435

@@ -273,6 +274,7 @@ void findBySimplePropertyReturnType() {
273274

274275
@Test
275276
public void saveNotBoundedRequestPlus() {
277+
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
276278
ApplicationContext ac = new AnnotationConfigApplicationContext(ConfigRequestPlus.class);
277279
// the Config class has been modified, these need to be loaded again
278280
CouchbaseTemplate couchbaseTemplateRP = (CouchbaseTemplate) ac.getBean(COUCHBASE_TEMPLATE);
@@ -311,7 +313,7 @@ public void saveNotBoundedRequestPlus() {
311313

312314
@Test
313315
public void saveNotBoundedWithDefaultRepository() {
314-
316+
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
315317
ApplicationContext ac = new AnnotationConfigApplicationContext(Config.class);
316318
// the Config class has been modified, these need to be loaded again
317319
CouchbaseTemplate couchbaseTemplateRP = (CouchbaseTemplate) ac.getBean(COUCHBASE_TEMPLATE);
@@ -565,6 +567,7 @@ void stringQueryReturnsSimpleType(){
565567

566568
@Test
567569
void count() {
570+
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
568571
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
569572

570573
airportRepository.countOne();
@@ -663,6 +666,7 @@ void threadSafeParametersTest() throws Exception {
663666
void distinct() {
664667
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
665668
String[] icaos = { "ic0", "ic1", "ic0", "ic1", "ic0", "ic1", "ic0" };
669+
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
666670

667671
try {
668672
for (int i = 0; i < iatas.length; i++) {

src/test/java/org/springframework/data/couchbase/util/JavaIntegrationTests.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors
2+
* Copyright 2020-2022 the original author or authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,12 @@
2727
import static org.springframework.data.couchbase.config.BeanNames.REACTIVE_COUCHBASE_TEMPLATE;
2828
import static org.springframework.data.couchbase.util.Util.waitUntilCondition;
2929

30+
import okhttp3.Credentials;
31+
import okhttp3.FormBody;
32+
import okhttp3.OkHttpClient;
33+
import okhttp3.Request;
34+
import okhttp3.Response;
35+
3036
import java.io.IOException;
3137
import java.time.Duration;
3238
import java.util.Collections;
@@ -39,7 +45,6 @@
3945
import java.util.function.Function;
4046
import java.util.function.Predicate;
4147

42-
import com.couchbase.client.core.io.CollectionIdentifier;
4348
import org.junit.jupiter.api.BeforeAll;
4449
import org.junit.jupiter.api.Timeout;
4550
import org.springframework.context.ApplicationContext;
@@ -60,6 +65,7 @@
6065
import com.couchbase.client.core.error.QueryException;
6166
import com.couchbase.client.core.error.ScopeNotFoundException;
6267
import com.couchbase.client.core.error.UnambiguousTimeoutException;
68+
import com.couchbase.client.core.io.CollectionIdentifier;
6369
import com.couchbase.client.core.json.Mapper;
6470
import com.couchbase.client.core.service.ServiceType;
6571
import com.couchbase.client.java.Bucket;
@@ -200,6 +206,7 @@ protected static void waitForQueryIndexerToHaveBucket(final Cluster cluster, fin
200206
}
201207

202208
if (!ready) {
209+
createAndDeleteBucket();// need to do this because of https://issues.couchbase.com/browse/MB-50132
203210
try {
204211
Thread.sleep(50);
205212
} catch (InterruptedException e) {}
@@ -211,6 +218,32 @@ protected static void waitForQueryIndexerToHaveBucket(final Cluster cluster, fin
211218
}
212219
}
213220

221+
private static void createAndDeleteBucket() {
222+
final OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
223+
.readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
224+
String hostPort = connectionString().replace("11210", "8091");
225+
String bucketname = UUID.randomUUID().toString();
226+
try {
227+
228+
Response postResponse = httpClient.newCall(new Request.Builder()
229+
.header("Authorization", Credentials.basic(config().adminUsername(), config().adminPassword()))
230+
.url("http://" + hostPort + "/pools/default/buckets/")
231+
.post(new FormBody.Builder().add("name", bucketname).add("bucketType", "membase").add("ramQuotaMB", "100")
232+
.add("replicaNumber", Integer.toString(0)).add("flushEnabled", "1").build())
233+
.build()).execute();
234+
235+
if (postResponse.code() != 202) {
236+
throw new IOException("Could not create bucket: " + postResponse + ", Reason: " + postResponse.body().string());
237+
}
238+
Response deleteResponse = httpClient.newCall(new Request.Builder()
239+
.header("Authorization", Credentials.basic(config().adminUsername(), config().adminPassword()))
240+
.url("http://" + hostPort + "/pools/default/buckets/" + bucketname).delete().build()).execute();
241+
System.out.println("deleteResponse: " + deleteResponse);
242+
} catch (IOException ioe) {
243+
ioe.printStackTrace();
244+
}
245+
}
246+
214247
/**
215248
* Improve test stability by waiting for a given service to report itself ready.
216249
*/

0 commit comments

Comments
 (0)