use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class SessionCreateHandlerTest method assertFromParameter.
private void assertFromParameter(String expected, String from) throws IOException {
HttpRequest request = post(Collections.singletonMap("from", from));
MockSessionFactory factory = new MockSessionFactory();
factory.applicationPackage = testApp;
HttpResponse response = createHandler(factory).handle(request);
assertNotNull(response);
assertThat(response.getStatus(), is(OK));
assertTrue(factory.createFromCalled);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"log\":[]" + tenantMessage + ",\"session-id\":\"" + expected + "\",\"prepared\":\"http://" + hostname + ":" + port + pathPrefix + expected + "/prepared\",\"content\":\"http://" + hostname + ":" + port + pathPrefix + expected + "/content/\",\"message\":\"Session " + expected + createdMessage + "}"));
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class SessionCreateHandlerTest method require_that_from_parameter_cannot_be_set_if_data_in_request.
@Ignore
@Test
public void require_that_from_parameter_cannot_be_set_if_data_in_request() throws IOException {
HttpRequest request = post(Collections.singletonMap("from", "active"));
HttpResponse response = createHandler().handle(request);
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Parameter 'from' is illegal for POST");
}
use of com.yahoo.container.jdisc.HttpRequest 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);
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_nocache_property_works.
@Test
public void require_that_nocache_property_works() throws IOException {
long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
final HttpRequest request = HttpRequest.createTestRequest(configUri, GET, null, Collections.singletonMap("nocache", "true"));
HttpResponse response = handler.handle(request);
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_request_gets_correct_fields_with_short_appid.
@Test
public void require_that_request_gets_correct_fields_with_short_appid() {
String uriShortAppId = "http://yahoo.com:8080/config/v2/tenant/jason/application/alcide/foo.bar/myid";
HttpRequest r = HttpRequest.createTestRequest(uriShortAppId, GET);
HttpConfigRequest req = HttpConfigRequest.createFromRequestV2(r);
assertThat(req.getApplicationId().tenant().value(), is("jason"));
assertThat(req.getApplicationId().application().value(), is("alcide"));
assertThat(req.getApplicationId().instance().value(), is("default"));
}
Aggregations