Skip to content

Instantly share code, notes, and snippets.

@henesgokdag
Created July 29, 2022 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henesgokdag/bb9112393fe5a61d949bdd1f513e1ad8 to your computer and use it in GitHub Desktop.
Save henesgokdag/bb9112393fe5a61d949bdd1f513e1ad8 to your computer and use it in GitHub Desktop.
CouchbaseTestContainer
@Testcontainers
@ActiveProfiles("container")
@SpringBootTest
public class CouchbaseTestContainer {
private static final DockerImageName COUCHBASE_IMAGE_ENTERPRISE = DockerImageName.parse("couchbase:enterprise")
.asCompatibleSubstituteFor("couchbase/server")
.withTag("7.1.0");
@ClassRule
public final static CouchbaseContainer container = new CouchbaseContainer(COUCHBASE_IMAGE_ENTERPRISE)
.withBucket(new BucketDefinition("Message"))
.withCredentials("enes","enesenes")
.withStartupTimeout(Duration.ofSeconds(90))
.waitingFor(Wait.defaultWaitStrategy());
@BeforeClass
public static void beforeClass(){ container.start();}
@DynamicPropertySource
static void bindCouchbaseProperties(DynamicPropertyRegistry registry){
container.start();
await().until(container::isRunning);
registry.add("spring.couchbase.host",container::getConnectionString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment