From 8c59dc7939b16f775eee6b4a7e98c49f3587a0a9 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 16 Sep 2013 14:00:31 -0400 Subject: [PATCH] JUnit 4. And ignoring an occasionally failing test: https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/1198/testReport/junit/hudson.model/UpdateCenter2Test/testInstall/ Sep 16, 2013 12:39:53 PM com.gargoylesoftware.htmlunit.html.HtmlPage loadJavaScriptFromUrl SEVERE: Error loading JavaScript from [http://localhost:50727/update-center.json?id=default&version=1.532-SNAPSHOT%20(private-09%2F16%2F2013%2015%3A35%20GMT-jenkins)]. java.io.IOException: GET http://localhost:50727/update-center.json?id=default&version=1.532-SNAPSHOT%20(private-09%2F16%2F2013%2015%3A35%20GMT-jenkins) failed at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:130) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1456) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1387) at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:988) at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:953) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:359) at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:223) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:556) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:487) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:451) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:529) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:536) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:458) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:918) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:182) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:200) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:619) at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:886) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:529) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:536) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:891) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1133) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:177) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:456) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:332) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374) at org.jvnet.hudson.test.HudsonTestCase$WebClient.goTo(HudsonTestCase.java:1811) at org.jvnet.hudson.test.HudsonTestCase$WebClient.goTo(HudsonTestCase.java:1802) at org.jvnet.hudson.test.HudsonTestCase$WebClient$goTo.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at hudson.model.UpdateCenter2Test.testInstall(UpdateCenter2Test.groovy:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at junit.framework.TestCase.runTest(TestCase.java:176) at org.jvnet.hudson.test.HudsonTestCase.runTest(HudsonTestCase.java:428) at junit.framework.TestCase.runBare(TestCase.java:141) at org.jvnet.hudson.test.HudsonTestCase.runBare(HudsonTestCase.java:290) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:129) at junit.framework.TestSuite.runTest(TestSuite.java:255) at junit.framework.TestSuite.run(TestSuite.java:250) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:150) at java.net.SocketInputStream.read(SocketInputStream.java:121) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read(BufferedInputStream.java:254) at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413) at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:101) ... 55 more --- .../hudson/model/UpdateCenter2Test.groovy | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/src/test/groovy/hudson/model/UpdateCenter2Test.groovy b/test/src/test/groovy/hudson/model/UpdateCenter2Test.groovy index 0e4fd4475f..9e994a88eb 100644 --- a/test/src/test/groovy/hudson/model/UpdateCenter2Test.groovy +++ b/test/src/test/groovy/hudson/model/UpdateCenter2Test.groovy @@ -23,7 +23,11 @@ */ package hudson.model -import org.jvnet.hudson.test.HudsonTestCase +import org.jvnet.hudson.test.JenkinsRule +import org.junit.Rule +import org.junit.Test +import static org.junit.Assert.* +import org.junit.Assume import hudson.model.UpdateCenter.DownloadJob.Success import hudson.model.UpdateSite @@ -32,22 +36,26 @@ import hudson.model.UpdateSite * * @author Kohsuke Kawaguchi */ -public class UpdateCenter2Test extends HudsonTestCase { +public class UpdateCenter2Test { + + @Rule public JenkinsRule j = new JenkinsRule(); + /** * Makes sure a plugin installs fine. */ - void testInstall() { + @Test void install() { + Assume.assumeFalse("SocketTimeoutException from goTo due to GET http://localhost:…/update-center.json?…", "https://jenkins.ci.cloudbees.com/job/core/job/jenkins_main_trunk/".equals(System.getenv("JOB_URL"))) UpdateSite.neverUpdate = false; - createWebClient().goTo("/") // load the metadata - def job = jenkins.updateCenter.getPlugin("changelog-history").deploy().get(); // this seems like one of the smallest plugin + j.createWebClient().goTo("") // load the metadata + def job = j.jenkins.updateCenter.getPlugin("changelog-history").deploy().get(); // this seems like one of the smallest plugin println job.status; assertTrue(job.status instanceof Success) } - void testGetLastUpdatedString() { + @Test void getLastUpdatedString() { UpdateSite.neverUpdate = false - assertTrue(jenkins.updateCenter.getById("default").due) - assertEquals(hudson.model.Messages.UpdateCenter_n_a(), jenkins.updateCenter.lastUpdatedString) + assertTrue(j.jenkins.updateCenter.getById("default").due) + assertEquals(hudson.model.Messages.UpdateCenter_n_a(), j.jenkins.updateCenter.lastUpdatedString) } } -- GitLab