Interface MongoDbClassExtension
-
- All Superinterfaces:
org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.Extension
,MongoDb
- All Known Implementing Classes:
StartLocalMongoDbClassExtension
,UseExistingMongoDbClassExtension
public interface MongoDbClassExtension extends MongoDb, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback
JUnit 5 Extension for running a MongoDB instance alongside the (integration) tests. Can be configured with custom user credentials and database name. UseMongoDb.getHosts()
to retrieve the host to connect to.Example usage:
@RegisterExtension @Order(0) static final MongoDbClassExtension MONGO_DB_EXTENSION = MongoDbClassExtension .builder() .withDatabase("my_db") .withUsername("my_user") .withPassword("my_s3cr3t") .build();
Normally a MongoDb is started on demand. For connecting to an already running MongoDb set the environment variable
TEST_MONGODB_CONNECTION_STRING
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
MongoDbClassExtension.Builder
-
Field Summary
-
Fields inherited from interface org.sdase.commons.server.mongo.testing.MongoDb
OVERRIDE_MONGODB_CONNECTION_STRING_SYSTEM_PROPERTY_NAME
-
-
Method Summary
Static Methods Modifier and Type Method Description static MongoDbClassExtension.Builder
builder()
-
Methods inherited from interface org.sdase.commons.server.mongo.testing.MongoDb
clearCollections, clearDatabase, createClient, getConnectionString, getDatabase, getHosts, getOptions, getPassword, getServerVersion, getUsername
-
-
-
-
Method Detail
-
builder
static MongoDbClassExtension.Builder builder()
-
-