Search in sources :

Example 11 with Request

use of com.yahoo.processing.Request in project vespa by vespa-engine.

the class JDiscContainerProcessingTest method requireThatBasicProcessingWorks.

@Test
public void requireThatBasicProcessingWorks() {
    try (JDisc container = getContainerWithRot13()) {
        Processing processing = container.processing();
        Request req = new Request();
        req.properties().set("title", "Good day!");
        Response response = processing.process(ComponentSpecification.fromString("foo"), req);
        assertThat(response.data().get(0).toString(), equalTo("Tbbq qnl!"));
    }
}
Also used : Response(com.yahoo.processing.Response) Request(com.yahoo.processing.Request) Test(org.junit.Test)

Example 12 with Request

use of com.yahoo.processing.Request in project vespa by vespa-engine.

the class AsynchronousSectionedRendererTest method createDataList.

public StringDataList createDataList() {
    Request request = new Request();
    StringDataList dataList = new StringDataList(request);
    dataList.add(new StringDataItem(request, "l1"));
    StringDataList secondLevel = new StringDataList(request);
    secondLevel.add(new StringDataItem(request, "l11"));
    secondLevel.add(new StringDataItem(request, "l12"));
    dataList.add(secondLevel);
    return dataList;
}
Also used : Request(com.yahoo.processing.Request)

Example 13 with Request

use of com.yahoo.processing.Request in project vespa by vespa-engine.

the class AsynchronousSectionedRendererTest method testEmptyProcessingRendering.

@Test
public void testEmptyProcessingRendering() throws IOException, InterruptedException {
    Request request = new Request();
    DataList dataList = ArrayDataList.create(request);
    assertThat(render(dataList), equalTo("{\"datalist\":[" + "]}"));
}
Also used : ArrayDataList(com.yahoo.processing.response.ArrayDataList) DataList(com.yahoo.processing.response.DataList) Request(com.yahoo.processing.Request) Test(org.junit.Test)

Example 14 with Request

use of com.yahoo.processing.Request in project vespa by vespa-engine.

the class AbstractProcessingHandler method handle.

@Override
@SuppressWarnings("unchecked")
public HttpResponse handle(HttpRequest request, ContentChannel channel) {
    com.yahoo.processing.Request processingRequest = new com.yahoo.processing.Request();
    populate("", request.propertyMap(), processingRequest.properties());
    populate("context", request.getJDiscRequest().context(), processingRequest.properties());
    processingRequest.properties().set(Request.JDISC_REQUEST, request);
    FreezeListener freezeListener = new FreezeListener(processingRequest, renderers, defaultRenderer, channel, renderingExecutor);
    processingRequest.properties().set(freezeListenerKey, freezeListener);
    Chain<COMPONENT> chain = chainRegistry.getComponent(resolveChainId(processingRequest.properties()));
    if (chain == null)
        throw new IllegalArgumentException("Chain '" + processingRequest.properties().get("chain") + "' not found");
    Execution execution = createExecution(chain, processingRequest);
    freezeListener.setExecution(execution);
    Response processingResponse = execution.process(processingRequest);
    return freezeListener.getHttpResponse(processingResponse);
}
Also used : Response(com.yahoo.processing.Response) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Execution(com.yahoo.processing.execution.Execution) Request(com.yahoo.processing.Request) HttpRequest(com.yahoo.container.jdisc.HttpRequest) Request(com.yahoo.processing.Request)

Example 15 with Request

use of com.yahoo.processing.Request in project vespa by vespa-engine.

the class MockUserDatabaseClientTest method createRequest.

/**
 * Creates a request which has an underlying jdisc request, which is needed to make the outgoing request
 */
private Request createRequest() {
    com.yahoo.jdisc.http.HttpRequest jdiscRequest = HttpRequest.newServerRequest(driver, URI.create("http://localhost/"));
    com.yahoo.container.jdisc.HttpRequest containerRequest = new com.yahoo.container.jdisc.HttpRequest(jdiscRequest, new ByteArrayInputStream(new byte[0]));
    Request request = new Request();
    request.properties().set("jdisc.request", containerRequest);
    request.properties().set("timeout", 1000);
    return request;
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) HttpRequest(com.yahoo.jdisc.http.HttpRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) Request(com.yahoo.processing.Request) HttpRequest(com.yahoo.jdisc.http.HttpRequest)

Aggregations

Request (com.yahoo.processing.Request)20 Test (org.junit.Test)16 Response (com.yahoo.processing.Response)12 Chain (com.yahoo.component.chain.Chain)10 Processor (com.yahoo.processing.Processor)10 DataList (com.yahoo.processing.response.DataList)3 HttpRequest (com.yahoo.jdisc.http.HttpRequest)2 Execution (com.yahoo.processing.execution.Execution)2 ErrorMessage (com.yahoo.processing.request.ErrorMessage)2 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 CompoundName (com.yahoo.processing.request.CompoundName)1 Properties (com.yahoo.processing.request.Properties)1 PropertyMap (com.yahoo.processing.request.properties.PropertyMap)1 ArrayDataList (com.yahoo.processing.response.ArrayDataList)1 IncomingData (com.yahoo.processing.response.IncomingData)1 ProcessorLibrary (com.yahoo.processing.test.ProcessorLibrary)1 AsyncDataProcessingInitiator (com.yahoo.processing.test.documentation.AsyncDataProcessingInitiator)1 AsyncDataProducer (com.yahoo.processing.test.documentation.AsyncDataProducer)1 ExampleProcessor (com.yahoo.processing.test.documentation.ExampleProcessor)1