minor formatting work
This commit is contained in:
parent
b7db6cef7f
commit
74da012f6f
|
@ -1,10 +1,7 @@
|
||||||
package com.baeldung.htmlunit;
|
package com.baeldung.htmlunit;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -14,7 +11,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
|
import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
|
|
||||||
import com.gargoylesoftware.htmlunit.WebClient;
|
import com.gargoylesoftware.htmlunit.WebClient;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||||
|
@ -33,8 +29,7 @@ public class HtmlUnitAndSpringTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
webClient = MockMvcWebClientBuilder
|
webClient = MockMvcWebClientBuilder.webAppContextSetup(wac).build();
|
||||||
.webAppContextSetup(wac).build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -44,18 +39,16 @@ public class HtmlUnitAndSpringTest {
|
||||||
|
|
||||||
String url = "http://localhost/message/showForm";
|
String url = "http://localhost/message/showForm";
|
||||||
page = webClient.getPage(url);
|
page = webClient.getPage(url);
|
||||||
|
|
||||||
HtmlTextInput messageText = page.getHtmlElementById("message");
|
HtmlTextInput messageText = page.getHtmlElementById("message");
|
||||||
messageText.setValueAttribute(text);
|
messageText.setValueAttribute(text);
|
||||||
|
|
||||||
HtmlForm form = page.getForms().get(0);
|
HtmlForm form = page.getForms().get(0);
|
||||||
HtmlSubmitInput submit = form.getOneHtmlElementByAttribute(
|
HtmlSubmitInput submit = form.getOneHtmlElementByAttribute("input", "type", "submit");
|
||||||
"input", "type", "submit");
|
|
||||||
HtmlPage newPage = submit.click();
|
HtmlPage newPage = submit.click();
|
||||||
|
|
||||||
String receivedText = newPage.getHtmlElementById("received")
|
String receivedText = newPage.getHtmlElementById("received").getTextContent();
|
||||||
.getTextContent();
|
|
||||||
|
|
||||||
Assert.assertEquals(receivedText, text);
|
Assert.assertEquals(receivedText, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue