Search in sources :

Example 11 with SimpletypesConfig

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);
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) Test(org.junit.Test)

Example 12 with SimpletypesConfig

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));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) Test(org.junit.Test)

Example 13 with SimpletypesConfig

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);
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) Test(org.junit.Test)

Example 14 with SimpletypesConfig

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));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) AppConfig(com.yahoo.foo.AppConfig) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Example 15 with SimpletypesConfig

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));
}
Also used : SimpletypesConfig(com.yahoo.foo.SimpletypesConfig) ConfigSubscriber(com.yahoo.config.subscription.ConfigSubscriber) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Aggregations

SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)19 Test (org.junit.Test)19 ConfigSubscriber (com.yahoo.config.subscription.ConfigSubscriber)11 TimingValues (com.yahoo.vespa.config.TimingValues)9 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)4 FileSource (com.yahoo.config.subscription.FileSource)3 DefParser (com.yahoo.config.codegen.DefParser)2 InnerCNode (com.yahoo.config.codegen.InnerCNode)2 GenericConfigSubscriber (com.yahoo.config.subscription.impl.GenericConfigSubscriber)2 JRTConfigSubscription (com.yahoo.config.subscription.impl.JRTConfigSubscription)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 StringReader (java.io.StringReader)2 ConfigSet (com.yahoo.config.subscription.ConfigSet)1 ConfigSourceSet (com.yahoo.config.subscription.ConfigSourceSet)1 MockConnection (com.yahoo.config.subscription.impl.MockConnection)1 AppConfig (com.yahoo.foo.AppConfig)1 Request (com.yahoo.jrt.Request)1 Utf8Array (com.yahoo.text.Utf8Array)1 LZ4PayloadCompressor (com.yahoo.vespa.config.LZ4PayloadCompressor)1 JRTServerConfigRequestV3 (com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3)1