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"));
}
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);
}
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));
}
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());
}
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));
}
Aggregations