|
34 | 34 |
|
35 | 35 | import com.jcraft.jsch.Channel;
|
36 | 36 | import com.jcraft.jsch.Session;
|
| 37 | +import de.flapdoodle.embed.mongo.MongodExecutable; |
| 38 | +import de.flapdoodle.embed.mongo.MongodStarter; |
| 39 | +import de.flapdoodle.embed.mongo.config.IMongodConfig; |
| 40 | +import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; |
| 41 | +import de.flapdoodle.embed.mongo.config.Net; |
| 42 | +import de.flapdoodle.embed.mongo.distribution.Version; |
| 43 | +import de.flapdoodle.embed.process.runtime.Network; |
37 | 44 | import io.vertx.core.AsyncResult;
|
38 | 45 | import io.vertx.core.DeploymentOptions;
|
39 | 46 | import io.vertx.core.Handler;
|
@@ -171,36 +178,42 @@ public void testDeployServiceWithJDBCAuthOptions(TestContext context) throws Exc
|
171 | 178 |
|
172 | 179 | @Test
|
173 | 180 | public void testDeployServiceWithMongoAuthOptions(TestContext context) throws Exception {
|
174 |
| - Async mongo = context.async(); |
175 |
| - vertx.deployVerticle("service:io.vertx.vertx-mongo-embedded-db", context.asyncAssertSuccess(v -> mongo.complete())); |
176 |
| - mongo.awaitSuccess(120 * 1000); // Enough time for downloading the db |
177 |
| - JsonObject config = new JsonObject().put("connection_string", "mongodb://localhost:27018"); |
178 |
| - MongoClient client = MongoClient.createNonShared(vertx, config); |
179 |
| - MongoAuth auth = MongoAuth.create(client, new JsonObject()); |
180 |
| - Async ready = context.async(); |
181 |
| - auth.insertUser("admin", "password", Collections.emptyList(), Collections.emptyList(), context.asyncAssertSuccess(v -> ready.complete())); |
182 |
| - ready.awaitSuccess(2000); |
183 |
| - Async async = context.async(); |
184 |
| - vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(new JsonObject().put("sshOptions", |
185 |
| - new JsonObject(). |
186 |
| - put("host", "localhost"). |
187 |
| - put("port", 5000). |
188 |
| - put("keyPairOptions", new JsonObject(). |
189 |
| - put("path", "src/test/resources/server-keystore.jks"). |
190 |
| - put("password", "wibble")). |
191 |
| - put("authOptions", new JsonObject().put("provider", "mongo").put("config", |
192 |
| - new JsonObject(). |
193 |
| - put("connection_string", "mongodb://localhost:27018"))))) |
194 |
| - , context.asyncAssertSuccess(v -> { |
195 |
| - async.complete(); |
196 |
| - })); |
197 |
| - async.awaitSuccess(2000); |
198 |
| - Session session = createSession("admin", "password", false); |
199 |
| - session.connect(); |
200 |
| - Channel channel = session.openChannel("shell"); |
201 |
| - channel.connect(); |
202 |
| - channel.disconnect(); |
203 |
| - session.disconnect(); |
| 181 | + MongodExecutable exe = MongodStarter.getDefaultInstance().prepare(new MongodConfigBuilder(). |
| 182 | + version(Version.Main.V3_4). |
| 183 | + net(new Net(27018, Network.localhostIsIPv6())). |
| 184 | + build()); |
| 185 | + exe.start(); |
| 186 | + try { |
| 187 | + JsonObject config = new JsonObject().put("connection_string", "mongodb://localhost:27018"); |
| 188 | + MongoClient client = MongoClient.createNonShared(vertx, config); |
| 189 | + MongoAuth auth = MongoAuth.create(client, new JsonObject()); |
| 190 | + Async ready = context.async(); |
| 191 | + auth.insertUser("admin", "password", Collections.emptyList(), Collections.emptyList(), context.asyncAssertSuccess(v -> ready.complete())); |
| 192 | + ready.awaitSuccess(2000); |
| 193 | + Async async = context.async(); |
| 194 | + vertx.deployVerticle("service:io.vertx.ext.shell", new DeploymentOptions().setConfig(new JsonObject().put("sshOptions", |
| 195 | + new JsonObject(). |
| 196 | + put("host", "localhost"). |
| 197 | + put("port", 5000). |
| 198 | + put("keyPairOptions", new JsonObject(). |
| 199 | + put("path", "src/test/resources/server-keystore.jks"). |
| 200 | + put("password", "wibble")). |
| 201 | + put("authOptions", new JsonObject().put("provider", "mongo").put("config", |
| 202 | + new JsonObject(). |
| 203 | + put("connection_string", "mongodb://localhost:27018"))))) |
| 204 | + , context.asyncAssertSuccess(v -> { |
| 205 | + async.complete(); |
| 206 | + })); |
| 207 | + async.awaitSuccess(2000); |
| 208 | + Session session = createSession("admin", "password", false); |
| 209 | + session.connect(); |
| 210 | + Channel channel = session.openChannel("shell"); |
| 211 | + channel.connect(); |
| 212 | + channel.disconnect(); |
| 213 | + session.disconnect(); |
| 214 | + } finally { |
| 215 | + exe.stop(); |
| 216 | + } |
204 | 217 | }
|
205 | 218 |
|
206 | 219 | @Override
|
|
0 commit comments