Skip to content

Commit

Permalink
Merge pull request #293 from basil/pom-cleanup
Browse files Browse the repository at this point in the history
Clean up build
  • Loading branch information
jglick committed Dec 16, 2021
2 parents fc8f8f7 + d51d78a commit 2a13b90
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 64 deletions.
34 changes: 15 additions & 19 deletions core/pom.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down Expand Up @@ -51,11 +52,6 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down Expand Up @@ -111,6 +107,12 @@
<version>20110809</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -119,6 +121,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
Expand All @@ -128,22 +131,27 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>htmlunit</artifactId>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness-htmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jolira</groupId>
Expand All @@ -165,25 +173,13 @@
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>test-annotations</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

18 changes: 9 additions & 9 deletions core/src/test/java/org/kohsuke/stapler/DispatcherTest.java
Expand Up @@ -5,7 +5,7 @@
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.TextPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebRequest;
import org.apache.commons.io.IOUtils;
import org.kohsuke.stapler.interceptor.RequirePOST;
import org.kohsuke.stapler.json.JsonBody;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void testVerbMatch() throws Exception {
}

private void check(WebClient wc, HttpMethod m) throws java.io.IOException {
TextPage p = wc.getPage(new WebRequestSettings(new URL(url, "verbMatch/"), m));
TextPage p = wc.getPage(new WebRequest(new URL(url, "verbMatch/"), m));
assertEquals("Got " + m.name(), p.getContent());
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public void testInterceptorStage() throws Exception {
assertEquals(404, e.getStatusCode());
}

WebRequestSettings req = new WebRequestSettings(new URL(url, "interceptorStage/foo"), HttpMethod.POST);
WebRequest req = new WebRequest(new URL(url, "interceptorStage/foo"), HttpMethod.POST);
req.setAdditionalHeader("Content-Type","application/json");
req.setRequestBody("{x:3,y:5}");
TextPage p = wc.getPage(req);
Expand All @@ -163,7 +163,7 @@ public void testInterceptorStageContentTypeWithCharset() throws Exception {
assertEquals(404, e.getStatusCode());
}

WebRequestSettings req = new WebRequestSettings(new URL(url, "interceptorStage/foo"), HttpMethod.POST);
WebRequest req = new WebRequest(new URL(url, "interceptorStage/foo"), HttpMethod.POST);
req.setAdditionalHeader("Content-Type","application/json; charset=utf-8");
req.setRequestBody("{x:3,y:5}");
TextPage p = wc.getPage(req);
Expand Down Expand Up @@ -227,7 +227,7 @@ public void testPutInheritance() throws Exception {
WebClient wc = new WebClient();

// the request should get to the overriding method and it should still see all the annotations in the base type
WebRequestSettings wrs = new WebRequestSettings(new URL(url, "putInheritance/foo"), HttpMethod.PUT);
WebRequest wrs = new WebRequest(new URL(url, "putInheritance/foo"), HttpMethod.PUT);
wrs.setRequestBody("Hello");
TextPage p = wc.getPage(wrs);
assertEquals("Hello World!", p.getContent());
Expand All @@ -241,7 +241,7 @@ public void testPutInheritance() throws Exception {
}

//Invoke Post as well
wrs = new WebRequestSettings(new URL(url, "putInheritance/acme"), HttpMethod.POST);
wrs = new WebRequest(new URL(url, "putInheritance/acme"), HttpMethod.POST);
wrs.setRequestBody("Hello");
p = wc.getPage(wrs);
assertEquals("POST: Hello", p.getContent());
Expand All @@ -255,14 +255,14 @@ public void testInterfaceMethods() throws Exception {
} catch (FailingHttpStatusCodeException x) {
assertEquals(HttpServletResponse.SC_METHOD_NOT_ALLOWED, x.getStatusCode());
}
assertEquals("default", wc.getPage(new WebRequestSettings(new URL(url, "usesInterfaceMethods/foo"), HttpMethod.POST)).getWebResponse().getContentAsString().trim());
assertEquals("default", wc.getPage(new WebRequest(new URL(url, "usesInterfaceMethods/foo"), HttpMethod.POST)).getWebResponse().getContentAsString().trim());
try {
wc.getPage(new URL(url, "overridesInterfaceMethods/foo"));
fail();
} catch (FailingHttpStatusCodeException x) {
assertEquals(HttpServletResponse.SC_METHOD_NOT_ALLOWED, x.getStatusCode());
}
assertEquals("due to UnionAnnotatedElement it is even inherited", "overridden", wc.getPage(new WebRequestSettings(new URL(url, "overridesInterfaceMethods/foo"), HttpMethod.POST)).getWebResponse().getContentAsString().trim());
assertEquals("due to UnionAnnotatedElement it is even inherited", "overridden", wc.getPage(new WebRequest(new URL(url, "overridesInterfaceMethods/foo"), HttpMethod.POST)).getWebResponse().getContentAsString().trim());
}
public interface InterfaceWithWebMethods {
@RequirePOST
Expand Down Expand Up @@ -309,7 +309,7 @@ public void testRequirePostOnBase() throws Exception {
}

// POST should succeed
wc.getPage(new WebRequestSettings(url, HttpMethod.POST));
wc.getPage(new WebRequest(url, HttpMethod.POST));
assertEquals(1, requirePostOnBase.hit);
}

Expand Down
13 changes: 7 additions & 6 deletions core/src/test/java/org/kohsuke/stapler/Stapler2Test.java
Expand Up @@ -26,8 +26,10 @@

package org.kohsuke.stapler;

import static org.junit.Assert.assertThrows;

import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebResponse;
import java.net.URL;
import javax.servlet.http.HttpServletResponse;
import org.jvnet.hudson.test.For;
Expand All @@ -40,16 +42,15 @@ public class Stapler2Test extends JettyTestCase {
@Issue("SECURITY-390")
public void testTraceXSS() throws Exception {
WebClient wc = new WebClient();
wc.setThrowExceptionOnFailingStatusCode(false);
WebResponse rsp;
FailingHttpStatusCodeException exc;
Dispatcher.TRACE = true;
try {
rsp = wc.getPage(new URL(this.url, "thing/<button>/x")).getWebResponse();
exc = assertThrows(FailingHttpStatusCodeException.class, () -> wc.getPage(new URL(this.url, "thing/<button>/x")).getWebResponse());
} finally {
Dispatcher.TRACE = false;
}
assertEquals(HttpServletResponse.SC_NOT_FOUND, rsp.getStatusCode());
String html = rsp.getContentAsString();
assertEquals(HttpServletResponse.SC_NOT_FOUND, exc.getStatusCode());
String html = exc.getResponse().getContentAsString();
assertTrue(html, html.contains("&lt;button&gt;"));
assertFalse(html, html.contains("<button>"));
}
Expand Down
Expand Up @@ -42,11 +42,15 @@ public void handleAlert(Page page, String message) {
HtmlPage page = wc.getPage(new URL(url, "/"));

page.executeJavaScript("v.foo(3,'test',callback);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);
assertEquals("string:test3",msg[0]);
msg[0] = null;

// test null unmarshalling and marshalling
page.executeJavaScript("v.foo(0,null,callback);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);
assertEquals("object:null",msg[0]);
}

Expand All @@ -57,6 +61,8 @@ public void testAnonymousBind() throws Exception {
WebClient wc = new WebClient();
HtmlPage page = wc.getPage(new URL(url, "/bindAnonymous"));
page.executeJavaScript("v.xyz('hello');");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);
assertEquals("hello",anonymousValue);
}

Expand Down
Expand Up @@ -38,6 +38,8 @@ public void handleAlert(Page page, String message) {
HtmlPage page = wc.getPage(new URL(url, "/"));

page.executeJavaScript("v.getSomeExcludedData(callback);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);

Map json = (Map)JSON.parse(msg[0]);
assertTrue(json.containsKey("name"));
Expand All @@ -57,6 +59,8 @@ public void handleAlert(Page page, String message) {
HtmlPage page = wc.getPage(new URL(url, "/"));

page.executeJavaScript("v.getSomeIncludedData(callback);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);

Map json = (Map)JSON.parse(msg[0]);
assertTrue(json.containsKey("name"));
Expand All @@ -76,6 +80,8 @@ public void handleAlert(Page page, String message) {
HtmlPage page = wc.getPage(new URL(url, "/"));

page.executeJavaScript("v.getSomeExcludedList(callback);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);

Object[] json = (Object[])JSON.parse(msg[0]);
assertEquals(3, json.length);
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/org/kohsuke/stapler/json/JsonBodyTest.java
Expand Up @@ -2,15 +2,15 @@

import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
import java.net.URL;
import org.kohsuke.stapler.test.JettyTestCase;

public class JsonBodyTest extends JettyTestCase {

public void testSmokes() throws Exception {
WebRequestSettings req = new WebRequestSettings(new URL(url, "double"), HttpMethod.POST);
WebRequest req = new WebRequest(new URL(url, "double"), HttpMethod.POST);
req.setAdditionalHeader("Content-Type", "application/json");
req.setRequestBody("{\"x\":10,\"y\":5}");
WebResponse response = new WebClient().getPage(req).getWebResponse();
Expand Down
Expand Up @@ -29,7 +29,7 @@ public void testMainFeature() throws Exception {
HtmlPage page = wc.getPage(new URL(url, "/form.html"));
HtmlForm f = page.getFormByName("main");
f.getInputByName("json").setValueAttribute("{\"first\":\"Kohsuke\",\"last\":\"Kawaguchi\"}");
f.submit();
f.submit(null);
}

public HttpResponse doSubmit(@SubmittedForm JSONObject o) {
Expand Down
2 changes: 2 additions & 0 deletions groovy/pom.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down Expand Up @@ -48,6 +49,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Expand Down
15 changes: 8 additions & 7 deletions jelly/pom.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down Expand Up @@ -36,10 +37,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
Expand Down Expand Up @@ -73,8 +70,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>htmlunit</artifactId>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness-htmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
Expand All @@ -90,23 +88,26 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.hudson</groupId>
<artifactId>commons-jelly-tags-define</artifactId>
<version>1.0.1-hudson-20071021</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
Expand Up @@ -33,6 +33,8 @@ public void test1() throws Exception {
//Check that prototype is included in the page
assertFalse(content.contains("/am/org/kohsuke/stapler/framework/prototype/prototype.js"));
page.executeJavaScript("v.foo('hello world', 2);");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);
assertEquals("hello world",value);
assertEquals(2, number);
}
Expand Down
Expand Up @@ -30,6 +30,8 @@ public void test1() throws Exception {
//Check that prototype is included in the page
assertTrue(content.contains("/am/org/kohsuke/stapler/framework/prototype/prototype.js"));
page.executeJavaScript("v.foo('hello world');");
wc.getJavaScriptEngine().processPostponedActions();
wc.waitForBackgroundJavaScript(10000);
assertEquals("hello world",value);
}

Expand Down
1 change: 1 addition & 0 deletions jrebel/pom.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
Expand Down

0 comments on commit 2a13b90

Please sign in to comment.