1 7 package org.jboss.test.webservice.samples; 8 9 11 import junit.framework.Test; 12 import org.jboss.axis.client.Call; 13 import org.jboss.axis.configuration.FileProvider; 14 import org.jboss.axis.encoding.XMLType; 15 import org.jboss.axis.transport.jms.JMSConstants; 16 import org.jboss.axis.transport.jms.JMSTransport; 17 import org.jboss.test.JBossTestCase; 18 19 import javax.naming.InitialContext ; 20 import javax.xml.namespace.QName ; 21 import javax.xml.rpc.ParameterMode ; 22 import java.io.ByteArrayInputStream ; 23 import java.util.HashMap ; 24 25 26 33 public class ServerSideJMSTestCase extends JBossTestCase 34 { 35 private static final String ENDPOINT_QUEUE = "queue/MessageDrivenEndpointQueue"; 36 private static final String TARGET_NAMESPACE = "http://org.jboss.test.webservice/samples"; 37 38 public ServerSideJMSTestCase(String name) 39 { 40 super(name); 41 } 42 43 44 public static Test suite() throws Exception 45 { 46 return getDeploySetup(ServerSideJMSTestCase.class, "ws4ee-samples-server-jms.jar"); 47 } 48 49 52 public void testSOAPMessageToEndpointQueue() throws Exception 53 { 54 InitialContext ctx = new InitialContext (); 56 HashMap ctxEnv = new HashMap (ctx.getEnvironment()); 57 ctxEnv.put("transport.jms.ConnectionFactoryJNDIName", "UIL2ConnectionFactory"); 58 JMSTransport transport = new JMSTransport(null, ctxEnv); 59 60 String clientConfig = 61 "<deployment name='JMS Test' xmlns='http://xml.apache.org/axis/wsdd/'" + 62 " xmlns:java='http://xml.apache.org/axis/wsdd/providers/java'>" + 63 " <handler name='JMSSender' type='java:org.jboss.axis.transport.jms.JMSSender' />" + 64 " <transport name='JMSTransport' pivot='JMSSender'/>" + 65 "</deployment>"; 66 try 67 { 68 FileProvider config = new FileProvider(new ByteArrayInputStream (clientConfig.getBytes())); 70 org.jboss.axis.client.Service service = new org.jboss.axis.client.Service(config); 71 Call call = (Call)service.createCall(); 72 73 call.setOperationName(new QName (TARGET_NAMESPACE, "getContactInfo")); 74 call.addParameter("organization", XMLType.XSD_STRING, ParameterMode.IN); 75 call.setReturnType(XMLType.XSD_STRING); 76 call.setProperty(JMSConstants.DESTINATION, ENDPOINT_QUEUE); 77 call.setTimeout(new Integer (1000)); 78 call.setTransport(transport); 79 80 String info = (String )call.invoke(new String []{"mafia"}); 81 assertEquals("The 'mafia' boss is currently out of office, please call again.", info); 82 } 83 finally 84 { 85 transport.shutdown(); 86 } 87 } 88 } 89 | Popular Tags |