1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.xml.script; |
21 |
|
|
22 |
|
import java.io.ByteArrayInputStream; |
23 |
|
import java.io.StringReader; |
24 |
|
import java.io.UnsupportedEncodingException; |
25 |
|
|
26 |
|
import javax.xml.transform.stream.StreamSource; |
27 |
|
|
28 |
|
import org.junit.Assert; |
29 |
|
import org.junit.Test; |
30 |
|
import org.w3c.dom.Document; |
31 |
|
import org.w3c.dom.Element; |
32 |
|
import org.w3c.dom.ls.LSInput; |
33 |
|
import org.xwiki.script.service.ScriptService; |
34 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
35 |
|
import org.xwiki.xml.script.XMLScriptService; |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 97.5% |
Uncovered Elements: 4 (162) |
Complexity: 30 |
Complexity Density: 0.23 |
|
43 |
|
public class XMLScriptServiceTest extends AbstractComponentTestCase |
44 |
|
{ |
45 |
|
private XMLScriptService xml; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
27 |
@Override... |
48 |
|
public void setUp() throws Exception |
49 |
|
{ |
50 |
27 |
this.xml = (XMLScriptService) getComponentManager().getInstance(ScriptService.class, "xml"); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void testGetDomDocument() |
57 |
|
{ |
58 |
|
|
59 |
1 |
Assert.assertNotNull(this.xml.createDOMDocument()); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void testParseString() |
64 |
|
{ |
65 |
1 |
Document result = this.xml.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b='c'>d</a>"); |
66 |
1 |
Assert.assertNotNull("Failed to parse content", result); |
67 |
1 |
Assert.assertEquals("Incorrect root node", "a", result.getDocumentElement().getLocalName()); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void testParseByteArray() throws UnsupportedEncodingException |
72 |
|
{ |
73 |
1 |
Document result = this.xml.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b='c'>d</a>".getBytes("UTF-8")); |
74 |
1 |
Assert.assertNotNull("Failed to parse content", result); |
75 |
1 |
Assert.assertEquals("Incorrect root node", "a", result.getDocumentElement().getLocalName()); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
78 |
1 |
@Test... |
79 |
|
public void testParseInputStream() throws UnsupportedEncodingException |
80 |
|
{ |
81 |
1 |
Document result = this.xml.parse( |
82 |
|
new ByteArrayInputStream("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b='c'>d</a>".getBytes("UTF-8"))); |
83 |
1 |
Assert.assertNotNull("Failed to parse content", result); |
84 |
1 |
Assert.assertEquals("Incorrect root node", "a", result.getDocumentElement().getLocalName()); |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
87 |
1 |
@Test... |
88 |
|
public void testParseWithDifferentEncoding() throws UnsupportedEncodingException |
89 |
|
{ |
90 |
1 |
Document result = |
91 |
|
this.xml.parse("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><a>\u00E9</a>".getBytes("ISO-8859-1")); |
92 |
1 |
Assert.assertNotNull("Failed to parse content", result); |
93 |
1 |
Assert.assertEquals("Incorrect root node", "a", result.getDocumentElement().getLocalName()); |
94 |
1 |
Assert.assertEquals("Incorrect content", "\u00E9", result.getDocumentElement().getTextContent()); |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
97 |
1 |
@Test... |
98 |
|
public void testParseWithWrongEncoding() throws UnsupportedEncodingException |
99 |
|
{ |
100 |
1 |
Document result = |
101 |
|
this.xml.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a>\u00E9</a>".getBytes("ISO-8859-1")); |
102 |
1 |
Assert.assertNull("Content should be invalid with the specified encoding", result); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
105 |
1 |
@Test... |
106 |
|
public void testParseWithoutXMLDeclaration() |
107 |
|
{ |
108 |
1 |
Document result = this.xml.parse("<a>\u00E9</a>"); |
109 |
1 |
Assert.assertNotNull("Failed to parse content", result); |
110 |
1 |
Assert.assertEquals("Incorrect root node", "a", result.getDocumentElement().getLocalName()); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
113 |
1 |
@Test... |
114 |
|
public void testParseInvalidDocument() throws UnsupportedEncodingException |
115 |
|
{ |
116 |
1 |
Document result = this.xml.parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a></b>"); |
117 |
1 |
Assert.assertNull("Invalid content shouldn't be parsed", result); |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
120 |
1 |
@Test... |
121 |
|
public void testParseNull() |
122 |
|
{ |
123 |
1 |
Document result = this.xml.parse((String) null); |
124 |
1 |
Assert.assertNull("Null Document input shouldn't be parsed", result); |
125 |
1 |
result = this.xml.parse((byte[]) null); |
126 |
1 |
Assert.assertNull("Null byte[] input shouldn't be parsed", result); |
127 |
1 |
result = this.xml.parse((ByteArrayInputStream) null); |
128 |
1 |
Assert.assertNull("Null InputStream input shouldn't be parsed", result); |
129 |
1 |
result = this.xml.parse((LSInput) null); |
130 |
1 |
Assert.assertNull("Null LSInput input shouldn't be parsed", result); |
131 |
|
} |
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
133 |
1 |
@Test... |
134 |
|
public void testParseAndSerialize() |
135 |
|
{ |
136 |
1 |
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\u00E9</a>"; |
137 |
1 |
String result = this.xml.serialize(this.xml.parse(content)); |
138 |
1 |
Assert.assertEquals("Not identical content after parse + serialize", content, result); |
139 |
|
|
140 |
1 |
content = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<a>\u00E9</a>"; |
141 |
1 |
result = this.xml.serialize(this.xml.parse(content)); |
142 |
1 |
Assert.assertEquals("Not identical content after parse + serialize", content, result); |
143 |
|
|
144 |
1 |
content = "<a>\u00E9</a>"; |
145 |
1 |
result = this.xml.serialize(this.xml.parse(content), false); |
146 |
1 |
Assert.assertEquals("Not identical content after parse + serialize", content, result); |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
149 |
1 |
@Test... |
150 |
|
public void testSerialize() |
151 |
|
{ |
152 |
1 |
Document d = createSimpleDocument(); |
153 |
1 |
String result = this.xml.serialize(d); |
154 |
1 |
Assert.assertEquals("Wrong serialization", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\u00E9</a>", result); |
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
157 |
1 |
@Test... |
158 |
|
public void testSerializeDocumentElement() |
159 |
|
{ |
160 |
1 |
Document d = createSimpleDocument(); |
161 |
1 |
String result = this.xml.serialize(d.getDocumentElement()); |
162 |
1 |
Assert.assertEquals("Wrong serialization", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a>\u00E9</a>", result); |
163 |
|
} |
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
165 |
1 |
@Test... |
166 |
|
public void testSerializeNode() |
167 |
|
{ |
168 |
1 |
Document d = createSimpleDocument(); |
169 |
1 |
Element b = d.createElement("b"); |
170 |
1 |
b.setTextContent("c"); |
171 |
1 |
d.getDocumentElement().appendChild(b); |
172 |
1 |
String result = this.xml.serialize(d.getDocumentElement().getElementsByTagName("b").item(0)); |
173 |
1 |
Assert.assertEquals("Wrong serialization", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<b>c</b>", result); |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
176 |
1 |
@Test... |
177 |
|
public void testSerializeNull() |
178 |
|
{ |
179 |
1 |
Assert.assertEquals("Wrong serialization for null document", "", this.xml.serialize(null)); |
180 |
|
} |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
182 |
0 |
public void testSerializeWithoutXmlDeclaration()... |
183 |
|
{ |
184 |
0 |
Document d = createSimpleDocument(); |
185 |
0 |
String result = this.xml.serialize(d.getDocumentElement(), false); |
186 |
0 |
Assert.assertEquals("Wrong serialization", "<a>\u00E9</a>", result); |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
189 |
1 |
@Test... |
190 |
|
public void testNewlineSerialization() |
191 |
|
{ |
192 |
1 |
Document d = this.xml.parse("<a>a\nb\n</a>"); |
193 |
1 |
String result = this.xml.serialize(d, false); |
194 |
1 |
Assert.assertEquals("Wrong newlines", "<a>a\nb\n</a>", result); |
195 |
|
|
196 |
1 |
d = this.xml.parse("<a>a\r\nb\r\n</a>"); |
197 |
1 |
result = this.xml.serialize(d, false); |
198 |
1 |
Assert.assertEquals("Wrong newlines", "<a>a\nb\n</a>", result); |
199 |
|
|
200 |
1 |
d = this.xml.parse("<a>a\rb\r</a>"); |
201 |
1 |
result = this.xml.serialize(d, false); |
202 |
1 |
Assert.assertEquals("Wrong newlines", "<a>a\nb\n</a>", result); |
203 |
|
} |
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
205 |
1 |
@Test... |
206 |
|
public void testSerializationWithDoctype() |
207 |
|
{ |
208 |
1 |
Document d = this.xml.parse("<?xml version='1.0' encoding='UTF-8' ?>" |
209 |
|
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " |
210 |
|
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" |
211 |
|
+ "<html><body>a</body></html>"); |
212 |
1 |
String result = this.xml.serialize(d, true); |
213 |
1 |
Assert.assertEquals("Failed Doctype", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
214 |
|
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " |
215 |
|
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" |
216 |
|
+ "<html><body>a</body></html>", result); |
217 |
1 |
result = this.xml.serialize(d, false); |
218 |
1 |
Assert.assertEquals("Failed Doctype", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " |
219 |
|
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" |
220 |
|
+ "<html><body>a</body></html>", result); |
221 |
|
} |
222 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
223 |
1 |
@Test... |
224 |
|
public void testDoctypeSerialization() |
225 |
|
{ |
226 |
1 |
Document d = this.xml.parse("<?xml version='1.0' encoding='UTF-8' ?>" |
227 |
|
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " |
228 |
|
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" |
229 |
|
+ "<html><body>a</body></html>"); |
230 |
1 |
String result = this.xml.serialize(d.getDoctype(), true); |
231 |
1 |
Assert.assertEquals("Doctype alone shouldn't be serialized", "", result); |
232 |
|
} |
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
234 |
1 |
@Test... |
235 |
|
public void testSerializeToSmallerCharset() |
236 |
|
{ |
237 |
1 |
Document d = this.xml.parse("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><a>\u0345</a>"); |
238 |
1 |
String result = this.xml.serialize(d); |
239 |
1 |
Assert.assertFalse("Non-latin1 character shouldn't be present in the output", result.contains("\u0345")); |
240 |
|
} |
241 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
242 |
1 |
@Test... |
243 |
|
public void testTransformDocument() |
244 |
|
{ |
245 |
1 |
Document d = this.xml.parse("<a b='c'>d</a>"); |
246 |
1 |
Document s = this.xml.parse("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
247 |
|
"<xsl:output method='xml' omit-xml-declaration='yes'/>" |
248 |
|
+ "<xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>"); |
249 |
1 |
String result = this.xml.transform(d, s); |
250 |
1 |
Assert.assertEquals("<a/>", result); |
251 |
|
} |
252 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
253 |
1 |
@Test... |
254 |
|
public void testTransformByteArray() throws UnsupportedEncodingException |
255 |
|
{ |
256 |
1 |
byte[] d = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b='c'>d</a>".getBytes("UTF-8"); |
257 |
1 |
byte[] s = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
258 |
|
+ "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
259 |
|
"<xsl:output method='xml' omit-xml-declaration='yes'/>" |
260 |
|
+ "<xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>").getBytes("UTF-8"); |
261 |
1 |
String result = this.xml.transform(d, s); |
262 |
1 |
Assert.assertEquals("<a/>", result); |
263 |
|
} |
264 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
265 |
1 |
@Test... |
266 |
|
public void testTransformString() throws UnsupportedEncodingException |
267 |
|
{ |
268 |
1 |
String d = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><a b='c'>d</a>"; |
269 |
1 |
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
270 |
|
+ "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
271 |
|
"<xsl:output method='xml' omit-xml-declaration='yes'/>" |
272 |
|
+ "<xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>"; |
273 |
1 |
String result = this.xml.transform(d, s); |
274 |
1 |
Assert.assertEquals("<a/>", result); |
275 |
|
} |
276 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
277 |
1 |
@Test... |
278 |
|
public void testTransformWithNullInputs() |
279 |
|
{ |
280 |
1 |
StreamSource d = new StreamSource(new StringReader("<a b='c'>d</a>")); |
281 |
1 |
StreamSource s = new StreamSource(new StringReader( |
282 |
|
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'><xsl:output method='xml'/>" |
283 |
|
+ "<xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>")); |
284 |
1 |
String result = this.xml.transform(null, s); |
285 |
1 |
Assert.assertNull(null, result); |
286 |
1 |
result = this.xml.transform(d, null); |
287 |
1 |
Assert.assertNull(null, result); |
288 |
1 |
result = this.xml.transform((StreamSource) null, (StreamSource) null); |
289 |
1 |
Assert.assertNull(null, result); |
290 |
|
} |
291 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
292 |
1 |
@Test... |
293 |
|
public void testTransformWithNullDocuments() |
294 |
|
{ |
295 |
1 |
Document d = this.xml.parse("<a b='c'>d</a>"); |
296 |
1 |
Document s = this.xml.parse("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
297 |
|
"<xsl:output method='xml'/><xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>"); |
298 |
1 |
String result = this.xml.transform(null, s); |
299 |
1 |
Assert.assertNull(null, result); |
300 |
1 |
result = this.xml.transform(d, null); |
301 |
1 |
Assert.assertNull(null, result); |
302 |
1 |
result = this.xml.transform((Document) null, (Document) null); |
303 |
1 |
Assert.assertNull(null, result); |
304 |
|
} |
305 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
306 |
1 |
@Test... |
307 |
|
public void testTransformWithNullStrings() |
308 |
|
{ |
309 |
1 |
String d = "<a b='c'>d</a>"; |
310 |
1 |
String s = "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
311 |
|
"<xsl:output method='xml'/><xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>"; |
312 |
1 |
String result = this.xml.transform(null, s); |
313 |
1 |
Assert.assertNull(null, result); |
314 |
1 |
result = this.xml.transform(d, null); |
315 |
1 |
Assert.assertNull(null, result); |
316 |
1 |
result = this.xml.transform((String) null, (String) null); |
317 |
1 |
Assert.assertNull(null, result); |
318 |
|
} |
319 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
320 |
1 |
@Test... |
321 |
|
public void testTransformWithNullByteArrays() throws UnsupportedEncodingException |
322 |
|
{ |
323 |
1 |
byte[] d = "<a b='c'>d</a>".getBytes("UTF-8"); |
324 |
1 |
byte[] s = ("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
325 |
|
"<xsl:output method='xml'/><xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>") |
326 |
|
.getBytes(); |
327 |
1 |
String result = this.xml.transform(null, s); |
328 |
1 |
Assert.assertNull(null, result); |
329 |
1 |
result = this.xml.transform(d, null); |
330 |
1 |
Assert.assertNull(null, result); |
331 |
1 |
result = this.xml.transform((byte[]) null, (byte[]) null); |
332 |
1 |
Assert.assertNull(null, result); |
333 |
|
} |
334 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
335 |
1 |
@Test... |
336 |
|
public void testTransformWithInvalidSheet() |
337 |
|
{ |
338 |
1 |
Document d = this.xml.parse("<a b='c'>d</a>"); |
339 |
1 |
Document s = this.xml.parse("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
340 |
|
"<xsl:output method='xml'/><xsl:template match='node()'><xsl:copy/></xsl:template></xsl:stylesheet>"); |
341 |
1 |
String result = this.xml.transform(s, d); |
342 |
1 |
Assert.assertEquals(null, result); |
343 |
|
} |
344 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
345 |
1 |
@Test... |
346 |
|
public void testTransformToText() |
347 |
|
{ |
348 |
1 |
Document d = this.xml.parse("<a b='c'>d</a>"); |
349 |
1 |
Document s = |
350 |
|
this.xml.parse("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" + |
351 |
|
"<xsl:output method='text'/><xsl:template match='node()'><xsl:value-of select='@*'/></xsl:template>" |
352 |
|
+ "</xsl:stylesheet>"); |
353 |
1 |
String result = this.xml.transform(d, s); |
354 |
1 |
Assert.assertEquals("c", result); |
355 |
|
} |
356 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
357 |
3 |
private Document createSimpleDocument()... |
358 |
|
{ |
359 |
3 |
Document d = this.xml.createDOMDocument(); |
360 |
3 |
Element a = d.createElement("a"); |
361 |
3 |
a.setTextContent("\u00E9"); |
362 |
3 |
d.appendChild(a); |
363 |
3 |
return d; |
364 |
|
} |
365 |
|
} |