Search in sources :

Example 6 with BufferedContentChannel

use of com.yahoo.jdisc.handler.BufferedContentChannel in project vespa by vespa-engine.

the class VipStatusHandlerTestCase method testFileNotFound.

@Test
public final void testFileNotFound() {
    final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(true).statusfile("/VipStatusHandlerTestCaseFileThatReallyReallyShouldNotExist").noSearchBackendsImpliesOutOfService(false));
    final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric);
    final NotFoundResponseHandler responseHandler = new NotFoundResponseHandler();
    final HttpRequest request = createRequest();
    final BufferedContentChannel requestContent = createChannel();
    handler.handleRequest(request, requestContent, responseHandler);
    final ByteBuffer b = responseHandler.channel.read();
    final byte[] asBytes = new byte[b.remaining()];
    b.get(asBytes);
    assertEquals(VipStatusHandler.StatusResponse.COULD_NOT_FIND_STATUS_FILE, Utf8.toString(asBytes));
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) VipStatusConfig(com.yahoo.container.core.VipStatusConfig) BufferedContentChannel(com.yahoo.jdisc.handler.BufferedContentChannel) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 7 with BufferedContentChannel

use of com.yahoo.jdisc.handler.BufferedContentChannel in project vespa by vespa-engine.

the class VipStatusHandlerTestCase method createChannel.

public static BufferedContentChannel createChannel() {
    BufferedContentChannel channel = new BufferedContentChannel();
    channel.close(null);
    return channel;
}
Also used : BufferedContentChannel(com.yahoo.jdisc.handler.BufferedContentChannel)

Example 8 with BufferedContentChannel

use of com.yahoo.jdisc.handler.BufferedContentChannel in project vespa by vespa-engine.

the class VipStatusHandlerTestCase method testHandleRequest.

@Test
public final void testHandleRequest() {
    final VipStatusConfig config = new VipStatusConfig(new VipStatusConfig.Builder().accessdisk(false).noSearchBackendsImpliesOutOfService(false));
    final VipStatusHandler handler = new VipStatusHandler(Executors.newCachedThreadPool(), config, metric);
    final MockResponseHandler responseHandler = new MockResponseHandler();
    final HttpRequest request = createRequest();
    final BufferedContentChannel requestContent = createChannel();
    handler.handleRequest(request, requestContent, responseHandler);
    final ByteBuffer b = responseHandler.channel.read();
    final byte[] asBytes = new byte[b.remaining()];
    b.get(asBytes);
    assertEquals(VipStatusHandler.OK_MESSAGE, Utf8.toString(asBytes));
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) VipStatusConfig(com.yahoo.container.core.VipStatusConfig) BufferedContentChannel(com.yahoo.jdisc.handler.BufferedContentChannel) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

BufferedContentChannel (com.yahoo.jdisc.handler.BufferedContentChannel)8 Test (org.junit.Test)5 VipStatusConfig (com.yahoo.container.core.VipStatusConfig)4 HttpRequest (com.yahoo.jdisc.http.HttpRequest)4 ByteBuffer (java.nio.ByteBuffer)4 Response (com.yahoo.jdisc.Response)1 OverloadException (com.yahoo.jdisc.handler.OverloadException)1 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Duration (java.time.Duration)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1