11package com .baeldung .htmlunit ;
22
3- import java .io .IOException ;
4-
53import org .junit .Assert ;
64import org .junit .Before ;
7- import org .junit .Ignore ;
85import org .junit .Test ;
96import org .junit .runner .RunWith ;
107import org .springframework .beans .factory .annotation .Autowired ;
1411import org .springframework .test .web .servlet .htmlunit .MockMvcWebClientBuilder ;
1512import org .springframework .web .context .WebApplicationContext ;
1613
17- import com .gargoylesoftware .htmlunit .FailingHttpStatusCodeException ;
1814import com .gargoylesoftware .htmlunit .WebClient ;
1915import com .gargoylesoftware .htmlunit .html .HtmlForm ;
2016import com .gargoylesoftware .htmlunit .html .HtmlPage ;
@@ -33,8 +29,7 @@ public class HtmlUnitAndSpringTest {
3329
3430 @ Before
3531 public void setup () {
36- webClient = MockMvcWebClientBuilder
37- .webAppContextSetup (wac ).build ();
32+ webClient = MockMvcWebClientBuilder .webAppContextSetup (wac ).build ();
3833 }
3934
4035 @ Test
@@ -44,18 +39,16 @@ public void givenAMessage_whenSent_thenItShows() throws Exception {
4439
4540 String url = "http://localhost/message/showForm" ;
4641 page = webClient .getPage (url );
47-
42+
4843 HtmlTextInput messageText = page .getHtmlElementById ("message" );
4944 messageText .setValueAttribute (text );
5045
5146 HtmlForm form = page .getForms ().get (0 );
52- HtmlSubmitInput submit = form .getOneHtmlElementByAttribute (
53- "input" , "type" , "submit" );
47+ HtmlSubmitInput submit = form .getOneHtmlElementByAttribute ("input" , "type" , "submit" );
5448 HtmlPage newPage = submit .click ();
5549
56- String receivedText = newPage .getHtmlElementById ("received" )
57- .getTextContent ();
50+ String receivedText = newPage .getHtmlElementById ("received" ).getTextContent ();
5851
59- Assert .assertEquals (receivedText , text );
52+ Assert .assertEquals (receivedText , text );
6053 }
6154}
0 commit comments