GH-90 - Upgrade to Flapdoodle MongoDB 4.3.2 (Boot 3 compatible).
Allows us to get rid of the custom MongoDB infrastructure test configuration.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -38,7 +38,7 @@
|
||||
|
||||
<archunit.version>1.0.0</archunit.version>
|
||||
<artifactory-maven-plugin.version>3.5.1</artifactory-maven-plugin.version>
|
||||
<flapdoodle-mongodb.version>3.5.0</flapdoodle-mongodb.version>
|
||||
<flapdoodle-mongodb.version>4.3.2</flapdoodle-mongodb.version>
|
||||
<jmolecules-bom.version>2022.2.2</jmolecules-bom.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
|
||||
<version>${flapdoodle-mongodb.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.modulith.testapp.TestApplication;
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@SpringBootTest(classes = TestApplication.class)
|
||||
class MongoDbEventPublicationAutoConfigurationIntegrationTests extends WithEmbeddedMongoDb {
|
||||
class MongoDbEventPublicationAutoConfigurationIntegrationTests {
|
||||
|
||||
@Autowired ApplicationContext context;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
*/
|
||||
@DataMongoTest
|
||||
@ContextConfiguration(classes = TestApplication.class)
|
||||
class MongoDbEventPublicationRepositoryTest extends WithEmbeddedMongoDb {
|
||||
class MongoDbEventPublicationRepositoryTest {
|
||||
|
||||
private static final PublicationTargetIdentifier TARGET_IDENTIFIER = PublicationTargetIdentifier.of("listener");
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.modulith.events.mongodb;
|
||||
|
||||
import de.flapdoodle.embed.mongo.MongodProcess;
|
||||
import de.flapdoodle.embed.mongo.MongodStarter;
|
||||
import de.flapdoodle.embed.mongo.config.ImmutableMongodConfig;
|
||||
import de.flapdoodle.embed.mongo.config.MongodConfig;
|
||||
import de.flapdoodle.embed.mongo.config.Net;
|
||||
import de.flapdoodle.embed.mongo.distribution.Version;
|
||||
import de.flapdoodle.embed.process.runtime.Network;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
|
||||
/**
|
||||
* Setup of embedded MongoDB as Spring beans so that it will properly bound to and shut down with an
|
||||
* {@link ApplicationContext}.
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@ContextConfiguration(classes = WithEmbeddedMongoDb.TestConfiguration.class)
|
||||
abstract class WithEmbeddedMongoDb {
|
||||
|
||||
@Configuration
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
Net mongoDbConfig() throws Exception {
|
||||
return new Net("localhost", Network.freeServerPort(Network.getLocalHost()), false);
|
||||
}
|
||||
|
||||
@Bean(destroyMethod = "stop")
|
||||
MongodProcess mongoDbProcess(Net config) throws Exception {
|
||||
|
||||
ImmutableMongodConfig mongodConfig = MongodConfig.builder()
|
||||
.version(Version.Main.PRODUCTION)
|
||||
.net(config)
|
||||
.build();
|
||||
|
||||
return MongodStarter.getDefaultInstance()
|
||||
.prepare(mongodConfig)
|
||||
.start();
|
||||
}
|
||||
|
||||
@Bean
|
||||
// Artificially depend on MongodProcess so that it will not shut down prior
|
||||
// to the repository -> template -> client -> process shutdown chain
|
||||
MongoClient mongoDbClient(Net config, MongodProcess process) {
|
||||
return MongoClients.create("mongodb://" + config.getBindIp() + ":" + config.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Flapdoodle
|
||||
de.flapdoodle.mongodb.embedded.version=6.0.3
|
||||
logging.level.de.flapdoodle.embed.mongo=WARN
|
||||
Reference in New Issue
Block a user