use of com.esotericsoftware.yamlbeans.YamlConfig in project yamlbeans by EsotericSoftware.
the class EmitterTest method testEmptySequence.
@Test
public void testEmptySequence() throws YamlException {
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.writeConfig.setFlowStyle(true);
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
List<String> list = new ArrayList<String>();
yamlWriter.write(list);
yamlWriter.close();
assertEquals("[]" + LINE_SEPARATOR, stringWriter.toString());
}
use of com.esotericsoftware.yamlbeans.YamlConfig in project yamlbeans by EsotericSoftware.
the class EmitterTest method testStateFlowMapingKeyCanonicalIsTrue.
@Test
public void testStateFlowMapingKeyCanonicalIsTrue() throws EmitterException, IOException {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("key1", "value1");
map.put("key2", "value2");
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.writeConfig.setFlowStyle(true);
yamlConfig.writeConfig.setWriteRootTags(false);
yamlConfig.writeConfig.setCanonical(true);
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write(map);
yamlWriter.close();
assertEquals("--- " + LINE_SEPARATOR + "{" + LINE_SEPARATOR + " ? !java.lang.String \"key1\"" + LINE_SEPARATOR + " : !java.lang.String \"value1\"," + LINE_SEPARATOR + " ? !java.lang.String \"key2\"" + LINE_SEPARATOR + " : !java.lang.String \"value2\"" + LINE_SEPARATOR + "}" + LINE_SEPARATOR, stringWriter.toString());
}
use of com.esotericsoftware.yamlbeans.YamlConfig in project yamlbeans by EsotericSoftware.
the class EmitterWriterTest method testWriteDoubleQuoted.
@Test
public void testWriteDoubleQuoted() throws YamlException {
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.writeConfig.setQuoteChar(Quote.DOUBLE);
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write("\u0001\u0011\u0111\u1111\u0007");
yamlWriter.close();
assertEquals("\"\\u0001\\u0011\\u0111\\u1111\\a\"" + LINE_SEPARATOR, stringWriter.toString());
stringWriter = new StringWriter();
yamlConfig.writeConfig.setWrapColumn(5);
yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write("testt est");
yamlWriter.close();
assertEquals("\"testt\\" + LINE_SEPARATOR + " \\ e\\" + LINE_SEPARATOR + " st\"" + LINE_SEPARATOR, stringWriter.toString());
}
use of com.esotericsoftware.yamlbeans.YamlConfig in project yamlbeans by EsotericSoftware.
the class EmitterWriterTest method testWriteSingleQuoted.
@Test
public void testWriteSingleQuoted() throws YamlException {
YamlConfig yamlConfig = new YamlConfig();
yamlConfig.writeConfig.setQuoteChar(Quote.SINGLE);
StringWriter stringWriter = new StringWriter();
YamlWriter yamlWriter = new YamlWriter(stringWriter, yamlConfig);
yamlWriter.write("\ntest");
yamlWriter.close();
assertEquals("\'" + LINE_SEPARATOR + " test\'" + LINE_SEPARATOR, stringWriter.toString());
}
Aggregations