Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions test/src/test/java/hudson/model/UpdateCenter2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down