This project requires Java and docker to be available.
./gradlew test
To run tests.
First have a look at DirectCouchbaseTest which configures couchbase client manually. Couchbase SDK went through complete rewrite betwee 2.x and 3.x branches, hence don't use the old one as migration can be painful.
This class extends a AbstractCouchbaseTest which setup a whole instance of Couchbase running inside docker image. It is using https://www.testcontainers.org/ but I am not reusing existing Couchbase image as it clashed with Micronaut and/or new SDK. It creates an instance with values hardcoded in initCluster.sh.
In this case the setup of Couchbase is done more in Micronaut-way, but still using custom defined classes.
Eventually you can simply inject Couchbase Collection like it is done in MicronautCouchbaseTest
Couchbase components are provided for injection in CouchbaseFactory, which is normal Micronaut dependency injection.
Configuration is provided through static and immutable way using CouchbaseConfiguration interface. This interface takes properties according to Micronaut convetion mapping from multiple sources.
In this example those are 4 different sources:
couchbase.username
- provided explicitly using @Property annotation on the test classcouchbase.password
- provided by explicitly by point to config filecouchbase.host
- default value defined on CouchbaseConfigurationcouchbase.default-bucket-name
- provided automatically by env specific properties file: application-test.yaml
File sources can be defined using yaml, json or .property format. See Micronaut propertySource for details.