use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.
the class DeployStateTest method testGetConfigDefinition.
@Test
public void testGetConfigDefinition() {
Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>();
defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test2", new String[] { "namespace=a.b", "doubleVal double default=1.0" }));
// defs.put(new ConfigDefinitionKey("test2", "c.d"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test2", new String[]{"namespace=c.d", "doubleVal double default=1.0"}));
defs.put(new ConfigDefinitionKey("test3", "xyzzy"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test3", new String[] { "namespace=xyzzy", "message string" }));
ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg//application/app1"));
DeployState state = createDeployState(app, defs);
assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")));
ConfigDefinition test1 = state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")).get();
assertNotNull(test1);
assertThat(test1.getName(), is("test2"));
assertThat(test1.getNamespace(), is("a.b"));
}
use of com.yahoo.vespa.config.ConfigDefinitionKey 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.ConfigDefinitionKey in project vespa by vespa-engine.
the class ApplicationDeployTest method testConfigDefinitionsFromJars.
@Test
public void testConfigDefinitionsFromJars() throws IOException {
String appName = "src/test/cfg//application/app1";
FilesApplicationPackage app = FilesApplicationPackage.fromFile(new File(appName), false);
Map<ConfigDefinitionKey, UnparsedConfigDefinition> defs = app.getAllExistingConfigDefs();
assertThat(defs.size(), is(5));
}
use of com.yahoo.vespa.config.ConfigDefinitionKey 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"));
}
use of com.yahoo.vespa.config.ConfigDefinitionKey in project vespa by vespa-engine.
the class DomConfigPayloadBuilderTest method testNameParsing.
@Test
public void testNameParsing() throws FileNotFoundException, ParserConfigurationException {
Element configRoot = getDocument(new StringReader("<config name=\"function-test\" version=\"1\" namespace=\"config\">" + "<int_val>1</int_val> +" + "</config>"));
ConfigDefinitionKey key = DomConfigPayloadBuilder.parseConfigName(configRoot);
assertThat(key.getName(), is("function-test"));
assertThat(key.getNamespace(), is("config"));
configRoot = getDocument(new StringReader("<config name=\"function_test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>"));
key = DomConfigPayloadBuilder.parseConfigName(configRoot);
assertThat(key.getName(), is("function_test"));
assertThat(key.getNamespace(), is("config"));
// Both namespace and name in name attribute
configRoot = getDocument(new StringReader("<config name=\"config.function-test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>"));
key = DomConfigPayloadBuilder.parseConfigName(configRoot);
assertThat(key.getName(), is("function-test"));
assertThat(key.getNamespace(), is("config"));
}
Aggregations