Search in sources :

Example 6 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class ProxiesTest method loadTestConfig.

private CeylonConfig loadTestConfig(String configName) throws IOException {
    String filename = "test/src/org/eclipse/ceylon/common/test/" + configName;
    CeylonConfig testConfig = loadConfig(filename);
    return testConfig;
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig)

Example 7 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class ProxiesTest method testProxyWithAlias.

@Test
public void testProxyWithAlias() throws Exception {
    CeylonConfig testConfig = loadTestConfig("proxy+alias.config");
    createStore(testConfig, new File("keystore"), null).setPassword("proxy-password", "ffff".toCharArray(), "mypassword".toCharArray());
    Proxies proxies = getProxies(testConfig);
    Proxy proxy = proxies.getProxy();
    Assert.assertEquals("myproxy", proxy.getHost());
    Assert.assertEquals(1234, proxy.getPort());
    Authentication auth = Authentication.fromConfig(testConfig);
    Assert.assertNotNull(auth.getProxyAuthenticator());
    auth.installProxy();
    mockPrompt.prompts.put("Password for default keystore (keystore):", "ffff");
    PasswordAuthentication up = Authenticator.requestPasswordAuthentication(null, 80, "ceylon-lang.org", "Hello, world", "fnar");
    Assert.assertEquals("me", up.getUserName());
    Assert.assertEquals("mypassword", new String(up.getPassword()));
    InetSocketAddress address = (InetSocketAddress) auth.getProxy().address();
    Assert.assertEquals("myproxy", address.getHostName());
    Assert.assertEquals(1234, address.getPort());
    List<java.net.Proxy> selectedProxies = auth.getProxySelector().select(URI.create("anything"));
    Assert.assertEquals(1, selectedProxies.size());
    Assert.assertEquals(java.net.Proxy.Type.HTTP, selectedProxies.get(0).type());
    Assert.assertEquals("myproxy", ((InetSocketAddress) selectedProxies.get(0).address()).getHostName());
    Assert.assertEquals(1234, ((InetSocketAddress) selectedProxies.get(0).address()).getPort());
    // Check there were no prompts
    mockPrompt.assertSeenOnlyGivenPrompts();
}
Also used : Proxy(org.eclipse.ceylon.common.config.Proxies.Proxy) Proxies(org.eclipse.ceylon.common.config.Proxies) CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) Authentication(org.eclipse.ceylon.common.config.Authentication) PasswordAuthentication(java.net.PasswordAuthentication) InetSocketAddress(java.net.InetSocketAddress) File(java.io.File) PasswordAuthentication(java.net.PasswordAuthentication) Test(org.junit.Test)

Example 8 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class ProxiesTest method testProxyNone.

@Test
public void testProxyNone() throws Exception {
    CeylonConfig testConfig = loadTestConfig("proxy-none.config");
    createStore(testConfig, new File("keystore"), null).setPassword("proxy-password", "ffff".toCharArray(), "mypassword".toCharArray());
    Proxies proxies = getProxies(testConfig);
    Proxy proxy = proxies.getProxy();
    Assert.assertNull(proxy.getHost());
    Assert.assertEquals(8080, proxy.getPort());
    Authentication auth = Authentication.fromConfig(testConfig);
    Assert.assertNull(auth.getProxyAuthenticator());
    auth.installProxy();
    Assert.assertNull(auth.getProxyAuthenticator());
    PasswordAuthentication up = Authenticator.requestPasswordAuthentication(null, 80, "ceylon-lang.org", "Hello, world", "fnar");
    Assert.assertNull(up);
    Assert.assertNull(auth.getProxy());
    Assert.assertNull(auth.getProxySelector());
    // Check there were no prompts
    mockPrompt.assertSeenOnlyGivenPrompts();
}
Also used : Proxy(org.eclipse.ceylon.common.config.Proxies.Proxy) Proxies(org.eclipse.ceylon.common.config.Proxies) CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) Authentication(org.eclipse.ceylon.common.config.Authentication) PasswordAuthentication(java.net.PasswordAuthentication) File(java.io.File) PasswordAuthentication(java.net.PasswordAuthentication) Test(org.junit.Test)

Example 9 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class RepositoriesTest method testSetRepositories.

@Test
public void testSetRepositories() {
    CeylonConfig configCopy = testConfig.copy();
    Repositories testRepos = Repositories.withConfig(configCopy);
    Map<String, Repository[]> repomap = testRepos.getRepositories();
    Repository[] reps = { new Repositories.SimpleRepository("", "./mods", null) };
    repomap.put(Repositories.REPO_TYPE_LOCAL_LOOKUP, reps);
    testRepos.setRepositories(repomap);
    Repository[] lookup = testRepos.getLocalLookupRepositories();
    Assert.assertTrue(lookup.length == 1);
    assertRepository(lookup[0], "%lookup-1", "./mods", null, null);
}
Also used : Repositories(org.eclipse.ceylon.common.config.Repositories) Repository(org.eclipse.ceylon.common.config.Repositories.Repository) CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) Test(org.junit.Test)

Example 10 with CeylonConfig

use of org.eclipse.ceylon.common.config.CeylonConfig in project ceylon by eclipse.

the class CeylonConfigTest method testSetOptionValues.

@Test
public void testSetOptionValues() {
    CeylonConfig tmpConfig = testConfig.copy();
    Assert.assertTrue(compareStringArraysSorted(new String[] { "hello" }, tmpConfig.getOptionValues("test.string-hello")));
    tmpConfig.setOptionValues("test.string-hello", new String[] { "hello", "world" });
    Assert.assertTrue(compareStringArraysSorted(new String[] { "hello", "world" }, tmpConfig.getOptionValues("test.string-hello")));
}
Also used : CeylonConfig(org.eclipse.ceylon.common.config.CeylonConfig) 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