2020import java .nio .charset .StandardCharsets ;
2121
2222import org .htmlunit .html .HtmlPage ;
23- import org .htmlunit .junit .BrowserRunner ;
2423import org .htmlunit .junit .annotation .Alerts ;
2524import org .htmlunit .junit .annotation .HtmlUnitNYI ;
2625import org .junit .After ;
27- import org .junit .Test ;
2826import org .junit .experimental .runners .Enclosed ;
27+ import org .junit .jupiter .api .Assertions ;
28+ import org .junit .jupiter .api .Test ;
2929import org .junit .runner .RunWith ;
3030import org .openqa .selenium .By ;
3131import org .openqa .selenium .WebDriver ;
@@ -57,7 +57,6 @@ public class NoHttpResponseTest {
5757 /**
5858 * Test using WebDriver.
5959 */
60- @ RunWith (BrowserRunner .class )
6160 public static class WithWebDriverTest extends WebDriverTestCase {
6261
6362 /**
@@ -133,7 +132,6 @@ public void callSubmitInButtonAndReturnTrue() throws Exception {
133132 /**
134133 * Test using WebClient with default configuration allowing to throw exception.
135134 */
136- @ RunWith (BrowserRunner .class )
137135 public static class WithWebClientTest extends SimpleWebTestCase {
138136
139137 /**
@@ -149,10 +147,14 @@ public void after() throws Exception {
149147 /**
150148 * @throws Throwable if the test fails
151149 */
152- @ Test (expected = FailingHttpStatusCodeException .class )
150+ @ Test
151+ @ Alerts ("§§URL§§" )
153152 public void submit () throws Throwable {
153+ expandExpectedAlertsVariables (URL_FIRST );
154+
154155 final MockWebConnection mockWebConnection = getMockWebConnection ();
155156 mockWebConnection .setResponse (URL_FIRST , HTML );
157+
156158 MiniServer .configureDropRequest (new URL (URL_FIRST , "page2?textfield=" ));
157159 final URL urlRightSubmit = new URL (URL_FIRST , "page2?textfield=new+value" );
158160 mockWebConnection .setResponse (urlRightSubmit ,
@@ -163,8 +165,11 @@ public void submit() throws Throwable {
163165 try (MiniServer miniServer = new MiniServer (PORT , mockWebConnection )) {
164166 miniServer .start ();
165167
166- HtmlPage page = getWebClient ().getPage (URL_FIRST );
167- page = page .getElementById ("inputSubmit" ).click ();
168+ final HtmlPage page = getWebClient ().getPage (URL_FIRST );
169+
170+ Assertions .assertThrows (FailingHttpStatusCodeException .class ,
171+ () -> page .getElementById ("inputSubmit" ).click ());
172+
168173 assertEquals (getExpectedAlerts ()[0 ], page .getUrl ());
169174 }
170175 }
0 commit comments