Search in sources :

Example 1 with TestLoggerFactory

use of io.vertx.test.netty.TestLoggerFactory in project vert.x by eclipse.

the class NetTest method testServerLogging.

@Test
public void testServerLogging() throws Exception {
    server.close();
    server = vertx.createNetServer(new NetServerOptions().setLogActivity(true));
    TestLoggerFactory factory = testLogging();
    assertTrue(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
Also used : TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Test(org.junit.Test)

Example 2 with TestLoggerFactory

use of io.vertx.test.netty.TestLoggerFactory in project vert.x by eclipse.

the class NetTest method testNoLogging.

@Test
public void testNoLogging() throws Exception {
    TestLoggerFactory factory = testLogging();
    assertFalse(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
Also used : TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Test(org.junit.Test)

Example 3 with TestLoggerFactory

use of io.vertx.test.netty.TestLoggerFactory in project vert.x by eclipse.

the class DatagramTest method testNoLogging.

@Test
public void testNoLogging() throws Exception {
    TestLoggerFactory factory = testLogging(new DatagramSocketOptions(), new DatagramSocketOptions());
    assertFalse(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Test(org.junit.Test)

Example 4 with TestLoggerFactory

use of io.vertx.test.netty.TestLoggerFactory in project vert.x by eclipse.

the class DatagramTest method testLogging.

private TestLoggerFactory testLogging(DatagramSocketOptions sendOptions, DatagramSocketOptions listenOptions) throws Exception {
    InternalLoggerFactory prev = InternalLoggerFactory.getDefaultFactory();
    TestLoggerFactory factory = new TestLoggerFactory();
    InternalLoggerFactory.setDefaultFactory(factory);
    try {
        peer1 = vertx.createDatagramSocket(sendOptions);
        peer2 = vertx.createDatagramSocket(listenOptions);
        peer2.exceptionHandler(t -> fail(t.getMessage()));
        peer2.listen(1234, "127.0.0.1", ar -> {
            assertTrue(ar.succeeded());
            Buffer buffer = TestUtils.randomBuffer(128);
            peer2.handler(packet -> {
                assertEquals(buffer, packet.data());
                testComplete();
            });
            peer1.send(buffer, 1234, "127.0.0.1", ar2 -> assertTrue(ar2.succeeded()));
        });
        await();
    } finally {
        InternalLoggerFactory.setDefaultFactory(prev);
    }
    return factory;
}
Also used : Buffer(io.vertx.core.buffer.Buffer) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) InternalLoggerFactory(io.netty.util.internal.logging.InternalLoggerFactory)

Example 5 with TestLoggerFactory

use of io.vertx.test.netty.TestLoggerFactory in project vert.x by eclipse.

the class DatagramTest method testListenLogging.

@Test
public void testListenLogging() throws Exception {
    TestLoggerFactory factory = testLogging(new DatagramSocketOptions(), new DatagramSocketOptions().setLogActivity(true));
    assertTrue(factory.hasName("io.netty.handler.logging.LoggingHandler"));
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) Test(org.junit.Test)

Aggregations

TestLoggerFactory (io.vertx.test.netty.TestLoggerFactory)24 Test (org.junit.Test)21 InternalLoggerFactory (io.netty.util.internal.logging.InternalLoggerFactory)4 DatagramSocketOptions (io.vertx.core.datagram.DatagramSocketOptions)3 Buffer (io.vertx.core.buffer.Buffer)2 DnsClientOptions (io.vertx.core.dns.DnsClientOptions)2 io.vertx.core (io.vertx.core)1 Message (io.vertx.core.eventbus.Message)1 MessageConsumer (io.vertx.core.eventbus.MessageConsumer)1 ClientAuth (io.vertx.core.http.ClientAuth)1 io.vertx.core.impl (io.vertx.core.impl)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 Logger (io.vertx.core.logging.Logger)1 LoggerFactory (io.vertx.core.logging.LoggerFactory)1 io.vertx.core.net (io.vertx.core.net)1 SocketAddressImpl (io.vertx.core.net.impl.SocketAddressImpl)1 ReadStream (io.vertx.core.streams.ReadStream)1 TestUtils.assertIllegalArgumentException (io.vertx.test.core.TestUtils.assertIllegalArgumentException)1 TestUtils.assertNullPointerException (io.vertx.test.core.TestUtils.assertNullPointerException)1