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)
| 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. |
no test coverage detected