MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / testDocument

Method testDocument

src/test/java/org/htmlunit/xml/XmlPageTest.java:200–215  ·  view source on GitHub ↗

Utility method to test XML page of different MIME types. @param content the XML content @param mimeType the MIME type @return the page returned by the WebClient @throws Exception if a problem occurs

(final String content, final String mimeType)

Source from the content-addressed store, hash-verified

198 * @throws Exception if a problem occurs
199 */
200 private XmlPage testDocument(final String content, final String mimeType) throws Exception {
201 final WebClient client = getWebClient();
202 final MockWebConnection webConnection = new MockWebConnection();
203 webConnection.setDefaultResponse(content, 200, "OK", mimeType);
204 client.setWebConnection(webConnection);
205 final Page page = client.getPage(URL_FIRST);
206 assertEquals(URL_FIRST, page.getUrl());
207 assertEquals("OK", page.getWebResponse().getStatusMessage());
208 assertEquals(HttpStatus.OK_200, page.getWebResponse().getStatusCode());
209 assertEquals(mimeType, page.getWebResponse().getContentType());
210 assertTrue(page instanceof XmlPage);
211 final XmlPage xmlPage = (XmlPage) page;
212 assertEquals(content, xmlPage.getWebResponse().getContentAsString());
213 assertNotNull(xmlPage.getXmlDocument());
214 return xmlPage;
215 }
216
217 /**
218 * Tests a simple invalid (badly formed) XML document.

Callers 5

namespaceMethod · 0.95
validDocumentMethod · 0.95
voiceXMLMethod · 0.95
xpathMethod · 0.95
xpathAttributeMethod · 0.95

Calls 14

setDefaultResponseMethod · 0.95
setWebConnectionMethod · 0.95
getPageMethod · 0.95
getUrlMethod · 0.95
getWebResponseMethod · 0.95
getXmlDocumentMethod · 0.95
assertTrueMethod · 0.80
assertNotNullMethod · 0.80
getWebClientMethod · 0.65
assertEqualsMethod · 0.45
getStatusMessageMethod · 0.45
getStatusCodeMethod · 0.45

Tested by

no test coverage detected