1 22 package org.jboss.test.invokers.test; 23 24 import java.util.ArrayList ; 25 import javax.naming.InitialContext ; 26 27 import junit.framework.Test; 28 import org.jboss.proxy.IClientContainer; 29 import org.jboss.test.JBossTestCase; 30 import org.jboss.test.invokers.interfaces.SimpleBMP; 31 import org.jboss.test.invokers.interfaces.SimpleBMPHome; 32 import org.jboss.test.invokers.interfaces.StatelessSession; 33 import org.jboss.test.invokers.interfaces.StatelessSessionHome; 34 import org.jboss.test.invokers.interfaces.BusinessObjectHome; 35 import org.jboss.test.invokers.interfaces.BusinessObject; 36 37 43 public class MultiInvokersUnitTestCase extends JBossTestCase 44 { 45 50 public MultiInvokersUnitTestCase(String name) 51 { 52 super(name); 53 } 54 55 56 61 public void testMultiInvokers() throws Exception 62 { 63 InitialContext ctx = new InitialContext (); 64 SimpleBMPHome home1 = (SimpleBMPHome)ctx.lookup("SimpleBMP"); 65 SimpleBMPHome home2 = (SimpleBMPHome)ctx.lookup("CompressionSimpleBMP"); 66 67 SimpleBMP bmp1 = home1.create(1, "bill"); 68 SimpleBMP bmp2 = home2.findByPrimaryKey(new Integer (1)); 70 getLog().debug(""); 71 getLog().debug("bmp1 name: " + bmp1.getName()); 72 getLog().debug("bmp2 name: " + bmp2.getName()); 73 getLog().debug("setting name to burke"); 74 bmp1.setName("burke"); 75 getLog().debug("bmp1 name: " + bmp1.getName()); 76 getLog().debug("bmp2 name: " + bmp2.getName()); 77 assertTrue("bmp1 " + bmp1.getName() + " == bmp2 " + bmp2.getName(), bmp1.getName().equals(bmp2.getName())); 78 79 StatelessSessionHome shome1 = (StatelessSessionHome)ctx.lookup("StatelessSession"); 80 StatelessSessionHome shome2 = (StatelessSessionHome)ctx.lookup("CompressionStatelessSession"); 81 StatelessSession ss1 = shome1.create(); 82 StatelessSession ss2 = shome2.create(); 83 84 ss1.getBMP(1); 85 ss2.getBMP(1); 86 87 } 88 89 96 public void testClientContainer() throws Exception 97 { 98 log.info("+++ testClientContainer"); 99 InitialContext ctx = new InitialContext (); 100 BusinessObjectHome home = (BusinessObjectHome)ctx.lookup("BusinessSession"); 101 IClientContainer container = (IClientContainer) home; 103 ArrayList interceptors = container.getInterceptors(); 104 for(int n = 0; n < interceptors.size(); n ++) 105 { 106 log.info(interceptors.get(n)); 107 } 108 BusinessObject bean = home.create(); 109 container = (IClientContainer) bean; 110 interceptors = container.getInterceptors(); 111 for(int n = 0; n < interceptors.size(); n ++) 112 { 113 log.info(interceptors.get(n)); 114 } 115 int last = interceptors.size() - 1; 117 interceptors.set(last, new InvokerInterceptor()); 118 container.setInterceptors(interceptors); 119 120 bean.doSomething(); 122 String reply = bean.doSomethingSlowly("arg1", "arg2"); 124 assertTrue("Reply is decorated with viaJMSGatewayMDB", 125 reply.indexOf("viaJMSGatewayMDB") > 0 ); 126 bean.remove(); 128 } 129 130 public static Test suite() throws Exception 131 { 132 return getDeploySetup(MultiInvokersUnitTestCase.class, "invokers.jar"); 133 } 134 135 } 136 | Popular Tags |