dain        2006/02/01 06:50:10

  Added:       modules/core/src/test/org/openejb/spring
                        StatelessEjbSpringTest.java spring.xml
  Log:

  Major refactor
  Split container into an object to represent a deployed ejb and a set of 
shared containers which process invocations
  Introduced interface between CMP container and CMP engine
  
  Revision  Changes    Path
  1.1                  
openejb/modules/core/src/test/org/openejb/spring/StatelessEjbSpringTest.java
  
  Index: StatelessEjbSpringTest.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.org/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: StatelessEjbSpringTest.java,v 1.1 2006/02/01 11:50:10 dain Exp $
   */
  package org.openejb.spring;
  
  import junit.framework.TestCase;
  import org.openejb.StatelessEjbDeployment;
  import org.openejb.slsb.MockLocal;
  import org.openejb.slsb.MockLocalHome;
  import org.springframework.context.support.AbstractXmlApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2006/02/01 11:50:10 $
   */
  public class StatelessEjbSpringTest extends TestCase {
      public void test() throws Exception {
          
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
          AbstractXmlApplicationContext context = new 
ClassPathXmlApplicationContext("org/openejb/spring/spring.xml");
  
          StatelessEjbDeployment statelessEjbDeployment = 
(StatelessEjbDeployment) context.getBean("StatelessEjbDeployment");
          MockLocalHome mockLocalHome = (MockLocalHome) 
statelessEjbDeployment.getEjbLocalHome();
          MockLocal mockLocal = mockLocalHome.create();
          assertEquals(42 + 1, mockLocal.intMethod(42));
          context.destroy();
      }
  }
  
  
  
  1.1                  
openejb/modules/core/src/test/org/openejb/spring/spring.xml
  
  Index: spring.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd";>
  <beans>
    <bean id="TransactionManager" 
class="org.apache.geronimo.transaction.manager.TransactionManagerImpl">
      <constructor-arg index="0" value="100"/>
      <constructor-arg index="1"><null/></constructor-arg>
      <constructor-arg index="2"><null/></constructor-arg>
    </bean>
  
    <bean id="TransactionContextManager" 
class="org.apache.geronimo.transaction.context.TransactionContextManager">
      <constructor-arg index="0" ref="TransactionManager"/>
      <constructor-arg index="1"><null/></constructor-arg>
    </bean>
  
    <bean id="TrackedConnectionAssociator" 
class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator"/>
  
    <bean id="ThreadPool" class="org.apache.geronimo.pool.ThreadPool">
      <constructor-arg index="0" value="5"/>
      <constructor-arg index="1" value="pool"/>
      <constructor-arg index="2" value="5000"/>
      <constructor-arg index="3"><null/></constructor-arg>
      <constructor-arg index="4" value=":name=ThreadPool"/>
    </bean>
  
    <bean id="StatelessEjbContainer" 
class="org.openejb.slsb.DefaultStatelessEjbContainer">
      <constructor-arg index="0" ref="TransactionContextManager"/>
      <constructor-arg index="1" ref="TrackedConnectionAssociator"/>
      <constructor-arg index="2"><null/></constructor-arg>
      <constructor-arg index="3"><null/></constructor-arg>
      <constructor-arg index="4" value="false"/>
      <constructor-arg index="5" value="false"/>
      <constructor-arg index="6" value="false"/>
    </bean>
  
    <bean id="StatelessEjbDeploymentFactory" 
class="org.openejb.StatelessEjbDeploymentFactory">
      <property name="containerId" value=":name=MockEJB"/>
      <property name="ejbName" value="org.openejb.slsb.MockEJB"/>
      <property name="beanClassName" value="org.openejb.slsb.MockEJB"/>
      <property name="homeInterfaceName" value="org.openejb.slsb.MockHome"/>
      <property name="localHomeInterfaceName" 
value="org.openejb.slsb.MockLocalHome"/>
      <property name="remoteInterfaceName" value="org.openejb.slsb.MockRemote"/>
      <property name="localInterfaceName" value="org.openejb.slsb.MockLocal"/>
  
      <property name="ejbContainer" ref="StatelessEjbContainer"/>
    </bean>
  
    <bean id="StatelessEjbDeployment" 
factory-bean="StatelessEjbDeploymentFactory" factory-method="create"/>
  </beans>
  
  
  

Reply via email to