1 25 26 package org.objectweb.jonas.jtests.clients.mcontext; 27 28 import javax.xml.namespace.QName ; 29 import javax.xml.rpc.Call ; 30 import javax.xml.rpc.Service ; 31 import javax.xml.rpc.ServiceFactory ; 32 33 import junit.framework.Test; 34 import junit.framework.TestSuite; 35 36 import org.objectweb.jonas.jtests.beans.mcontext.BeanAccessor; 37 import org.objectweb.jonas.jtests.beans.mcontext.BeanAccessorHome; 38 import org.objectweb.jonas.jtests.beans.mcontext.TestMC2; 39 import org.objectweb.jonas.jtests.beans.mcontext.TestMC2Home; 40 import org.objectweb.jonas.jtests.util.JWebServicesTestCase; 41 42 45 public class F_MessageContext extends JWebServicesTestCase { 46 47 public F_MessageContext(String name) { 48 super(name); 49 } 50 51 public static Test suite() { 52 return new TestSuite(F_MessageContext.class); 53 } 54 55 public void setUp() throws Exception { 56 super.setUp(); 57 58 useEar("mcontext"); 59 } 60 61 public void tearDown() throws Exception { 62 super.tearDown(); 63 } 64 65 66 public void testWSCallLocal() throws Exception { 67 String port = System.getProperty("http.port"); 68 69 Service service = ServiceFactory.newInstance().createService(new QName ("jonas:MessageContextTest", 70 "MessageContextTestService")); 71 Call call = service.createCall(new QName ("LocalMContextPort"), 72 new QName ("serviceEndpointMethodHasMessageContext")); 73 call.setTargetEndpointAddress("http://localhost:" + port + "/mcontext/MessageContextWS/LocalMContextPort"); 74 Boolean b = (Boolean ) call.invoke(new Object []{}); 75 76 assertTrue("ServiceEndpoint invokation cannot access the MessageContext", 77 b.booleanValue()); 78 } 79 80 public void testWSCallRemote() throws Exception { 81 String port = System.getProperty("http.port"); 82 83 Service service = ServiceFactory.newInstance().createService(new QName ("jonas:MessageContextTest", 84 "MessageContextTestService")); 85 Call call = service.createCall(new QName ("RemoteMContextPort"), 86 new QName ("serviceEndpointMethodHasMessageContext")); 87 call.setTargetEndpointAddress("http://localhost:" + port + "/mcontext/MessageContextWS/RemoteMContextPort"); 88 Boolean b = (Boolean ) call.invoke(new Object []{}); 89 90 assertTrue("ServiceEndpoint invokation cannot access the MessageContext", 91 b.booleanValue()); 92 } 93 94 public void testEJBCallLocal() throws Exception { 95 BeanAccessorHome home = (BeanAccessorHome) ictx.lookup("BeanAccessorHome"); 96 BeanAccessor accessor = home.create(); 97 assertFalse("ejb call have access to the MessageContext.", 98 accessor.localBeanHasMessageContext()); 99 } 100 101 public void testEJBCallRemote() throws Exception { 102 Object obj = ictx.lookup("TestMC2Home"); 103 TestMC2Home home = (TestMC2Home) javax.rmi.PortableRemoteObject.narrow(obj, TestMC2Home.class); 104 TestMC2 mc2 = home.create(); 105 assertFalse("ejb call have access to the MessageContext.", 106 mc2.remoteMethodHasMessageContext()); 107 } 108 109 public static void main (String args[]) { 110 String testtorun = null; 111 for (int argn = 0; argn < args.length; argn++) { 113 String s_arg = args[argn]; 114 Integer i_arg; 115 if (s_arg.equals("-n")) { 116 testtorun = args[++argn]; 117 } 118 } 119 if (testtorun == null) { 120 junit.textui.TestRunner.run(suite()); 121 } else { 122 junit.textui.TestRunner.run(new F_MessageContext(testtorun)); 123 } 124 } 125 126 } 127 | Popular Tags |