use of com.yahoo.processing.Request in project vespa by vespa-engine.
the class RequestTestCase method testCloning.
@Test
public void testCloning() {
Request request = new Request();
request.properties().set("a", "a1");
request.properties().set("b", "b1");
request.errors().add(new ErrorMessage("foo"));
request.errors().add(new ErrorMessage("bar"));
Request rcloned = request.clone();
rcloned.properties().set("c", "c1");
rcloned.errors().add(new ErrorMessage("baz"));
request.properties().set("d", "d1");
request.errors().add(new ErrorMessage("boz"));
assertEquals("a1", request.properties().get("a"));
assertEquals("a1", rcloned.properties().get("a"));
assertEquals("b1", request.properties().get("b"));
assertEquals("b1", rcloned.properties().get("b"));
assertEquals(null, request.properties().get("c"));
assertEquals("c1", rcloned.properties().get("c"));
assertEquals("d1", request.properties().get("d"));
assertEquals(null, rcloned.properties().get("d"));
assertEquals(3, request.errors().size());
assertEquals(1, rcloned.errors().size());
assertEquals("foo", request.errors().get(0).getMessage());
assertEquals("bar", request.errors().get(1).getMessage());
assertEquals("boz", request.errors().get(2).getMessage());
assertEquals("baz", rcloned.errors().get(0).getMessage());
}
use of com.yahoo.processing.Request in project vespa by vespa-engine.
the class ProcessingTestCase method testChainedProcessing1.
/**
* Execute three simple processors doing some phony processing
*/
@Test
public void testChainedProcessing1() {
// Create a chain
Chain<Processor> chain = new Chain<>(new CombineData(), new Get6DataItems(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Verify the result
assertEquals(6 - 1, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.3", response.data().get(2).toString());
assertEquals("second.3", response.data().get(3).toString());
assertEquals("third.3", response.data().get(4).toString());
}
use of com.yahoo.processing.Request in project vespa by vespa-engine.
the class ProcessingTestCase method testChainedProcessing2.
/**
* Execute the same processors in a different order
*/
@Test
public void testChainedProcessing2() {
// Create a chain
Chain<Processor> chain = new Chain<>(new Get6DataItems(), new CombineData(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Check the result
assertEquals(6, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.4, third.4", response.data().get(2).toString());
assertEquals("second.4", response.data().get(3).toString());
assertEquals("first.6, third.6", response.data().get(4).toString());
assertEquals("second.6", response.data().get(5).toString());
}
use of com.yahoo.processing.Request in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testAsyncExecution.
/**
* Execute a processing chain which forks off into multiple threads
*/
@Test
public void testAsyncExecution() {
// Create a chain
Chain<Processor> chain = new Chain<>(new CombineData(), new BlockingSplitter(2), new Get6DataItems(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Verify the result
assertEquals(6 * 2 - 1, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.3", response.data().get(2).toString());
assertEquals("second.3", response.data().get(3).toString());
assertEquals("third.3", response.data().get(4).toString());
// from the parallel execution
assertEquals("first.2", response.data().get(5).toString());
assertEquals("second.2", response.data().get(6).toString());
assertEquals("third.2", response.data().get(7).toString());
assertEquals("first.3", response.data().get(8).toString());
assertEquals("second.3", response.data().get(9).toString());
assertEquals("third.3", response.data().get(10).toString());
}
use of com.yahoo.processing.Request in project vespa by vespa-engine.
the class JDiscContainerProcessingTest method processing_and_rendering_works.
@Test
public void processing_and_rendering_works() throws Exception {
try (JDisc container = getContainerWithRot13()) {
Processing processing = container.processing();
Request req = new Request();
req.properties().set("title", "Good day!");
byte[] rendered = processing.processAndRender(ComponentSpecification.fromString("foo"), ComponentSpecification.fromString("default"), req);
String renderedAsString = new String(rendered, "utf-8");
assertThat(renderedAsString, containsString("Tbbq qnl!"));
}
}
Aggregations