1   
2   
3   
4   
5   
6   
7   
8   package it.imolinfo.jbi4ejb.test.integration;
9   
10  import it.imolinfo.jbi4ejb.runtime.ejbproxy.StatelessEJBProxy;
11  import it.imolinfo.jbi4ejb.runtime.ejbproxy.StatelessEJBProxyFactory;
12  import it.imolinfo.jbi4ejb.test.TestUtils;
13  import it.imolinfo.jbi4ejb.webservice.generator.DynamicEJBWSDLGenerator;
14  import it.imolinfo.jbi4ejb.webservice.generator.WSDLDescriptor;
15  
16  import java.util.Properties;
17  
18  import junit.framework.TestCase;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  
23  
24  
25  
26  public class TestEJBJNDI extends TestCase {
27  
28      
29      private static final Log LOG = LogFactory.getLog(TestEJBJNDI.class);   
30      
31      
32  
33  
34      @SuppressWarnings("unchecked")
35      public void _testGFUserProfile() {
36          
37          testEJBJNDIRemoteInterface(
38                  "it.imolinfo.test14.complex.TestComplexSessionRemote",
39                  "/home/marco/NetBeansProjects/EJBModule14/dist/EJBModule14.jar",
40                  "ejb/TestComplexSessionBean",                
41                  "getUserProfile", new Object[] { "pippo" }, TestUtils.GLASSFISH_v2);
42      }
43  
44  
45      
46  
47  
48      @SuppressWarnings("unchecked")
49      public void _testIBMUserProfile() {
50          
51          testEJBJNDIRemoteInterface(
52                  "it.imolinfo.test14.complex.TestComplexSessionRemote",
53                  "/home/marco/IBM/rationalsdp7.0/workspace/TestEJBClient/TestEJBClient.jar",
54                  "ejb/TestComplexSessionBeanWS",
55                  "getUserProfile", new Object[] { "pippo" }, TestUtils.WEBSPHERE_6);
56      }
57      
58      
59  
60  
61      @SuppressWarnings("unchecked")
62      public void _testUserProfileJBoss() {
63          
64          testEJBJNDIRemoteInterface(
65                  "it.imolinfo.test14.complex.TestComplexSessionRemote",
66                  "/home/marco/NetBeansProjects/EJBModule14/dist/EJBModule14.jar",
67                  "ejb/TestComplexSessionBean",                   
68                  "getUserProfile", new Object[] { "pippo" }, TestUtils.JBOSS_V4);
69      }    
70  
71      
72  
73  
74  
75  
76  
77  
78  
79  
80      @SuppressWarnings("unchecked")
81      private void testEJBJNDIRemoteInterface(String remoteInterfaceName,
82              String jarPath, String jndiName, String methodName, Object[] args, String asType) {
83  
84          if (System.getProperty("localRepository") == null) {
85              fail("Set the localRepository variable to the maven repository");
86          }
87  
88          try {
89              
90           
91              Properties classesId = TestUtils.getClassesIdFromJar(remoteInterfaceName, jarPath);
92              
93              
94              WSDLDescriptor descriptor = new WSDLDescriptor(jndiName, "jndi");
95              descriptor.setJndiProperties(TestUtils.getJndiProperties(asType));
96              
97              
98              String wsdlFileName = DynamicEJBWSDLGenerator
99              .generateWSDLFromRemoteInterface(remoteInterfaceName,
100                     jarPath, descriptor);
101             
102             
103             StatelessEJBProxy ejbProxy = StatelessEJBProxyFactory.getEJBFromJNDIName(wsdlFileName,
104                     remoteInterfaceName, jndiName, TestUtils.getJndiProperties(asType), TestUtils.getOrbProperties(asType),
105                     classesId, TestUtils.getJarFilesName("1.2.2"));
106             
107 
108             
109             Object res = ejbProxy.invokeMethod(methodName, args);
110 
111             LOG.debug(res);
112 
113         } catch (Throwable ex) {
114             ex.printStackTrace();
115             fail(ex.getMessage());
116         }
117     }
118     
119     
120     
121 
122 
123 }