As far as I can tell the following is how I need to set the global configuration properties before I attempt to do anything with my plugin, however I get an exception thrown (stack trace below) on the first line: HtmlPage p = j.createWebClient().goTo("configure");
I'm using 'org.jenkins-ci.main:jenkins-test-harness:1.596.1'
Any idea why this is not working? Is this the best way to configure global plugin properties as defined in global.jelly?
public class PluginTest {
...
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
public void configure() throws Exception {
// Set global configuration for the plugin
HtmlPage p = j.createWebClient().goTo("configure");
HtmlForm form = p.getFormByName("configure");
HtmlInput url = form.getInputByName("_.url");
url.setValueAttribute("
http://localhost:1234/");
HtmlInput apiKey = form.getInputByName("_.apiKey");
apiKey.setValueAttribute("mykey");
form.submit();
// Set job configuration
FreeStyleProject project = j.createFreeStyleProject();
SelectApplicationBuilder before = new SelectApplicationBuilder("36", "LATEST", "NONE");
project.getBuildersList().add(before);
j.submit(j.createWebClient().getPage(project,"configure").getFormByName("config"));
SelectApplicationBuilder after = project.getBuildersList().get(SelectApplicationBuilder.class);
j.assertEqualBeans(before, after, "applicationId, releaseNumber, buildNumberSource");
}
}
======= EXCEPTION START ========
EcmaError: lineNumber=[3] column=[0] lineSource=[ Event.extend(event, element);] name=[ReferenceError] sourceName=[
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js] message=[ReferenceError: "section" is not defined. (
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js#3)]
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "section" is not defined. (
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js#3)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:528)
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.executeEventListeners(EventListenersContainer.java:155)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:207)
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.JenkinsRule$WebClient.goTo(JenkinsRule.java:2024)
at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:2004)
at com.inedo.buildmaster.TriggerBuildBuilderTest.selectApplicationBuilder_configure(TriggerBuildBuilderTest.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.jvnet.hudson.test.JenkinsRule$2.evaluate(JenkinsRule.java:489)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "section" is not defined. (
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js#3)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3652)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3630)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3715)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1759)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.name(ScriptRuntime.java:1698)
at script.(
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js:3)
at script.(
http://localhost:54546/jenkins/static/da4d8661/scripts/prototype.js:5662)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:879)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:427)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:263)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3058)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:486)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:451)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522)
... 45 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "section" is not defined. (
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js#3)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3652)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3630)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3715)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1759)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.name(ScriptRuntime.java:1698)
at script.(
http://localhost:54546/jenkins/adjuncts/da4d8661/lib/form/breadcrumb-config-outline/init.js:3)
at script.(
http://localhost:54546/jenkins/static/da4d8661/scripts/prototype.js:5662)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:879)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:427)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:263)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3058)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:486)
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.executeEventListeners(EventListenersContainer.java:155)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:207)
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.JenkinsRule$WebClient.goTo(JenkinsRule.java:2024)
at org.jvnet.hudson.test.JenkinsRule$WebClient.goTo(JenkinsRule.java:2004)
at com.inedo.buildmaster.TriggerBuildBuilderTest.selectApplicationBuilder_configure(TriggerBuildBuilderTest.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.jvnet.hudson.test.JenkinsRule$2.evaluate(JenkinsRule.java:489)
at org.junit.rules.RunRules.evaluate(RunRules.java:18)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
== CALLING JAVASCRIPT ==
function (event) {
Event.extend(event, element);
handler.call(element, event);
}
======= EXCEPTION END ========