summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-03-03 11:19:47 (EST)
committer Steffen Pingel2012-03-03 11:19:47 (EST)
commitba9ff548c30b5ad4b9f35c8d4b10ff90e5eb291f (patch)
tree2735c00ca8ae6206265496642b2f579b4e7261a0
parent4ec3e15f91f15e89e65137a977cb379b99ee4a25 (diff)
downloadorg.eclipse.mylyn.commons-ba9ff548c30b5ad4b9f35c8d4b10ff90e5eb291f.zip
org.eclipse.mylyn.commons-ba9ff548c30b5ad4b9f35c8d4b10ff90e5eb291f.tar.gz
org.eclipse.mylyn.commons-ba9ff548c30b5ad4b9f35c8d4b10ff90e5eb291f.tar.bz2
RESOLVED - bug 372971: force proxy configuration
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372971 Change-Id: Ia2406e83383378fb90bea74cf98dd70fd8914c53
-rw-r--r--org.eclipse.mylyn.commons.repositories.http.tests/src/org/eclipse/mylyn/commons/repositories/http/tests/CommonHttpClientTest.java6
-rw-r--r--org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java45
-rw-r--r--org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ManagedTestSuite.java46
3 files changed, 52 insertions, 45 deletions
diff --git a/org.eclipse.mylyn.commons.repositories.http.tests/src/org/eclipse/mylyn/commons/repositories/http/tests/CommonHttpClientTest.java b/org.eclipse.mylyn.commons.repositories.http.tests/src/org/eclipse/mylyn/commons/repositories/http/tests/CommonHttpClientTest.java
index 660ec4e..338053f 100644
--- a/org.eclipse.mylyn.commons.repositories.http.tests/src/org/eclipse/mylyn/commons/repositories/http/tests/CommonHttpClientTest.java
+++ b/org.eclipse.mylyn.commons.repositories.http.tests/src/org/eclipse/mylyn/commons/repositories/http/tests/CommonHttpClientTest.java
@@ -39,6 +39,7 @@ import org.eclipse.mylyn.commons.repositories.http.core.HttpRequestProcessor;
import org.eclipse.mylyn.commons.repositories.http.core.HttpUtil;
import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
import org.eclipse.mylyn.internal.commons.repositories.http.core.PollingSslProtocolSocketFactory;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -46,6 +47,11 @@ import org.junit.Test;
*/
public class CommonHttpClientTest {
+ @BeforeClass
+ public static void setUpClass() {
+ CommonTestUtil.fixProxyConfiguration();
+ }
+
@Test
public void testCertificateAuthenticationCertificate() throws Exception {
if (CommonTestUtil.isCertificateAuthBroken()) {
diff --git a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java
index d4351c1..e8b9cd7 100644
--- a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java
+++ b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/CommonTestUtil.java
@@ -18,13 +18,19 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintStream;
import java.io.Writer;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.Enumeration;
+import java.util.Map.Entry;
import java.util.Properties;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -35,8 +41,10 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.mylyn.commons.core.CoreUtil;
+import org.eclipse.mylyn.commons.net.WebUtil;
import org.eclipse.mylyn.commons.repositories.core.auth.CertificateCredentials;
import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials;
+import org.eclipse.mylyn.internal.commons.net.CommonsNetPlugin;
import org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
@@ -319,7 +327,7 @@ public class CommonTestUtil {
}
public static boolean runHeartbeatTestsOnly() {
- return !Boolean.parseBoolean(System.getProperty("org.eclipse.mylyn.tests.all"));
+ return !Boolean.parseBoolean(System.getProperty("org.eclipse.mylyn.tests.all", "true"));
};
/**
@@ -456,4 +464,39 @@ public class CommonTestUtil {
return username;
}
+ public static void fixProxyConfiguration() {
+ if (Platform.isRunning() && CommonsNetPlugin.getProxyService() != null
+ && CommonsNetPlugin.getProxyService().isSystemProxiesEnabled()
+ && !CommonsNetPlugin.getProxyService().hasSystemProxies()) {
+ // XXX e3.5/gtk.x86_64 activate manual proxy configuration which
+ // defaults to Java system properties if system proxy support is
+ // not available
+ System.err.println("Forcing manual proxy configuration");
+ CommonsNetPlugin.getProxyService().setSystemProxiesEnabled(false);
+ CommonsNetPlugin.getProxyService().setProxiesEnabled(true);
+ }
+ }
+
+ public static void dumpSystemInfo(PrintStream out) {
+ Properties p = System.getProperties();
+ if (Platform.isRunning()) {
+ p.put("build.system", Platform.getOS() + "-" + Platform.getOSArch() + "-" + Platform.getWS());
+ } else {
+ p.put("build.system", "standalone");
+ }
+ String info = "System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
+ for (Entry<Object, Object> entry : p.entrySet()) {
+ info = info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"), entry.getValue().toString());
+ }
+ out.println(info);
+ out.print("Proxy : " + WebUtil.getProxyForUrl("http://mylyn.eclipse.org") + " (Platform)");
+ try {
+ out.print(" / " + ProxySelector.getDefault().select(new URI("http://mylyn.eclipse.org")) + " (Java)");
+ } catch (URISyntaxException e) {
+ // ignore
+ }
+ out.println();
+ out.println();
+ }
+
}
diff --git a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ManagedTestSuite.java b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ManagedTestSuite.java
index 3f653c0..114b20d 100644
--- a/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ManagedTestSuite.java
+++ b/org.eclipse.mylyn.commons.sdk.util/src/org/eclipse/mylyn/commons/sdk/util/ManagedTestSuite.java
@@ -11,18 +11,12 @@
package org.eclipse.mylyn.commons.sdk.util;
-import java.net.ProxySelector;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Pattern;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
@@ -31,10 +25,6 @@ import junit.framework.TestListener;
import junit.framework.TestResult;
import junit.framework.TestSuite;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.mylyn.commons.net.WebUtil;
-import org.eclipse.mylyn.internal.commons.net.CommonsNetPlugin;
-
/**
* Prints the name of each test to System.err when it started and dumps a stack trace of all thread to System.err if a
* test takes longer than 10 minutes.
@@ -155,7 +145,8 @@ public class ManagedTestSuite extends TestSuite {
@Override
public void run(TestResult result) {
result.addListener(listener);
- dumpSystemInfo();
+ CommonTestUtil.fixProxyConfiguration();
+ CommonTestUtil.dumpSystemInfo(System.err);
super.run(result);
listener.dumpResults(result);
@@ -176,37 +167,4 @@ public class ManagedTestSuite extends TestSuite {
}, true);
}
- private static void dumpSystemInfo() {
- if (Platform.isRunning() && CommonsNetPlugin.getProxyService() != null
- && CommonsNetPlugin.getProxyService().isSystemProxiesEnabled()
- && !CommonsNetPlugin.getProxyService().hasSystemProxies()) {
- // XXX e3.5/gtk.x86_64 activate manual proxy configuration which
- // defaults to Java system properties if system proxy support is
- // not available
- System.err.println("Forcing manual proxy configuration");
- CommonsNetPlugin.getProxyService().setSystemProxiesEnabled(false);
- CommonsNetPlugin.getProxyService().setProxiesEnabled(true);
- }
-
- Properties p = System.getProperties();
- if (Platform.isRunning()) {
- p.put("build.system", Platform.getOS() + "-" + Platform.getOSArch() + "-" + Platform.getWS());
- } else {
- p.put("build.system", "standalone");
- }
- String info = "System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
- for (Entry<Object, Object> entry : p.entrySet()) {
- info = info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"), entry.getValue().toString());
- }
- System.err.println(info);
- System.err.print("Proxy : " + WebUtil.getProxyForUrl("http://mylyn.eclipse.org") + " (Platform)");
- try {
- System.err.print(" / " + ProxySelector.getDefault().select(new URI("http://mylyn.eclipse.org")) + " (Java)");
- } catch (URISyntaxException e) {
- // ignore
- }
- System.err.println();
- System.err.println();
- }
-
}