From 155341dfa3a36db0067e133fb7ab92ec341ad5a0 Mon Sep 17 00:00:00 2001 From: mikereiche Date: Wed, 5 Jan 2022 15:23:36 -0800 Subject: [PATCH] Bump Couchase SDK to 324 on 50x. Also incorporates minor changes from main. Closes #1284. --- pom.xml | 4 +- .../cache/CouchbaseCacheConfiguration.java | 2 +- .../cache/CouchbaseCacheManager.java | 2 +- .../AbstractCouchbaseConfiguration.java | 2 +- .../core/CouchbaseExceptionTranslator.java | 2 +- .../core/CouchbaseTemplateSupport.java | 5 +-- .../ReactiveCouchbaseTemplateSupport.java | 4 +- .../convert/AbstractCouchbaseConverter.java | 2 +- .../convert/CouchbaseCustomConversions.java | 2 +- .../convert/CouchbaseJsr310Converters.java | 2 +- .../core/convert/CustomConversions.java | 2 +- .../convert/MappingCouchbaseConverter.java | 3 +- .../BasicCouchbasePersistentProperty.java | 2 +- .../core/mapping/CouchbaseDocument.java | 14 +++---- .../couchbase/core/mapping/CouchbaseList.java | 4 +- .../mapping/CouchbasePersistentEntity.java | 2 +- .../mapping/CouchbasePersistentProperty.java | 2 +- .../core/mapping/CouchbaseStorable.java | 2 +- .../ValidatingCouchbaseEventListener.java | 2 +- .../core/query/N1qlSecondaryIndexed.java | 2 +- .../data/couchbase/core/query/Query.java | 2 +- .../couchbase/core/query/QueryCriteria.java | 2 +- .../couchbase/core/query/StringQuery.java | 2 +- .../couchbase/core/query/ViewIndexed.java | 2 +- .../couchbase/core/query/WithConsistency.java | 2 +- .../data/couchbase/core/support/AnyId.java | 2 +- .../couchbase/core/support/AnyIdReactive.java | 2 +- .../couchbase/core/support/OneAndAll.java | 2 +- .../core/support/OneAndAllEntity.java | 2 +- .../core/support/OneAndAllEntityReactive.java | 2 +- .../core/support/OneAndAllExists.java | 2 +- .../core/support/OneAndAllExistsReactive.java | 2 +- .../couchbase/core/support/OneAndAllId.java | 2 +- .../core/support/OneAndAllIdReactive.java | 2 +- .../core/support/OneAndAllReactive.java | 2 +- .../repository/DynamicProxyable.java | 2 +- .../data/couchbase/repository/Query.java | 2 +- .../repository/query/CountFragment.java | 2 +- .../repository/query/N1qlQueryCreator.java | 2 +- .../repository/query/OldN1qlQueryCreator.java | 2 +- .../query/StringBasedN1qlQueryParser.java | 4 +- .../repository/query/support/N1qlUtils.java | 1 - .../repository/support/ViewPostProcessor.java | 2 +- ...mplateQueryCollectionIntegrationTests.java | 2 +- ...ouchbaseTemplateQueryIntegrationTests.java | 2 +- .../MappingCouchbaseConverterTests.java | 2 +- .../core/query/QueryCriteriaTests.java | 2 +- ...mplateQueryCollectionIntegrationTests.java | 2 +- .../couchbase/domain/AirportRepository.java | 18 ++++++--- ...chbaseRepositoryQueryIntegrationTests.java | 29 +++++++++++---- .../query/N1qlQueryCreatorTests.java | 2 +- .../StringN1qlQueryCreatorMockedTests.java | 2 +- .../util/ClusterInvocationProvider.java | 1 - .../couchbase/util/JavaIntegrationTests.java | 37 ++++++++++++++++++- .../couchbase/util/TestClusterConfig.java | 1 - .../data/couchbase/util/Util.java | 4 +- 56 files changed, 129 insertions(+), 84 deletions(-) diff --git a/pom.xml b/pom.xml index 7837f92cd..08842280b 100644 --- a/pom.xml +++ b/pom.xml @@ -19,8 +19,8 @@ - 3.2.3 - 3.2.3 + 3.2.4 + 3.2.4 3.0.0-SNAPSHOT spring.data.couchbase 2.10.13 diff --git a/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheConfiguration.java b/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheConfiguration.java index d542938db..031e8b445 100644 --- a/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheConfiguration.java +++ b/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheConfiguration.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheManager.java b/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheManager.java index 3e35ed686..3ec1f1ff7 100644 --- a/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheManager.java +++ b/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheManager.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java index 7992d2ba3..6982d64f4 100644 --- a/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java +++ b/src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/CouchbaseExceptionTranslator.java b/src/main/java/org/springframework/data/couchbase/core/CouchbaseExceptionTranslator.java index 5ff351532..264c8334e 100644 --- a/src/main/java/org/springframework/data/couchbase/core/CouchbaseExceptionTranslator.java +++ b/src/main/java/org/springframework/data/couchbase/core/CouchbaseExceptionTranslator.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java index ca5f4aec9..1181bc89a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java @@ -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. @@ -197,7 +196,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws /** * Set the {@link EntityCallbacks} instance to use when invoking * {@link org.springframework.data.mapping.callback.EntityCallback callbacks} like the {@link BeforeConvertCallback}. - *

