diff --git a/boot-data-couchbase/pom.xml b/boot-data-couchbase/pom.xml
index 6f0b2b368..d4cfbf7e3 100644
--- a/boot-data-couchbase/pom.xml
+++ b/boot-data-couchbase/pom.xml
@@ -48,6 +48,11 @@
reactor-test
test
+
+ org.springframework.boot
+ spring-boot-testcontainers
+ test
+
org.testcontainers
junit-jupiter
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/DataConfig.java b/boot-data-couchbase/src/main/java/com/example/demo/DataConfig.java
new file mode 100644
index 000000000..ce69e822d
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/DataConfig.java
@@ -0,0 +1,18 @@
+package com.example.demo;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.couchbase.repository.auditing.EnableReactiveCouchbaseAuditing;
+import org.springframework.data.domain.ReactiveAuditorAware;
+import reactor.core.publisher.Mono;
+
+@Configuration(proxyBeanMethods = false)
+// see: https://jira.spring.io/browse/DATACOUCH-644
+@EnableReactiveCouchbaseAuditing
+public class DataConfig {
+
+ @Bean
+ public ReactiveAuditorAware reactiveAuditorAware() {
+ return () -> Mono.just("hantsy");
+ }
+}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/DataInitializer.java b/boot-data-couchbase/src/main/java/com/example/demo/DataInitializer.java
new file mode 100644
index 000000000..3e5f70cc9
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/DataInitializer.java
@@ -0,0 +1,41 @@
+package com.example.demo;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+import reactor.core.publisher.Flux;
+
+import java.util.UUID;
+
+@Component
+@RequiredArgsConstructor
+@Slf4j
+@Profile("dev")
+public class DataInitializer implements CommandLineRunner {
+
+ private final PostRepository posts;
+
+ @Override
+ public void run(String[] args) {
+ log.info("start data initialization ...");
+ this.posts
+ .deleteAll()
+ .thenMany(
+ Flux
+ .just("Post one", "Post two")
+ .flatMap(
+ title -> this.posts.save(Post.builder().id(UUID.randomUUID().toString()).title(title).content("content of " + title).build())
+ )
+ )
+ .log("[initialization log]")
+ .subscribe(
+ data -> log.info("saved data: {}", data),
+ error -> log.error("error: {}", error.getMessage()),
+ () -> log.info("done initialization...")
+ );
+
+ }
+
+}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/DemoApplication.java b/boot-data-couchbase/src/main/java/com/example/demo/DemoApplication.java
index c100552c8..db90d9f48 100644
--- a/boot-data-couchbase/src/main/java/com/example/demo/DemoApplication.java
+++ b/boot-data-couchbase/src/main/java/com/example/demo/DemoApplication.java
@@ -38,140 +38,3 @@ public static void main(String[] args) {
}
-@Configuration
-class WebConfig {
- @Bean
- public RouterFunction routes(PostHandler handler) {
- return route(GET("/posts"), handler::all)
- .andRoute(POST("/posts"), handler::create)
- .andRoute(GET("/posts/{id}"), handler::get)
- .andRoute(PUT("/posts/{id}"), handler::update)
- .andRoute(DELETE("/posts/{id}"), handler::delete);
- }
-}
-
-@Configuration(proxyBeanMethods = false)
-// see: https://jira.spring.io/browse/DATACOUCH-644
-@EnableReactiveCouchbaseAuditing
-class DataConfig {
-
- @Bean
- public ReactiveAuditorAware reactiveAuditorAware() {
- return () -> Mono.just("hantsy");
- }
-}
-
-@Component
-@Slf4j
-@Profile("default")
-class DataInitializer implements CommandLineRunner {
-
- private final PostRepository posts;
-
- public DataInitializer(PostRepository posts) {
- this.posts = posts;
- }
-
- @Override
- public void run(String[] args) {
- log.info("start data initialization ...");
- this.posts
- .deleteAll()
- .thenMany(
- Flux
- .just("Post one", "Post two")
- .flatMap(
- title -> this.posts.save(Post.builder().id(UUID.randomUUID().toString()).title(title).content("content of " + title).build())
- )
- )
- .log("[initialization log]")
- .subscribe(
- data -> log.info("saved data: {}", data),
- error -> log.error("error: {}", error.getMessage()),
- () -> log.info("done initialization...")
- );
-
- }
-
-}
-
-@Component
-@RequiredArgsConstructor
-class PostHandler {
- private final PostRepository posts;
-
- public Mono all(ServerRequest req) {
- return ServerResponse.ok().body(this.posts.findAll(), Post.class);
- }
-
- public Mono create(ServerRequest req) {
- return req.bodyToMono(Post.class)
- .flatMap(post -> this.posts.save(post))
- .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build());
- }
-
- public Mono get(ServerRequest req) {
- return this.posts.findById(req.pathVariable("id"))
- .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class))
- .switchIfEmpty(ServerResponse.notFound().build());
- }
-
- public Mono update(ServerRequest req) {
-
- return Mono
- .zip(
- (data) -> {
- Post p = (Post) data[0];
- Post p2 = (Post) data[1];
- p.setTitle(p2.getTitle());
- p.setContent(p2.getContent());
- return p;
- },
- this.posts.findById(req.pathVariable("id")),
- req.bodyToMono(Post.class)
- )
- .cast(Post.class)
- .flatMap(post -> this.posts.save(post))
- .flatMap(post -> ServerResponse.noContent().build());
-
- }
-
- public Mono delete(ServerRequest req) {
- return ServerResponse.noContent().build(this.posts.deleteById(req.pathVariable("id")));
- }
-
-}
-
-interface PostRepository extends ReactiveCouchbaseRepository {
-}
-
-@Document
-@Data
-@ToString
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-class Post {
-
- @Id
- @GeneratedValue(strategy = GenerationStrategy.UNIQUE)
- private String id;
- private String title;
- private String content;
-
- @CreatedBy
- private String createdBy;
-
- @CreatedDate
- private LocalDateTime createdAt;
-
- @LastModifiedBy
- private String lastModifiedBy;
-
- @LastModifiedDate
- private LocalDateTime lastModifiedAt;
-
- @Version
- Long version;
-
-}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/Post.java b/boot-data-couchbase/src/main/java/com/example/demo/Post.java
new file mode 100644
index 000000000..82e0c158f
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/Post.java
@@ -0,0 +1,40 @@
+package com.example.demo;
+
+import lombok.*;
+import org.springframework.data.annotation.*;
+import org.springframework.data.couchbase.core.mapping.Document;
+import org.springframework.data.couchbase.core.mapping.id.GeneratedValue;
+import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy;
+
+import java.time.LocalDateTime;
+
+@Document
+@Data
+@ToString
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Post {
+
+ @Id
+ @GeneratedValue(strategy = GenerationStrategy.UNIQUE)
+ private String id;
+ private String title;
+ private String content;
+
+ @CreatedBy
+ private String createdBy;
+
+ @CreatedDate
+ private LocalDateTime createdAt;
+
+ @LastModifiedBy
+ private String lastModifiedBy;
+
+ @LastModifiedDate
+ private LocalDateTime lastModifiedAt;
+
+ @Version
+ Long version;
+
+}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/PostHandler.java b/boot-data-couchbase/src/main/java/com/example/demo/PostHandler.java
new file mode 100644
index 000000000..b7699f85b
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/PostHandler.java
@@ -0,0 +1,56 @@
+package com.example.demo;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.server.ServerRequest;
+import org.springframework.web.reactive.function.server.ServerResponse;
+import reactor.core.publisher.Mono;
+
+import java.net.URI;
+
+@Component
+@RequiredArgsConstructor
+public class PostHandler {
+ private final PostRepository posts;
+
+ public Mono all(ServerRequest req) {
+ return ServerResponse.ok().body(this.posts.findAll(), Post.class);
+ }
+
+ public Mono create(ServerRequest req) {
+ return req.bodyToMono(Post.class)
+ .flatMap(post -> this.posts.save(post))
+ .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build());
+ }
+
+ public Mono get(ServerRequest req) {
+ return this.posts.findById(req.pathVariable("id"))
+ .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class))
+ .switchIfEmpty(ServerResponse.notFound().build());
+ }
+
+ public Mono update(ServerRequest req) {
+
+ return Mono
+ .zip(
+ (data) -> {
+ Post p = (Post) data[0];
+ Post p2 = (Post) data[1];
+ p.setTitle(p2.getTitle());
+ p.setContent(p2.getContent());
+ return p;
+ },
+ this.posts.findById(req.pathVariable("id")),
+ req.bodyToMono(Post.class)
+ )
+ .cast(Post.class)
+ .flatMap(post -> this.posts.save(post))
+ .flatMap(post -> ServerResponse.noContent().build());
+
+ }
+
+ public Mono delete(ServerRequest req) {
+ return ServerResponse.noContent().build(this.posts.deleteById(req.pathVariable("id")));
+ }
+
+}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/PostRepository.java b/boot-data-couchbase/src/main/java/com/example/demo/PostRepository.java
new file mode 100644
index 000000000..b51cbbc93
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/PostRepository.java
@@ -0,0 +1,6 @@
+package com.example.demo;
+
+import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository;
+
+public interface PostRepository extends ReactiveCouchbaseRepository {
+}
diff --git a/boot-data-couchbase/src/main/java/com/example/demo/WebConfig.java b/boot-data-couchbase/src/main/java/com/example/demo/WebConfig.java
new file mode 100644
index 000000000..94ad624ee
--- /dev/null
+++ b/boot-data-couchbase/src/main/java/com/example/demo/WebConfig.java
@@ -0,0 +1,21 @@
+package com.example.demo;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.reactive.function.server.RouterFunction;
+import org.springframework.web.reactive.function.server.ServerResponse;
+
+import static org.springframework.web.reactive.function.server.RequestPredicates.*;
+import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+
+@Configuration
+public class WebConfig {
+ @Bean
+ public RouterFunction routes(PostHandler handler) {
+ return route(GET("/posts"), handler::all)
+ .andRoute(POST("/posts"), handler::create)
+ .andRoute(GET("/posts/{id}"), handler::get)
+ .andRoute(PUT("/posts/{id}"), handler::update)
+ .andRoute(DELETE("/posts/{id}"), handler::delete);
+ }
+}
diff --git a/boot-data-couchbase/src/main/resources/application.properties b/boot-data-couchbase/src/main/resources/application.properties
index ff0e8474a..ac096580f 100644
--- a/boot-data-couchbase/src/main/resources/application.properties
+++ b/boot-data-couchbase/src/main/resources/application.properties
@@ -1,8 +1,9 @@
# couchbase connection
-spring.couchbase.connection-string=couchbase://localhost
-spring.couchbase.username=Administrator
-spring.couchbase.password=password
-# couchbase bucket name
+#spring.couchbase.connection-string=couchbase://localhost
+#spring.couchbase.username=Administrator
+#spring.couchbase.password=password
+## couchbase bucket name
+# required to activate spring testcontainers???
spring.data.couchbase.bucket-name=demo
# by default, it is disabled, you have to enable auto indexing in Couchbase console.
spring.data.couchbase.autoIndex=true
diff --git a/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryTest.java b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryTest.java
index d19716be5..d2c261976 100644
--- a/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryTest.java
+++ b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryTest.java
@@ -5,57 +5,27 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.util.TestPropertyValues;
-import org.springframework.context.ApplicationContextInitializer;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.context.annotation.Import;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.testcontainers.couchbase.BucketDefinition;
-import org.testcontainers.couchbase.CouchbaseContainer;
-import org.testcontainers.utility.DockerImageName;
import reactor.test.StepVerifier;
-import java.time.Duration;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import static org.assertj.core.api.Assertions.assertThat;
-@SpringBootTest
-@ContextConfiguration(initializers = PostRepositoryTest.TestContainerInitializer.class)
+@DataCouchbaseTest
+@Import(TestcontainersConfiguration.class)
@ActiveProfiles("test")
@Slf4j
class PostRepositoryTest {
- static class TestContainerInitializer implements ApplicationContextInitializer {
- private static final String COUCHBASE_IMAGE_NAME = "couchbase";
- private static final String DEFAULT_IMAGE_NAME = "couchbase/server:6";
- private static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse(COUCHBASE_IMAGE_NAME)
- .asCompatibleSubstituteFor(DEFAULT_IMAGE_NAME);
-
- @Override
- public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
- final CouchbaseContainer couchbaseContainer = new CouchbaseContainer(DEFAULT_IMAGE)
- .withCredentials("Administrator", "password")
- .withBucket(new BucketDefinition("demo").withPrimaryIndex(true))
- .withStartupTimeout(Duration.ofSeconds(60));
-
- couchbaseContainer.start();
-
- configurableApplicationContext
- .addApplicationListener((ApplicationListener) event -> couchbaseContainer.stop());
- TestPropertyValues.of(
- "spring.couchbase.connection-string=" + couchbaseContainer.getConnectionString(),
- "spring.couchbase.username=" + couchbaseContainer.getUsername(),
- "spring.couchbase.password=" + couchbaseContainer.getPassword(),
- "spring.data.couchbase.bucket-name=demo"
- )
- .applyTo(configurableApplicationContext.getEnvironment());
- }
+ @TestConfiguration
+ @Import(DataConfig.class)
+ static class TestConfig {
}
@Autowired
@@ -74,7 +44,8 @@ public void setup() {
)
.subscribe(data -> {
log.debug("saved data: {}", data);
- countDownLatch.countDown();;
+ countDownLatch.countDown();
+ ;
});
countDownLatch.await(1000, java.util.concurrent.TimeUnit.MILLISECONDS);
}
diff --git a/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithContextInitializerTest.java b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithContextInitializerTest.java
new file mode 100644
index 000000000..30d3102c0
--- /dev/null
+++ b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithContextInitializerTest.java
@@ -0,0 +1,101 @@
+package com.example.demo;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.data.domain.Sort;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.testcontainers.couchbase.BucketDefinition;
+import org.testcontainers.couchbase.CouchbaseContainer;
+import org.testcontainers.utility.DockerImageName;
+import reactor.test.StepVerifier;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SpringBootTest
+@ContextConfiguration(initializers = PostRepositoryWithContextInitializerTest.TestContainerInitializer.class)
+@ActiveProfiles("test")
+@Slf4j
+class PostRepositoryWithContextInitializerTest {
+
+ static class TestContainerInitializer implements ApplicationContextInitializer {
+ private static final String COUCHBASE_IMAGE_NAME = "couchbase";
+ private static final String DEFAULT_IMAGE_NAME = "couchbase/server:7";
+ private static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse(COUCHBASE_IMAGE_NAME)
+ .asCompatibleSubstituteFor(DEFAULT_IMAGE_NAME);
+
+ @Override
+ public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
+ final CouchbaseContainer couchbaseContainer = new CouchbaseContainer(DEFAULT_IMAGE)
+ .withCredentials("Administrator", "password")
+ .withBucket(new BucketDefinition("demo")
+ .withPrimaryIndex(true)
+ )
+ .withStartupTimeout(Duration.ofSeconds(60));
+
+ couchbaseContainer.start();
+
+ configurableApplicationContext
+ .addApplicationListener((ApplicationListener) event -> couchbaseContainer.stop());
+ TestPropertyValues.of(
+ "spring.couchbase.connection-string=" + couchbaseContainer.getConnectionString(),
+ "spring.couchbase.username=" + couchbaseContainer.getUsername(),
+ "spring.couchbase.password=" + couchbaseContainer.getPassword(),
+ "spring.data.couchbase.bucket-name=demo"
+ )
+ .applyTo(configurableApplicationContext.getEnvironment());
+ }
+ }
+
+ @Autowired
+ private PostRepository posts;
+
+ @SneakyThrows
+ @BeforeEach
+ public void setup() {
+ var countDownLatch = new CountDownLatch(1);
+ this.posts
+ .saveAll(
+ List.of(
+ Post.builder().title("Post one").content("content of post one").build(),
+ Post.builder().title("Post two").content("content of post two").build()
+ )
+ )
+ .subscribe(data -> {
+ log.debug("saved data: {}", data);
+ countDownLatch.countDown();
+ ;
+ });
+ countDownLatch.await(1000, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
+ @Test
+ void testLoadUsers() {
+ this.posts.findAll(Sort.by(Sort.Direction.ASC, "title"))
+ .log()
+ .as(StepVerifier::create)
+ .consumeNextWith(user -> {
+ assertThat(user.getTitle()).isEqualTo("Post one");
+ //verify data auditing
+ assertThat(user.getCreatedBy()).isEqualTo("hantsy");
+ assertThat(user.getCreatedAt()).isNotNull();
+ })
+ .consumeNextWith(user -> assertThat(user.getTitle()).isEqualTo("Post two"))
+ //.expectNextCount(2)
+ .verifyComplete();
+ }
+
+}
diff --git a/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainresTest.java b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainersTest.java
similarity index 83%
rename from boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainresTest.java
rename to boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainersTest.java
index 22aecff41..c1050803f 100644
--- a/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainresTest.java
+++ b/boot-data-couchbase/src/test/java/com/example/demo/PostRepositoryWithTestcontainersTest.java
@@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.couchbase.DataCouchbaseTest;
import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Import;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.ActiveProfiles;
@@ -30,7 +31,7 @@
@Testcontainers
@ActiveProfiles("test")
@Slf4j
-class PostRepositoryWithTestcontainresTest {
+class PostRepositoryWithTestcontainersTest {
@TestConfiguration
@@ -39,11 +40,12 @@ static class TestConfig {
}
private static final String COUCHBASE_IMAGE_NAME = "couchbase";
- private static final String DEFAULT_IMAGE_NAME = "couchbase/server:6";
+ private static final String DEFAULT_IMAGE_NAME = "couchbase/server:7";
private static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse(COUCHBASE_IMAGE_NAME)
.asCompatibleSubstituteFor(DEFAULT_IMAGE_NAME);
@Container
+ @ServiceConnection
final static CouchbaseContainer couchbaseContainer = new CouchbaseContainer(DEFAULT_IMAGE)
.withCredentials("Administrator", "password")
.withBucket(new BucketDefinition("demo").withPrimaryIndex(true))
@@ -51,13 +53,13 @@ static class TestConfig {
.withStartupTimeout(Duration.ofSeconds(60))
.waitingFor(Wait.forHealthcheck());
- @DynamicPropertySource
- static void bindCouchbaseProperties(DynamicPropertyRegistry registry) {
- registry.add("spring.couchbase.connection-string", couchbaseContainer::getConnectionString);
- registry.add("spring.couchbase.username", couchbaseContainer::getUsername);
- registry.add("spring.couchbase.password", couchbaseContainer::getPassword);
- registry.add("spring.data.couchbase.bucket-name", () -> "demo");
- }
+// @DynamicPropertySource
+// static void bindCouchbaseProperties(DynamicPropertyRegistry registry) {
+// registry.add("spring.couchbase.connection-string", couchbaseContainer::getConnectionString);
+// registry.add("spring.couchbase.username", couchbaseContainer::getUsername);
+// registry.add("spring.couchbase.password", couchbaseContainer::getPassword);
+// registry.add("spring.data.couchbase.bucket-name", () -> "demo");
+// }
@Autowired
private PostRepository posts;
diff --git a/boot-data-couchbase/src/test/java/com/example/demo/TestcontainersConfiguration.java b/boot-data-couchbase/src/test/java/com/example/demo/TestcontainersConfiguration.java
new file mode 100644
index 000000000..50f79c500
--- /dev/null
+++ b/boot-data-couchbase/src/test/java/com/example/demo/TestcontainersConfiguration.java
@@ -0,0 +1,30 @@
+package com.example.demo;
+
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.context.annotation.Bean;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.couchbase.BucketDefinition;
+import org.testcontainers.couchbase.CouchbaseContainer;
+import org.testcontainers.utility.DockerImageName;
+
+import java.time.Duration;
+
+@TestConfiguration(proxyBeanMethods = false)
+public class TestcontainersConfiguration {
+ private static final String COUCHBASE_IMAGE_NAME = "couchbase";
+ private static final String DEFAULT_IMAGE_NAME = "couchbase/server:7";
+ private static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse(COUCHBASE_IMAGE_NAME)
+ .asCompatibleSubstituteFor(DEFAULT_IMAGE_NAME);
+
+ @Bean
+ @ServiceConnection
+ public CouchbaseContainer couchbaseContainer() {
+ return new CouchbaseContainer(DEFAULT_IMAGE)
+ .withCredentials("Administrator", "password")
+ .withBucket(new BucketDefinition("demo").withPrimaryIndex(true))
+ .withStartupAttempts(5)
+ .withStartupTimeout(Duration.ofSeconds(120))
+ .waitingFor(Wait.forHealthcheck());
+ }
+}
diff --git a/session-data-mongo/nbactions.xml b/session-data-mongo/nbactions.xml
deleted file mode 100644
index 616e0d02f..000000000
--- a/session-data-mongo/nbactions.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.example.demo.Application
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
diff --git a/session-data-mongo/pom.xml b/session-data-mongo/pom.xml
index 97766bbbd..641725038 100644
--- a/session-data-mongo/pom.xml
+++ b/session-data-mongo/pom.xml
@@ -126,13 +126,16 @@
assertj-core
test
+
org.seleniumhq.selenium
htmlunit-driver
+ 4.13.0
test
+
- net.sourceforge.htmlunit
+ org.htmlunit
htmlunit
test
diff --git a/session-data-redis/nbactions.xml b/session-data-redis/nbactions.xml
deleted file mode 100644
index 616e0d02f..000000000
--- a/session-data-redis/nbactions.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.example.demo.Application
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
diff --git a/session-data-redis/pom.xml b/session-data-redis/pom.xml
index 11678e817..58a96b950 100644
--- a/session-data-redis/pom.xml
+++ b/session-data-redis/pom.xml
@@ -129,13 +129,16 @@
assertj-core
test
+
org.seleniumhq.selenium
htmlunit-driver
+ 4.13.0
test
+
- net.sourceforge.htmlunit
+ org.htmlunit
htmlunit
test
diff --git a/session/nbactions.xml b/session/nbactions.xml
deleted file mode 100644
index 616e0d02f..000000000
--- a/session/nbactions.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.example.demo.Application
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.demo.Application
- java
-
-
-
diff --git a/session/pom.xml b/session/pom.xml
index 45c4cfa88..d8f33cfdd 100644
--- a/session/pom.xml
+++ b/session/pom.xml
@@ -116,13 +116,15 @@
assertj-core
test
+
org.seleniumhq.selenium
htmlunit-driver
- test
+ 4.13.0
+
- net.sourceforge.htmlunit
+ org.htmlunit
htmlunit
test