1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.xml.transform;
18
19 import javax.xml.transform.Transformer;
20 import javax.xml.transform.TransformerException;
21 import javax.xml.transform.TransformerFactory;
22 import javax.xml.transform.dom.DOMResult;
23
24 import junit.framework.TestCase;
25 import org.w3c.dom.Element;
26
27 public class StringSourceTest extends TestCase {
28
29 public void testStringSource() throws TransformerException {
30 Transformer transformer = TransformerFactory.newInstance().newTransformer();
31 String content = "<prefix:content xmlns:prefix='namespace'/>";
32 DOMResult result = new DOMResult();
33 transformer.transform(new StringSource(content), result);
34 Element rootElement = (Element) result.getNode().getFirstChild();
35 assertEquals("Invalid local name", "content", rootElement.getLocalName());
36 assertEquals("Invalid prefix", "prefix", rootElement.getPrefix());
37 assertEquals("Invalid namespace", "namespace", rootElement.getNamespaceURI());
38 }
39 }