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

Method asXml

src/test/java/org/htmlunit/html/DomTextTest.java:149–172  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

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

Callers 15

getAttributeLowerCaseMethod · 0.45
getAttributeMixedCaseMethod · 0.45
getAttributeUpperCaseMethod · 0.45
setAttributeLowerCaseMethod · 0.45
setAttributeMixedCaseMethod · 0.45
setAttributeUpperCaseMethod · 0.45
hasAttributeLowerCaseMethod · 0.45
hasAttributeMixedCaseMethod · 0.45
hasAttributeUpperCaseMethod · 0.45

Calls 9

setDefaultResponseMethod · 0.95
toByteArrayMethod · 0.95
setWebConnectionMethod · 0.95
getPageMethod · 0.95
getHtmlElementByIdMethod · 0.95
getWebClientMethod · 0.65
lengthMethod · 0.65
getFirstChildMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected