Last active
August 29, 2015 14:22
-
-
Save patrykorwat/b5a0ac1e797c082c6b3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.vertx.core.DeploymentOptions; | |
import io.vertx.core.json.JsonArray; | |
import io.vertx.core.json.JsonObject; | |
import io.vertx.rxjava.core.Vertx; | |
import io.vertx.rxjava.ext.mongo.MongoService; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
public class MongoCommandProblemTest { | |
private static final String MONGO_SERVICE_ADDRESS = "vertx.mongo"; | |
private Vertx vertx; | |
@Before | |
public void setUp() throws Exception { | |
vertx = Vertx.vertx(); | |
vertx.deployVerticleObservable("service:io.vertx.vertx-mongo-embedded-db").toBlocking().last(); | |
JsonObject config = new JsonObject() | |
.put("address", MONGO_SERVICE_ADDRESS) | |
.put("connection_string", "mongodb://localhost:27018") | |
.put("db_name", "test"); | |
DeploymentOptions deploymentOptions = new DeploymentOptions(); | |
deploymentOptions.setConfig(config); | |
vertx.deployVerticleObservable("service:io.vertx.mongo-service", deploymentOptions).toBlocking().last(); | |
} | |
@Test | |
public void testMongoServiceClient() throws Exception { | |
MongoService mongoService = MongoService.createEventBusProxy(vertx, MONGO_SERVICE_ADDRESS); | |
JsonObject command = new JsonObject() | |
.put("aggregate", "collection_name") | |
.put("pipeline", new JsonArray()); | |
mongoService.runCommandObservable(command).toBlocking().last(); | |
} | |
@After | |
public void tearDown() throws Exception { | |
vertx.closeObservable().toBlocking().last(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>sth.vertx</groupId> | |
<artifactId>mongo-command-problem</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<vertx.version>3.0.0-milestone5</vertx.version> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>io.vertx</groupId> | |
<artifactId>vertx-mongo-embedded-db</artifactId> | |
<version>${vertx.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>io.vertx</groupId> | |
<artifactId>vertx-mongo-service</artifactId> | |
<version>${vertx.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>io.vertx</groupId> | |
<artifactId>vertx-rx-java</artifactId> | |
<version>${vertx.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.12</version> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment