Search in sources :

Example 21 with CompositeCloseable

use of io.servicetalk.concurrent.api.CompositeCloseable in project servicetalk by apple.

the class InsufficientlySizedExecutorHttpTest method tearDown.

@AfterEach
void tearDown() throws Exception {
    CompositeCloseable closeable = newCompositeCloseable();
    if (client != null) {
        closeable.append(client);
    }
    if (server != null) {
        closeable.append(server);
    }
    if (null != executor) {
        closeable.append(executor);
    }
    closeable.close();
}
Also used : CompositeCloseable(io.servicetalk.concurrent.api.CompositeCloseable) AsyncCloseables.newCompositeCloseable(io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable) AfterEach(org.junit.jupiter.api.AfterEach)

Example 22 with CompositeCloseable

use of io.servicetalk.concurrent.api.CompositeCloseable in project servicetalk by apple.

the class InvokingThreadsRecorder method close.

@Override
public void close() throws Exception {
    CompositeCloseable compositeCloseable = newCompositeCloseable();
    if (client != null) {
        compositeCloseable.append(client);
    }
    if (context != null) {
        compositeCloseable.append(context);
    }
    compositeCloseable.append(ioExecutor);
    compositeCloseable.close();
}
Also used : CompositeCloseable(io.servicetalk.concurrent.api.CompositeCloseable) AsyncCloseables.newCompositeCloseable(io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable)

Example 23 with CompositeCloseable

use of io.servicetalk.concurrent.api.CompositeCloseable in project servicetalk by apple.

the class MultiAddressUrlHttpClientTest method multipleRequestsToMultipleServers.

@Test
void multipleRequestsToMultipleServers() throws Exception {
    try (CompositeCloseable closeables = newCompositeCloseable()) {
        ServerContext serverCtx2 = startNewLocalServer(httpService, closeables);
        String hostHeader2 = hostHeader(serverHostAndPort(serverCtx2));
        ServerContext serverCtx3 = startNewLocalServer(httpService, closeables);
        String hostHeader3 = hostHeader(serverHostAndPort(serverCtx3));
        List<HttpResponseStatus> statuses = asList(OK, CREATED, ACCEPTED, MOVED_PERMANENTLY, SEE_OTHER, PERMANENT_REDIRECT, BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, INTERNAL_SERVER_ERROR, NOT_IMPLEMENTED, BAD_GATEWAY);
        for (HttpResponseStatus status : statuses) {
            makeGetRequestAndValidate(hostHeader, status);
            makeGetRequestAndValidate(hostHeader2, status);
            makeGetRequestAndValidate(hostHeader3, status);
        }
    }
}
Also used : ServerContext(io.servicetalk.transport.api.ServerContext) HttpResponseStatus(io.servicetalk.http.api.HttpResponseStatus) CompositeCloseable(io.servicetalk.concurrent.api.CompositeCloseable) AsyncCloseables.newCompositeCloseable(io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable) Test(org.junit.jupiter.api.Test)

Aggregations

CompositeCloseable (io.servicetalk.concurrent.api.CompositeCloseable)23 AsyncCloseables.newCompositeCloseable (io.servicetalk.concurrent.api.AsyncCloseables.newCompositeCloseable)16 AfterEach (org.junit.jupiter.api.AfterEach)10 ServerContext (io.servicetalk.transport.api.ServerContext)7 AsyncCloseables (io.servicetalk.concurrent.api.AsyncCloseables)3 Completable (io.servicetalk.concurrent.api.Completable)3 Single.succeeded (io.servicetalk.concurrent.api.Single.succeeded)3 HttpExecutionStrategies.defaultStrategy (io.servicetalk.http.api.HttpExecutionStrategies.defaultStrategy)3 StreamingHttpClient (io.servicetalk.http.api.StreamingHttpClient)3 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)3 StreamingHttpResponse (io.servicetalk.http.api.StreamingHttpResponse)3 StreamingHttpService (io.servicetalk.http.api.StreamingHttpService)3 AddressUtils.localAddress (io.servicetalk.transport.netty.internal.AddressUtils.localAddress)3 AddressUtils.serverHostAndPort (io.servicetalk.transport.netty.internal.AddressUtils.serverHostAndPort)3 ExecutionContextExtension (io.servicetalk.transport.netty.internal.ExecutionContextExtension)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Test (org.junit.jupiter.api.Test)3 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)3 Channel (io.netty.channel.Channel)2 Buffer (io.servicetalk.buffer.api.Buffer)2