use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class CfgConfigPayloadBuilderTest method createConfigPayloadUtf8.
@Test
public void createConfigPayloadUtf8() {
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder().stringval("Hei \u00E6\u00F8\u00E5 \uBC14\uB451 \u00C6\u00D8\u00C5 hallo");
SimpletypesConfig config = new SimpletypesConfig(builder);
String expectedJson = inputJson("{", " 'longval': '0',", " 'intval': '0',", " 'stringval': 'Hei \u00e6\u00f8\u00e5 \ubc14\ub451 \u00c6\u00d8\u00c5 hallo',", " 'boolval': 'false',", " 'doubleval': '0.0',", " 'enumval': 'VAL1'", "}");
CfgConfigPayloadBuilderTest.assertDeserializedConfigEqualsJson(config, expectedJson);
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class ConfigUtilsTest method testGetMd5OfString.
@Test
public void testGetMd5OfString() {
String expectedMd5 = "c9246ed8c8ab55b1c463c501c84075e6";
String expectedChangedMd5 = "f6f81062ef5f024f1912798490ba7dfc";
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
System.out.println(payload);
assertThat(ConfigUtils.getMd5(payload.toString(true)), is(expectedMd5));
payload.getSlime().get().setString("fabio", "bar");
System.out.println(payload);
assertThat(ConfigUtils.getMd5(payload.toString(true)), is(expectedChangedMd5));
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class ConfigInstanceSerializerTest method test_that_leaf_types_are_serialized_to_json_types.
@Test
public void test_that_leaf_types_are_serialized_to_json_types() throws IOException {
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
builder.boolval(false);
builder.stringval("foo");
builder.intval(13);
builder.longval(14);
builder.doubleval(3.14);
builder.enumval(SimpletypesConfig.Enumval.Enum.VAL2);
final SimpletypesConfig config = new SimpletypesConfig(builder);
final String expectedJson = inputJson("{", " 'boolval': false,", " 'doubleval': 3.14,", " 'enumval': 'VAL2',", " 'intval': 13,", " 'longval': 14,", " 'stringval': 'foo'", "}");
assertConfigEquals(expectedJson, config);
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class ConfigSubscriptionTest method testEquals.
@Test
public void testEquals() {
ConfigSubscriber sub = new ConfigSubscriber();
final String payload = "boolval true";
ConfigSubscription<SimpletypesConfig> a = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test"), sub, new RawSource(payload), new TimingValues());
ConfigSubscription<SimpletypesConfig> b = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test"), sub, new RawSource(payload), new TimingValues());
ConfigSubscription<SimpletypesConfig> c = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test2"), sub, new RawSource(payload), new TimingValues());
assertEquals(b, a);
assertEquals(a, a);
assertEquals(b, b);
assertEquals(c, c);
assertNotEquals(c, a);
assertNotEquals(c, b);
ConfigSubscriber subscriber = new ConfigSubscriber();
ConfigSet configSet = new ConfigSet();
AppConfig.Builder a0builder = new AppConfig.Builder().message("A message, 0").times(88);
configSet.addBuilder("app/0", a0builder);
AppConfig.Builder a1builder = new AppConfig.Builder().message("A message, 1").times(89);
configSet.addBuilder("app/1", a1builder);
ConfigSubscription<AppConfig> c1 = ConfigSubscription.get(new ConfigKey<>(AppConfig.class, "app/0"), subscriber, configSet, new TimingValues());
ConfigSubscription<AppConfig> c2 = ConfigSubscription.get(new ConfigKey<>(AppConfig.class, "app/1"), subscriber, configSet, new TimingValues());
assertTrue(c1.equals(c1));
assertFalse(c1.equals(c2));
}
use of com.yahoo.foo.SimpletypesConfig in project vespa by vespa-engine.
the class JRTConfigRequesterTest method testTransientErrorSubscribed.
@Test
public void testTransientErrorSubscribed() {
ConfigSubscriber subscriber = new ConfigSubscriber();
final TimingValues timingValues = getTestTimingValues();
JRTConfigSubscription<SimpletypesConfig> sub = createSubscription(subscriber, timingValues);
sub.setConfig(1L, config());
final MockConnection connection = new MockConnection(new ErrorResponseHandler(com.yahoo.jrt.ErrorCode.TIMEOUT));
JRTConfigRequester requester = new JRTConfigRequester(connection, timingValues);
requester.request(sub);
waitUntilResponse(connection);
assertThat(requester.getFatalFailures(), is(0));
assertThat(requester.getTransientFailures(), is(1));
}
Aggregations