use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class JRTConfigRequestFactoryTest method testCreateFromRaw.
@Test
public void testCreateFromRaw() {
Class<FunctionTestConfig> clazz = FunctionTestConfig.class;
final String configId = "foo";
RawConfig config = new RawConfig(new ConfigKey<>(clazz, configId), "595f44fec1e92a71d3e9e77456ba80d1");
// Default vespa version
JRTClientConfigRequest request = JRTConfigRequestFactory.createFromRaw(config, 1000);
assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
// Create with vespa version set
String version = "5.37.38";
System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
request = JRTConfigRequestFactory.createFromRaw(config, 1000);
assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method config_builder_can_be_created_from_generic_payload.
@Test
public void config_builder_can_be_created_from_generic_payload() {
FunctionTestConfig config = createVariableAccessConfigWithBuilder();
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(ConfigInstance.serialize(config));
assertFunctionTestPayload(config, payload);
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstancePayloadTest method function_test_payload_is_correctly_deserialized.
@Test
public void function_test_payload_is_correctly_deserialized() {
FunctionTestConfig orig = createVariableAccessConfigWithBuilder();
List<String> lines = ConfigInstance.serialize(orig);
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines);
FunctionTestConfig config = ConfigInstanceUtil.getNewInstance(FunctionTestConfig.class, "foo", payload);
FunctionTest.assertVariableAccessValues(config, "foo");
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class FunctionTest method testRandomOrder.
@Test
public void testRandomOrder() {
assertNull(config);
String configId = "file:" + PATH + "randomorder.txt";
ConfigGetter<FunctionTestConfig> getter = new ConfigGetter<>(FunctionTestConfig.class);
FunctionTestConfig config = getter.getConfig(configId);
assertFalse(config.bool_val());
assertTrue(config.bool_with_def());
assertEquals(5, config.int_val());
assertEquals(-14, config.int_with_def());
assertEquals(666000666000L, config.long_val());
assertEquals(-333000333000L, config.long_with_def());
assertEquals(41.23, config.double_val(), 0.000001);
assertEquals(-12, config.double_with_def(), 0.000001);
assertEquals("foo", config.string_val());
assertEquals("bar and foo", config.stringwithdef());
assertEquals(FunctionTestConfig.Enum_val.FOOBAR, config.enum_val());
assertEquals(FunctionTestConfig.Enumwithdef.BAR2, config.enumwithdef());
assertEquals(configId, config.refval());
assertEquals(configId, config.refwithdef());
assertEquals("autoexec.bat", config.fileVal().value());
assertEquals(1, config.boolarr().size());
assertEquals(0, config.intarr().size());
assertEquals(0, config.longarr().size());
assertEquals(2, config.doublearr().size());
assertEquals(1, config.stringarr().size());
assertEquals(1, config.enumarr().size());
assertEquals(0, config.refarr().size());
assertEquals(0, config.fileArr().size());
assertEquals(2, config.myarray().size());
}
use of com.yahoo.foo.FunctionTestConfig in project vespa by vespa-engine.
the class ConfigInstanceSerializationTest method require_symmetrical_serialization_and_deserialization_with_builder.
@Test
public void require_symmetrical_serialization_and_deserialization_with_builder() {
FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
// NOTE: configId must be ':parent:' because the library replaces ReferenceNodes with that value with
// the instance's configId. (And the config used here contains such nodes.)
List<String> lines = ConfigInstance.serialize(config);
ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines);
FunctionTestConfig config2 = ConfigInstanceUtil.getNewInstance(FunctionTestConfig.class, ":parent:", payload);
assertThat(config, is(config2));
assertThat(ConfigInstance.serialize(config), is(ConfigInstance.serialize(config2)));
}
Aggregations