1
2
3
4
5 package com.jcabi.http.response;
6
7 import com.google.common.base.Joiner;
8 import com.jcabi.http.Response;
9 import com.jcabi.http.request.FakeRequest;
10 import com.jcabi.matchers.XhtmlMatchers;
11 import org.hamcrest.MatcherAssert;
12 import org.junit.jupiter.api.Test;
13
14
15
16
17
18
19 final class JsoupResponseTest {
20
21
22
23
24
25 @Test
26 void normalizesHtml() throws Exception {
27 final Response resp = new FakeRequest().withBody(
28 Joiner.on(' ').join(
29 "<html xmlns='http://www.w3.org/1999/xhtml'>",
30 "<head><meta name='test'></head>",
31 "<p>Hello world"
32 )
33 ).fetch();
34 MatcherAssert.assertThat(
35 "should contains normalized response",
36 new JsoupResponse(resp).body(),
37 XhtmlMatchers.hasXPaths(
38 "/xhtml:html/xhtml:head",
39 "/xhtml:html/xhtml:body/xhtml:p[.=\"Hello world\"]"
40 )
41 );
42 }
43
44 }