use of com.yahoo.vespa.http.server.FeedHandlerV3 in project vespa by vespa-engine.
the class FeedTesterV3 method feedManyDocument.
@Test
public void feedManyDocument() throws Exception {
final FeedHandlerV3 feedHandlerV3 = setupFeederHandler();
HttpResponse httpResponse = feedHandlerV3.handle(createRequest(100));
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
httpResponse.render(outStream);
assertThat(httpResponse.getContentType(), is("text/plain"));
String result = Utf8.toString(outStream.toByteArray());
assertThat(Splitter.on("\n").splitToList(result).size(), is(101));
}
use of com.yahoo.vespa.http.server.FeedHandlerV3 in project vespa by vespa-engine.
the class FeedTesterV3 method setupFeederHandler.
FeedHandlerV3 setupFeederHandler() throws Exception {
Executor threadPool = Executors.newCachedThreadPool();
DocumentmanagerConfig docMan = new DocumentmanagerConfig(new DocumentmanagerConfig.Builder().enablecompression(true));
FeedHandlerV3 feedHandlerV3 = new FeedHandlerV3(new FeedHandlerV3.Context(threadPool, AccessLog.voidAccessLog(), new NullFeedMetric()), docMan, null, /* session cache */
null, /* thread pool config */
new DocumentApiMetrics(MetricReceiver.nullImplementation, "test")) {
@Override
protected ReferencedResource<SharedSourceSession> retainSource(SessionCache sessionCache, SourceSessionParams sessionParams) {
SharedSourceSession sharedSourceSession = mock(SharedSourceSession.class);
try {
Mockito.stub(sharedSourceSession.sendMessageBlocking(anyObject())).toAnswer((Answer) invocation -> {
Object[] args = invocation.getArguments();
PutDocumentMessage putDocumentMessage = (PutDocumentMessage) args[0];
ReplyContext replyContext = (ReplyContext) putDocumentMessage.getContext();
replyContext.feedReplies.add(new OperationStatus("message", replyContext.docId, ErrorCode.OK, false, "trace"));
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
return result;
});
} catch (InterruptedException e) {
e.printStackTrace();
}
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
ReferencedResource<SharedSourceSession> refSharedSessopn = new ReferencedResource<>(sharedSourceSession, () -> {
});
return refSharedSessopn;
}
};
feedHandlerV3.injectDocumentManangerForTests(createDoctypeManager());
return feedHandlerV3;
}
use of com.yahoo.vespa.http.server.FeedHandlerV3 in project vespa by vespa-engine.
the class FeedTesterV3 method feedOneDocument.
@Test
public void feedOneDocument() throws Exception {
final FeedHandlerV3 feedHandlerV3 = setupFeederHandler();
HttpResponse httpResponse = feedHandlerV3.handle(createRequest(1));
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
httpResponse.render(outStream);
assertThat(httpResponse.getContentType(), is("text/plain"));
assertThat(Utf8.toString(outStream.toByteArray()), is("1230 OK message trace\n"));
}
Aggregations