Search in sources :

Example 26 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode 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));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 27 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class HttpGetConfigHandlerTest method require_that_handler_can_handle_long_appid_request_with_configid.

@Test
public void require_that_handler_can_handle_long_appid_request_with_configid() throws IOException {
    String uriLongAppId = "http://yahoo.com:8080/config/v2/tenant/" + tenant.value() + "/application/myapplication/environment/staging/region/myregion/instance/myinstance/foo.bar/myid";
    final 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").instanceName("myinstance").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    HttpResponse response = handler.handle(HttpRequest.createTestRequest(uriLongAppId, GET));
    assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) ApplicationId(com.yahoo.config.provision.ApplicationId) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) Test(org.junit.Test) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest)

Example 28 with InnerCNode

use of com.yahoo.config.codegen.InnerCNode in project vespa by vespa-engine.

the class HttpConfigResponseTest method require_that_response_is_created_from_config.

@Test
public void require_that_response_is_created_from_config() throws IOException {
    final long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    // TODO: Hope to be able to remove this mess soon.
    DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
    InnerCNode targetDef = dParser.getTree();
    ConfigResponse configResponse = SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5");
    HttpConfigResponse response = HttpConfigResponse.createFromConfig(configResponse);
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) StringReader(java.io.StringReader) SlimeConfigResponse(com.yahoo.vespa.config.protocol.SlimeConfigResponse) ConfigResponse(com.yahoo.vespa.config.protocol.ConfigResponse) DefParser(com.yahoo.config.codegen.DefParser) Test(org.junit.Test)

Aggregations

InnerCNode (com.yahoo.config.codegen.InnerCNode)28 Test (org.junit.Test)23 DefParser (com.yahoo.config.codegen.DefParser)21 StringReader (java.io.StringReader)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)17 Cursor (com.yahoo.slime.Cursor)15 Slime (com.yahoo.slime.Slime)14 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)10 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)7 HttpResponse (com.yahoo.container.jdisc.HttpResponse)5 Ignore (org.junit.Ignore)5 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)3 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)3 HttpRequest (com.yahoo.container.jdisc.HttpRequest)2 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)2 ConfigBuilder (com.yahoo.config.ConfigBuilder)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Utf8Array (com.yahoo.text.Utf8Array)1 LZ4PayloadCompressor (com.yahoo.vespa.config.LZ4PayloadCompressor)1 ConfigResponse (com.yahoo.vespa.config.protocol.ConfigResponse)1