diff options
Diffstat (limited to 'tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java')
-rw-r--r-- | tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java index 918fee7b0..e5718e65b 100644 --- a/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java +++ b/tests/org.eclipse.core.tests.net/src/org/eclipse/core/tests/net/SystemProxyTest.java @@ -13,49 +13,38 @@ *******************************************************************************/ package org.eclipse.core.tests.net; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - import org.eclipse.core.internal.net.ProxyData; import org.eclipse.core.internal.net.ProxySelector; import org.eclipse.core.net.proxy.IProxyData; import org.eclipse.core.net.proxy.IProxyService; +import org.junit.*; -public class SystemProxyTest extends TestCase { +public class SystemProxyTest { private boolean isProxiesDefault; private boolean isSystemProxiesDefault; private Map<String, IProxyData> proxyDataMap = new HashMap<>(); - public SystemProxyTest() { - super(); - } - - public SystemProxyTest(String name) { - super(name); - } - - public static Test suite() { - return new TestSuite(SystemProxyTest.class); - } - - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp() throws Exception { isSystemProxiesDefault = isSystemProxiesEnabled(); setSystemProxiesEnabled(true); isProxiesDefault = isProxiesEnabled(); setProxiesEnabled(true); } - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void tearDown() throws Exception { setProxiesEnabled(isProxiesDefault); setSystemProxiesEnabled(isSystemProxiesDefault); IProxyData[] data = getProxyManager().getProxyData(); @@ -79,8 +68,7 @@ public class SystemProxyTest extends TestCase { private void setProxiesEnabled(boolean enabled) { this.getProxyManager().setProxiesEnabled(enabled); - if (enabled && this.getProxyManager().isSystemProxiesEnabled() - && !this.getProxyManager().hasSystemProxies()) { + if (enabled && this.getProxyManager().isSystemProxiesEnabled() && !this.getProxyManager().hasSystemProxies()) { assertEquals(false, this.getProxyManager().isProxiesEnabled()); } else { assertEquals(enabled, this.getProxyManager().isProxiesEnabled()); @@ -100,8 +88,7 @@ public class SystemProxyTest extends TestCase { assertEquals(expectedData.getPort(), data.getPort()); assertEquals(expectedData.getUserId(), data.getUserId()); assertEquals(expectedData.getPassword(), data.getPassword()); - assertEquals(expectedData.isRequiresAuthentication(), data - .isRequiresAuthentication()); + assertEquals(expectedData.isRequiresAuthentication(), data.isRequiresAuthentication()); assertEquals(expectedData.getSource(), data.getSource()); } @@ -139,36 +126,40 @@ public class SystemProxyTest extends TestCase { } /** - * This test needs system env set. See {@link #initializeTestProxyData()} - * for values. + * This test needs system env set. See {@link #initializeTestProxyData()} for + * values. */ + @Test public void testGetProxyDataForHost_LinuxEnvSettings() { initializeTestProxyData("LINUX_ENV"); checkGetProxyDataForHost(); } /** - * This test needs system env set. See {@link #initializeTestProxyData()} - * for values. + * This test needs system env set. See {@link #initializeTestProxyData()} for + * values. */ + @Test public void testProxySelector_LinuxEnvSettings() { initializeTestProxyData("LINUX_ENV"); checkProxySelector(); } /** - * This test needs Gnome settings set. See - * {@link #initializeTestProxyData()} for values. + * This test needs Gnome settings set. See {@link #initializeTestProxyData()} + * for values. */ + @Test public void testGetProxyDataForHost_LinuxGnomeSettings() { initializeTestProxyData("LINUX_GNOME"); checkGetProxyDataForHost(); } /** - * This test needs Gnome settings set. See - * {@link #initializeTestProxyData()} for values. + * This test needs Gnome settings set. See {@link #initializeTestProxyData()} + * for values. */ + @Test public void testProxySelector_LinuxGnomeSettings() { initializeTestProxyData("LINUX_GNOME"); checkProxySelector(); @@ -178,6 +169,7 @@ public class SystemProxyTest extends TestCase { * This test needs Windows IE settings manually set. See * {@link #initializeTestProxyData()} for values. */ + @Test public void testGetProxyDataForHost_WindowsIEManualSettings() { initializeTestProxyData("WINDOWS_IE"); checkGetProxyDataForHost(); @@ -187,6 +179,7 @@ public class SystemProxyTest extends TestCase { * This test needs Windows IE settings manually set. See * {@link #initializeTestProxyData()} for values. */ + @Test public void testProxySelector_WindowsIEManualSettings() { initializeTestProxyData("WINDOWS_IE"); checkProxySelector(); @@ -195,47 +188,38 @@ public class SystemProxyTest extends TestCase { /** * This test needs Windows IE settings manually set. See * {@link #initializeTestProxyData()} for values. Additionally set - * <code>"eclipse.*;nonexisting.com;*.eclipse.org;www.*.com;*.test.*"</code> - * as proxy bypass in the IE settings. + * <code>"eclipse.*;nonexisting.com;*.eclipse.org;www.*.com;*.test.*"</code> as + * proxy bypass in the IE settings. * * @throws URISyntaxException */ - public void testNonProxiedHosts_WindowsIEManualSettings() - throws URISyntaxException { - IProxyData[] proxiesData = getProxyManager().select( - new URI("http://eclipse")); + @Test + public void testNonProxiedHosts_WindowsIEManualSettings() throws URISyntaxException { + IProxyData[] proxiesData = getProxyManager().select(new URI("http://eclipse")); assertEquals(1, proxiesData.length); - proxiesData = getProxyManager().select( - new URI("http://eclipse.org/bugs")); + proxiesData = getProxyManager().select(new URI("http://eclipse.org/bugs")); assertEquals(0, proxiesData.length); - proxiesData = getProxyManager().select( - new URI("http://nonexisting.com")); + proxiesData = getProxyManager().select(new URI("http://nonexisting.com")); assertEquals(0, proxiesData.length); - proxiesData = getProxyManager().select( - new URI("http://www.eclipse.org")); + proxiesData = getProxyManager().select(new URI("http://www.eclipse.org")); assertEquals(0, proxiesData.length); - proxiesData = getProxyManager().select( - new URI("http://www.myDomain.com")); + proxiesData = getProxyManager().select(new URI("http://www.myDomain.com")); assertEquals(0, proxiesData.length); - proxiesData = getProxyManager().select( - new URI("http://www.test.edu")); + proxiesData = getProxyManager().select(new URI("http://www.test.edu")); assertEquals(0, proxiesData.length); } private void initializeTestProxyData(String proxyDataSource) { - proxyDataMap.put(IProxyData.HTTP_PROXY_TYPE, new ProxyData( - IProxyData.HTTP_PROXY_TYPE, "127.0.0.1", 8081, false, - proxyDataSource)); - proxyDataMap.put(IProxyData.HTTPS_PROXY_TYPE, new ProxyData( - IProxyData.HTTPS_PROXY_TYPE, "127.0.0.2", 8082, false, - proxyDataSource)); - proxyDataMap.put(IProxyData.SOCKS_PROXY_TYPE, new ProxyData( - IProxyData.SOCKS_PROXY_TYPE, "127.0.0.3", 8083, false, - proxyDataSource)); + proxyDataMap.put(IProxyData.HTTP_PROXY_TYPE, + new ProxyData(IProxyData.HTTP_PROXY_TYPE, "127.0.0.1", 8081, false, proxyDataSource)); + proxyDataMap.put(IProxyData.HTTPS_PROXY_TYPE, + new ProxyData(IProxyData.HTTPS_PROXY_TYPE, "127.0.0.2", 8082, false, proxyDataSource)); + proxyDataMap.put(IProxyData.SOCKS_PROXY_TYPE, + new ProxyData(IProxyData.SOCKS_PROXY_TYPE, "127.0.0.3", 8083, false, proxyDataSource)); } }
\ No newline at end of file |