I have a service in which I need to implement functional tests(Cucumber) which makes some rest call.
Now earlier in my previous spring projects I had used fongo but I guess its not working with Vert.x
Now for my cucumber tests, how do I implement the fake mongo/embedded mongo or is their a another library all together. I also tried vertx-embedded-mongo-db but there it lacks good documentation.
I had a similar requirement and I achieved it by using vertx-embedded-mongodb
What I did is started vertx-embedded-mongodb
vertical and then I started my verticle which listens to mongo port 27018
.
DeploymentOptions embeddedMongoOptions = new DeploymentOptions()
.setWorker(true)
.setConfig(new JsonObject().put("port", 27018).put("version", "3.4.3"));
vertx.rxDeployVerticle(EmbeddedMongoVerticle.class.getName(), embeddedMongoOptions)
.map(id -> {
return new DeploymentOptions()
.setWorker(true)
.setConfig(myApplicationCongig);
})
.flatMap(options -> vertx.rxDeployVerticle(MyApp.class.getName(), options))
.subscribe();
Just make sure that your applications mongo is configured to listen 27018 instead of 27017 for test env.
Also above solution is only for Vert.x 3.x.x
. vertx-embedded-mongodb
is no longer supported for 4.x.x
.