1717package org .springframework .boot .autoconfigure .couchbase ;
1818
1919import java .time .Duration ;
20+ import java .util .Collections ;
21+ import java .util .List ;
2022
2123import com .couchbase .client .java .Bucket ;
2224import com .couchbase .client .java .Cluster ;
2325import com .couchbase .client .java .CouchbaseBucket ;
2426import com .couchbase .client .java .bucket .BucketType ;
27+ import com .couchbase .client .java .cluster .BucketSettings ;
2528import com .couchbase .client .java .cluster .ClusterInfo ;
2629import com .couchbase .client .java .cluster .DefaultBucketSettings ;
30+ import com .couchbase .client .java .cluster .UserRole ;
31+ import com .couchbase .client .java .cluster .UserSettings ;
2732import com .couchbase .client .java .env .CouchbaseEnvironment ;
2833import org .junit .jupiter .api .AfterEach ;
34+ import org .junit .jupiter .api .BeforeAll ;
2935import org .junit .jupiter .api .BeforeEach ;
3036import org .junit .jupiter .api .Test ;
3137import org .testcontainers .couchbase .CouchbaseContainer ;
@@ -51,12 +57,19 @@ class CouchbaseAutoConfigurationIntegrationTests {
5157
5258 @ Container
5359 static final CouchbaseContainer couchbase = new CouchbaseContainer ().withClusterAdmin ("spring" , "password" )
54- .withNewBucket (DefaultBucketSettings .builder ().enableFlush (true ).name ("default" ).password ("secret" )
55- .quota (100 ).replicas (0 ).type (BucketType .COUCHBASE ).build ())
5660 .withStartupAttempts (5 ).withStartupTimeout (Duration .ofMinutes (10 ));
5761
5862 private AnnotationConfigApplicationContext context ;
5963
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+
6073 @ BeforeEach
6174 void setUp () {
6275 this .context = new AnnotationConfigApplicationContext ();
0 commit comments