diff --git a/test/src/test/java/hudson/model/UpdateCenter2Test.java b/test/src/test/java/hudson/model/UpdateCenter2Test.java index 671d10ca4715..3abf854db1c8 100644 --- a/test/src/test/java/hudson/model/UpdateCenter2Test.java +++ b/test/src/test/java/hudson/model/UpdateCenter2Test.java @@ -27,6 +27,7 @@ import hudson.model.UpdateCenter.DownloadJob.Success; import hudson.model.UpdateCenter.DownloadJob.Failure; import static org.junit.Assert.*; +import static org.junit.Assume.assumeNotNull; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.Issue; @@ -48,7 +49,9 @@ public class UpdateCenter2Test { @Test public void install() throws Exception { UpdateSite.neverUpdate = false; j.jenkins.pluginManager.doCheckUpdatesServer(); // load the metadata - DownloadJob job = (DownloadJob) j.jenkins.getUpdateCenter().getPlugin("changelog-history").deploy().get(); // this seems like one of the smallest plugin + UpdateSite.Plugin plugin = j.jenkins.getUpdateCenter().getPlugin("changelog-history"); + assumeNotNull(plugin); + DownloadJob job = (DownloadJob) plugin.deploy().get(); // this seems like one of the smallest plugin System.out.println(job.status); assertTrue(job.status instanceof Success); } @@ -66,8 +69,10 @@ public class UpdateCenter2Test { String wrongChecksum = "ABCDEFG1234567890"; // usually the problem is the file having a wrong checksum, but changing the expected one works just the same - j.jenkins.getUpdateCenter().getSite("default").getPlugin("changelog-history").sha512 = wrongChecksum; - DownloadJob job = (DownloadJob) j.jenkins.getUpdateCenter().getPlugin("changelog-history").deploy().get(); + UpdateSite.Plugin plugin = j.jenkins.getUpdateCenter().getSite("default").getPlugin("changelog-history"); + assumeNotNull(plugin); + plugin.sha512 = wrongChecksum; + DownloadJob job = (DownloadJob) plugin.deploy().get(); assertTrue(job.status instanceof Failure); assertTrue("error message references checksum", ((Failure) job.status).problem.getMessage().contains(wrongChecksum)); } diff --git a/test/src/test/java/hudson/model/UpdateCenterPluginInstallTest.java b/test/src/test/java/hudson/model/UpdateCenterPluginInstallTest.java index fe651a8263c9..cae5ae3f9892 100644 --- a/test/src/test/java/hudson/model/UpdateCenterPluginInstallTest.java +++ b/test/src/test/java/hudson/model/UpdateCenterPluginInstallTest.java @@ -26,7 +26,7 @@ import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.junit.Assert; -import org.junit.Assume; +import static org.junit.Assume.*; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; @@ -44,10 +44,14 @@ public class UpdateCenterPluginInstallTest { @Rule public JenkinsRule jenkinsRule = new JenkinsRule(); - public void setup() throws IOException { - jenkinsRule.jenkins.getUpdateCenter().getSite(UpdateCenter.ID_DEFAULT).updateDirectlyNow(false); + private void setup() { + try { + jenkinsRule.jenkins.getUpdateCenter().getSite(UpdateCenter.ID_DEFAULT).updateDirectlyNow(false); + } catch (Exception x) { + assumeNoException(x); + } InetSocketAddress address = new InetSocketAddress("updates.jenkins-ci.org", 80); - Assume.assumeFalse("Unable to resolve updates.jenkins-ci.org. Skip test.", address.isUnresolved()); + assumeFalse("Unable to resolve updates.jenkins-ci.org. Skip test.", address.isUnresolved()); } @Test