Search in sources :

Example 11 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class EventBusOptions method toJson.

/**
   * Builds a JSON object representing the current {@link EventBusOptions}.
   *
   * @return the JSON representation
   */
public JsonObject toJson() {
    JsonObject json = new JsonObject();
    EventBusOptionsConverter.toJson(this, json);
    return json;
}
Also used : JsonObject(io.vertx.core.json.JsonObject)

Example 12 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class ClusteredEventBus method start.

@Override
public void start(Handler<AsyncResult<Void>> resultHandler) {
    clusterManager.<String, ClusterNodeInfo>getAsyncMultiMap(SUBS_MAP_NAME, ar2 -> {
        if (ar2.succeeded()) {
            subs = ar2.result();
            server = vertx.createNetServer(getServerOptions());
            server.connectHandler(getServerHandler());
            server.listen(asyncResult -> {
                if (asyncResult.succeeded()) {
                    int serverPort = getClusterPublicPort(options, server.actualPort());
                    String serverHost = getClusterPublicHost(options);
                    serverID = new ServerID(serverPort, serverHost);
                    nodeInfo = new ClusterNodeInfo(clusterManager.getNodeID(), serverID);
                    haManager.addDataToAHAInfo(SERVER_ID_HA_KEY, new JsonObject().put("host", serverID.host).put("port", serverID.port));
                    if (resultHandler != null) {
                        started = true;
                        resultHandler.handle(Future.succeededFuture());
                    }
                } else {
                    if (resultHandler != null) {
                        resultHandler.handle(Future.failedFuture(asyncResult.cause()));
                    } else {
                        log.error(asyncResult.cause());
                    }
                }
            });
        } else {
            if (resultHandler != null) {
                resultHandler.handle(Future.failedFuture(ar2.cause()));
            } else {
                log.error(ar2.cause());
            }
        }
    });
}
Also used : ServerID(io.vertx.core.net.impl.ServerID) JsonObject(io.vertx.core.json.JsonObject)

Example 13 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class EventBusTestBase method testSendJsonObject.

@Test
public void testSendJsonObject() {
    JsonObject obj = new JsonObject();
    obj.put(TestUtils.randomUnicodeString(100), TestUtils.randomUnicodeString(100)).put(TestUtils.randomUnicodeString(100), TestUtils.randomInt());
    testSend(obj, (received) -> {
        assertEquals(obj, received);
        // Make sure it's copied
        assertFalse(obj == received);
    });
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 14 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class EventBusTestBase method testPublishJsonObject.

@Test
public void testPublishJsonObject() {
    JsonObject obj = new JsonObject();
    obj.put(TestUtils.randomUnicodeString(100), TestUtils.randomUnicodeString(100)).put(TestUtils.randomUnicodeString(100), TestUtils.randomInt());
    testPublish(obj, (received) -> {
        assertEquals(obj, received);
        // Make sure it's copied
        assertFalse(obj == received);
    });
}
Also used : JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 15 with JsonObject

use of io.vertx.core.json.JsonObject in project vert.x by eclipse.

the class FileSystemTest method testDefaultOptionOptions.

@Test
public void testDefaultOptionOptions() {
    OpenOptions def = new OpenOptions();
    OpenOptions json = new OpenOptions(new JsonObject());
    assertEquals(def.getPerms(), json.getPerms());
    assertEquals(def.isRead(), json.isRead());
    assertEquals(def.isWrite(), json.isWrite());
    assertEquals(def.isCreate(), json.isCreate());
    assertEquals(def.isCreateNew(), json.isCreateNew());
    assertEquals(def.isDeleteOnClose(), json.isDeleteOnClose());
    assertEquals(def.isTruncateExisting(), json.isTruncateExisting());
    assertEquals(def.isSparse(), json.isSparse());
    assertEquals(def.isSync(), json.isSync());
    assertEquals(def.isDsync(), json.isDsync());
}
Also used : OpenOptions(io.vertx.core.file.OpenOptions) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)185 Test (org.junit.Test)136 JsonArray (io.vertx.core.json.JsonArray)44 ArrayList (java.util.ArrayList)11 DeploymentOptions (io.vertx.core.DeploymentOptions)8 HashMap (java.util.HashMap)8 Launcher (io.vertx.core.Launcher)7 Buffer (io.vertx.core.buffer.Buffer)7 IOException (java.io.IOException)7 Instant (java.time.Instant)7 AsciiString (io.netty.util.AsciiString)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Message (io.vertx.core.eventbus.Message)4 File (java.io.File)4 Random (java.util.Random)4 AbstractVerticle (io.vertx.core.AbstractVerticle)3 Vertx (io.vertx.core.Vertx)3 VertxOptions (io.vertx.core.VertxOptions)3 VertxInternal (io.vertx.core.impl.VertxInternal)3 DecodeException (io.vertx.core.json.DecodeException)3