Search in sources :

Example 1 with Repeat

use of io.vertx.test.core.Repeat in project vert.x by eclipse.

the class VertxTest method testWorkerExecutorConcurrentCloseWithVertx.

@Repeat(times = 100)
@Test
public void testWorkerExecutorConcurrentCloseWithVertx() throws InterruptedException {
    Vertx vertx = Vertx.vertx();
    try {
        CountDownLatch latch = new CountDownLatch(1);
        WorkerExecutor workerExecutor = vertx.createSharedWorkerExecutor("test");
        vertx.runOnContext(v -> {
            latch.countDown();
            workerExecutor.close();
        });
        latch.await();
    } finally {
        vertx.close();
    }
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test) Repeat(io.vertx.test.core.Repeat)

Example 2 with Repeat

use of io.vertx.test.core.Repeat in project vert.x by eclipse.

the class Http1xTest method testCloseServerConnectionWithPendingMessages.

@Test
@Repeat(times = 10)
public void testCloseServerConnectionWithPendingMessages() throws Exception {
    int n = 5;
    server.requestHandler(req -> {
        vertx.setTimer(100, id -> {
            req.response().close();
        });
    });
    startServer(testAddress);
    client.close();
    client = vertx.createHttpClient(createBaseClientOptions().setMaxPoolSize(n).setPipelining(true));
    AtomicBoolean completed = new AtomicBoolean();
    client.connectionHandler(conn -> {
        conn.closeHandler(v -> {
            if (completed.compareAndSet(false, true)) {
                testComplete();
            }
        });
    });
    for (int i = 0; i < n * 2; i++) {
        client.request(requestOptions).compose(HttpClientRequest::send).onComplete(onFailure(resp -> {
        }));
    }
    await();
}
Also used : HttpServerImpl(io.vertx.core.http.impl.HttpServerImpl) IntStream(java.util.stream.IntStream) java.util(java.util) io.vertx.core(io.vertx.core) ContextInternal(io.vertx.core.impl.ContextInternal) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Http1xOrH2CHandler(io.vertx.core.http.impl.Http1xOrH2CHandler) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) SimpleServer(io.vertx.test.verticles.SimpleServer) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WriteStream(io.vertx.core.streams.WriteStream) BiConsumer(java.util.function.BiConsumer) RecordParser(io.vertx.core.parsetools.RecordParser) JsonObject(io.vertx.core.json.JsonObject) Assume(org.junit.Assume) CheckingSender(io.vertx.test.core.CheckingSender) VertxInternal(io.vertx.core.impl.VertxInternal) Http1xUpgradeToH2CHandler(io.vertx.core.http.impl.Http1xUpgradeToH2CHandler) ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) java.util.concurrent(java.util.concurrent) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) Test(org.junit.Test) Http1xServerConnection(io.vertx.core.http.impl.Http1xServerConnection) EventLoop(io.netty.channel.EventLoop) Future(io.vertx.core.Future) io.vertx.core.net(io.vertx.core.net) Collectors(java.util.stream.Collectors) File(java.io.File) LongConsumer(java.util.function.LongConsumer) Channel(io.netty.channel.Channel) Consumer(java.util.function.Consumer) EventLoopContext(io.vertx.core.impl.EventLoopContext) JsonArray(io.vertx.core.json.JsonArray) Repeat(io.vertx.test.core.Repeat) Stream(java.util.stream.Stream) Buffer(io.vertx.core.buffer.Buffer) HttpUtils(io.vertx.core.http.impl.HttpUtils) Cert(io.vertx.test.tls.Cert) ChannelHandler(io.netty.channel.ChannelHandler) PUT(io.vertx.core.http.HttpMethod.PUT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.junit.Test) Repeat(io.vertx.test.core.Repeat)

Aggregations

Repeat (io.vertx.test.core.Repeat)2 Channel (io.netty.channel.Channel)1 ChannelHandler (io.netty.channel.ChannelHandler)1 EventLoop (io.netty.channel.EventLoop)1 TooLongFrameException (io.netty.handler.codec.TooLongFrameException)1 io.vertx.core (io.vertx.core)1 Future (io.vertx.core.Future)1 Buffer (io.vertx.core.buffer.Buffer)1 PUT (io.vertx.core.http.HttpMethod.PUT)1 Http1xOrH2CHandler (io.vertx.core.http.impl.Http1xOrH2CHandler)1 Http1xServerConnection (io.vertx.core.http.impl.Http1xServerConnection)1 Http1xUpgradeToH2CHandler (io.vertx.core.http.impl.Http1xUpgradeToH2CHandler)1 HttpServerImpl (io.vertx.core.http.impl.HttpServerImpl)1 HttpUtils (io.vertx.core.http.impl.HttpUtils)1 ConcurrentHashSet (io.vertx.core.impl.ConcurrentHashSet)1 ContextInternal (io.vertx.core.impl.ContextInternal)1 EventLoopContext (io.vertx.core.impl.EventLoopContext)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1