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;
}
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());
}
}
});
}
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);
});
}
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);
});
}
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());
}
Aggregations