Search in sources :

Example 11 with CeylonConfig

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));
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) Test(org.junit.Test)

Example 12 with CeylonConfig

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"));
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) Test(org.junit.Test)

Example 13 with CeylonConfig

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);
        }
    }
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) File(java.io.File) Before(org.junit.Before)

Example 14 with CeylonConfig

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);
    }
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) IOException(java.io.IOException) File(java.io.File) Test(org.junit.Test)

Example 15 with CeylonConfig

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"));
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Test(org.junit.Test)

Aggregations

CeylonConfig (org.eclipse.ceylon.common.config.CeylonConfig)28 Test (org.junit.Test)16 File (java.io.File)12 Authentication (org.eclipse.ceylon.common.config.Authentication)7 Proxy (org.eclipse.ceylon.common.config.Proxies.Proxy)7 PasswordAuthentication (java.net.PasswordAuthentication)6 Proxies (org.eclipse.ceylon.common.config.Proxies)6 InetSocketAddress (java.net.InetSocketAddress)5 Repositories (org.eclipse.ceylon.common.config.Repositories)3 Repository (org.eclipse.ceylon.common.config.Repositories.Repository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 BuildException (org.apache.tools.ant.BuildException)2 CeylonBaseTool (org.eclipse.ceylon.common.tool.CeylonBaseTool)2 Before (org.junit.Before)2 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 HashSet (java.util.HashSet)1