use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method testFunctionTest_DefaultValues.
@Test
public void testFunctionTest_DefaultValues() throws FileNotFoundException, ParserConfigurationException {
Element configRoot = getDocument(new FileReader(new File("src/test/cfg/admin/userconfigs/functiontest-defaultvalues.xml")));
ConfigPayload config = ConfigPayload.fromBuilder(new DomConfigPayloadBuilder(null).build(configRoot));
String expected = "" + "{" + "\"bool_val\":\"false\"," + "\"int_val\":\"5\"," + "\"long_val\":\"1234567890123\"," + "\"double_val\":\"41.23\"," + "\"string_val\":\"foo\"," + "\"enum_val\":\"FOOBAR\"," + "\"refval\":\":parent:\"," + "\"fileVal\":\"vespa.log\"," + "\"basicStruct\":{\"bar\":\"3\",\"intArr\":[\"10\"]}," + "\"rootStruct\":{\"inner0\":{\"index\":\"11\"},\"inner1\":{\"index\":\"12\"}," + "\"innerArr\":[{\"stringVal\":\"deep\"}]}," + "\"boolarr\":[\"false\"]," + "\"doublearr\":[\"2344\",\"123\"]," + "\"stringarr\":[\"bar\"]," + "\"enumarr\":[\"VALUES\"]," + "\"myarray\":[{\"refval\":\":parent:\",\"fileVal\":\"command.com\",\"myStruct\":{\"a\":\"1\"},\"stringval\":[\"baah\",\"yikes\"],\"anotherarray\":[{\"foo\":\"7\"}]},{\"refval\":\":parent:\",\"fileVal\":\"display.sys\",\"myStruct\":{\"a\":\"-1\"},\"anotherarray\":[{\"foo\":\"1\"},{\"foo\":\"2\"}]}]" + "}";
assertPayload(expected, config);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class ConfigTester method createConfigPayload.
static ConfigPayload createConfigPayload(String key, String value) {
Slime slime = new Slime();
slime.setObject().setString(key, value);
return new ConfigPayload(slime);
}
use of com.yahoo.vespa.config.ConfigPayload in project vespa by vespa-engine.
the class GetConfigProcessor method returnEmpty.
private void returnEmpty(JRTServerConfigRequest request) {
ConfigPayload emptyPayload = ConfigPayload.empty();
String configMd5 = ConfigUtils.getMd5(emptyPayload);
ConfigResponse config = SlimeConfigResponse.fromConfigPayload(emptyPayload, null, 0, configMd5);
request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5());
respond(request);
}
use of com.yahoo.vespa.config.ConfigPayload 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.vespa.config.ConfigPayload 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));
}
Aggregations