Skip to content

Commit ddf2a8b

Browse files
committed
reduce jetty dependencies
1 parent 85edd5d commit ddf2a8b

File tree

12 files changed

+51
-160
lines changed

12 files changed

+51
-160
lines changed

src/test/java/org/htmlunit/WebDriverTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.eclipse.jetty.server.Request;
5858
import org.eclipse.jetty.server.Server;
5959
import org.htmlunit.MockWebConnection.RawResponseData;
60+
import org.htmlunit.WebServerTestCase.SSLVariant;
6061
import org.htmlunit.html.HtmlElement;
6162
import org.htmlunit.javascript.JavaScriptEngine;
6263
import org.htmlunit.junit.TestCaseCorrector;
@@ -668,7 +669,7 @@ protected void startWebServer(final MockWebConnection mockConnection, final Char
668669

669670
if (STATIC_SERVER_ == null) {
670671

671-
final Server server = JettyServerUtils.startWebServer(PORT, "./", servlets, serverCharset, isBasicAuthentication(), null);
672+
final Server server = JettyServerUtils.startWebServer(PORT, "./", servlets, serverCharset, isBasicAuthentication(), SSLVariant.NONE);
672673
STATIC_SERVER_STARTER_ = ExceptionUtils.getStackTrace(new Throwable("StaticServerStarter"));
673674
STATIC_SERVER_ = server;
674675
}

src/test/java/org/htmlunit/WebServerTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static Server createWebServer(final String resourceBase, final String[] c
123123
public static Server createWebServer(final int port, final String resourceBase, final String[] classpath,
124124
final Map<String, Class<? extends Servlet>> servlets) throws Exception {
125125

126-
return JettyServerUtils.startWebServer(port, resourceBase, servlets, null, false, null);
126+
return JettyServerUtils.startWebServer(port, resourceBase, servlets, null, false, SSLVariant.NONE);
127127
}
128128

129129
/**

src/test/java/org/htmlunit/libraries/BirdTest.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616

1717
import java.net.URL;
1818

19-
import org.eclipse.jetty.server.Server;
2019
import org.htmlunit.WebDriverTestCase;
21-
import org.htmlunit.WebServerTestCase;
2220
import org.htmlunit.junit.annotation.Alerts;
23-
import org.junit.jupiter.api.AfterAll;
2421
import org.junit.jupiter.api.BeforeAll;
2522
import org.junit.jupiter.api.Test;
2623
import org.openqa.selenium.WebDriver;
@@ -32,27 +29,12 @@
3229
*/
3330
public class BirdTest extends WebDriverTestCase {
3431

35-
/** The server. */
36-
protected static Server SERVER_;
37-
3832
/**
3933
* @throws Exception if an error occurs
4034
*/
4135
@BeforeAll
42-
public static void startSesrver() throws Exception {
43-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/bird/", null);
44-
}
45-
46-
/**
47-
* @throws Exception if an error occurs
48-
*/
49-
@AfterAll
50-
public static void stopServer() throws Exception {
51-
if (SERVER_ != null) {
52-
SERVER_.stop();
53-
SERVER_.destroy();
54-
SERVER_ = null;
55-
}
36+
public static void startServer() throws Exception {
37+
startWebServer("src/test/resources/libraries/bird/", null, null);
5638
}
5739

5840
/**

src/test/java/org/htmlunit/libraries/CurvyCornersTest.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
import java.net.URL;
1818

19-
import org.eclipse.jetty.server.Server;
2019
import org.htmlunit.WebDriverTestCase;
21-
import org.htmlunit.WebServerTestCase;
22-
import org.junit.jupiter.api.AfterAll;
2320
import org.junit.jupiter.api.BeforeAll;
2421
import org.junit.jupiter.api.Test;
2522
import org.openqa.selenium.WebDriver;
@@ -32,27 +29,12 @@
3229
*/
3330
public class CurvyCornersTest extends WebDriverTestCase {
3431

35-
/** The server. */
36-
protected static Server SERVER_;
37-
3832
/**
3933
* @throws Exception if an error occurs
4034
*/
4135
@BeforeAll
42-
public static void startSesrver() throws Exception {
43-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/curvyCorners/1.2.9-beta/", null);
44-
}
45-
46-
/**
47-
* @throws Exception if an error occurs
48-
*/
49-
@AfterAll
50-
public static void stopServer() throws Exception {
51-
if (SERVER_ != null) {
52-
SERVER_.stop();
53-
SERVER_.destroy();
54-
SERVER_ = null;
55-
}
36+
public static void startServer() throws Exception {
37+
startWebServer("src/test/resources/libraries/curvyCorners/1.2.9-beta/", null, null);
5638
}
5739

5840
/**

src/test/java/org/htmlunit/libraries/ExtJS22Test.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616

1717
import java.util.List;
1818

19-
import org.eclipse.jetty.server.Server;
2019
import org.htmlunit.WebDriverTestCase;
21-
import org.htmlunit.WebServerTestCase;
2220
import org.htmlunit.junit.annotation.Alerts;
23-
import org.junit.jupiter.api.AfterAll;
2421
import org.junit.jupiter.api.BeforeAll;
2522
import org.junit.jupiter.api.Test;
2623
import org.openqa.selenium.By;
@@ -35,26 +32,12 @@
3532
*/
3633
public class ExtJS22Test extends WebDriverTestCase {
3734

38-
private static Server SERVER_;
39-
4035
/**
4136
* @throws Exception if an error occurs
4237
*/
4338
@BeforeAll
44-
public static void startSesrver() throws Exception {
45-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/ExtJS/" + getVersion(), null);
46-
}
47-
48-
/**
49-
* @throws Exception if an error occurs
50-
*/
51-
@AfterAll
52-
public static void stopServer() throws Exception {
53-
if (SERVER_ != null) {
54-
SERVER_.stop();
55-
SERVER_.destroy();
56-
SERVER_ = null;
57-
}
39+
public static void startServer() throws Exception {
40+
startWebServer("src/test/resources/libraries/ExtJS/" + getVersion(), null, null);
5841
}
5942

6043
/**

src/test/java/org/htmlunit/libraries/Html2CanvasTest.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
import java.net.URL;
1818
import java.time.Duration;
1919

20-
import org.eclipse.jetty.server.Server;
2120
import org.htmlunit.WebDriverTestCase;
22-
import org.htmlunit.WebServerTestCase;
2321
import org.htmlunit.junit.annotation.Alerts;
2422
import org.htmlunit.junit.annotation.HtmlUnitNYI;
25-
import org.junit.jupiter.api.AfterAll;
2623
import org.junit.jupiter.api.Assertions;
2724
import org.junit.jupiter.api.BeforeAll;
2825
import org.junit.jupiter.api.Test;
@@ -37,27 +34,12 @@
3734
*/
3835
public class Html2CanvasTest extends WebDriverTestCase {
3936

40-
/** The server. */
41-
protected static Server SERVER_;
42-
4337
/**
4438
* @throws Exception if an error occurs
4539
*/
4640
@BeforeAll
47-
public static void startSesrver() throws Exception {
48-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/html2canvas/", null);
49-
}
50-
51-
/**
52-
* @throws Exception if an error occurs
53-
*/
54-
@AfterAll
55-
public static void stopServer() throws Exception {
56-
if (SERVER_ != null) {
57-
SERVER_.stop();
58-
SERVER_.destroy();
59-
SERVER_ = null;
60-
}
41+
public static void startServer() throws Exception {
42+
startWebServer("src/test/resources/libraries/html2canvas/", null, null);
6143
}
6244

6345
/**

src/test/java/org/htmlunit/libraries/MooTools121Test.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919
import java.util.Arrays;
2020
import java.util.List;
2121

22-
import org.eclipse.jetty.server.Server;
2322
import org.htmlunit.WebDriverTestCase;
24-
import org.htmlunit.WebServerTestCase;
2523
import org.htmlunit.junit.annotation.Alerts;
26-
import org.junit.jupiter.api.AfterAll;
2724
import org.junit.jupiter.api.BeforeAll;
2825
import org.junit.jupiter.api.Test;
2926
import org.openqa.selenium.By;
@@ -40,26 +37,12 @@
4037
*/
4138
public class MooTools121Test extends WebDriverTestCase {
4239

43-
private static Server SERVER_;
44-
4540
/**
4641
* @throws Exception if an error occurs
4742
*/
4843
@BeforeAll
49-
public static void startSesrver() throws Exception {
50-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/mootools/1.2.1", null);
51-
}
52-
53-
/**
54-
* @throws Exception if an error occurs
55-
*/
56-
@AfterAll
57-
public static void stopServer() throws Exception {
58-
if (SERVER_ != null) {
59-
SERVER_.stop();
60-
SERVER_.destroy();
61-
SERVER_ = null;
62-
}
44+
public static void startServer() throws Exception {
45+
startWebServer("src/test/resources/libraries/mootools/1.2.1", null, null);
6346
}
6447

6548
/**

src/test/java/org/htmlunit/libraries/MyFacesTest.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
*/
1515
package org.htmlunit.libraries;
1616

17-
import org.eclipse.jetty.server.Server;
1817
import org.htmlunit.WebDriverTestCase;
19-
import org.htmlunit.WebServerTestCase;
2018
import org.htmlunit.junit.annotation.HtmlUnitNYI;
21-
import org.junit.jupiter.api.AfterAll;
2219
import org.junit.jupiter.api.BeforeAll;
2320
import org.junit.jupiter.api.Test;
2421

@@ -29,27 +26,12 @@
2926
*/
3027
public class MyFacesTest extends WebDriverTestCase {
3128

32-
/** The server. */
33-
protected static Server SERVER_;
34-
3529
/**
3630
* @throws Exception if an error occurs
3731
*/
3832
@BeforeAll
39-
public static void startSesrver() throws Exception {
40-
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/myfaces/4_0_2", null);
41-
}
42-
43-
/**
44-
* @throws Exception if an error occurs
45-
*/
46-
@AfterAll
47-
public static void stopServer() throws Exception {
48-
if (SERVER_ != null) {
49-
SERVER_.stop();
50-
SERVER_.destroy();
51-
SERVER_ = null;
52-
}
33+
public static void startServer() throws Exception {
34+
startWebServer("src/test/resources/libraries/myfaces/4_0_2", null, null);
5335
}
5436

5537
/**

src/test/java/org/htmlunit/libraries/PolymerWebComponentsTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import org.htmlunit.WebDriverTestCase;
1818
import org.htmlunit.junit.annotation.Alerts;
19-
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.BeforeAll;
2020
import org.junit.jupiter.api.Test;
2121
import org.openqa.selenium.By;
2222
import org.openqa.selenium.WebDriver;
@@ -28,6 +28,14 @@
2828
*/
2929
public class PolymerWebComponentsTest extends WebDriverTestCase {
3030

31+
/**
32+
* @throws Exception if an error occurs
33+
*/
34+
@BeforeAll
35+
public static void startServer() throws Exception {
36+
startWebServer("src/test/resources/libraries/polymer/0_6_1", null, null);
37+
}
38+
3139
/**
3240
* See https://github.com/HtmlUnit/htmlunit/issues/23.
3341
*
@@ -43,13 +51,4 @@ public void hello() throws Exception {
4351

4452
verify(() -> driver.findElement(By.tagName("body")).getText(), getExpectedAlerts()[0]);
4553
}
46-
47-
/**
48-
* Performs pre-test initialization.
49-
* @throws Exception if an error occurs
50-
*/
51-
@BeforeEach
52-
public void setUp() throws Exception {
53-
startWebServer("src/test/resources/libraries/polymer/0_6_1", null, null);
54-
}
5554
}

src/test/java/org/htmlunit/libraries/TinyMceTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.htmlunit.WebDriverTestCase;
2121
import org.htmlunit.junit.annotation.Alerts;
2222
import org.htmlunit.junit.annotation.HtmlUnitNYI;
23-
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.BeforeAll;
2424
import org.junit.jupiter.api.Test;
2525
import org.openqa.selenium.By;
2626
import org.openqa.selenium.WebDriver;
@@ -38,6 +38,14 @@
3838
*/
3939
public class TinyMceTest extends WebDriverTestCase {
4040

41+
/**
42+
* @throws Exception if an error occurs
43+
*/
44+
@BeforeAll
45+
public static void startServer() throws Exception {
46+
startWebServer("src/test/resources/libraries/tinymce/3.2.7", null, null);
47+
}
48+
4149
/**
4250
* @throws Exception if an error occurs
4351
*/
@@ -88,13 +96,4 @@ private void test(final String fileName, final int expectedTotal, final int expe
8896
final int failed = Integer.parseInt(failedSpan.getText());
8997
assertEquals(expectedFailed, failed);
9098
}
91-
92-
/**
93-
* Performs pre-test initialization.
94-
* @throws Exception if an error occurs
95-
*/
96-
@BeforeEach
97-
public void setUp() throws Exception {
98-
startWebServer("src/test/resources/libraries/tinymce/3.2.7", null, null);
99-
}
10099
}

0 commit comments

Comments
 (0)