dblevins    2005/02/19 04:46:40

  Modified:    modules/core/src/test/org/openejb/slsb MockEJBContainer.java
                        MockEJBContainerGBean.java
  Log:

  Removed getProxyFactory from EJBContainer interface and all references to it.
  Fixed the WSContainer so it doesn't put instances of InvocationResult in the 
soap message.
  Fixed the invocation test in WSContainerTest.
  Slightly improved the ulgy EJBInvocationStream code.
  
  Revision  Changes    Path
  1.4       +38 -7     
openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainer.java
  
  Index: MockEJBContainer.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MockEJBContainer.java     3 Feb 2005 00:07:59 -0000       1.3
  +++ MockEJBContainer.java     19 Feb 2005 09:46:40 -0000      1.4
  @@ -56,6 +56,7 @@
   
   import org.apache.geronimo.core.service.Invocation;
   import org.apache.geronimo.core.service.InvocationResult;
  +import org.apache.geronimo.core.service.SimpleInvocationResult;
   import org.apache.geronimo.gbean.GBeanData;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoBuilder;
  @@ -73,10 +74,12 @@
   public class MockEJBContainer implements EJBContainer {
       private final ProxyInfo proxyInfo;
       private final Class ejbClass;
  +    private final Method[] methods;
   
       public MockEJBContainer() {
           this.proxyInfo = new ProxyInfo(EJBComponentType.STATELESS, "foo", 
MockHome.class, MockRemote.class, MockLocalHome.class, MockLocal.class, 
MockServiceEndpoint.class, null);
           ejbClass = MockEJB.class;
  +        methods = ejbClass.getMethods();
       }
   
       public MockEJBContainer(URL ejbJarURL, String ejbName, String ejbClass, 
String home, String remote, String localHome, String local, String 
serviceEndpoint) {
  @@ -84,11 +87,28 @@
           try {
               this.proxyInfo = new ProxyInfo(EJBComponentType.STATELESS, 
ejbName, cl.loadClass(home), cl.loadClass(remote), cl.loadClass(localHome), 
cl.loadClass(local), cl.loadClass(serviceEndpoint), null);
               this.ejbClass = cl.loadClass(ejbClass);
  +            this.methods = this.ejbClass.getMethods();
           } catch (ClassNotFoundException e) {
               throw (IllegalStateException) new IllegalStateException("Could 
not initialize the MockEJBContainer").initCause(e);
           }
       }
   
  +    public int getMethodIndex(Method callMethod) {
  +        Method ejbMethod = null;
  +        try {
  +            ejbMethod = ejbClass.getMethod(callMethod.getName(), 
callMethod.getParameterTypes());
  +        } catch (NoSuchMethodException e) {
  +            throw new IllegalArgumentException("Method does not exist in 
bean class: " + callMethod);
  +        }
  +
  +        for (int i = 0; i < methods.length; i++) {
  +            if (methods[i].equals(ejbMethod)) {
  +                return i;
  +            }
  +        }
  +        throw new IllegalArgumentException("Method does not exist in bean 
class: " + callMethod);
  +    }
  +
       public Object getContainerID() {
           return null;
       }
  @@ -120,6 +140,16 @@
           return ejbMethod.invoke(ejb, args);
       }
   
  +    public InvocationResult invoke(Invocation invocation) throws Throwable {
  +        try {
  +            org.openejb.EJBInvocation i = (org.openejb.EJBInvocation) 
invocation;
  +            Object result = invoke(methods[i.getMethodIndex()], 
i.getArguments(), i.getId());
  +            return new SimpleInvocationResult(true, result);
  +        } catch (Throwable throwable) {
  +            return new SimpleInvocationResult(false, throwable);
  +        }
  +    }
  +
       public String[] getJndiNames() {
           return new String[0];
       }
  @@ -152,19 +182,20 @@
           return null;
       }
   
  -    public InvocationResult invoke(Invocation invocation) throws Throwable {
  -        return null;
  -    }
  -
       public static final GBeanInfo GBEAN_INFO;
   
       static {
           GBeanInfoBuilder infoFactory = new 
GBeanInfoBuilder(MockEJBContainer.class);
   
  -        infoFactory.addOperation("invoke", new Class[]{Invocation.class});
  -        infoFactory.addOperation("invoke", new Class[]{Method.class, 
Object[].class, Object.class});
           infoFactory.addAttribute("EJBName", String.class, true);
           infoFactory.addAttribute("ProxyInfo", ProxyInfo.class, true);
  +
  +        infoFactory.addOperation("getMethodIndex", new Class[] 
{Method.class});
  +        infoFactory.addOperation("getEJBObject", new Class[] {Object.class});
  +        infoFactory.addOperation("getEJBLocalObject", new Class[] 
{Object.class});
  +
  +        infoFactory.addOperation("invoke", new Class[]{Invocation.class});
  +        infoFactory.addOperation("invoke", new Class[]{Method.class, 
Object[].class, Object.class});
   
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
  
  
  
  1.2       +2 -1      
openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainerGBean.java
  
  Index: MockEJBContainerGBean.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/slsb/MockEJBContainerGBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MockEJBContainerGBean.java        3 Feb 2005 00:07:59 -0000       1.1
  +++ MockEJBContainerGBean.java        19 Feb 2005 09:46:40 -0000      1.2
  @@ -71,6 +71,7 @@
           infoFactory.addAttribute("localHome", String.class, true);
           infoFactory.addAttribute("local", String.class, true);
           infoFactory.addAttribute("serviceEndpoint", String.class, true);
  +        infoFactory.addOperation("getMethodIndex", new Class[] 
{Method.class});
           infoFactory.addOperation("invoke", new Class[]{Invocation.class});
           infoFactory.addOperation("invoke", new Class[]{Method.class, 
Object[].class, Object.class});
           infoFactory.addAttribute("EJBName", String.class, true);
  
  
  

Reply via email to