[jboss-cvs] JBossAS SVN: r57718 - in branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful: . unit

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 18 21:28:45 EDT 2006


Author: bdecoste
Date: 2006-10-18 21:28:41 -0400 (Wed, 18 Oct 2006)
New Revision: 57718

Added:
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStateful.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceBean.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceRemote.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateless.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatelessBean.java
Modified:
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java
   branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
Log:
test for injection and passivation/activation of @Clustered SFSB into SLSB and ServiceBean

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStateful.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStateful.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStateful.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,45 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface ClusteredStateful extends ConcurrentStateful
+{
+   boolean interceptorAccessed();
+
+   boolean testSessionContext();
+   
+   boolean wasPassivated();
+   String getInterceptorState();
+   void setInterceptorState(String param);
+   
+   void testThrownException() throws Exception;
+   
+   void testExceptionCause() throws Exception;
+   void testSerializedState(String state);
+   
+   void removeBean();
+   
+   void testResources() throws Exception;
+}

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ClusteredStatefulBean.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,209 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateful;
+import javax.ejb.PrePassivate;
+import javax.ejb.PostActivate;
+import javax.interceptor.Interceptors;
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.Container;
+
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.ejb.cache.tree.CacheConfig;
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.serial.io.JBossObjectOutputStream;
+import org.jboss.serial.io.JBossObjectInputStream;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateful(name="ClusteredStatefulBean")
+ at Remote(org.jboss.ejb3.test.stateful.ClusteredStateful.class)
+ at Local(org.jboss.ejb3.test.stateful.StatefulLocal.class)
+ at RemoteBinding(jndiBinding = "ClusteredStateful",
+               interceptorStack="RemoteBindingStatefulSessionClientInterceptors",
+               factory = org.jboss.ejb3.test.stateful.StatefulRemoteProxyFactory.class)
+ at CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1, name="jboss.cache:service=EJB3SFSBClusteredCache")
+ at SecurityDomain("test")
+ at Resources({@Resource(name="jdbc/ds", mappedName="java:/DefaultDS")})
+ at Clustered
+public class ClusteredStatefulBean implements ClusteredStateful
+{
+   private static final Logger log = Logger.getLogger(ClusteredStatefulBean.class);
+   
+   @Resource
+   private SessionContext sessionContext;
+   
+//   @Resource(mappedName="java:/DefaultDS")
+//   private transient javax.sql.DataSource datasource;
+   
+//   @Resource(mappedName="java:/ConnectionFactory")
+//   public transient javax.jms.QueueConnectionFactory connectionFactory; 
+
+   private String state;
+   private int stuff;
+   private boolean wasPassivated = false;
+
+   @Interceptors(MyInterceptor.class)
+   public String getInterceptorState()
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+
+   @Interceptors(MyInterceptor.class)
+   public void setInterceptorState(String param)
+   {
+      throw new RuntimeException("NOT REACHABLE");
+   }
+   
+   public boolean testSessionContext()
+   {
+      return sessionContext.isCallerInRole("role");
+   }
+   
+   public void testResources() throws Exception
+   {
+//      datasource.toString();
+//      connectionFactory.toString();
+      
+      javax.sql.DataSource ds = (javax.sql.DataSource)new InitialContext().lookup(Container.ENC_CTX_NAME + "/env/jdbc/ds");
+      ds.toString();
+   }
+
+   public String getState() throws Exception
+   {
+      Thread.sleep(1000);
+      return state;
+   }
+
+   public void setState(String state) throws Exception
+   {
+	  log.info("!!! setState " + this);
+      Thread.sleep(1000);
+      this.state = state;
+   }
+
+   public boolean interceptorAccessed()
+   {
+      return RemoteBindingInterceptor.accessed;
+   }
+
+   public void testThrownException() throws Exception
+   {
+      throw new Exception();
+   }
+
+   public void testExceptionCause() throws Exception
+   {
+      Object o = null;
+      o.toString();
+   }
+
+   @PrePassivate
+   public void passivate()
+   {
+      log.info("************ passivating " + this);  
+      wasPassivated = true;
+   }
+   
+   @PostActivate
+   public void activate()
+   {
+      log.info("************ activating");
+   }
+
+   public void testSerializedState(String state)
+   {
+      this.state = state;
+
+      ClusteredStatefulBean bean = null;
+      try
+      {
+         ObjectOutputStream out;
+
+         ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+         out = new JBossObjectOutputStream(baos, false);
+         out.writeObject(this);
+         out.flush();
+
+         ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+
+         JBossObjectInputStream is = new JBossObjectInputStream(bais);
+         bean = (ClusteredStatefulBean)is.readObject();
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+
+      if (!state.equals(bean.state)) throw new RuntimeException("failed to serialize: " + bean.state);
+   }
+
+   public boolean wasPassivated()
+   {
+	  log.info("************ wasPassivated " + wasPassivated + " " + this);  
+      return wasPassivated;
+   }
+
+   @Init
+   public void ejbCreate(Integer state)
+   {
+      this.state=state.toString();
+   }
+
+   @Init
+   public void ejbCreate(State state)
+   {
+      this.state=state.getState();
+   }
+
+   @Init
+   public void ejbCreate(String state)
+   {
+      this.state=state;
+   }
+   
+   public void removeBean()
+   {
+      
+   }
+}

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceBean.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceBean.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceBean.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,54 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+
+import org.jboss.annotation.ejb.Service;
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Service
+ at Remote(ServiceRemote.class)
+ at SecurityDomain("other")
+public class ServiceBean implements ServiceRemote
+{
+	private static final Logger log = Logger.getLogger(ServiceBean.class);
+	
+	@EJB
+	private Stateful stateful;
+	
+	@EJB
+	private ClusteredStateful clusteredStateful;
+	   
+	public void testInjection() throws Exception
+	{
+		log.info("!!! testInjection ... " + clusteredStateful);
+		stateful.getState();
+		
+		clusteredStateful.getState();
+	}
+}

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceRemote.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceRemote.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/ServiceRemote.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,30 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface ServiceRemote
+{
+   void testInjection() throws Exception;
+}

Modified: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateful.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -36,7 +36,6 @@
    boolean testSessionContext();
    
    public boolean wasPassivated();
-   public void clearPassivated();
    public String getInterceptorState();
    public void setInterceptorState(String param);
    

Modified: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatefulBean.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -37,7 +37,6 @@
 import javax.ejb.PostActivate;
 import javax.interceptor.Interceptors;
 import javax.naming.InitialContext;
-import javax.naming.NamingEnumeration;
 
 import org.jboss.ejb3.Container;
 
@@ -78,6 +77,7 @@
 
    private String state;
    private int stuff;
+   private boolean wasPassivated = false;
 
    @Interceptors(MyInterceptor.class)
    public String getInterceptorState()
@@ -146,8 +146,6 @@
       log.info("************ activating");
    }
 
-   private static boolean wasPassivated = false;
-
    public void testSerializedState(String state)
    {
       this.state = state;
@@ -185,11 +183,6 @@
       return wasPassivated;
    }
 
-   public void clearPassivated()
-   {
-      wasPassivated = false;
-   }
-
    @Init
    public void ejbCreate(Integer state)
    {

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateless.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateless.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/Stateless.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,30 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface Stateless
+{
+   void testInjection() throws Exception;
+}

Added: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatelessBean.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatelessBean.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/StatelessBean.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -0,0 +1,54 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.ejb3.test.stateful;
+
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless(name="StatelessBean")
+ at RemoteBinding(jndiBinding = "Stateless")
+ at Remote(org.jboss.ejb3.test.stateful.Stateless.class)
+public class StatelessBean implements org.jboss.ejb3.test.stateful.Stateless
+{
+	private static final Logger log = Logger.getLogger(StatelessBean.class);
+   
+	@EJB
+	private Stateful stateful;
+	
+	@EJB
+	private ClusteredStateful clusteredStateful;
+	   
+	public void testInjection() throws Exception
+	{
+		log.info("!!! testInjection ... " + clusteredStateful);
+		stateful.getState();
+	   
+		clusteredStateful.getState();
+	}
+}

Modified: branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	2006-10-18 23:59:42 UTC (rev 57717)
+++ branches/JEE5_TCK/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	2006-10-19 01:28:41 UTC (rev 57718)
@@ -27,14 +27,17 @@
 
 import org.jboss.ejb3.ClientKernelAbstraction;
 import org.jboss.ejb3.KernelAbstractionFactory;
+import org.jboss.ejb3.test.stateful.ClusteredStateful;
 import org.jboss.ejb3.test.stateful.ConcurrentStateful;
 import org.jboss.ejb3.test.stateful.SmallCacheStateful;
 import org.jboss.ejb3.test.stateful.Stateful;
 import org.jboss.ejb3.test.stateful.StatefulInvoker;
 import org.jboss.ejb3.test.stateful.StatefulLocal;
 import org.jboss.ejb3.test.stateful.StatefulTx;
+import org.jboss.ejb3.test.stateful.Stateless;
 import org.jboss.ejb3.test.stateful.ProxyFactoryInterface;
 import org.jboss.ejb3.test.stateful.RemoteBindingInterceptor;
+import org.jboss.ejb3.test.stateful.ServiceRemote;
 import org.jboss.ejb3.test.stateful.State;
 import org.jboss.ejb3.test.stateful.StatefulHome;
 import org.jboss.ejb3.test.stateful.ExtendedState;
@@ -107,7 +110,7 @@
       }
    }
    
-   public void testSmallCache() throws Exception
+   public void atestSmallCache() throws Exception
    {
       ConcurrentInvocation[] threads = new ConcurrentInvocation[5];
       for (int i = 0; i < 5; i++) threads[i] = new ConcurrentInvocation(i);
@@ -124,7 +127,7 @@
    
    
 
-   public void testStatefulSynchronization() throws Exception
+   public void atestStatefulSynchronization() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -134,7 +137,7 @@
 
    }
    
-   public void testEJBObject() throws Exception
+   public void atestEJBObject() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -147,7 +150,7 @@
       assertNotNull(stateful);
    }
    
-   public void testStatefulTx() throws Exception
+   public void atestStatefulTx() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -172,7 +175,7 @@
       }
    }
    
-   public void testTemplateInterfaceTx() throws Exception
+   public void atestTemplateInterfaceTx() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -190,7 +193,7 @@
       }
    }
    
-   public void testLocalSFSB() throws Exception
+   public void atestLocalSFSB() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -210,7 +213,7 @@
       }
    }
    
-   public void testNotSerialableSFSB() throws Exception
+   public void atestNotSerialableSFSB() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -222,7 +225,7 @@
       assertEquals("state", state);
    }
    
-   public void testSFSBInit() throws Exception
+   public void atestSFSBInit() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -236,7 +239,7 @@
       assertEquals("Extended_init", s);
    }
    
-   public void testStackTrace() throws Exception
+   public void atestStackTrace() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -256,7 +259,7 @@
       }
    }
    
-   public void testExceptionCase() throws Exception
+   public void atestExceptionCase() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -277,7 +280,7 @@
       }
    }
    
-   public void testRemoteBindingProxyFactory() throws Exception
+   public void atestRemoteBindingProxyFactory() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -286,7 +289,7 @@
       assertNotNull(stateful);
    }
    
-   public void testRemoteBindingInterceptorStack() throws Exception
+   public void atestRemoteBindingInterceptorStack() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
@@ -297,22 +300,27 @@
       assertTrue(RemoteBindingInterceptor.accessed);
    }
 
