Class WithEmbeddedMongo

java.lang.Object
fr.ght1pc9kc.testy.mongo.WithEmbeddedMongo
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver

public class WithEmbeddedMongo extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.ParameterResolver
Allow to launch en Embedded Mongo DB

The flapdoodle download the expected version of Mongo DB in ~/.embedmongo and run a database for the test.

From this database, an async MongoClient is created and a Spring ReactiveMongoDatabaseFactory wrap it.

See Also:
  • Field Details

  • Constructor Details

    • WithEmbeddedMongo

      public WithEmbeddedMongo()
  • Method Details

    • getMongoFactory

      public org.springframework.data.mongodb.ReactiveMongoDatabaseFactory getMongoFactory()
      Retrieve the latest initialized Factory. Avoid to require ExtensionContext and allow SpringBoot mock.

      If possible, prefer inject ReactiveMongoDatabaseFactory in test method instead.

      Returns:
      the ReactiveMongoDatabaseFactory created in the beforeAll.
    • getMongoTemplate

      public org.springframework.data.mongodb.core.ReactiveMongoTemplate getMongoTemplate(org.junit.jupiter.api.extension.ExtensionContext context)
    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws IOException
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      Throws:
      IOException
    • afterAll

      public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
    • supportsParameter

      public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Specified by:
      supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
    • resolveParameter

      public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Specified by:
      resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
    • builder