use of com.yahoo.vespa.config.ConfigDefinition in project vespa by vespa-engine.
the class DeployStateTest method testDefinitionRepoIsUsed.
@Test
public void testDefinitionRepoIsUsed() {
Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>();
defs.put(new ConfigDefinitionKey("foo", "bar"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("foo", new String[] { "namespace=bar", "foo int default=0" }));
defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("namespace-in-filename", new String[] { "namespace=a.b", "doubleVal double default=1.0" }));
ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg//application/app1"));
DeployState state = createDeployState(app, defs);
assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("foo", "bar")));
ConfigDefinition overridden = state.getConfigDefinition(new ConfigDefinitionKey("namespace-in-filename", "a.b")).get();
assertNotNull(overridden);
Double defaultValue = overridden.getDoubleDefs().get("doubleVal").getDefVal();
assertNotNull(defaultValue);
assertThat(defaultValue.intValue(), is(0));
}
use of com.yahoo.vespa.config.ConfigDefinition in project vespa by vespa-engine.
the class ApplicationDeployTest method testConfigDefinitionsAndNamespaces.
/**
* Tests that config definitions with namespace are treated properly when they have the format
* as in the config definitions dir ($VESPA_HOME/share/vespa/configdefinitions on a machine
* with Vespa packages installed) (does not test when read from user def files). Also tests a config
* definition without version in file name
*/
@Test
public void testConfigDefinitionsAndNamespaces() {
final File appDir = new File("src/test/cfg/application/configdeftest");
FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir);
DeployState deployState = new DeployState.Builder().applicationPackage(app).build(true);
ConfigDefinition def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", CNode.DEFAULT_NAMESPACE)).get();
assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
def = deployState.getConfigDefinition(new ConfigDefinitionKey("baz", "xyzzy")).get();
assertThat(def.getNamespace(), is("xyzzy"));
def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", "qux")).get();
assertThat(def.getNamespace(), is("qux"));
// A config def without version in filename and version in file header
def = deployState.getConfigDefinition(new ConfigDefinitionKey("xyzzy", CNode.DEFAULT_NAMESPACE)).get();
assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
assertThat(def.getName(), is("xyzzy"));
}
Aggregations