use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.
the class CeylonConfigTest method testCopy.
@Test
public void testCopy() {
CeylonConfig tmpConfig = testConfig.copy();
Assert.assertTrue(compareConfigs(tmpConfig, testConfig));
}
use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.
the class CeylonConfigTest method testRemoveSection.
@Test
public void testRemoveSection() {
CeylonConfig tmpConfig = testConfig.copy();
Assert.assertTrue(tmpConfig.isSectionDefined("test"));
tmpConfig.removeSection("test");
Assert.assertFalse(tmpConfig.isSectionDefined("test"));
Assert.assertFalse(tmpConfig.isOptionDefined("test.string-hello"));
}
use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.
the class CeylonConfigTest method setup.
@Before
public void setup() throws IOException {
String org = System.getProperty("ceylon.home");
try {
if (org == null) {
System.setProperty("ceylon.home", "/tmp");
}
testConfig = CeylonConfigFinder.loadConfigFromFile(new File("test/src/org/eclipse/ceylon/common/test/test.config"));
localConfig = CeylonConfigFinder.loadLocalConfig(new File("test/src/org/eclipse/ceylon/common/test"));
mergedConfig = CeylonConfigFinder.loadConfigFromFile(new File("test/src/org/eclipse/ceylon/common/test/test.config"));
CeylonConfig localConfig2 = CeylonConfigFinder.loadLocalConfig(new File("test/src/org/eclipse/ceylon/common/test"));
mergedConfig.merge(localConfig2);
} finally {
if (org == null) {
System.clearProperty("ceylon.home");
} else {
System.setProperty("ceylon.home", org);
}
}
}
use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.
the class ConfigWriterTest method testWritingAndOverwriting.
@Test
public void testWritingAndOverwriting() {
try {
File configFile = new File(testDir, ".ceylon/config");
CeylonConfig testConfigCopy = testConfig.copy();
testConfigCopy.setOption("test.quasar", "PKS 1127-145");
ConfigWriter.instance().write(testConfigCopy, configFile);
CeylonConfig localDirConfig = CeylonConfigFinder.loadLocalConfig(testDir);
localDirConfig.setOption("test.pulsar", "CP 1919");
localDirConfig.setOption("test.string-escapes2", "\n\t\"\\# ");
localDirConfig.removeOption("test.one");
localDirConfig.removeSection("test.multiple");
ConfigWriter.instance().write(localDirConfig, configFile);
String contents1 = readFile(new File("test/src/org/eclipse/ceylon/common/test/writer-overwriting.config"));
String contents2 = readFile(configFile);
Assert.assertEquals(contents1, contents2);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.
the class ConfigWriterTest method testCRUD.
@Test
public void testCRUD() throws IOException {
CeylonConfig testConfigCopy = testConfig.copy();
testConfigCopy.setOption("test.two", "twee");
testConfigCopy.setOption("test.string-hello", "hola");
testConfigCopy.setOption("test.string-world", "mundo");
testConfigCopy.setOption("test.string-spaces", " con espacios ");
testConfigCopy.setOption("test.string-multiline", "wim\nzus\njet");
testConfigCopy.setOption("test.string-multiline-with-spaces", "wim\nzus\njet");
testConfigCopy.setOption("test.string-quoted-multiline", "wim\nzus\njet ");
testConfigCopy.setOption("test.three", "tres");
testConfigCopy.setOptionValues("test.multiple.strings", new String[] { "wim", "zus" });
testConfigCopy.setOptionValues("test.section.Aap.foo", new String[] { "1", "2", "3" });
testConfigCopy.removeOption("test.section.Noot.foo");
testConfigCopy.removeOption("test.section.Mies.foo");
testConfigCopy.removeOption("test.section.Mies.fooz");
testConfigCopy.setOptionValues("test.section.Mies.bar", new String[] { "test1", "test2" });
testConfigCopy.setOptionValues("test.newsection.baz", new String[] { "qed", "qam" });
testConfigCopy.setOption("anothersection.buzz", "lightyear");
String contents = readFile(new File("test/src/org/eclipse/ceylon/common/test/writer-crud.config"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
ConfigWriter.instance().write(testConfigCopy, testFile, out);
Assert.assertEquals(contents, out.toString("UTF-8"));
}
Aggregations