1 7 package org.jboss.test.jbossnet.document; 8 9 11 import junit.framework.Test; 12 import org.jboss.axis.utils.DOM2Utils; 13 import org.jboss.test.jbossnet.JBossNetTestBase; 14 import org.w3c.dom.Document ; 15 import org.w3c.dom.Element ; 16 17 import javax.xml.namespace.QName ; 18 import javax.xml.parsers.DocumentBuilder ; 19 import javax.xml.rpc.Call ; 20 import javax.xml.rpc.Service ; 21 import java.io.ByteArrayInputStream ; 22 import java.net.URL ; 23 24 30 public class ObjectElementTestCase extends JBossNetTestBase 31 { 32 public static final String xmlstr = "<root><child>Hello</child><child>World</child></root>"; 33 34 private String namespaceURI = "http://jboss.net/document"; 35 private Service service; 36 37 public ObjectElementTestCase(String name) 38 { 39 super(name); 40 } 41 42 protected void setUp() throws Exception 43 { 44 super.setUp(); 45 URL wsdlURL = new URL (SERVICES_LOCATION + "/ObjectElementServer?wsdl"); 46 service = createService(wsdlURL, new QName (namespaceURI, "ObjectElementServerService")); 47 } 48 49 51 public void testProcessElement() throws Exception 52 { 53 DocumentBuilder builder = DOM2Utils.getDocumentBuilder(); 54 Document doc = builder.parse(new ByteArrayInputStream (xmlstr.getBytes())); 55 Element rootEl = doc.getDocumentElement(); 56 57 Call call = service.createCall(new QName (namespaceURI, "ObjectElementServer"), "processElement"); 58 59 Object retObj = call.invoke(new Object []{rootEl}); 60 assertNotNull("Return obj is null", retObj); 61 assertTrue("Return obj is not an Element: " + retObj.getClass().getName(), retObj instanceof Element ); 62 } 63 64 66 public void testProcessObject() throws Exception 67 { 68 DocumentBuilder builder = DOM2Utils.getDocumentBuilder(); 69 Document doc = builder.parse(new ByteArrayInputStream (xmlstr.getBytes())); 70 Element rootEl = doc.getDocumentElement(); 71 72 Call call = service.createCall(new QName (namespaceURI, "ObjectElementServer"), "processObject"); 73 74 Object retObj = call.invoke(new Object []{rootEl}); 75 assertNotNull("Return obj is null", retObj); 76 assertTrue("Return obj is not an Element: " + retObj.getClass().getName(), retObj instanceof Element ); 77 } 78 79 80 public static Test suite() throws Exception 81 { 82 return getDeploySetup(ObjectElementTestCase.class, "jbossnet-document.wsr"); 83 } 84 85 } 86 | Popular Tags |