Skip to content

Commit

Permalink
Bump up Mongo version
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed Feb 15, 2024
1 parent f54da10 commit 70edb47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
6 changes: 3 additions & 3 deletions transponder-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.10</version>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.11.1</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>3.2.0</version>
<version>4.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,37 @@
import org.junit.BeforeClass;
import org.orienteer.transponder.AbstractUniversalTest;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;

import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
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.mongo.tests.MongodForTestsFactory;
import de.flapdoodle.embed.process.runtime.Network;
import de.flapdoodle.embed.mongo.transitions.Mongod;
import de.flapdoodle.embed.mongo.transitions.MongodStarter;
import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess;
import de.flapdoodle.reverse.TransitionWalker.ReachedState;

public class MongoDBUniversalTest extends AbstractUniversalTest {

private static MongodExecutable mongodExecutable;
private static ReachedState<RunningMongodProcess> running;
private static MongoClient mongo;
private static MongodForTestsFactory mongoFactory;
private static MongoDatabase mongoDb;

@BeforeClass
public static void initMongoDB() throws Exception {
MongodStarter starter = MongodStarter.getDefaultInstance();

int port = Network.freeServerPort(Network.getLocalHost());
MongodConfig mongodConfig = MongodConfig.builder()
.version(Version.Main.PRODUCTION)
.net(new Net(port, Network.localhostIsIPv6()))
.build();

mongodExecutable = starter.prepare(mongodConfig);
MongodProcess mongod = mongodExecutable.start();
mongo = new MongoClient("localhost", port);
mongoFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
mongoDb = mongoFactory.newDatabase(mongo);
running = Mongod.instance().start(Version.Main.V5_0);

mongo = MongoClients.create("mongodb://"+running.current().getServerAddress());

mongoDb = mongo.getDatabase("test-db");
}

@AfterClass
public static void shutdownMongoDB() throws Exception {
if(mongoFactory!=null) mongoFactory.shutdown();
if(mongodExecutable!=null) mongodExecutable.stop();
if(mongoDb!=null) mongoDb.drop();
if(mongo!=null) mongo.close();
if(running!=null) running.close();
}

public MongoDBUniversalTest() {
Expand Down

0 comments on commit 70edb47

Please sign in to comment.