@throws Exception if the test fails
()
| 147 | * @throws Exception if the test fails |
| 148 | */ |
| 149 | @Test |
| 150 | public void asXml() throws Exception { |
| 151 | final String unicodeString = "\u064A\u0627 \u0644\u064A\u064A\u0644"; |
| 152 | final String html = DOCTYPE_HTML |
| 153 | + "<html>\n" |
| 154 | + "<head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head>\n" |
| 155 | + "<body><span id='foo'>" + unicodeString + "</span></body></html>"; |
| 156 | |
| 157 | final int[] expectedValues = {1610, 1575, 32, 1604, 1610, 1610, 1604}; |
| 158 | |
| 159 | final WebClient client = getWebClient(); |
| 160 | final MockWebConnection webConnection = new MockWebConnection(); |
| 161 | |
| 162 | webConnection.setDefaultResponse(StringUtils.toByteArray(html, UTF_8), 200, "OK", MimeType.TEXT_HTML); |
| 163 | client.setWebConnection(webConnection); |
| 164 | |
| 165 | final HtmlPage page = client.getPage(URL_FIRST); |
| 166 | final String xml = page.getHtmlElementById("foo").getFirstChild().asXml(); |
| 167 | assertEquals(expectedValues.length, xml.length()); |
| 168 | int index = 0; |
| 169 | for (final int expectedValue : expectedValues) { |
| 170 | assertEquals(expectedValue, xml.codePointAt(index++)); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * @throws Exception if the test fails |
no test coverage detected