Skip to content

Commit b9f23f3

Browse files
committed
DATACOUCH-135 - Migrate to Couchbase SDK 2.0 and add N1QL find method.
Adaptation were made to use SDK 2.0: - Reworked the configuration approach (more parts to be configured, like Environment, Cluster and Bucket) - Added a new xml schema for configuration of 2.0 version - Adapted the template - Added N1QL support in the template (findByN1QL) - Removed the cache package - Adapted the repository - Better separated Unit Tests from Integration Tests All integration and unit tests pass, except one (SimpleCouchbaseRepositoryTests.shouldFindCustom). Customisation of a ViewQuery will be addressed in another ticket.
1 parent 28dcdee commit b9f23f3

File tree

126 files changed

+4134
-3115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+4134
-3115
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Spring Data Couchbase - v2
2+
This branch is a work in progress, it will contain the do-over of the `Spring-Data Couchbase` connector
3+
for the `Couchbase Java SDK 2.x` generation.
4+
5+
Below is the v1 README as of `75bce39`:
6+
17
# Spring Data Couchbase
28

39
The primary goal of the [Spring Data](http://www.springsource.org/spring-data) project is to make it easier to build

pom.xml

+163-154
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,164 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
4-
<modelVersion>4.0.0</modelVersion>
5-
6-
<groupId>org.springframework.data</groupId>
7-
<artifactId>spring-data-couchbase</artifactId>
8-
<version>1.4.0.BUILD-SNAPSHOT</version>
9-
10-
<name>Spring Data Couchbase</name>
11-
<description>Spring Data integration for Couchbase</description>
12-
<url>https://github.com/SpringSource/spring-data-couchbase</url>
13-
14-
<parent>
15-
<groupId>org.springframework.data.build</groupId>
16-
<artifactId>spring-data-parent</artifactId>
17-
<version>1.7.0.BUILD-SNAPSHOT</version>
18-
</parent>
19-
20-
<properties>
21-
22-
<dist.key>DATACOUCH</dist.key>
23-
24-
<couchbase>1.4.7</couchbase>
25-
<jackson>2.3.2</jackson>
26-
<springdata.commons>1.11.0.BUILD-SNAPSHOT</springdata.commons>
27-
<validation>1.0.0.GA</validation>
28-
</properties>
29-
30-
<dependencies>
31-
32-
<dependency>
33-
<groupId>org.springframework</groupId>
34-
<artifactId>spring-context</artifactId>
35-
</dependency>
36-
<dependency>
37-
<groupId>org.springframework</groupId>
38-
<artifactId>spring-web</artifactId>
39-
</dependency>
40-
<dependency>
41-
<groupId>org.springframework</groupId>
42-
<artifactId>spring-tx</artifactId>
43-
</dependency>
44-
45-
<dependency>
46-
<groupId>${project.groupId}</groupId>
47-
<artifactId>spring-data-commons</artifactId>
48-
<version>${springdata.commons}</version>
49-
</dependency>
50-
51-
<dependency>
52-
<groupId>com.couchbase.client</groupId>
53-
<artifactId>couchbase-client</artifactId>
54-
<version>${couchbase}</version>
55-
</dependency>
56-
57-
<dependency>
58-
<groupId>org.springframework</groupId>
59-
<artifactId>spring-test</artifactId>
60-
<version>${spring}</version>
61-
<scope>test</scope>
62-
</dependency>
63-
64-
<dependency>
65-
<groupId>org.hibernate</groupId>
66-
<artifactId>hibernate-validator</artifactId>
67-
<version>4.2.0.Final</version>
68-
<scope>test</scope>
69-
</dependency>
70-
71-
<dependency>
72-
<groupId>org.apache.httpcomponents</groupId>
73-
<artifactId>httpclient</artifactId>
74-
<version>4.3.3</version>
75-
<scope>test</scope>
76-
</dependency>
77-
78-
<dependency>
79-
<groupId>com.fasterxml.jackson.core</groupId>
80-
<artifactId>jackson-databind</artifactId>
81-
<version>${jackson}</version>
82-
</dependency>
83-
84-
<dependency>
85-
<groupId>joda-time</groupId>
86-
<artifactId>joda-time</artifactId>
87-
<version>${jodatime}</version>
88-
<optional>true</optional>
89-
</dependency>
90-
91-
<!-- JSR 303 Validation -->
92-
<dependency>
93-
<groupId>javax.validation</groupId>
94-
<artifactId>validation-api</artifactId>
95-
<version>${validation}</version>
96-
<optional>true</optional>
97-
</dependency>
98-
99-
<!-- CDI -->
100-
<dependency>
101-
<groupId>javax.enterprise</groupId>
102-
<artifactId>cdi-api</artifactId>
103-
<version>${cdi}</version>
104-
<scope>provided</scope>
105-
<optional>true</optional>
106-
</dependency>
107-
108-
<dependency>
109-
<groupId>org.apache.openwebbeans.test</groupId>
110-
<artifactId>cditest-owb</artifactId>
111-
<version>${webbeans}</version>
112-
<scope>test</scope>
113-
</dependency>
114-
115-
<dependency>
116-
<groupId>javax.servlet</groupId>
117-
<artifactId>servlet-api</artifactId>
118-
<version>3.0-alpha-1</version>
119-
<scope>test</scope>
120-
</dependency>
121-
122-
</dependencies>
123-
124-
<repositories>
125-
<repository>
126-
<id>spring-libs-snapshot</id>
127-
<url>https://repo.spring.io/libs-snapshot</url>
128-
</repository>
129-
</repositories>
130-
131-
<pluginRepositories>
132-
<pluginRepository>
133-
<id>spring-plugins-release</id>
134-
<url>https://repo.spring.io/plugins-release</url>
135-
</pluginRepository>
136-
</pluginRepositories>
137-
138-
<build>
139-
<plugins>
140-
<plugin>
141-
<groupId>org.apache.maven.plugins</groupId>
142-
<artifactId>maven-assembly-plugin</artifactId>
143-
</plugin>
144-
<plugin>
145-
<groupId>org.codehaus.mojo</groupId>
146-
<artifactId>wagon-maven-plugin</artifactId>
147-
</plugin>
148-
<plugin>
149-
<groupId>org.asciidoctor</groupId>
150-
<artifactId>asciidoctor-maven-plugin</artifactId>
151-
</plugin>
152-
</plugins>
153-
</build>
154-
155-
</project>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.springframework.data</groupId>
8+
<artifactId>spring-data-couchbase</artifactId>
9+
<version>2.0.0.BUILD-SNAPSHOT</version>
10+
11+
<name>Spring Data Couchbase</name>
12+
<description>Spring Data integration for Couchbase</description>
13+
<url>https://github.com/SpringSource/spring-data-couchbase</url>
14+
15+
<parent>
16+
<groupId>org.springframework.data.build</groupId>
17+
<artifactId>spring-data-parent</artifactId>
18+
<version>1.7.0.BUILD-SNAPSHOT</version>
19+
</parent>
20+
21+
<properties>
22+
23+
<dist.key>DATACOUCH</dist.key>
24+
25+
<couchbase>2.2.0-dp</couchbase>
26+
<jackson>2.3.2</jackson>
27+
<springdata.commons>1.11.0.BUILD-SNAPSHOT</springdata.commons>
28+
<validation>1.0.0.GA</validation>
29+
</properties>
30+
31+
<dependencies>
32+
33+
<dependency>
34+
<groupId>org.springframework</groupId>
35+
<artifactId>spring-context</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework</groupId>
39+
<artifactId>spring-web</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework</groupId>
43+
<artifactId>spring-tx</artifactId>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>${project.groupId}</groupId>
48+
<artifactId>spring-data-commons</artifactId>
49+
<version>${springdata.commons}</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>com.couchbase.client</groupId>
54+
<artifactId>java-client</artifactId>
55+
<version>${couchbase}</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.springframework</groupId>
60+
<artifactId>spring-test</artifactId>
61+
<version>${spring}</version>
62+
<scope>test</scope>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>org.hibernate</groupId>
67+
<artifactId>hibernate-validator</artifactId>
68+
<version>4.2.0.Final</version>
69+
<scope>test</scope>
70+
</dependency>
71+
72+
<dependency>
73+
<groupId>org.apache.httpcomponents</groupId>
74+
<artifactId>httpclient</artifactId>
75+
<version>4.3.3</version>
76+
<scope>test</scope>
77+
</dependency>
78+
79+
<dependency>
80+
<groupId>com.fasterxml.jackson.core</groupId>
81+
<artifactId>jackson-databind</artifactId>
82+
<version>${jackson}</version>
83+
</dependency>
84+
85+
<dependency>
86+
<groupId>joda-time</groupId>
87+
<artifactId>joda-time</artifactId>
88+
<version>${jodatime}</version>
89+
<optional>true</optional>
90+
</dependency>
91+
92+
<!-- JSR 303 Validation -->
93+
<dependency>
94+
<groupId>javax.validation</groupId>
95+
<artifactId>validation-api</artifactId>
96+
<version>${validation}</version>
97+
<optional>true</optional>
98+
</dependency>
99+
100+
<!-- CDI -->
101+
<dependency>
102+
<groupId>javax.enterprise</groupId>
103+
<artifactId>cdi-api</artifactId>
104+
<version>${cdi}</version>
105+
<scope>provided</scope>
106+
<optional>true</optional>
107+
</dependency>
108+
109+
<dependency>
110+
<groupId>org.apache.openwebbeans.test</groupId>
111+
<artifactId>cditest-owb</artifactId>
112+
<version>${webbeans}</version>
113+
<scope>test</scope>
114+
</dependency>
115+
116+
<dependency>
117+
<groupId>javax.servlet</groupId>
118+
<artifactId>servlet-api</artifactId>
119+
<version>3.0-alpha-1</version>
120+
<scope>test</scope>
121+
</dependency>
122+
123+
</dependencies>
124+
125+
<repositories>
126+
<repository>
127+
<id>spring-libs-snapshot</id>
128+
<url>https://repo.spring.io/libs-snapshot</url>
129+
</repository>
130+
<repository>
131+
<id>couchbase</id>
132+
<name>couchbase repo</name>
133+
<url>http://files.couchbase.com/maven2</url>
134+
<snapshots>
135+
<enabled>false</enabled>
136+
</snapshots>
137+
</repository>
138+
</repositories>
139+
140+
<pluginRepositories>
141+
<pluginRepository>
142+
<id>spring-plugins-release</id>
143+
<url>https://repo.spring.io/plugins-release</url>
144+
</pluginRepository>
145+
</pluginRepositories>
146+
147+
<build>
148+
<plugins>
149+
<plugin>
150+
<groupId>org.apache.maven.plugins</groupId>
151+
<artifactId>maven-assembly-plugin</artifactId>
152+
</plugin>
153+
<plugin>
154+
<groupId>org.codehaus.mojo</groupId>
155+
<artifactId>wagon-maven-plugin</artifactId>
156+
</plugin>
157+
<plugin>
158+
<groupId>org.asciidoctor</groupId>
159+
<artifactId>asciidoctor-maven-plugin</artifactId>
160+
</plugin>
161+
</plugins>
162+
</build>
163+
164+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.springframework.data.couchbase;
2+
3+
import java.util.Collections;
4+
import java.util.List;
5+
6+
import com.couchbase.client.java.env.CouchbaseEnvironment;
7+
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
8+
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.context.annotation.Bean;
11+
import org.springframework.context.annotation.Configuration;
12+
import org.springframework.core.env.Environment;
13+
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
14+
import org.springframework.data.couchbase.core.CouchbaseTemplate;
15+
import org.springframework.data.couchbase.core.WriteResultChecking;
16+
17+
@Configuration
18+
public class IntegrationTestApplicationConfig extends AbstractCouchbaseConfiguration {
19+
20+
@Autowired
21+
private Environment springEnv;
22+
23+
@Bean
24+
public String couchbaseAdminUser() {
25+
return springEnv.getProperty("couchbase.adminUser", "Administrator");
26+
}
27+
28+
@Bean
29+
public String couchbaseAdminPassword() {
30+
return springEnv.getProperty("couchbase.adminUser", "password");
31+
}
32+
33+
@Override
34+
protected List<String> getBootstrapHosts() {
35+
return Collections.singletonList(springEnv.getProperty("couchbase.host", "127.0.0.1"));
36+
}
37+
38+
@Override
39+
protected String getBucketName() {
40+
return springEnv.getProperty("couchbase.bucket", "default");
41+
}
42+
43+
@Override
44+
protected String getBucketPassword() {
45+
return springEnv.getProperty("couchbase.password", "");
46+
}
47+
48+
49+
//TODO maybe create the bucket if doesn't exist
50+
51+
@Override
52+
protected CouchbaseEnvironment getEnvironment() {
53+
return DefaultCouchbaseEnvironment.builder()
54+
.connectTimeout(10000)
55+
.kvTimeout(10000)
56+
.queryTimeout(10000)
57+
.viewTimeout(10000)
58+
.build();
59+
}
60+
61+
@Override
62+
public CouchbaseTemplate couchbaseTemplate() throws Exception {
63+
CouchbaseTemplate template = super.couchbaseTemplate();
64+
template.setWriteResultChecking(WriteResultChecking.LOG);
65+
return template;
66+
}
67+
}

0 commit comments

Comments
 (0)