From 08ab1b788fcdeade243f1cfcc67db2d31d19fd83 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 27 Jan 2014 12:43:31 -0800 Subject: [PATCH] Let -Dignore.random.failures work on UpdateCenterTest, which is currently failing and so blocking validated merge. --- .../test/java/hudson/model/UpdateCenterTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) rename {core => test}/src/test/java/hudson/model/UpdateCenterTest.java (88%) diff --git a/core/src/test/java/hudson/model/UpdateCenterTest.java b/test/src/test/java/hudson/model/UpdateCenterTest.java similarity index 88% rename from core/src/test/java/hudson/model/UpdateCenterTest.java rename to test/src/test/java/hudson/model/UpdateCenterTest.java index 380d90b38a..191dd20de1 100644 --- a/core/src/test/java/hudson/model/UpdateCenterTest.java +++ b/test/src/test/java/hudson/model/UpdateCenterTest.java @@ -29,7 +29,6 @@ import net.sf.json.JSONObject; import org.apache.commons.io.IOUtils; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.net.URL; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; @@ -46,11 +45,16 @@ import org.junit.Test; public class UpdateCenterTest { @Test public void data() throws Exception { try { - new URL("http://updates.jenkins-ci.org/").openStream(); - } catch (IOException e) { - assumeNoException("No internet connectivity", e); // JENKINS-2095 + doData(); + } catch (Exception x) { + if (Boolean.getBoolean("ignore.random.failures")) { + assumeNoException("Might be no Internet connectivity, or might start failing due to expiring certificate through no fault of code changes", x); + } else { + throw x; + } } - + } + private void doData() throws Exception { URL url = new URL("http://updates.jenkins-ci.org/update-center.json?version=build"); String jsonp = IOUtils.toString(url.openStream()); JSONObject json = JSONObject.fromObject(jsonp.substring(jsonp.indexOf('(') + 1, jsonp.lastIndexOf(')')));