3939import org .eclipse .jetty .server .ServerConnector ;
4040import org .eclipse .jetty .server .SslConnectionFactory ;
4141import org .eclipse .jetty .server .handler .HandlerList ;
42- import org .eclipse .jetty .server .handler .HandlerWrapper ;
4342import org .eclipse .jetty .server .handler .ResourceHandler ;
4443import org .eclipse .jetty .servlet .DefaultServlet ;
4544import org .eclipse .jetty .util .security .Constraint ;
5251import org .junit .jupiter .api .AfterEach ;
5352
5453/**
55- * A WebTestCase which starts a local server, and doens 't use WebDriver.
56- *
54+ * A WebTestCase which starts a local server, and doesn 't use WebDriver.
55+ * <p>
5756 * <b>Note that {@link WebDriverTestCase} should be used unless HtmlUnit-specific feature
5857 * is needed and Selenium does not support it.</b>
5958 *
@@ -122,7 +121,7 @@ protected void startWebServer(final String resourceBase, final String[] classpat
122121
123122 /**
124123 * This is usually needed if you want to have a running server during many tests invocation.
125- *
124+ * <p>
126125 * Creates and starts a web server on the default {@link #PORT}.
127126 * The given resourceBase is used to be the ROOT directory that serves the default context.
128127 * <p><b>Don't forget to stop the returned Server after the test</b>
@@ -133,12 +132,12 @@ protected void startWebServer(final String resourceBase, final String[] classpat
133132 * @throws Exception if an error occurs
134133 */
135134 public static Server createWebServer (final String resourceBase , final String [] classpath ) throws Exception {
136- return createWebServer (PORT , resourceBase , classpath , null , null );
135+ return createWebServer (PORT , resourceBase , classpath , null );
137136 }
138137
139138 /**
140139 * This is usually needed if you want to have a running server during many tests invocation.
141- *
140+ * <p>
142141 * Creates and starts a web server on the default {@link #PORT}.
143142 * The given resourceBase is used to be the ROOT directory that serves the default context.
144143 * <p><b>Don't forget to stop the returned Server after the test</b>
@@ -147,12 +146,11 @@ public static Server createWebServer(final String resourceBase, final String[] c
147146 * @param resourceBase the base of resources for the default context
148147 * @param classpath additional classpath entries to add (may be null)
149148 * @param servlets map of {String, Class} pairs: String is the path spec, while class is the class
150- * @param handler wrapper for handler (can be null)
151149 * @return the newly created server
152150 * @throws Exception if an error occurs
153151 */
154152 public static Server createWebServer (final int port , final String resourceBase , final String [] classpath ,
155- final Map <String , Class <? extends Servlet >> servlets , final HandlerWrapper handler ) throws Exception {
153+ final Map <String , Class <? extends Servlet >> servlets ) throws Exception {
156154
157155 final Server server = buildServer (port );
158156
@@ -181,13 +179,7 @@ public static Server createWebServer(final int port, final String resourceBase,
181179 }
182180 }
183181 context .setClassLoader (loader );
184- if (handler != null ) {
185- handler .setHandler (context );
186- server .setHandler (handler );
187- }
188- else {
189- server .setHandler (context );
190- }
182+ server .setHandler (context );
191183
192184 tryStart (port , server );
193185 return server ;
@@ -407,8 +399,7 @@ public static void tryStart(final int port, final Server server) throws Exceptio
407399 }
408400 catch (final IOException e ) {
409401 // looks like newer jetty already catches the bind exception
410- final Throwable cause = e .getCause ();
411- if (cause != null && cause instanceof BindException ) {
402+ if (e .getCause () instanceof BindException ) {
412403 if (System .currentTimeMillis () > maxWait ) {
413404 // destroy the server to free all associated resources
414405 server .stop ();
0 commit comments