User: starksm 
  Date: 02/04/05 09:59:39

  Modified:    src/main/org/jboss/test/cts/ejb Tag: Branch_2_4
                        StatefulSessionBean.java
  Log:
  Add tests of execeptions thrown from the SessionSynchronization methods
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.1  +28 -60    
jbosstest/src/main/org/jboss/test/cts/ejb/StatefulSessionBean.java
  
  Index: StatefulSessionBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/cts/ejb/StatefulSessionBean.java,v
  retrieving revision 1.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- StatefulSessionBean.java  17 Jun 2001 16:47:51 -0000      1.12
  +++ StatefulSessionBean.java  5 Apr 2002 17:59:39 -0000       1.12.2.1
  @@ -1,77 +1,57 @@
   package org.jboss.test.cts.ejb;
   
  -
  -
  -import org.jboss.test.util.ejb.*;
  -import java.security.Principal;
  -import java.io.*;
  -import javax.naming.*;
  -import java.util.*;
  -import javax.ejb.*;
  -import org.jboss.test.cts.interfaces.*;
  +import javax.naming.Context;
  +import javax.naming.InitialContext;
  +import javax.ejb.CreateException;
  +import javax.ejb.EJBException;
  +import javax.ejb.EJBObject;
  +import javax.ejb.SessionSynchronization;
  +
  +import org.jboss.test.cts.interfaces.BeanContextInfo;
  +import org.jboss.test.cts.interfaces.StatefulSessionHome;
  +import org.jboss.test.cts.interfaces.StatefulSession;
   import org.jboss.test.util.ejb.SessionSupport;
   
  -
   /**
    *
  - *   @see <related>
  - *   @author $Author: sparre $
  - *   @version $Revision: 1.12 $
  + *   @author $Author: starksm $
  + *   @version $Revision: 1.12.2.1 $
    */
  -
   public class StatefulSessionBean
      extends SessionSupport
      implements SessionSynchronization
   {
      private int counter;
  -
  -   /**
  -    * Method ejbCreate
  -    *
  -    *
  -    * @throws CreateException
  -    *
  -    */
  +   /** A flag indicating if we should throw */
  +   private int ssExceptionIndex = -1;
   
      public void ejbCreate ()
         throws CreateException
      {
      }
  -
  -   /**
  -    * Method afterBegin
  -    *
  -    *
  -    */
  +   public void ejbCreate (int ssExceptionIndex)
  +      throws CreateException
  +   {
  +      this.ssExceptionIndex = ssExceptionIndex;
  +   }
   
      public void afterBegin ()
      {
  -      System.out.println("Calling afterBegin( )...");
  +      System.out.println("In afterBegin( )...");
  +      if( ssExceptionIndex == StatefulSessionHome.THROW_EX_IN_AFTER_BEGIN )
  +         throw new RuntimeException("afterBegin failure test");
      }
  -
  -   /**
  -    * Method afterCompletion
  -    *
  -    *
  -    * @param isCommited
  -    *
  -    */
  -
      public void afterCompletion (boolean isCommited)
      {
  -      System.out.println("Calling afterCompletion( )");
  -      System.out.println("isCommited = " + isCommited);
  +      System.out.println("In afterCompletion(), isCommited = " + isCommited);
  +      if( ssExceptionIndex == StatefulSessionHome.THROW_EX_IN_AFTER_COMPLETION )
  +         throw new RuntimeException("afterCompletion failure test");
      }
  -
  -   /**
  -    * Method beforeCompletion
  -    *
  -    *
  -    */
  -
      public void beforeCompletion ()
      {
  -      System.out.println("Calling beforeCompletion( )...");
  +      System.out.println("In beforeCompletion( )...");
  +      if( ssExceptionIndex == StatefulSessionHome.THROW_EX_IN_BEFORE_COMPLETION )
  +         throw new RuntimeException("beforeCompletion failure test");
      }
   
      /**
  @@ -83,7 +63,6 @@
       * @return
       *
       */
  -
      public String method1 (String msg)
      {
         return msg;
  @@ -94,7 +73,6 @@
       *
       *
       */
  -
      public void incCounter ()
      {
         counter++;
  @@ -105,7 +83,6 @@
       *
       *
       */
  -
      public void decCounter ()
      {
         counter--;
  @@ -118,7 +95,6 @@
       * @return
       *
       */
  -
      public int getCounter ()
      {
         return counter;
  @@ -131,7 +107,6 @@
       * @param value
       *
       */
  -
      public void setCounter (int value)
      {
         counter = value;
  @@ -144,7 +119,6 @@
       * @return
       *
       */
  -
      public BeanContextInfo getBeanContextInfo ()
         throws java.rmi.RemoteException
      {
  @@ -170,7 +144,6 @@
       *
       *
       */
  -
      public void loopbackTest ()
         throws java.rmi.RemoteException
      {
  @@ -208,17 +181,12 @@
       * @throws java.rmi.RemoteException
       *
       */
  -
      public void loopbackTest (EJBObject obj)
         throws java.rmi.RemoteException
      {
  -
         // This should throw an exception. 
         StatefulSession bean = ( StatefulSession ) obj;
   
         bean.method1("Hello");
      }
   }
  -
  -
  -/*------ Formatted by Jindent 3.23 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to