Search in sources :

Example 1 with DefaultNodeSelector

use of io.vertx.core.spi.cluster.impl.DefaultNodeSelector in project vert.x by eclipse.

the class WriteHandlerLookupFailureTest method test.

@Test
public void test() {
    Throwable cause = new Throwable();
    VertxOptions options = new VertxOptions();
    options.getEventBusOptions().setHost("localhost").setPort(0);
    NodeSelector nodeSelector = new DefaultNodeSelector() {

        @Override
        public void selectForSend(Message<?> message, Promise<String> promise) {
            promise.fail(cause);
        }

        @Override
        public void selectForPublish(Message<?> message, Promise<Iterable<String>> promise) {
            promise.fail("Not implemented");
        }
    };
    new VertxBuilder(options).init().clusterNodeSelector(nodeSelector).clusteredVertx(onSuccess(node -> {
        vertx = node;
        MessageProducer<String> sender = vertx.eventBus().sender("foo");
        sender.write("the_string", onFailure(err -> {
            assertSame(cause, err);
            testComplete();
        }));
    }));
    await();
}
Also used : NodeSelector(io.vertx.core.spi.cluster.NodeSelector) DefaultNodeSelector(io.vertx.core.spi.cluster.impl.DefaultNodeSelector) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) VertxBuilder(io.vertx.core.impl.VertxBuilder) Test(org.junit.Test) VertxTestBase(io.vertx.test.core.VertxTestBase) Collections(java.util.Collections) Promise(io.vertx.core.Promise) DefaultNodeSelector(io.vertx.core.spi.cluster.impl.DefaultNodeSelector) NodeSelector(io.vertx.core.spi.cluster.NodeSelector) DefaultNodeSelector(io.vertx.core.spi.cluster.impl.DefaultNodeSelector) VertxBuilder(io.vertx.core.impl.VertxBuilder) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Aggregations

Promise (io.vertx.core.Promise)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 VertxBuilder (io.vertx.core.impl.VertxBuilder)1 NodeSelector (io.vertx.core.spi.cluster.NodeSelector)1 DefaultNodeSelector (io.vertx.core.spi.cluster.impl.DefaultNodeSelector)1 VertxTestBase (io.vertx.test.core.VertxTestBase)1 Collections (java.util.Collections)1 Test (org.junit.Test)1