Search in sources :

Example 16 with TestLoggerFactory

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

the class NetTest method testLogging.

private TestLoggerFactory testLogging() throws Exception {
    InternalLoggerFactory prev = InternalLoggerFactory.getDefaultFactory();
    TestLoggerFactory factory = new TestLoggerFactory();
    InternalLoggerFactory.setDefaultFactory(factory);
    try {
        server.connectHandler(so -> {
            so.write("fizzbuzz").end();
        });
        server.listen(1234, "localhost", onSuccess(v1 -> {
            client.connect(1234, "localhost", onSuccess(so -> {
                so.closeHandler(v2 -> testComplete());
            }));
        }));
        await();
    } finally {
        InternalLoggerFactory.setDefaultFactory(prev);
    }
    return factory;
}
Also used : java.util(java.util) io.vertx.core(io.vertx.core) io.vertx.core.impl(io.vertx.core.impl) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Cert(io.vertx.test.core.tls.Cert) TestUtils.assertNullPointerException(io.vertx.test.core.TestUtils.assertNullPointerException) AtomicReference(java.util.concurrent.atomic.AtomicReference) LoggerFactory(io.vertx.core.logging.LoggerFactory) InetAddress(java.net.InetAddress) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReadStream(io.vertx.core.streams.ReadStream) OutputStreamWriter(java.io.OutputStreamWriter) JsonObject(io.vertx.core.json.JsonObject) Assume(org.junit.Assume) Logger(io.vertx.core.logging.Logger) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) BufferedWriter(java.io.BufferedWriter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Message(io.vertx.core.eventbus.Message) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test) X509Certificate(javax.security.cert.X509Certificate) io.vertx.core.net(io.vertx.core.net) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) JsonArray(io.vertx.core.json.JsonArray) CountDownLatch(java.util.concurrent.CountDownLatch) Rule(org.junit.Rule) Buffer(io.vertx.core.buffer.Buffer) ClientAuth(io.vertx.core.http.ClientAuth) InternalLoggerFactory(io.netty.util.internal.logging.InternalLoggerFactory) MessageConsumer(io.vertx.core.eventbus.MessageConsumer) SocketAddressImpl(io.vertx.core.net.impl.SocketAddressImpl) TemporaryFolder(org.junit.rules.TemporaryFolder) Trust(io.vertx.test.core.tls.Trust) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException) TestUtils.assertIllegalArgumentException(io.vertx.test.core.TestUtils.assertIllegalArgumentException) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) InternalLoggerFactory(io.netty.util.internal.logging.InternalLoggerFactory)

Example 17 with TestLoggerFactory

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

the class DatagramTest method testSendLogging.

@Test
public void testSendLogging() throws Exception {
    TestLoggerFactory factory = testLogging(new DatagramSocketOptions().setLogActivity(true), new DatagramSocketOptions());
    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)

Example 18 with TestLoggerFactory

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

the class NetTest method testClientLogging.

@Test
public void testClientLogging() throws Exception {
    client.close();
    client = vertx.createNetClient(new NetClientOptions().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 19 with TestLoggerFactory

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

the class TestUtils method testLogging.

public static TestLoggerFactory testLogging(Runnable runnable) {
    InternalLoggerFactory prev = InternalLoggerFactory.getDefaultFactory();
    TestLoggerFactory factory = new TestLoggerFactory();
    InternalLoggerFactory.setDefaultFactory(factory);
    try {
        runnable.run();
    } finally {
        InternalLoggerFactory.setDefaultFactory(prev);
    }
    return factory;
}
Also used : TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) InternalLoggerFactory(io.netty.util.internal.logging.InternalLoggerFactory)

Example 20 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 : 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