Search in sources :

Example 1 with AppConfig

use of com.yahoo.foo.AppConfig in project vespa by vespa-engine.

the class ConfigGetterTest method testGetTwice.

@Test
public void testGetTwice() {
    ConfigGetter<AppConfig> getter = new ConfigGetter<>(AppConfig.class);
    AppConfig config = getter.getConfig("raw:message \"one\"");
    assertThat(config.message(), is("one"));
    config = getter.getConfig("raw:message \"two\"");
    assertThat(config.message(), is("two"));
}
Also used : AppConfig(com.yahoo.foo.AppConfig) Test(org.junit.Test)

Example 2 with AppConfig

use of com.yahoo.foo.AppConfig in project vespa by vespa-engine.

the class ConfigGetterTest method testGetFromFileSource.

@Test
public void testGetFromFileSource() {
    ConfigGetter<AppConfig> getter = new ConfigGetter<>(new FileSource(new File("src/test/resources/configs/foo/app.cfg")), AppConfig.class);
    AppConfig config = getter.getConfig("test");
    verifyFooValues(config);
}
Also used : AppConfig(com.yahoo.foo.AppConfig) File(java.io.File) Test(org.junit.Test)

Example 3 with AppConfig

use of com.yahoo.foo.AppConfig in project vespa by vespa-engine.

the class ConfigGetterTest method testsStaticGetConfig.

@Test
public void testsStaticGetConfig() {
    int times = 11;
    String message = "testGetConfig";
    String a0 = "a0";
    String configId = "raw:times " + times + "\nmessage " + message + "\na[1]\na[0].name " + a0;
    AppConfig config = ConfigGetter.getConfig(AppConfig.class, configId);
    assertThat(config.times(), is(times));
    assertThat(config.message(), is(message));
    assertThat(config.a().size(), is(1));
    assertThat(config.a(0).name(), is(a0));
    AppService service = new AppService(configId, sourceSet);
    AppConfig serviceConfig = service.getConfig();
    assertTrue(service.isConfigured());
    assertThat(config, is(serviceConfig));
}
Also used : AppConfig(com.yahoo.foo.AppConfig) Test(org.junit.Test)

Example 4 with AppConfig

use of com.yahoo.foo.AppConfig in project vespa by vespa-engine.

the class ConfigInstanceTest method testRetainOldValuesOnConfigUpdates.

/**
 * Verifies that values set in previous setConfig() calls are
 * retained when the payload in a new setConfig() call does not
 * overwrite them.
 */
@Test
@Ignore
public void testRetainOldValuesOnConfigUpdates() {
    AppConfig config = new AppConfig(new AppConfig.Builder());
    // config.setConfig(Arrays.asList("message \"one\"", "times 333"), "", 0L);
    assertEquals("one", config.message());
    assertEquals(333, config.times());
    // config.setConfig(Arrays.asList("message \"two\""), "", 0L);
    assertEquals("two", config.message());
    assertEquals("config.times retains previously set value", 333, config.times());
    // config.setConfig(Arrays.asList("times 666"), "", 0L);
    assertEquals("config.message retains previously set value", "two", config.message());
    assertEquals(666, config.times());
}
Also used : AppConfig(com.yahoo.foo.AppConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with AppConfig

use of com.yahoo.foo.AppConfig in project vespa by vespa-engine.

the class ConfigSetSubscriptionTest method testConfigSubscription.

@Test
public void testConfigSubscription() {
    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 : AppConfig(com.yahoo.foo.AppConfig) TimingValues(com.yahoo.vespa.config.TimingValues) Test(org.junit.Test)

Aggregations

AppConfig (com.yahoo.foo.AppConfig)13 Test (org.junit.Test)13 TimingValues (com.yahoo.vespa.config.TimingValues)2 File (java.io.File)2 SimpletypesConfig (com.yahoo.foo.SimpletypesConfig)1 Ignore (org.junit.Ignore)1