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;
}
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();
}
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();
}
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);
}
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")));
}
Aggregations