+ *

* Overrides potentially existing {@link EntityCallbacks}. * * @param entityCallbacks must not be {@literal null}. diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java index e5560ff39..a36b68596 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java @@ -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. @@ -206,7 +206,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws * Set the {@link ReactiveEntityCallbacks} instance to use when invoking * {@link org.springframework.data.mapping.callback.ReactiveEntityCallbacks callbacks} like the * {@link ReactiveBeforeConvertCallback}. - *

+ *

* Overrides potentially existing {@link EntityCallbacks}. * * @param reactiveEntityCallbacks must not be {@literal null}. diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java b/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java index 4139162e1..e216779ff 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseCustomConversions.java b/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseCustomConversions.java index f99ca1c05..ba265d4e4 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseCustomConversions.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseCustomConversions.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseJsr310Converters.java b/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseJsr310Converters.java index ecb84232a..ead6f1ae4 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseJsr310Converters.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/CouchbaseJsr310Converters.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/CustomConversions.java b/src/main/java/org/springframework/data/couchbase/core/convert/CustomConversions.java index 89e163f87..8b19a21ad 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/CustomConversions.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/CustomConversions.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java index 1e7162d0a..6436cba0b 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java @@ -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 void setApplicationContext(ApplicationContext applicationContext) { /** * COPIED Set the {@link EntityCallbacks} instance to use when invoking * {@link org.springframework.data.mapping.callback.EntityCallback callbacks} like the {@link AfterConvertCallback}. - *

* Overrides potentially existing {@link EntityCallbacks}. * * @param entityCallbacks must not be {@literal null}. diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentProperty.java b/src/main/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentProperty.java index 19fb1a99e..9d1d0b686 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentProperty.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentProperty.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java index a7ca373ec..ead8146ed 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java @@ -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 @@ 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. *

- * 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}. *

@@ -81,7 +81,7 @@ public CouchbaseDocument(final String id) { 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 final Object get(final String key) { * * @return */ - public final HashMap export() { - HashMap toExport = new HashMap(content); + public final TreeMap export() { + TreeMap toExport = new TreeMap(content); for (Map.Entry entry : content.entrySet()) { if (entry.getValue() instanceof CouchbaseDocument) { toExport.put(entry.getKey(), ((CouchbaseDocument) entry.getValue()).export()); @@ -262,10 +262,8 @@ public CouchbaseDocument setId(String id) { /** * Verifies that only values of a certain and supported type can be stored. - *

*

* If this is not the case, a {@link IllegalArgumentException} is thrown. - *

* * @param value the object to verify its type. */ diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseList.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseList.java index 7280e8e36..d7cd4b8a1 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseList.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseList.java @@ -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. @@ -186,10 +186,8 @@ public final boolean isEmpty() { /** * Verifies that only values of a certain and supported type can be stored. - *

*

* If this is not the case, a {@link IllegalArgumentException} is thrown. - *

* * @param value the object to verify its type. */ diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentEntity.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentEntity.java index 195e7eb33..f768aab9c 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentEntity.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentEntity.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentProperty.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentProperty.java index f279e1d82..dba19b16d 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentProperty.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbasePersistentProperty.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseStorable.java b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseStorable.java index f985940bf..b4e5ae15a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseStorable.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseStorable.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/mapping/event/ValidatingCouchbaseEventListener.java b/src/main/java/org/springframework/data/couchbase/core/mapping/event/ValidatingCouchbaseEventListener.java index ebd388ef6..e5ca99993 100644 --- a/src/main/java/org/springframework/data/couchbase/core/mapping/event/ValidatingCouchbaseEventListener.java +++ b/src/main/java/org/springframework/data/couchbase/core/mapping/event/ValidatingCouchbaseEventListener.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java b/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java index d1b1533ac..50b9597f0 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/Query.java b/src/main/java/org/springframework/data/couchbase/core/query/Query.java index 41d0a6300..e0b38e66a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/Query.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/Query.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/QueryCriteria.java b/src/main/java/org/springframework/data/couchbase/core/query/QueryCriteria.java index 776936e37..df9fd644a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/QueryCriteria.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/QueryCriteria.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java b/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java index 8ae788949..52ed05d13 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java b/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java index 0383cd6bd..001ecd405 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/query/WithConsistency.java b/src/main/java/org/springframework/data/couchbase/core/query/WithConsistency.java index 0b1daa142..99470174f 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/WithConsistency.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/WithConsistency.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/AnyId.java b/src/main/java/org/springframework/data/couchbase/core/support/AnyId.java index 5c5104e22..9b77d031a 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/AnyId.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/AnyId.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/AnyIdReactive.java b/src/main/java/org/springframework/data/couchbase/core/support/AnyIdReactive.java index daae7ed8d..7a387fcb9 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/AnyIdReactive.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/AnyIdReactive.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAll.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAll.java index b5b147e8e..1cc17c634 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAll.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAll.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntity.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntity.java index 510174177..da4f0dcb2 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntity.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntity.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntityReactive.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntityReactive.java index 74bdd0e66..a4f77fea4 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntityReactive.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllEntityReactive.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExists.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExists.java index 382ed211f..42736507f 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExists.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExists.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExistsReactive.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExistsReactive.java index 2b346f150..03d244d45 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExistsReactive.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllExistsReactive.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllId.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllId.java index 25c3baef5..104849003 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllId.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllId.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllIdReactive.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllIdReactive.java index beea89035..b7e000d65 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllIdReactive.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllIdReactive.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllReactive.java b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllReactive.java index 0e0b0487f..ef477759c 100644 --- a/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllReactive.java +++ b/src/main/java/org/springframework/data/couchbase/core/support/OneAndAllReactive.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/DynamicProxyable.java b/src/main/java/org/springframework/data/couchbase/repository/DynamicProxyable.java index 128bdb8da..01e56fb32 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/DynamicProxyable.java +++ b/src/main/java/org/springframework/data/couchbase/repository/DynamicProxyable.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/Query.java b/src/main/java/org/springframework/data/couchbase/repository/Query.java index 86bf78f33..39eab1425 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/Query.java +++ b/src/main/java/org/springframework/data/couchbase/repository/Query.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/CountFragment.java b/src/main/java/org/springframework/data/couchbase/repository/query/CountFragment.java index 187391e61..0503e1b4d 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/CountFragment.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/CountFragment.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreator.java b/src/main/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreator.java index 1a9b5e444..8af78c70c 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreator.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreator.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/OldN1qlQueryCreator.java b/src/main/java/org/springframework/data/couchbase/repository/query/OldN1qlQueryCreator.java index b87f72038..a8bbe2215 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/OldN1qlQueryCreator.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/OldN1qlQueryCreator.java @@ -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. diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/StringBasedN1qlQueryParser.java b/src/main/java/org/springframework/data/couchbase/repository/query/StringBasedN1qlQueryParser.java index 576cb9f8b..6a5e4c584 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/StringBasedN1qlQueryParser.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/StringBasedN1qlQueryParser.java @@ -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 N1qlSpelValues createN1qlSpelValues(String bucketName, String collection, 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) { diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/support/N1qlUtils.java b/src/main/java/org/springframework/data/couchbase/repository/query/support/N1qlUtils.java index df606b42e..522b018e7 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/support/N1qlUtils.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/support/N1qlUtils.java @@ -26,7 +26,6 @@ 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; diff --git a/src/main/java/org/springframework/data/couchbase/repository/support/ViewPostProcessor.java b/src/main/java/org/springframework/data/couchbase/repository/support/ViewPostProcessor.java index 34851e30f..c0ec3516a 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/support/ViewPostProcessor.java +++ b/src/main/java/org/springframework/data/couchbase/repository/support/ViewPostProcessor.java @@ -62,7 +62,7 @@ public ViewMetadataProvider getViewMetadataProvider() { /** * {@link MethodInterceptor} to inspect the currently invoked {@link Method} for a {@link View} annotation. - *

+ *

* If a View annotation is found, it will bind it to a locally held ThreadLocal for later lookup in the * SimpleCouchbaseRepository class. * diff --git a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java index 4b4543eae..7cb960916 100644 --- a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryCollectionIntegrationTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryIntegrationTests.java index 7c1c7b85e..3239e22c3 100644 --- a/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryIntegrationTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java b/src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java index 49652573a..d807c915b 100644 --- a/src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/mapping/MappingCouchbaseConverterTests.java @@ -455,7 +455,7 @@ void writesAndReadsCustomConvertedClass() { List listOfValues = new ArrayList<>(); listOfValues.add(value); listOfValues.add(value2); - Map mapOfValues = new HashMap<>(); + Map mapOfValues = new TreeMap<>(); mapOfValues.put("val1", value); mapOfValues.put("val2", value2); diff --git a/src/test/java/org/springframework/data/couchbase/core/query/QueryCriteriaTests.java b/src/test/java/org/springframework/data/couchbase/core/query/QueryCriteriaTests.java index 226a5b3aa..8c8ce4d57 100644 --- a/src/test/java/org/springframework/data/couchbase/core/query/QueryCriteriaTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/query/QueryCriteriaTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/core/query/ReactiveCouchbaseTemplateQueryCollectionIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/core/query/ReactiveCouchbaseTemplateQueryCollectionIntegrationTests.java index a6306e9a4..5c5fd29cf 100644 --- a/src/test/java/org/springframework/data/couchbase/core/query/ReactiveCouchbaseTemplateQueryCollectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/query/ReactiveCouchbaseTemplateQueryCollectionIntegrationTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/domain/AirportRepository.java b/src/test/java/org/springframework/data/couchbase/domain/AirportRepository.java index ca4267bb8..d17c3d39e 100644 --- a/src/test/java/org/springframework/data/couchbase/domain/AirportRepository.java +++ b/src/test/java/org/springframework/data/couchbase/domain/AirportRepository.java @@ -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, @ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS) Airport findByIata(Iata iata); + @ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS) + Airport findByIataIn(java.util.Collection 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, @ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS) List 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 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 getAllByIataNoCAS(String iata); @@ -116,10 +122,10 @@ public interface AirportRepository extends CouchbaseRepository, Long countFancyExpression(@Param("projectIds") List projectIds, @Param("planIds") List 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 @@ Long countFancyExpression(@Param("projectIds") List projectIds, @Param(" @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(); diff --git a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java index 4c812a761..c56cd1061 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java @@ -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.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 @@ void findBySimplePropertyReturnType() { @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 void saveNotBoundedRequestPlus() { @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 @@ void findByEnum() { 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 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 void testExpiryAnnotation() { } @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 @@ void stringQueryReturnsSimpleType(){ List iatas = airportRepository.getStrings(); assertEquals(Arrays.asList(airport1.getIata(), airport2.getIata()), iatas); List 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 iataAndIcaos = airportRepository.getStringArrays(); @@ -565,6 +578,7 @@ void stringQueryReturnsSimpleType(){ @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 @@ void threadSafeParametersTest() throws Exception { 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 LocalValidatorFactoryBean validator() { @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 diff --git a/src/test/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreatorTests.java b/src/test/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreatorTests.java index 05dfe8dae..e60f3865e 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreatorTests.java +++ b/src/test/java/org/springframework/data/couchbase/repository/query/N1qlQueryCreatorTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/repository/query/StringN1qlQueryCreatorMockedTests.java b/src/test/java/org/springframework/data/couchbase/repository/query/StringN1qlQueryCreatorMockedTests.java index f1ac9b4ee..66f124e3a 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/query/StringN1qlQueryCreatorMockedTests.java +++ b/src/test/java/org/springframework/data/couchbase/repository/query/StringN1qlQueryCreatorMockedTests.java @@ -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. diff --git a/src/test/java/org/springframework/data/couchbase/util/ClusterInvocationProvider.java b/src/test/java/org/springframework/data/couchbase/util/ClusterInvocationProvider.java index e4d159f65..a32bb6854 100644 --- a/src/test/java/org/springframework/data/couchbase/util/ClusterInvocationProvider.java +++ b/src/test/java/org/springframework/data/couchbase/util/ClusterInvocationProvider.java @@ -31,7 +31,6 @@ *

* Note that the internals on what and how the containers are managed is up to the {@link TestCluster} implementation, * and if it is unmanaged than this very well be mostly a "stub". - *

* * @since 2.0.0 */ diff --git a/src/test/java/org/springframework/data/couchbase/util/JavaIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/util/JavaIntegrationTests.java index 5ba592487..90b9ab0c8 100644 --- a/src/test/java/org/springframework/data/couchbase/util/JavaIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/util/JavaIntegrationTests.java @@ -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.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.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.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 @@ protected static void waitForQueryIndexerToHaveBucket(final Cluster cluster, fin } 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 @@ protected static void waitForQueryIndexerToHaveBucket(final Cluster cluster, fin } } + 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. */ diff --git a/src/test/java/org/springframework/data/couchbase/util/TestClusterConfig.java b/src/test/java/org/springframework/data/couchbase/util/TestClusterConfig.java index 3dc867ac3..bdaac406a 100644 --- a/src/test/java/org/springframework/data/couchbase/util/TestClusterConfig.java +++ b/src/test/java/org/springframework/data/couchbase/util/TestClusterConfig.java @@ -79,7 +79,6 @@ public Optional clusterCert() { * Finds the first node with a given service enabled in the config. *

* This method can be used to find bootstrap nodes and similar. - *

* * @param service the service to find. * @return a node config if found, empty otherwise. diff --git a/src/test/java/org/springframework/data/couchbase/util/Util.java b/src/test/java/org/springframework/data/couchbase/util/Util.java index f03c13487..06710bb90 100644 --- a/src/test/java/org/springframework/data/couchbase/util/Util.java +++ b/src/test/java/org/springframework/data/couchbase/util/Util.java @@ -33,7 +33,7 @@ public class Util { * Waits and sleeps for a little bit of time until the given condition is met. * *

Sleeps 1ms between "false" invocations. It will wait at most one minute to prevent hanging forever in case - * the condition never becomes true.

+ * the condition never becomes true. * * @param supplier return true once it should stop waiting. */ @@ -83,7 +83,7 @@ public static boolean threadRunning(final String name) { * Reads a file from the resources folder (in the same path as the requesting test class). * *

The class will be automatically loaded relative to the namespace and converted - * to a string.

+ * to a string. * * @param filename the filename of the resource. * @param clazz the reference class.