1 7 8 10 package org.jboss.test.jbossnet.ejbsimple; 11 12 import junit.framework.Test; 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.DocumentBuilderFactory ; 19 import java.net.URL ; 20 import java.util.Arrays ; 21 22 30 31 public class EJBEndpointTestCase extends JBossNetTestBase 32 { 33 private QName HELLO_REMOTE_SERVICE = new QName ("http://" + getServerHost() + ":8080/jboss-net/services/HelloRemote", "HelloRemoteService"); 34 private QName HELLO_LOCAL_SERVICE = new QName ("http://" + getServerHost() + ":8080/jboss-net/services/HelloLocal", "HelloLocalService"); 35 36 public EJBEndpointTestCase(String name) 38 { 39 super(name); 40 } 41 42 43 HelloRemote hello; 44 HelloRemote helloLocal; 45 46 47 public void setUp() throws Exception 48 { 49 super.setUp(); 50 URL wsdlURL = new URL (SERVICES_LOCATION + "/HelloRemote?wsdl"); 51 hello = (HelloRemote)createService(wsdlURL, HELLO_REMOTE_SERVICE).getPort(HelloRemote.class); 52 wsdlURL = new URL (SERVICES_LOCATION + "/HelloLocal?wsdl"); 53 helloLocal = (HelloRemote)createService(wsdlURL, HELLO_LOCAL_SERVICE).getPort(HelloRemote.class); 54 } 55 56 57 protected String getAxisConfiguration() 58 { 59 return "jbossnet/ejbsimple/client/client-config.wsdd"; 60 } 61 62 63 public void testClientParser() throws Exception 64 { 65 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 66 assertEquals("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl", docFactory.getClass().getName()); 67 } 68 69 70 public void testHello() throws Exception 71 { 72 assertEquals("Hello World!", hello.hello("World")); 73 assertEquals("Hello World!", helloLocal.hello("World")); 74 } 75 76 77 public void testHowdy() throws Exception 78 { 79 HelloData data = new HelloData(); 80 data.setName("CGJ"); 81 assertEquals("Howdy CGJ!", hello.howdy(data)); 82 assertEquals("Howdy CGJ!", helloLocal.howdy(data)); 83 } 84 85 86 public void testTypedArrays() throws Exception 87 { 88 HelloData[] values = new HelloData[]{new HelloData(), new HelloData()}; 89 assertTrue(Arrays.equals(hello.typedArrays(values), values)); 90 assertTrue(Arrays.equals(helloLocal.typedArrays(values), values)); 91 } 92 93 94 public void testArrays() throws Exception 95 { 96 Object [] values = new Object []{new String ("Test"), new Integer (1), new HelloData()}; 97 assertTrue(Arrays.equals(hello.arrays(values), values)); 98 assertTrue(Arrays.equals(helloLocal.arrays(values), values)); 99 } 100 101 102 public void testReverse() throws Exception 103 { 104 Object [] values = new Object []{new String ("Test"), new Integer (1), new HelloData()}; 105 Object [] expected = new Object []{new HelloData(), new Integer (1), new String ("Test")}; 106 assertTrue(Arrays.equals(hello.reverse(values), expected)); 107 assertTrue(Arrays.equals(helloLocal.reverse(values), expected)); 108 } 109 110 111 public void testElement() throws Exception 112 { 113 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 114 Document doc = docFactory.newDocumentBuilder().newDocument(); 115 Element testElement = doc.createElement("TestElement"); 116 assertEquals(testElement.getNodeName(), hello.element(testElement).getNodeName()); 117 assertEquals(testElement.getNodeName(), helloLocal.element(testElement).getNodeName()); 118 } 119 120 121 public static Test suite() throws Exception 122 { 123 return getDeploySetup(EJBEndpointTestCase.class, "jbossnet-ejbsimple.ear"); 124 } 125 126 127 public static void main(String [] args) 128 { 129 junit.textui.TestRunner.run(EJBEndpointTestCase.class); 130 } 131 132 } 133 | Popular Tags |