1 17 package org.apache.servicemix.jbi.jaxp; 18 19 import javax.xml.namespace.QName ; 20 import javax.xml.transform.dom.DOMSource ; 21 22 import junit.framework.TestCase; 23 24 import org.apache.servicemix.jbi.util.DOMUtil; 25 import org.w3c.dom.Document ; 26 import org.w3c.dom.Element ; 27 import org.w3c.dom.Node ; 28 29 public class SourceTransformerTest extends TestCase { 30 31 private SourceTransformer transformer = new SourceTransformer(); 32 33 36 public void testToDOMNodeSource() throws Exception { 37 Node node = transformer.toDOMNode(new StringSource( 38 "<definition xmlns:tns='http://foo.bar.com'><value>tns:bar</value></definition>")); 39 40 assertNotNull(node); 41 assertTrue(node instanceof Document ); 42 Document doc = (Document ) node; 43 Element e = (Element ) doc.getDocumentElement().getFirstChild(); 44 QName q = DOMUtil.createQName(e, e.getFirstChild().getNodeValue()); 45 assertEquals("http://foo.bar.com", q.getNamespaceURI()); 46 } 47 48 public void testToDOMSourceFromStream() throws Exception { 49 DOMSource domsource = transformer.toDOMSourceFromStream(new StringSource( 50 "<definition xmlns:tns='http://foo.bar.com'><value>Jürgen</value></definition>")); 51 assertNotNull(domsource); 52 } 53 54 } 55 | Popular Tags |