|
17 | 17 | package org.springframework.boot.autoconfigure.couchbase; |
18 | 18 |
|
19 | 19 | import java.time.Duration; |
20 | | -import java.util.Collections; |
21 | | -import java.util.List; |
22 | 20 |
|
23 | 21 | import com.couchbase.client.java.Bucket; |
24 | 22 | import com.couchbase.client.java.Cluster; |
25 | 23 | import com.couchbase.client.java.CouchbaseBucket; |
26 | | -import com.couchbase.client.java.bucket.BucketType; |
27 | | -import com.couchbase.client.java.cluster.BucketSettings; |
28 | 24 | import com.couchbase.client.java.cluster.ClusterInfo; |
29 | | -import com.couchbase.client.java.cluster.DefaultBucketSettings; |
30 | | -import com.couchbase.client.java.cluster.UserRole; |
31 | | -import com.couchbase.client.java.cluster.UserSettings; |
32 | 25 | import com.couchbase.client.java.env.CouchbaseEnvironment; |
33 | 26 | import org.junit.jupiter.api.AfterEach; |
34 | | -import org.junit.jupiter.api.BeforeAll; |
35 | 27 | import org.junit.jupiter.api.BeforeEach; |
36 | 28 | import org.junit.jupiter.api.Test; |
| 29 | +import org.testcontainers.couchbase.BucketDefinition; |
37 | 30 | import org.testcontainers.couchbase.CouchbaseContainer; |
38 | 31 | import org.testcontainers.junit.jupiter.Container; |
39 | 32 | import org.testcontainers.junit.jupiter.Testcontainers; |
|
55 | 48 | @Testcontainers(disabledWithoutDocker = true) |
56 | 49 | class CouchbaseAutoConfigurationIntegrationTests { |
57 | 50 |
|
| 51 | + private static final String BUCKET_NAME = "cbbucket"; |
| 52 | + |
58 | 53 | @Container |
59 | | - static final CouchbaseContainer couchbase = new CouchbaseContainer().withClusterAdmin("spring", "password") |
60 | | - .withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10)); |
| 54 | + static final CouchbaseContainer couchbase = new CouchbaseContainer().withCredentials("spring", "password") |
| 55 | + .withStartupAttempts(5).withStartupTimeout(Duration.ofMinutes(10)) |
| 56 | + .withBucket(new BucketDefinition(BUCKET_NAME).withPrimaryIndex(false)); |
61 | 57 |
|
62 | 58 | private AnnotationConfigApplicationContext context; |
63 | 59 |
|
64 | | - @BeforeAll |
65 | | - static void createBucket() { |
66 | | - BucketSettings bucketSettings = DefaultBucketSettings.builder().enableFlush(true).name("default") |
67 | | - .password("password").quota(100).replicas(0).type(BucketType.COUCHBASE).build(); |
68 | | - List<UserRole> userSettings = Collections.singletonList(new UserRole("admin")); |
69 | | - couchbase.createBucket(bucketSettings, |
70 | | - UserSettings.build().password(bucketSettings.password()).roles(userSettings), true); |
71 | | - } |
72 | | - |
73 | 60 | @BeforeEach |
74 | 61 | void setUp() { |
75 | 62 | this.context = new AnnotationConfigApplicationContext(); |
76 | 63 | this.context.register(CouchbaseAutoConfiguration.class); |
77 | 64 | TestPropertyValues.of("spring.couchbase.bootstrap-hosts=" + couchbase.getContainerIpAddress(), |
78 | 65 | "spring.couchbase.env.bootstrap.http-direct-port:" + couchbase.getMappedPort(8091), |
79 | 66 | "spring.couchbase.username:spring", "spring.couchbase.password:password", |
80 | | - "spring.couchbase.bucket.name:default").applyTo(this.context.getEnvironment()); |
| 67 | + "spring.couchbase.bucket.name:" + BUCKET_NAME).applyTo(this.context.getEnvironment()); |
81 | 68 | } |
82 | 69 |
|
83 | 70 | @AfterEach |
|
0 commit comments