use of io.vertx.core.net.NetSocket in project vertx-tcp-eventbus-bridge by vert-x3.
the class TcpEventBusBridgeTest method testSendsFromOtherSideOfBridge.
@Test
public void testSendsFromOtherSideOfBridge(TestContext context) {
NetClient client = vertx.createNetClient();
final Async async = context.async();
client.connect(7000, "localhost", conn -> {
context.assertFalse(conn.failed());
NetSocket socket = conn.result();
final FrameParser parser = new FrameParser(parse -> {
context.assertTrue(parse.succeeded());
JsonObject frame = parse.result();
context.assertNotEquals("err", frame.getString("type"));
context.assertEquals(true, frame.getBoolean("send"));
context.assertEquals("hi", frame.getJsonObject("body").getString("value"));
client.close();
async.complete();
});
socket.handler(parser);
FrameHelper.sendFrame("register", "ping", null, socket);
});
}
use of io.vertx.core.net.NetSocket in project vertx-tcp-eventbus-bridge by vert-x3.
the class TcpEventBusBridgeTest method testSendMessageWithReplyBacktrack.
@Test
public void testSendMessageWithReplyBacktrack(TestContext context) {
// Send a request and get a response
NetClient client = vertx.createNetClient();
final Async async = context.async();
client.connect(7000, "localhost", conn -> {
context.assertFalse(conn.failed());
NetSocket socket = conn.result();
final FrameParser parser = new FrameParser(parse -> {
context.assertTrue(parse.succeeded());
JsonObject frame = parse.result();
context.assertNotEquals("err", frame.getString("type"));
context.assertEquals(true, frame.getBoolean("send"));
context.assertEquals("Hello vert.x", frame.getJsonObject("body").getString("value"));
client.close();
async.complete();
});
socket.handler(parser);
FrameHelper.sendFrame("send", "hello", "#backtrack", new JsonObject().put("value", "vert.x"), socket);
});
}
use of io.vertx.core.net.NetSocket in project vertx-tcp-eventbus-bridge by vert-x3.
the class TcpEventBusBridgeInteropTest method testSendMessageWithDuplicateReplyID.
@Test
public void testSendMessageWithDuplicateReplyID(TestContext context) {
// replies must always return to the same origin
NetClient client = vertx.createNetClient();
final Async async = context.async();
client.connect(7000, "localhost", conn -> {
context.assertFalse(conn.failed());
NetSocket socket = conn.result();
vertx.eventBus().consumer("third-party-receiver", msg -> context.fail());
final FrameParser parser = new FrameParser(parse -> {
context.assertTrue(parse.succeeded());
client.close();
async.complete();
});
socket.handler(parser);
FrameHelper.sendFrame("send", "hello", "third-party-receiver", new JsonObject().put("value", "vert.x"), socket);
});
}
Aggregations