diff --git a/pom.xml b/pom.xml index 57662b90..4a250d73 100644 --- a/pom.xml +++ b/pom.xml @@ -18,8 +18,8 @@ - 2.2.8 - 2.2.8 + 2.4.1 + 2.4.1 2.0.0.BUILD-SNAPSHOT diff --git a/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateViewListener.java b/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryListener.java similarity index 88% rename from src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateViewListener.java rename to src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryListener.java index 86fa8f69..822ae50d 100644 --- a/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateViewListener.java +++ b/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateQueryListener.java @@ -20,18 +20,21 @@ import java.util.Collections; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.cluster.ClusterInfo; +import com.couchbase.client.java.query.Index; +import com.couchbase.client.java.query.N1qlQuery; import com.couchbase.client.java.view.DefaultView; import com.couchbase.client.java.view.DesignDocument; import com.couchbase.client.java.view.View; import org.springframework.data.couchbase.config.BeanNames; +import org.springframework.data.couchbase.repository.index.IndexedRepositoryTests; import org.springframework.test.context.TestContext; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; /** * @author Michael Nitschinger */ -public class CouchbaseTemplateViewListener extends DependencyInjectionTestExecutionListener { +public class CouchbaseTemplateQueryListener extends DependencyInjectionTestExecutionListener { @Override public void beforeTestClass(final TestContext testContext) throws Exception { @@ -39,6 +42,7 @@ public class CouchbaseTemplateViewListener extends DependencyInjectionTestExecut ClusterInfo clusterInfo = (ClusterInfo) testContext.getApplicationContext().getBean(BeanNames.COUCHBASE_CLUSTER_INFO); populateTestData(client, clusterInfo); createAndWaitForDesignDocs(client); + client.query(N1qlQuery.simple(Index.createPrimaryIndex().on(client.name()))); } private void populateTestData(Bucket client, ClusterInfo clusterInfo) { diff --git a/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateTests.java b/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateTests.java index ac01c09e..5e7d97ea 100644 --- a/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateTests.java +++ b/src/integration/java/org/springframework/data/couchbase/core/CouchbaseTemplateTests.java @@ -67,7 +67,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * @author Anastasiia Smirnova */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = IntegrationTestApplicationConfig.class) -@TestExecutionListeners(CouchbaseTemplateViewListener.class) +@TestExecutionListeners(CouchbaseTemplateQueryListener.class) public class CouchbaseTemplateTests { @Rule @@ -83,7 +83,7 @@ public class CouchbaseTemplateTests { private void removeIfExist(String key) { try { - client.remove(key); + template.remove(key); } catch (DocumentDoesNotExistException e) { //ignore diff --git a/src/integration/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateViewListener.java b/src/integration/java/org/springframework/data/couchbase/core/RxCouchbaseTemplateQueryListener.java similarity index 91% rename from src/integration/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateViewListener.java rename to src/integration/java/org/springframework/data/couchbase/core/RxCouchbaseTemplateQueryListener.java index 9fc8909c..fd543982 100644 --- a/src/integration/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateViewListener.java +++ b/src/integration/java/org/springframework/data/couchbase/core/RxCouchbaseTemplateQueryListener.java @@ -21,6 +21,8 @@ import java.util.Collections; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.cluster.ClusterInfo; import com.couchbase.client.java.error.DocumentDoesNotExistException; +import com.couchbase.client.java.query.Index; +import com.couchbase.client.java.query.N1qlQuery; import com.couchbase.client.java.view.*; import org.springframework.data.couchbase.config.BeanNames; @@ -31,7 +33,7 @@ import rx.Observable; /** * @author Subhashni Balakrishnan */ -public class ReactiveCouchbaseTemplateViewListener extends DependencyInjectionTestExecutionListener { +public class RxCouchbaseTemplateQueryListener extends DependencyInjectionTestExecutionListener { @Override public void beforeTestClass(final TestContext testContext) throws Exception { @@ -39,6 +41,7 @@ public class ReactiveCouchbaseTemplateViewListener extends DependencyInjectionTe ClusterInfo clusterInfo = (ClusterInfo) testContext.getApplicationContext().getBean(BeanNames.COUCHBASE_CLUSTER_INFO); populateTestData(client, clusterInfo); createAndWaitForDesignDocs(client); + client.query(N1qlQuery.simple(Index.createPrimaryIndex().on(client.name()))); } private void populateTestData(Bucket client, ClusterInfo clusterInfo) { diff --git a/src/integration/java/org/springframework/data/couchbase/core/RxJavaCouchbaseTemplateTests.java b/src/integration/java/org/springframework/data/couchbase/core/RxJavaCouchbaseTemplateTests.java index e4aba8cf..41a5d95f 100644 --- a/src/integration/java/org/springframework/data/couchbase/core/RxJavaCouchbaseTemplateTests.java +++ b/src/integration/java/org/springframework/data/couchbase/core/RxJavaCouchbaseTemplateTests.java @@ -28,8 +28,6 @@ import com.couchbase.client.java.Bucket; import com.couchbase.client.java.PersistTo; import com.couchbase.client.java.ReplicateTo; import com.couchbase.client.java.document.RawJsonDocument; -import com.couchbase.client.java.error.DocumentAlreadyExistsException; -import com.couchbase.client.java.error.DocumentDoesNotExistException; import com.couchbase.client.java.query.AsyncN1qlQueryResult; import com.couchbase.client.java.query.N1qlParams; import com.couchbase.client.java.query.N1qlQuery; @@ -39,7 +37,6 @@ import com.couchbase.client.java.view.Stale; import com.couchbase.client.java.view.ViewQuery; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; @@ -60,7 +57,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; **/ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = ReactiveIntegrationTestApplicationConfig.class) -@TestExecutionListeners(ReactiveCouchbaseTemplateViewListener.class) +@TestExecutionListeners(RxCouchbaseTemplateQueryListener.class) public class RxJavaCouchbaseTemplateTests { @Rule @@ -76,12 +73,18 @@ public class RxJavaCouchbaseTemplateTests { private void removeIfExist(String key) { - template.remove(key).subscribe(); + template.remove(key).subscribe( + v -> {}, + err -> {} + ); } private void removeCollectionIfExist(Collection beers) { template.remove(beers, PersistTo.MASTER, ReplicateTo.NONE) - .subscribe(); + .subscribe( + v -> {}, + err -> {} + ); } @Test @@ -129,7 +132,7 @@ public class RxJavaCouchbaseTemplateTests { removeIfExist(id); template.save(beer).subscribe(); - Object result = client.get(id); + Object result = template.findById(id, ReactiveBeer.class).toBlocking().single(); assertNotNull(result); template.remove(beer).subscribe(); @@ -154,7 +157,7 @@ public class RxJavaCouchbaseTemplateTests { ComplexPerson complex = new ComplexPerson(id, names, votes, info1, info2); - template.save(complex).toBlocking(); + template.save(complex).subscribe(); assertNotNull(client.get(id)); ComplexPerson response = template.findById(id, ComplexPerson.class).toBlocking().single(); @@ -199,12 +202,10 @@ public class RxJavaCouchbaseTemplateTests { @Test public void shouldQueryRaw() { - N1qlQuery query = N1qlQuery.simple(select("name").from(i(client.name())) - .where(x("name").isNotMissing())); + N1qlQuery query = N1qlQuery.simple(select("name").from(i(client.name())).limit(1)); AsyncN1qlQueryResult queryResult = template.queryN1QL(query).toBlocking().single(); - assertNotNull(queryResult); - assertTrue(queryResult.errors().toString(), queryResult.finalSuccess().toBlocking().single()); + assertTrue(queryResult.finalSuccess().toBlocking().single()); assertFalse(queryResult.rows().toList().toBlocking().single().isEmpty()); } @@ -212,7 +213,7 @@ public class RxJavaCouchbaseTemplateTests { public void shouldQueryWithMapping() { FullFragment ff1 = new FullFragment("fullFragment1", 1, "fullFragment", "test1"); FullFragment ff2 = new FullFragment("fullFragment2", 2, "fullFragment", "test2"); - template.save(Arrays.asList(ff1, ff2)); + template.save(Arrays.asList(ff1, ff2)).subscribe(); N1qlQuery query = N1qlQuery.simple(select(i("value")) //"value" is a n1ql keyword apparently .from(i(client.name())) @@ -270,9 +271,9 @@ public class RxJavaCouchbaseTemplateTests { String id = "simple-doc-with-update-expiry-for-read"; DocumentWithTouchOnRead doc = new DocumentWithTouchOnRead(id); template.save(doc).subscribe(); - Thread.sleep(1500); + Thread.sleep(1000); assertNotNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single()); - Thread.sleep(1500); + Thread.sleep(1000); assertNotNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single()); Thread.sleep(3000); assertNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single()); diff --git a/src/integration/java/org/springframework/data/couchbase/repository/ReactivePartyRepository.java b/src/integration/java/org/springframework/data/couchbase/repository/ReactivePartyRepository.java index 7e8cd4c5..a1be5f7d 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/ReactivePartyRepository.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/ReactivePartyRepository.java @@ -13,15 +13,15 @@ import reactor.core.publisher.Mono; /** * @author Subhashni Balakrishnan */ -@ViewIndexed(designDoc = "party", viewName = "all") -@N1qlSecondaryIndexed(indexName = "party") +@ViewIndexed(designDoc = "reactiveParty", viewName = "all") +@N1qlSecondaryIndexed(indexName = "reactiveParty") public interface ReactivePartyRepository extends ReactiveCouchbaseRepository { Flux findByAttendeesGreaterThanEqual(int minAttendees); Flux findByEventDateIs(Date targetDate); - @View(designDocument = "party", viewName = "byDate") + @View(designDocument = "reactiveParty", viewName = "byDate") Flux findFirst3ByEventDateGreaterThanEqual(Date targetDate); Flux findAllByDescriptionNotNull(); diff --git a/src/integration/java/org/springframework/data/couchbase/repository/ReactiveUserRepository.java b/src/integration/java/org/springframework/data/couchbase/repository/ReactiveUserRepository.java index 0f3db1d1..fe648eca 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/ReactiveUserRepository.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/ReactiveUserRepository.java @@ -20,25 +20,29 @@ import java.util.List; import com.couchbase.client.java.view.ViewQuery; +import org.springframework.data.couchbase.core.query.N1qlSecondaryIndexed; import org.springframework.data.couchbase.core.query.Query; import org.springframework.data.couchbase.core.query.View; +import org.springframework.data.couchbase.core.query.ViewIndexed; import reactor.core.publisher.Flux; /** * @author Subhashni Balakrishnan */ +@ViewIndexed(designDoc = "reactiveUser", viewName = "all") +@N1qlSecondaryIndexed(indexName = "reactiveUser") public interface ReactiveUserRepository extends ReactiveCouchbaseRepository { @View(designDocument = "user", viewName = "all") Flux customViewQuery(ViewQuery query); - @Query("#{#n1ql.selectEntity} WHERE username = $1") + @Query("#{#n1ql.selectEntity} WHERE username = $1 and #{#n1ql.filter}") Flux findByUsername(String username); - @Query("SELECT * FROM #{#n1ql.bucket} WHERE username = $1") + @Query("SELECT * FROM #{#n1ql.bucket} WHERE username = $1 and #{#n1ql.filter}") Flux findByUsernameBadSelect(String username); - @Query("#{#n1ql.selectEntity} WHERE username LIKE '%-#{3 + 1}'") + @Query("#{#n1ql.selectEntity} WHERE username LIKE '%-#{3 + 1}' and #{#n1ql.filter}") Flux findByUsernameWithSpelAndPlaceholder(); @Query diff --git a/src/integration/java/org/springframework/data/couchbase/repository/UserRepository.java b/src/integration/java/org/springframework/data/couchbase/repository/UserRepository.java index 5b3b116b..29554022 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/UserRepository.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/UserRepository.java @@ -20,8 +20,10 @@ import java.util.List; import com.couchbase.client.java.view.ViewQuery; +import org.springframework.data.couchbase.core.query.N1qlSecondaryIndexed; import org.springframework.data.couchbase.core.query.Query; import org.springframework.data.couchbase.core.query.View; +import org.springframework.data.couchbase.core.query.ViewIndexed; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -29,6 +31,8 @@ import org.springframework.data.domain.Slice; /** * @author Michael Nitschinger */ +@ViewIndexed(designDoc = "user", viewName = "all") +@N1qlSecondaryIndexed(indexName = "User") public interface UserRepository extends CouchbaseRepository { @View(designDocument = "user", viewName = "all") diff --git a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java index 9fe208d9..dfc04efb 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTestListener.java @@ -1,6 +1,7 @@ package org.springframework.data.couchbase.repository.index; import com.couchbase.client.java.Bucket; +import com.couchbase.client.java.error.DesignDocumentDoesNotExistException; import com.couchbase.client.java.query.Index; import com.couchbase.client.java.query.N1qlQuery; @@ -18,8 +19,12 @@ public class IndexedRepositoryTestListener extends DependencyInjectionTestExecut @Override public void beforeTestClass(final TestContext testContext) throws Exception { Bucket client = (Bucket) testContext.getApplicationContext().getBean(BeanNames.COUCHBASE_BUCKET); - client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC); - client.bucketManager().removeDesignDocument("foo"); + try { + client.bucketManager().removeDesignDocument(IndexedRepositoryTests.VIEW_DOC); + client.bucketManager().removeDesignDocument("foo"); + } catch (DesignDocumentDoesNotExistException ex) { + //ignore + } client.query(N1qlQuery.simple(Index.dropPrimaryIndex(client.name()))); client.query(N1qlQuery.simple(Index.dropIndex(client.name(), IndexedRepositoryTests.SECONDARY))); } diff --git a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java index 99fcc432..be1f9119 100644 --- a/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java +++ b/src/integration/java/org/springframework/data/couchbase/repository/index/IndexedRepositoryTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.*; import java.util.Arrays; +import com.couchbase.client.java.error.DesignDocumentDoesNotExistException; import com.couchbase.client.java.query.N1qlQuery; import com.couchbase.client.java.query.N1qlQueryResult; import com.couchbase.client.java.view.DesignDocument; @@ -81,13 +82,10 @@ public class IndexedRepositoryTests { IndexedUserRepository repository = factory.getRepository(IndexedUserRepository.class); String bucket = template.getCouchbaseBucket().name(); - N1qlQuery existQuery = N1qlQuery.simple("SELECT COUNT(name) = 1 AS exist FROM system:indexes WHERE keyspace_id = \"" + bucket - + "\" AND is_primary"); + N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"`"); N1qlQueryResult exist = template.queryN1QL(existQuery); assertTrue(exist.finalSuccess()); - assertEquals(1, exist.allRows().size()); - assertEquals(true, exist.allRows().get(0).value().getBoolean("exist")); } @Test @@ -95,22 +93,24 @@ public class IndexedRepositoryTests { IndexedUserRepository repository = factory.getRepository(IndexedUserRepository.class); String bucket = template.getCouchbaseBucket().name(); - N1qlQuery existQuery = N1qlQuery.simple("SELECT COUNT(name) = 1 AS exist FROM system:indexes WHERE keyspace_id = \"" + bucket - + "\" AND name = \"" + SECONDARY + "\""); + N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"` USE INDEX (" + SECONDARY +")"); N1qlQueryResult exist = template.queryN1QL(existQuery); assertTrue(exist.finalSuccess()); - assertEquals(1, exist.allRows().size()); - assertEquals(true, exist.allRows().get(0).value().getBoolean("exist")); } @Test public void shouldFindViewIndex() { IndexedUserRepository repository = factory.getRepository(IndexedUserRepository.class); - DesignDocument designDoc = template.getCouchbaseBucket() - .bucketManager() - .getDesignDocument(VIEW_DOC); + DesignDocument designDoc = null; + try { + designDoc = template.getCouchbaseBucket() + .bucketManager() + .getDesignDocument(VIEW_DOC); + } catch(DesignDocumentDoesNotExistException ex) { + + } assertNotNull(designDoc); for (View view : designDoc.views()) { @@ -123,22 +123,24 @@ public class IndexedRepositoryTests { AnotherIndexedUserRepository repository = ignoringIndexFactory.getRepository(AnotherIndexedUserRepository.class); String bucket = template.getCouchbaseBucket().name(); - N1qlQuery existQuery = N1qlQuery.simple("SELECT COUNT(name) = 1 AS exist FROM system:indexes WHERE keyspace_id = \"" + bucket - + "\" AND name = \"" + IGNORED_SECONDARY + "\""); + N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"` USE INDEX (" + IGNORED_SECONDARY +")"); N1qlQueryResult exist = template.queryN1QL(existQuery); - assertTrue(exist.finalSuccess()); - assertEquals(1, exist.allRows().size()); - assertEquals(false, exist.allRows().get(0).value().getBoolean("exist")); + assertFalse(exist.finalSuccess()); } @Test public void shouldNotFindViewIndexWithIgnoringIndexManager() { AnotherIndexedUserRepository repository = ignoringIndexFactory.getRepository(AnotherIndexedUserRepository.class); - DesignDocument designDoc = template.getCouchbaseBucket() - .bucketManager() - .getDesignDocument(VIEW_DOC); + DesignDocument designDoc = null; + try { + designDoc = template.getCouchbaseBucket() + .bucketManager() + .getDesignDocument(VIEW_DOC); + } catch(DesignDocumentDoesNotExistException ex) { + //ignored + } if (designDoc != null) { for (View view : designDoc.views()) { diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java index c1c9f5a6..95990656 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors + * Copyright 2012-2017 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. @@ -30,6 +30,7 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; * * @author Simon Baslé * @author Simon Bland + * @author Subhashni Balakrishnan */ /*package*/ class CouchbaseEnvironmentFactoryBean extends AbstractFactoryBean { @@ -123,14 +124,6 @@ import org.springframework.beans.factory.config.AbstractFactoryBean; this.couchbaseEnvBuilder.sslKeystorePassword(sslKeystorePassword); } - public void setQueryEnabled(boolean queryEnabled) { - this.couchbaseEnvBuilder.queryEnabled(queryEnabled); - } - - public void setQueryPort(int queryPort) { - this.couchbaseEnvBuilder.queryPort(queryPort); - } - public void setBootstrapHttpEnabled(boolean bootstrapHttpEnabled) { this.couchbaseEnvBuilder.bootstrapHttpEnabled(bootstrapHttpEnabled); } diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java index c5a18482..b5355be8 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentNoShutdownProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors + * Copyright 2012-2017 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. @@ -16,9 +16,14 @@ package org.springframework.data.couchbase.config; +import java.security.KeyStore; +import java.util.concurrent.TimeUnit; + +import com.couchbase.client.core.env.WaitStrategyFactory; import com.couchbase.client.core.event.EventBus; import com.couchbase.client.core.metrics.MetricsCollector; import com.couchbase.client.core.metrics.NetworkLatencyMetricsCollector; +import com.couchbase.client.core.node.MemcachedHashingStrategy; import com.couchbase.client.core.retry.RetryStrategy; import com.couchbase.client.core.time.Delay; import com.couchbase.client.deps.io.netty.channel.EventLoopGroup; @@ -32,6 +37,7 @@ import rx.Scheduler; * * @author Simon Baslé * @author Jonathan Edwards + * @author Subhashni Balakrishnan */ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment { @@ -42,8 +48,8 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment } @Override - public Observable shutdown() { - return Observable.just(false); + public boolean shutdown() { + return false; } //===== DELEGATION METHODS ===== @@ -58,6 +64,11 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment return delegate.ioPool(); } + @Override + public EventLoopGroup kvIoPool() { + return delegate.kvIoPool(); + } + @Override public Scheduler scheduler() { return delegate.scheduler(); @@ -83,18 +94,6 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment return delegate.sslKeystorePassword(); } - @Override - @Deprecated - public boolean queryEnabled() { - return delegate.queryEnabled(); - } - - @Override - @Deprecated - public int queryPort() { - return delegate.queryPort(); - } - @Override public boolean bootstrapHttpEnabled() { return delegate.bootstrapHttpEnabled(); @@ -324,4 +323,39 @@ public class CouchbaseEnvironmentNoShutdownProxy implements CouchbaseEnvironment public long searchTimeout() { return delegate.searchTimeout(); } + + @Override + public WaitStrategyFactory requestBufferWaitStrategy() { + return delegate.requestBufferWaitStrategy(); + } + + @Override + public EventLoopGroup viewIoPool() { + return delegate.viewIoPool(); + } + + @Override + public EventLoopGroup searchIoPool() { + return delegate.searchIoPool(); + } + + @Override + public EventLoopGroup queryIoPool() { + return delegate.queryIoPool(); + } + + @Override + public KeyStore sslKeystore() { + return delegate.sslKeystore(); + } + + @Override + public boolean shutdown(long timeout, TimeUnit timeUnit) { + return delegate.shutdown(timeout, timeUnit); + } + + @Override + public MemcachedHashingStrategy memcachedHashingStrategy() { + return delegate.memcachedHashingStrategy(); + } } diff --git a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java index 61caa967..ee2dfdc2 100644 --- a/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java +++ b/src/main/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors + * Copyright 2012-2017 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. @@ -44,8 +44,6 @@ import org.springframework.util.StringUtils; *
  • {@link DefaultCouchbaseEnvironment.Builder#sslEnabled(boolean) sslEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#sslKeystoreFile(String) sslKeystoreFile}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#sslKeystorePassword(String) sslKeystorePassword}
  • - *
  • {@link DefaultCouchbaseEnvironment.Builder#queryEnabled(boolean) queryEnabled}
  • - *
  • {@link DefaultCouchbaseEnvironment.Builder#queryPort(int) queryPort}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpEnabled(boolean) bootstrapHttpEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapCarrierEnabled(boolean) bootstrapCarrierEnabled}
  • *
  • {@link DefaultCouchbaseEnvironment.Builder#bootstrapHttpDirectPort(int) bootstrapHttpDirectPort}
  • @@ -69,6 +67,7 @@ import org.springframework.util.StringUtils; * * * @author Simon Baslé + * @author Subhashni Balakrishnan */ public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionParser { @@ -117,8 +116,6 @@ public class CouchbaseEnvironmentParser extends AbstractSingleBeanDefinitionPars setPropertyValue(envDefinitionBuilder, envElement, "sslEnabled", "sslEnabled"); setPropertyValue(envDefinitionBuilder, envElement, "sslKeystoreFile", "sslKeystoreFile"); setPropertyValue(envDefinitionBuilder, envElement, "sslKeystorePassword", "sslKeystorePassword"); - setPropertyValue(envDefinitionBuilder, envElement, "queryEnabled", "queryEnabled"); - setPropertyValue(envDefinitionBuilder, envElement, "queryPort", "queryPort"); setPropertyValue(envDefinitionBuilder, envElement, "bootstrapHttpEnabled", "bootstrapHttpEnabled"); setPropertyValue(envDefinitionBuilder, envElement, "bootstrapCarrierEnabled", "bootstrapCarrierEnabled"); setPropertyValue(envDefinitionBuilder, envElement, "bootstrapHttpDirectPort", "bootstrapHttpDirectPort"); diff --git a/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java b/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java index 11ed153c..e3fa0581 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java +++ b/src/main/java/org/springframework/data/couchbase/repository/support/IndexManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors + * Copyright 2012-2017 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. @@ -24,6 +24,7 @@ import java.util.Collections; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.bucket.BucketManager; import com.couchbase.client.java.document.json.JsonObject; +import com.couchbase.client.java.error.DesignDocumentDoesNotExistException; import com.couchbase.client.java.query.AsyncN1qlQueryResult; import com.couchbase.client.java.query.Index; import com.couchbase.client.java.query.Statement; @@ -53,6 +54,7 @@ import org.springframework.data.repository.core.RepositoryInformation; * Index creation will be attempted in parallel using the asynchronous APIs, but the overall process is still blocking. * * @author Simon Baslé + * @author Subhashni Balakrishnan */ public class IndexManager { @@ -281,7 +283,12 @@ public class IndexManager { } com.couchbase.client.java.view.View view = DefaultView.create(viewName, mapFunction, reduceFunction); - DesignDocument doc = manager.getDesignDocument(config.designDoc()); + DesignDocument doc = null; + try { + doc = manager.getDesignDocument(config.designDoc()); + } catch(DesignDocumentDoesNotExistException ex) { + //ignore + } if (doc != null) { for (com.couchbase.client.java.view.View existingView : doc.views()) { if (existingView.name().equals(viewName)) { diff --git a/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java b/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java index b1b84863..fed7dd29 100644 --- a/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java +++ b/src/test/java/org/springframework/data/couchbase/config/CouchbaseEnvironmentParserTest.java @@ -79,8 +79,6 @@ public class CouchbaseEnvironmentParserTest { assertThat(env.sslEnabled(), allOf(equalTo(true), not(defaultEnv.sslEnabled()))); assertThat(env.sslKeystoreFile(), is(equalTo("test"))); assertThat(env.sslKeystorePassword(), is(equalTo("test"))); - assertThat(env.queryEnabled(), allOf(equalTo(true), not(defaultEnv.queryEnabled()))); - assertThat(env.queryPort(), is(equalTo(7))); assertThat(env.bootstrapHttpEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapHttpEnabled()))); assertThat(env.bootstrapCarrierEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapCarrierEnabled()))); assertThat(env.bootstrapHttpDirectPort(), is(equalTo(8))); diff --git a/src/test/java/org/springframework/data/couchbase/repository/RepositoryIndexUsageTest.java b/src/test/java/org/springframework/data/couchbase/repository/RepositoryIndexUsageTest.java index 7b32860e..701a6348 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/RepositoryIndexUsageTest.java +++ b/src/test/java/org/springframework/data/couchbase/repository/RepositoryIndexUsageTest.java @@ -75,7 +75,7 @@ public class RepositoryIndexUsageTest { @Test public void testFindAllUsesViewWithConfiguredConsistency() { - String expectedQueryParams = "reduce=false&stale=false"; + String expectedQueryParams = "ViewQuery(string/all){params=\"reduce=false&stale=false\"}"; repository.findAll(); verify(couchbaseOperations, never()).queryView(any(ViewQuery.class)); @@ -89,7 +89,7 @@ public class RepositoryIndexUsageTest { @Test public void testFindAllKeysUsesViewWithConfiguredConsistency() { - String expectedQueryParams = "reduce=false&stale=false"; + String expectedQueryParams = "ViewQuery(string/all){params=\"reduce=false&stale=false\", keys=\"[\"someKey\"]\"}"; repository.findAll(Collections.singleton("someKey")); verify(couchbaseOperations, never()).queryView(any(ViewQuery.class)); @@ -103,7 +103,7 @@ public class RepositoryIndexUsageTest { @Test public void testCountUsesViewWithConfiguredConsistencyAndReduces() { - String expectedQueryParams = "reduce=true&stale=false"; + String expectedQueryParams = "ViewQuery(string/all){params=\"reduce=true&stale=false\"}"; repository.count(); verify(couchbaseOperations, never()).findByView(any(ViewQuery.class), any(Class.class)); @@ -123,7 +123,7 @@ public class RepositoryIndexUsageTest { @Test public void testDeleteAllUsesViewWithConfiguredConsistency() { - String expectedQueryParams = "reduce=false&stale=false"; + String expectedQueryParams = "ViewQuery(string/all){params=\"reduce=false&stale=false\"}"; repository.deleteAll(); verify(couchbaseOperations, never()).findByView(any(ViewQuery.class), any(Class.class)); diff --git a/src/test/resources/configurations/couchbaseEnv-bean.xml b/src/test/resources/configurations/couchbaseEnv-bean.xml index d280a67c..65ab5b25 100644 --- a/src/test/resources/configurations/couchbaseEnv-bean.xml +++ b/src/test/resources/configurations/couchbaseEnv-bean.xml @@ -23,8 +23,6 @@ sslEnabled="true" sslKeystoreFile="test" sslKeystorePassword="test" - queryEnabled="true" - queryPort="7" bootstrapHttpEnabled="false" bootstrapCarrierEnabled="false" bootstrapHttpDirectPort="8"