Bump Couchase SDK to 324 on 50x. (#1285)

Also incorporates minor changes from main.

Closes #1284.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
This commit is contained in:
Michael Reiche
2022-01-06 15:00:30 -08:00
committed by GitHub
parent 7d0deb44d6
commit 197012688e
52 changed files with 127 additions and 78 deletions

View File

@@ -19,8 +19,8 @@
</parent>
<properties>
<couchbase>3.2.3</couchbase>
<couchbase.osgi>3.2.3</couchbase.osgi>
<couchbase>3.2.4</couchbase>
<couchbase.osgi>3.2.4</couchbase.osgi>
<springdata.commons>3.0.0-SNAPSHOT</springdata.commons>
<java-module-name>spring.data.couchbase</java-module-name>
<jodatime>2.10.13</jodatime>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,5 @@
/*
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -816,7 +816,6 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter implem
/**
* COPIED Set the {@link EntityCallbacks} instance to use when invoking
* {@link org.springframework.data.mapping.callback.EntityCallback callbacks} like the {@link AfterConvertCallback}.
* <p>
* Overrides potentially existing {@link EntityCallbacks}.
*
* @param entityCallbacks must not be {@literal null}.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,13 +18,13 @@ package org.springframework.data.couchbase.core.mapping;
import com.couchbase.client.java.json.JsonObject;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Map;
/**
* A {@link CouchbaseDocument} is an abstract representation of a document stored inside Couchbase Server.
* <p>
* It acts like a {@link HashMap}, but only allows those types to be written that are supported by the underlying
* It acts like a {@link TreeMap}, but only allows those types to be written that are supported by the underlying
* storage format, which is currently JSON. Note that JSON conversion is not happening here, but performed at a
* different stage based on the payload stored in the {@link CouchbaseDocument}.
* <p>
@@ -81,7 +81,7 @@ public class CouchbaseDocument implements CouchbaseStorable {
public CouchbaseDocument(final String id, final int expiration) {
this.id = id;
this.expiration = expiration;
content = new HashMap<>();
content = new TreeMap<>();
}
/**
@@ -115,8 +115,8 @@ public class CouchbaseDocument implements CouchbaseStorable {
*
* @return
*/
public final HashMap<String, Object> export() {
HashMap<String, Object> toExport = new HashMap<String, Object>(content);
public final TreeMap<String, Object> export() {
TreeMap<String, Object> toExport = new TreeMap<String, Object>(content);
for (Map.Entry<String, Object> entry : content.entrySet()) {
if (entry.getValue() instanceof CouchbaseDocument) {
toExport.put(entry.getKey(), ((CouchbaseDocument) entry.getValue()).export());
@@ -215,7 +215,7 @@ public class CouchbaseDocument implements CouchbaseStorable {
/**
* Returns the expiration time of the document.
* <p>
* <p/>
* If the expiration time is 0, then the document will be persisted until deleted manually ("forever").
*
* @return the expiration time of the document.
@@ -226,9 +226,9 @@ public class CouchbaseDocument implements CouchbaseStorable {
/**
* Set the expiration time of the document.
* <p>
* <p/>
* If the expiration time is 0, then the document will be persisted until deleted manually ("forever").
* <p>
* <p/>
* Expiration should be expressed as seconds if <= 30 days (30 x 24 x 60 x 60 seconds), or as an expiry date (UTC,
* UNIX time ie. seconds form the Epoch) if > 30 days.
*
@@ -262,10 +262,8 @@ public class CouchbaseDocument implements CouchbaseStorable {
/**
* Verifies that only values of a certain and supported type can be stored.
* <p/>
* <p>
* If this is not the case, a {@link IllegalArgumentException} is thrown.
* </p>
*
* @param value the object to verify its type.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 the original author or authors.
* Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,7 +184,7 @@ public class StringBasedN1qlQueryParser {
String delete = N1QLExpression.delete().from(b).toString();
String returning = " returning " + N1qlUtils.createReturningExpressionForDelete(b).toString();
return new N1qlSpelValues(selectEntity, entity, b, typeSelection, delete, returning);
return new N1qlSpelValues(selectEntity, entity, i(b).toString(), typeSelection, delete, returning);
}
private String getProjectedOrDistinctFields(String b, Class resultClass, String[] fields, String[] distinctFields) {

View File

@@ -26,7 +26,6 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.data.couchbase.core.convert.CouchbaseConverter;
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
import org.springframework.data.couchbase.core.mapping.Field;
import org.springframework.data.couchbase.core.query.N1QLExpression;
import org.springframework.data.couchbase.core.query.N1QLQuery;
import org.springframework.data.couchbase.repository.query.CouchbaseEntityInformation;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors
* Copyright 2021-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors
* Copyright 2012-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -455,7 +455,7 @@ public class MappingCouchbaseConverterTests {
List<BigDecimal> listOfValues = new ArrayList<>();
listOfValues.add(value);
listOfValues.add(value2);
Map<String, BigDecimal> mapOfValues = new HashMap<>();
Map<String, BigDecimal> mapOfValues = new TreeMap<>();
mapOfValues.put("val1", value);
mapOfValues.put("val2", value2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors
* Copyright 2021-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,6 +77,12 @@ public interface AirportRepository extends CouchbaseRepository<Airport, String>,
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
Airport findByIata(Iata iata);
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
Airport findByIataIn(java.util.Collection<Iata> iatas);
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
Airport findByIataIn(Iata[] iata);
// NOT_BOUNDED to test ScanConsistency
// @ScanConsistency(query = QueryScanConsistency.NOT_BOUNDED)
Airport iata(String iata);
@@ -89,11 +95,11 @@ public interface AirportRepository extends CouchbaseRepository<Airport, String>,
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
List<RemoveResult> deleteByIata(String iata);
@Query("SELECT __cas, * from `#{#n1ql.bucket}` where iata = $1")
@Query("SELECT __cas, * from #{#n1ql.bucket} where iata = $1")
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
List<Airport> getAllByIataNoID(String iata);
@Query("SELECT __id, * from `#{#n1ql.bucket}` where iata = $1")
@Query("SELECT __id, * from #{#n1ql.bucket} where iata = $1")
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
List<Airport> getAllByIataNoCAS(String iata);
@@ -116,10 +122,10 @@ public interface AirportRepository extends CouchbaseRepository<Airport, String>,
Long countFancyExpression(@Param("projectIds") List<String> projectIds, @Param("planIds") List<String> planIds,
@Param("active") Boolean active);
@Query("SELECT 1 FROM `#{#n1ql.bucket}` WHERE anything = 'count(*)'") // looks like count query, but is not
@Query("SELECT 1 FROM #{#n1ql.bucket} WHERE anything = 'count(*)'") // looks like count query, but is not
Long countBad();
@Query("SELECT count(*) FROM `#{#n1ql.bucket}`")
@Query("SELECT count(*) FROM #{#n1ql.bucket}")
Long countGood();
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
@@ -156,7 +162,7 @@ public interface AirportRepository extends CouchbaseRepository<Airport, String>,
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
Long countDistinctIcaoBy();
@Query("SELECT 1 FROM `#{#n1ql.bucket}` WHERE #{#n1ql.filter} " + " #{#projectIds != null ? 'AND blah IN $1' : ''} "
@Query("SELECT 1 FROM #{#n1ql.bucket} WHERE #{#n1ql.filter} " + " #{#projectIds != null ? 'AND blah IN $1' : ''} "
+ " #{#planIds != null ? 'AND blahblah IN $2' : ''} " + " #{#active != null ? 'AND false = $3' : ''} ")
Long countOne();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,6 +68,7 @@ import org.springframework.data.couchbase.domain.Airport;
import org.springframework.data.couchbase.domain.AirportMini;
import org.springframework.data.couchbase.domain.AirportRepository;
import org.springframework.data.couchbase.domain.AirportRepositoryScanConsistencyTest;
import org.springframework.data.couchbase.domain.Iata;
import org.springframework.data.couchbase.domain.NaiveAuditorAware;
import org.springframework.data.couchbase.domain.Person;
import org.springframework.data.couchbase.domain.PersonRepository;
@@ -273,6 +274,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
@Test
public void saveNotBoundedRequestPlus() {
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
ApplicationContext ac = new AnnotationConfigApplicationContext(ConfigRequestPlus.class);
// the Config class has been modified, these need to be loaded again
CouchbaseTemplate couchbaseTemplateRP = (CouchbaseTemplate) ac.getBean(COUCHBASE_TEMPLATE);
@@ -311,7 +313,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
@Test
public void saveNotBoundedWithDefaultRepository() {
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
ApplicationContext ac = new AnnotationConfigApplicationContext(Config.class);
// the Config class has been modified, these need to be loaded again
CouchbaseTemplate couchbaseTemplateRP = (CouchbaseTemplate) ac.getBean(COUCHBASE_TEMPLATE);
@@ -369,9 +371,19 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
try {
vie = new Airport("airports::vie", "vie", "loww");
vie = airportRepository.save(vie);
Airport airport2 = airportRepository.findByIata(vie.getIata());
Airport airport2 = airportRepository.findByIata(Iata.vie);
assertNotNull(airport2, "should have found " + vie);
assertEquals(airport2.getId(), vie.getId());
Airport airport3 = airportRepository.findByIataIn(new Iata[] { Iata.vie, Iata.xxx });
assertNotNull(airport3, "should have found " + vie);
assertEquals(airport3.getId(), vie.getId());
java.util.Collection<Iata> iatas = new ArrayList<>();
iatas.add(Iata.vie);
iatas.add(Iata.xxx);
Airport airport4 = airportRepository.findByIataIn(iatas);
assertNotNull(airport4, "should have found " + vie);
assertEquals(airport4.getId(), vie.getId());
} finally {
airportRepository.delete(vie);
@@ -545,7 +557,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
}
@Test
void stringQueryReturnsSimpleType(){
void stringQueryReturnsSimpleType() {
Airport airport1 = new Airport("1", "myIata1", "MyIcao");
airportRepository.save(airport1);
Airport airport2 = new Airport("2", "myIata2__", "MyIcao");
@@ -553,7 +565,8 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
List<String> iatas = airportRepository.getStrings();
assertEquals(Arrays.asList(airport1.getIata(), airport2.getIata()), iatas);
List<Long> iataLengths = airportRepository.getLongs();
assertEquals(Arrays.asList(airport1.getIata().length(), airport2.getIata().length()).toString(), iataLengths.toString());
assertEquals(Arrays.asList(airport1.getIata().length(), airport2.getIata().length()).toString(),
iataLengths.toString());
// this is somewhat broken, because decode is told that each "row" is just a String instead of a String[]
// As such, only the first element is returned. (QueryExecutionConverts.unwrapWrapperTypes)
List<String[]> iataAndIcaos = airportRepository.getStringArrays();
@@ -565,6 +578,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
@Test
void count() {
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
airportRepository.countOne();
@@ -663,6 +677,7 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
void distinct() {
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
String[] icaos = { "ic0", "ic1", "ic0", "ic1", "ic0", "ic1", "ic0" };
airportRepository.withOptions(QueryOptions.queryOptions().scanConsistency(REQUEST_PLUS)).deleteAll();
try {
for (int i = 0; i < iatas.length; i++) {
@@ -904,13 +919,13 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
@Bean
public ValidatingCouchbaseEventListener validationEventListener() {
return new ValidatingCouchbaseEventListener( validator());
return new ValidatingCouchbaseEventListener(validator());
}
}
@Configuration
@EnableCouchbaseRepositories("org.springframework.data.couchbase")
// @EnableCouchbaseAuditing(auditorAwareRef = "auditorAwareRef", dateTimeProviderRef = "dateTimeProviderRef")
@EnableCouchbaseAuditing(auditorAwareRef = "auditorAwareRef", dateTimeProviderRef = "dateTimeProviderRef")
static class ConfigRequestPlus extends AbstractCouchbaseConfiguration {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 the original author or authors.
* Copyright 2017-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 the original author or authors
* Copyright 2020-2022 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,12 @@ import static org.springframework.data.couchbase.config.BeanNames.COUCHBASE_TEMP
import static org.springframework.data.couchbase.config.BeanNames.REACTIVE_COUCHBASE_TEMPLATE;
import static org.springframework.data.couchbase.util.Util.waitUntilCondition;
import okhttp3.Credentials;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
@@ -39,7 +45,6 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Predicate;
import com.couchbase.client.core.io.CollectionIdentifier;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Timeout;
import org.springframework.context.ApplicationContext;
@@ -60,6 +65,7 @@ import com.couchbase.client.core.error.ParsingFailureException;
import com.couchbase.client.core.error.QueryException;
import com.couchbase.client.core.error.ScopeNotFoundException;
import com.couchbase.client.core.error.UnambiguousTimeoutException;
import com.couchbase.client.core.io.CollectionIdentifier;
import com.couchbase.client.core.json.Mapper;
import com.couchbase.client.core.service.ServiceType;
import com.couchbase.client.java.Bucket;
@@ -200,6 +206,7 @@ public class JavaIntegrationTests extends ClusterAwareIntegrationTests {
}
if (!ready) {
createAndDeleteBucket();// need to do this because of https://issues.couchbase.com/browse/MB-50132
try {
Thread.sleep(50);
} catch (InterruptedException e) {}
@@ -211,6 +218,32 @@ public class JavaIntegrationTests extends ClusterAwareIntegrationTests {
}
}
private static void createAndDeleteBucket() {
final OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build();
String hostPort = connectionString().replace("11210", "8091");
String bucketname = UUID.randomUUID().toString();
try {
Response postResponse = httpClient.newCall(new Request.Builder()
.header("Authorization", Credentials.basic(config().adminUsername(), config().adminPassword()))
.url("http://" + hostPort + "/pools/default/buckets/")
.post(new FormBody.Builder().add("name", bucketname).add("bucketType", "membase").add("ramQuotaMB", "100")
.add("replicaNumber", Integer.toString(0)).add("flushEnabled", "1").build())
.build()).execute();
if (postResponse.code() != 202) {
throw new IOException("Could not create bucket: " + postResponse + ", Reason: " + postResponse.body().string());
}
Response deleteResponse = httpClient.newCall(new Request.Builder()
.header("Authorization", Credentials.basic(config().adminUsername(), config().adminPassword()))
.url("http://" + hostPort + "/pools/default/buckets/" + bucketname).delete().build()).execute();
System.out.println("deleteResponse: " + deleteResponse);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/**
* Improve test stability by waiting for a given service to report itself ready.
*/