-   public void testPassivation() throws Exception
+   public void atestPassivation() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
       
       System.out.println("testPassivation");
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      stateless.testInjection();
+      
+      ServiceRemote service = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
+      service.testInjection();
+      
       Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
       assertNotNull(stateful);
       stateful.setState("state");
       assertEquals("state", stateful.getState());
       stateful.testSerializedState("state");
-      stateful.clearPassivated();
       assertEquals(null, stateful.getInterceptorState());
       stateful.setInterceptorState("hello world");
       assertFalse(stateful.testSessionContext());
-      Thread.sleep(5 * 1000);
+      Thread.sleep(10 * 1000);
       assertTrue(stateful.wasPassivated());
       
       assertEquals("state", stateful.getState());
@@ -327,14 +335,60 @@
       assertFalse(stateful.testSessionContext());
       
       stateful.testResources();
+      
+      stateless.testInjection();
+      
+      service.testInjection();
    }
    
-   public void testRemove() throws Exception
+   public void testClusteredPassivation() throws Exception
    {
       SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
       SecurityAssociation.setCredential("password".toCharArray());
       
       System.out.println("testPassivation");
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      stateless.testInjection();
+      
+      ServiceRemote service = (ServiceRemote) getInitialContext().lookup("ServiceBean/remote");
+      service.testInjection();
+      
+      ClusteredStateful stateful = (ClusteredStateful)getInitialContext().lookup("ClusteredStateful");
+      assertNotNull(stateful);
+      System.out.println("!!!! clusteredStateful " + stateful);
+      stateful.setState("state");
+      assertEquals("state", stateful.getState());
+      stateful.testSerializedState("state");
+      assertEquals(null, stateful.getInterceptorState());
+      stateful.setInterceptorState("hello world");
+      assertFalse(stateful.testSessionContext());
+      Thread.sleep(10 * 1000);
+      assertTrue(stateful.wasPassivated());
+      
+      assertEquals("state", stateful.getState());
+      assertEquals("hello world", stateful.getInterceptorState());
+
+      Stateful another = (Stateful)getInitialContext().lookup("Stateful");
+      assertEquals(null, another.getInterceptorState());
+      another.setInterceptorState("foo");
+      assertEquals("foo", another.getInterceptorState());
+      assertEquals("hello world", stateful.getInterceptorState());
+      
+      assertFalse(stateful.testSessionContext());
+      
+      stateful.testResources();
+      
+      stateless.testInjection();
+      
+      service.testInjection();
+   }
+   
+   public void atestRemove() throws Exception
+   {
+      SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
+      SecurityAssociation.setCredential("password".toCharArray());
+      
+      System.out.println("testPassivation");
       Stateful stateful = (Stateful)getInitialContext().lookup("Stateful");
       assertNotNull(stateful);
  //     stateful.setState("state");
@@ -351,14 +405,14 @@
       }
    }
 
-   public void testRemoveWithRollback() throws Exception
+   public void atestRemoveWithRollback() throws Exception
    {
       Tester test = (Tester) getInitialContext().lookup("TesterBean/remote");
       test.testRollback1();
       test.testRollback2();
    }
    
-   public void testConcurrentAccess() throws Exception
+   public void atestConcurrentAccess() throws Exception
    {
       ConcurrentStateful stateful = (ConcurrentStateful) new InitialContext().lookup("ConcurrentStateful");
       stateful.getState();
@@ -407,7 +461,7 @@
       assertTrue(wasConcurrentException);
    }
    
-   public void testOverrideConcurrentAccess() throws Exception
+   public void atestOverrideConcurrentAccess() throws Exception
    {
       ConcurrentStateful stateful = (ConcurrentStateful) new InitialContext().lookup("OverrideConcurrentStateful");
       stateful.getState();
@@ -435,7 +489,7 @@
       assertTrue(wasConcurrentException);
    }
    
-   public void testJmxName() throws Exception
+   public void atestJmxName() throws Exception
    {
       ObjectName deployment = new ObjectName("test.ejb3:name=Bill,service=EJB3");
 




More information about the jboss-cvs-commits mailing list