use of com.yahoo.config.codegen.DefParser in project vespa by vespa-engine.
the class ConfigFileFormatterTest method assertConfigFormat.
private void assertConfigFormat(Slime slime, String expected_simpletypes) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree();
new ConfigFileFormat(def).encode(baos, slime);
assertThat(baos.toString(), is(expected_simpletypes));
}
use of com.yahoo.config.codegen.DefParser in project vespa by vespa-engine.
the class ConfigDefinition method generateClass.
public ConfigDefinitionClass generateClass() {
File tempDir = Files.createTempDir();
DefParser parser = new DefParser(name, new StringReader(StringUtilities.implode(defSchema, "\n")));
JavaClassBuilder builder = new JavaClassBuilder(parser.getTree(), parser.getNormalizedDefinition(), tempDir, null);
String className = builder.className();
return new ConfigDefinitionClass(className, builder.javaPackage(), builder.getConfigClass(className));
}
use of com.yahoo.config.codegen.DefParser in project vespa by vespa-engine.
the class DefaultValueApplierTest method apply.
public Slime apply(Slime slime, String... extraFields) {
StringBuilder defBuilder = new StringBuilder();
defBuilder.append("namespace=test").append("\n");
defBuilder.append("str string").append("\n");
for (String field : extraFields) {
defBuilder.append(field).append("\n");
}
Cursor cursor = slime.get();
cursor.setString("str", "myvalue");
InnerCNode def = new DefParser("simpletypes", new StringReader(defBuilder.toString())).getTree();
DefaultValueApplier applier = new DefaultValueApplier();
return applier.applyDefaults(slime, def);
}
use of com.yahoo.config.codegen.DefParser in project vespa by vespa-engine.
the class ZKApplicationPackage method getAllExistingConfigDefs.
@Override
public Map<ConfigDefinitionKey, UnparsedConfigDefinition> getAllExistingConfigDefs() {
Map<ConfigDefinitionKey, UnparsedConfigDefinition> ret = new LinkedHashMap<>();
List<String> allDefs = liveApp.getChildren(ConfigCurator.DEFCONFIGS_ZK_SUBPATH);
for (final String nodeName : allDefs) {
final ConfigDefinitionKey key = ConfigUtils.createConfigDefinitionKeyFromZKString(nodeName);
ret.put(key, new UnparsedConfigDefinition() {
@Override
public ConfigDefinition parse() {
DefParser parser = new DefParser(key.getName(), retrieveConfigDefReader(nodeName));
return ConfigDefinitionBuilder.createConfigDefinition(parser.getTree());
}
@Override
public String getUnparsedContent() {
try {
return IOUtils.readAll(retrieveConfigDefReader(nodeName));
} catch (Exception e) {
throw new RuntimeException("Error retriving def file", e);
}
}
});
}
return ret;
}
use of com.yahoo.config.codegen.DefParser in project vespa by vespa-engine.
the class ConfigResponseFactoryTest method setup.
@Before
public void setup() {
DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
def = dParser.getTree();
}
Aggregations