[jboss-cvs] JBossAS SVN: r108669 - in branches/infinispan-int/testsuite/src: main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053 and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 19 13:52:07 EDT 2010
Author: pferraro
Date: 2010-10-19 13:52:06 -0400 (Tue, 19 Oct 2010)
New Revision: 108669
Added:
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/unit/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/unit/ConsistentPassivatedStateUnitTestCase.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingBean.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingRemote.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulator.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulatorMBean.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/unit/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/unit/ClusteredCacheCleanStartUnitTestCase.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationBase.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationRemote.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatefulBean.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatelessBean.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/unit/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/ExplicitFailoverInterceptor.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStateful.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStatefulBean.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/Person.java
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/unit/
branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/unit/PersistenceContextReplicationTestCase.java
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1136/
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1136/jboss-beans.xml
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1346/
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1346/META-INF/
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree921/
branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree921/META-INF/
Log:
Migrated here from ejb3 testsuite
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/unit/ConsistentPassivatedStateUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/unit/ConsistentPassivatedStateUnitTestCase.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1053/unit/ConsistentPassivatedStateUnitTestCase.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,213 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1053.unit;
+
+import java.rmi.dgc.VMID;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedBeanMonitor;
+import org.jboss.ejb3.test.stateful.nested.base.std.NestedStateful;
+import org.jboss.ejb3.test.stateful.nested.base.std.ParentStatefulRemote;
+import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner;
+import org.jboss.ejb3.test.stateful.unit.NestedBeanTestRunner.NestedBeanSet;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jnp.interfaces.NamingContext;
+
+/**
+ * FIXME This is a very weak test for EJBTHREE-1053;
+ * replace with something better when EJBTHREE-1053 is fixed
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 68169 $
+ */
+public class ConsistentPassivatedStateUnitTestCase
+ extends JBossClusteredTestCase
+{
+ private NestedBeanTestRunner runner;
+
+
+ public ConsistentPassivatedStateUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ConsistentPassivatedStateUnitTestCase.class,
+ "clusteredsession-nested.jar");
+ }
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ runner = new NestedBeanTestRunner(getInitialContext(0), getLog());
+ runner.setUp();
+ // Use a sleep time equal to 2 thread runs + a 100 ms fudge
+ runner.setSleepTime(10100L);
+ // For clustered beans, an invocation is a passivation
+ runner.setPassivationPerInvocation(1);
+ // For clustered beans, passivation occurs after already called
+ // @PrePassivate for replication, so don't get a 2nd event
+ runner.setPassivationPerSleep(0);
+ }
+
+ private InitialContext getInitialContext(int node) throws Exception {
+ // Connect to the serverX JNDI
+ String[] urls = getNamingURLs();
+ Properties env1 = new Properties();
+ env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ env1.setProperty(Context.PROVIDER_URL, urls[node]);
+ return new InitialContext(env1);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (runner != null)
+ runner.tearDown();
+ }
+
+ /**
+ *
+ *
+ * @throws Exception
+ */
+ public void testConsistentPassivatedState()
+ throws Exception
+ {
+ getLog().debug("Running testConsistentPassivatedState()");
+ getLog().debug("=======================================");
+
+ int parentInv = 0;
+ int nestedInv = 0;
+
+
+ String[] namingURLS = this.getNamingURLs();
+
+ Properties env = new Properties();
+ env.put(NamingContext.PROVIDER_URL, namingURLS[0]);
+
+ Context ctx = new InitialContext(env);
+
+ getLog().debug("Looking up NestedBeanMonitorBean...");
+ NestedBeanMonitor monitor = (NestedBeanMonitor) ctx.lookup("NestedBeanMonitorBean/remote");
+ VMID monitorVM = monitor.getVMID();
+ runner.addRemovable(monitor);
+ ParentStatefulRemote parent = null;
+ boolean vmMatch = true;
+ for (int i = 0; i < 20 && vmMatch; i++)
+ {
+ env.put(NamingContext.PROVIDER_URL, namingURLS[i % 2]);
+ ctx = new InitialContext(env);
+
+ getLog().debug("Looking up testParentStateful... Attempt " + (i + 1));
+ parent = (ParentStatefulRemote) ctx.lookup("testParentStateful/remote");
+
+ VMID parentVM = parent.getVMID();
+ vmMatch = monitorVM.equals(parentVM);
+ runner.addRemovable(parent);
+ if (vmMatch)
+ {
+ runner.removeBean(parent);
+ }
+ }
+
+ assertFalse("Monitor and SFSB in same VM", vmMatch);
+
+ // Reset the parent to initialize all the beans
+ parent.reset();
+
+ // Monitor the parent
+ monitor.monitor(parent);
+
+ // Reset the parent to clean things up
+ parent.reset();
+ parentInv++;
+ nestedInv++;
+
+ NestedStateful nested = (NestedStateful) parent.getNested();
+ parentInv++;
+ runner.addRemovable(nested);
+
+ NestedBeanSet beanSet = runner.getNestedBeanSet();
+
+ int attempts = 0;
+ while (beanSet.parent.getVMID().equals(beanSet.nested.getVMID()))
+ {
+ if (++attempts == 20)
+ {
+ System.err.println("Unable to obtain nested bean running on separate VM from parent");
+ log.warn("Unable to obtain nested bean running on separate VM from parent");
+ return;
+ }
+ beanSet = runner.getNestedBeanSet();
+ }
+
+ // Exercise the beans, trigger replication
+ assertEquals("Remote counter: ", 1, parent.increment());
+ parentInv++;
+ nestedInv++;
+ assertEquals("Remote counter: ", 2, parent.increment());
+ parentInv++;
+ nestedInv++;
+ assertEquals("Local counter: ", 1, parent.incrementLocal());
+ parentInv++;
+ assertEquals("Local counter: ", 2, parent.incrementLocal());
+ parentInv++;
+
+ // This call activates the nested bean without triggering the @PrePassivate
+ // callback at the end of the call because of the way the bean
+ // implements Optimized
+ nested.getPrePassivate();
+
+ // Passivate. The nested bean will get the @PrePassivate callback since
+ // the previous call activated it
+ sleep(runner.getSleepTime());
+
+ // NOTE: here the invocation goes through the monitor, which has a
+ // different proxy. It may pick a different target server than that
+ // used by our 'nested' variable's proxy. If so, we then test if the
+ // state is as expected on the 2nd server.
+ // If by chance it picks the same target as 'nested', this test is meaningless
+ // So, any failures will be transient
+ // TODO if JBCACHE-1190 is fixed this test may need some re-work
+ int prePass = monitor.getNestedPassivations();
+ assertTrue("EJBTHREE-1053 Deep nested passivate count (" + prePass +
+ ") incorrect, expected " + (nestedInv + 1) + " or " + (parentInv + 1),
+ prePass == nestedInv + 1 || prePass == parentInv + 1);
+
+ getLog().debug("ok");
+ }
+
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingBean.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingBean.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1136;
+
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * A meaningless bean, just so we can deploy a clustered SFSB and
+ * check the state of the SFSB cache thereafter.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 60635 $
+ */
+ at Stateful
+ at Clustered
+public class DoNothingBean implements DoNothingRemote
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ public void doNothing()
+ {
+ // TODO Auto-generated method stub
+ }
+
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingRemote.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/DoNothingRemote.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1136;
+
+import javax.ejb.Remote;
+
+/**
+ * A meaningless interface, just so we can deploy a clustered SFSB and
+ * check the state of the SFSB cache thereafter.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 60233 $
+ */
+ at Remote
+public interface DoNothingRemote
+{
+ void doNothing();
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulator.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulator.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulator.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1136;
+
+import org.infinispan.Cache;
+import org.infinispan.context.Flag;
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.ha.ispn.CacheContainerRegistry;
+
+/**
+ * MBean that stores a key/value in a cache during start
+ * and then allows a caller to check if the value is still there.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+ at JMX(name = "jboss.test:service=Ejb3SFSBCacheManipulator", exposedInterface = SFSBCacheManipulatorMBean.class)
+public class SFSBCacheManipulator implements SFSBCacheManipulatorMBean
+{
+ public static final String KEY = "key";
+ public static final String VALUE = "value";
+
+ private CacheContainerRegistry registry;
+ private String cacheContainerName;
+ private String cacheName;
+
+ public void setCacheContainerRegistry(CacheContainerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public void setCacheContainerName(String cacheContainerName)
+ {
+ this.cacheContainerName = cacheContainerName;
+ }
+
+ public void setCacheName(String cacheName)
+ {
+ this.cacheName = cacheName;
+ }
+
+ @Override
+ public String lookup()
+ {
+ Cache<String, String> cache = this.registry.getCacheContainer(this.cacheContainerName).getCache(this.cacheName);
+ String value = cache.get(KEY);
+ cache.evict(KEY);
+ cache.stop();
+ return value;
+ }
+
+ public void start()
+ {
+ Cache<String, String> cache = this.registry.getCacheContainer(this.cacheContainerName).getCache(this.cacheName);
+ cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).put(KEY, VALUE);
+ cache.evict(KEY);
+ }
+
+ public void stop()
+ {
+ Cache<String, String> cache = this.registry.getCacheContainer(this.cacheContainerName).getCache(this.cacheName);
+ cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).remove(KEY);
+ cache.stop();
+ }
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulatorMBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulatorMBean.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/SFSBCacheManipulatorMBean.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1136;
+
+
+/**
+ * MBean that stores a key/value in a cache during start
+ * and then allows a caller to check if the value is still there.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface SFSBCacheManipulatorMBean
+{
+ String lookup();
+}
\ No newline at end of file
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/unit/ClusteredCacheCleanStartUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/unit/ClusteredCacheCleanStartUnitTestCase.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1136/unit/ClusteredCacheCleanStartUnitTestCase.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1136.unit;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.cluster.ejb3.clusteredsession.ejbthree1136.SFSBCacheManipulator;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Tests that StatefulTreeCache properly cleans up state when initializing.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClusteredCacheCleanStartUnitTestCase extends JBossTestCase
+{
+ /**
+ * Create a new ClusteredCacheCleanupTestCase.
+ *
+ * @param name
+ */
+ public ClusteredCacheCleanStartUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ClusteredCacheCleanStartUnitTestCase.class, "ejbthree1136.sar");
+ }
+
+ public void testClusteredCacheCleanStart() throws Exception
+ {
+ assertEquals("Extraneous data present before deploy", SFSBCacheManipulator.VALUE, getExtraneousData());
+
+ deploy("ejbthree1136-bean.jar");
+
+ try
+ {
+ assertEquals("Extraneous data removed", null, getExtraneousData());
+ }
+ finally
+ {
+ undeploy("ejbthree1136-bean.jar");
+ }
+ }
+
+ private Object getExtraneousData() throws Exception
+ {
+ ObjectName on = new ObjectName("jboss.test:service=Ejb3SFSBCacheManipulator");
+ return invoke(on, "lookup", new Object[]{}, new String[]{});
+ }
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationBase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationBase.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationBase.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1346;
+
+import java.rmi.dgc.VMID;
+
+import javax.interceptor.Interceptors;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.cluster.ejb3.clusteredsession.NodeAnswer;
+import org.jboss.test.cluster.ejb3.clusteredsession.util.ExplicitFailoverInterceptor;
+
+/**
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 57207 $
+ */
+public class DisableClusteredAnnotationBase implements java.io.Serializable, DisableClusteredAnnotationRemote
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ private Logger log = Logger.getLogger(getClass());
+ public static final NodeAnswer myId = new NodeAnswer(new VMID(), "answer");
+
+ // Remote Interface implementation ----------------------------------------------
+
+ // Mimic explict failover
+ @Interceptors({ExplicitFailoverInterceptor.class})
+ public NodeAnswer getNodeState()
+ {
+ log.info("getNodeState, " + myId);
+ return myId;
+ }
+
+ public void setUpFailover(String failover) {
+ // To setup the failover property
+ log.info("Setting up failover property: " +failover);
+ System.setProperty ("JBossCluster-DoFail", failover);
+ }
+
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationRemote.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationRemote.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationRemote.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1346;
+
+import org.jboss.test.cluster.ejb3.clusteredsession.NodeAnswer;
+
+/**
+ * Comment
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 61136 $
+ */
+public interface DisableClusteredAnnotationRemote
+{
+ NodeAnswer getNodeState();
+
+ public void setUpFailover(String failover);
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatefulBean.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatefulBean.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1346;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Test for EJBTHREE-1346. The @Clustered is overridden via jboss.xml
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 67628 $
+ */
+ at Stateful(name="DisableClusteredAnnotationStateful")
+ at Clustered(partition="BogusPartition")
+ at Remote(DisableClusteredAnnotationRemote.class)
+public class DisableClusteredAnnotationStatefulBean extends DisableClusteredAnnotationBase
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Only difference from superclass is the added class-level annotations
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatelessBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatelessBean.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/DisableClusteredAnnotationStatelessBean.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1346;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.Clustered;
+
+/**
+ * Test for EJBTHREE-1346. The @Clustered is overridden via jboss.xml
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 67628 $
+ */
+ at Stateless(name="DisableClusteredAnnotationStateless")
+ at Clustered(partition="BogusPartition")
+ at Remote(DisableClusteredAnnotationRemote.class)
+public class DisableClusteredAnnotationStatelessBean extends DisableClusteredAnnotationBase
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ // Only difference from superclass is the added class-level annotations
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree1346/unit/DisableClusteredAnnotationUnitTestCase.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree1346.unit;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.ejb3.clusteredsession.NodeAnswer;
+import org.jboss.test.cluster.ejb3.clusteredsession.ejbthree1346.DisableClusteredAnnotationRemote;
+
+/**
+ * Tests the @Clustered beans with <clustered>false</clustered> in jboss.xml
+ * do not exhibit clustering behavior.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 83582 $
+ */
+public class DisableClusteredAnnotationUnitTestCase extends JBossClusteredTestCase
+{
+ public DisableClusteredAnnotationUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ final String jarName = "ejbthree1346.jar";
+ Test t1 = JBossClusteredTestCase.getDeploySetup(DisableClusteredAnnotationUnitTestCase.class,
+ jarName);
+ return t1;
+ }
+
+ protected InitialContext getInitialContext(int node) throws Exception {
+ // Connect to the server0 JNDI
+ String[] urls = getNamingURLs();
+ Properties env1 = new Properties();
+ env1.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ env1.setProperty(Context.PROVIDER_URL, urls[node]);
+ return new InitialContext(env1);
+ }
+
+ /** Validate the stateful bean is not clustered by having failover not work */
+ public void testStatefulBean() throws Exception
+ {
+ // Connect to the server0 JNDI
+ InitialContext ctx = getInitialContext(0);
+
+ DisableClusteredAnnotationRemote stateful = null;
+ try
+ {
+ stateful = (DisableClusteredAnnotationRemote) ctx.lookup("DisableClusteredAnnotationStateful/remote");
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ fail(nnfe.getMessage());
+ }
+
+ NodeAnswer node1 = stateful.getNodeState ();
+ getLog ().debug ("Node 1 ID: " +node1);
+
+ // Now we switch to the other node, simulating a failure on node 1
+ //
+ stateful.setUpFailover("once");
+ try
+ {
+ stateful.getNodeState ();
+ fail("GenericClusteringException did not propagate");
+ }
+ catch (Exception good) {}
+ }
+
+ /** Test stateless bean by demonstrating no load balancing */
+ public void testStatelessBean() throws Exception
+ {
+ InitialContext ctx = getInitialContext(0);
+
+ DisableClusteredAnnotationRemote stateless = null;
+
+ try
+ {
+ stateless = (DisableClusteredAnnotationRemote) ctx.lookup("DisableClusteredAnnotationStateless/remote");
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ fail(nnfe.getMessage());
+ }
+
+ NodeAnswer node1 = stateless.getNodeState();
+ assertNotNull(node1);
+ getLog ().debug ("Node 1 ID: " +node1);
+
+ for (int i = 0; i < 20; i++)
+ {
+ assertEquals(node1, stateless.getNodeState());
+ }
+ }
+
+ @Override
+ public void testServerFound() throws Exception
+ {
+ // The superclass throws an exception, but we want this
+ // to be a failure, not an error
+ try
+ {
+ super.testServerFound();
+ }
+ catch (Exception e)
+ {
+ // Use assertNull to get the stack trace in the test report
+ assertNull("Deployment had no exceptions", e);
+ }
+ }
+
+
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/ExplicitFailoverInterceptor.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/ExplicitFailoverInterceptor.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/ExplicitFailoverInterceptor.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921;
+
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
+import org.jboss.logging.Logger;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * Used for testing clustering: allows to explicitly makes a call to node fail
+ * This will mimic a dead server. This is used as a ejb3 interceptor now.
+ * @author Ben Wang
+ *
+ */
+public class ExplicitFailoverInterceptor
+{
+ private Logger log = Logger.getLogger(ExplicitFailoverInterceptor.class);
+
+ @AroundInvoke
+ public Object invoke(InvocationContext ctx)
+ throws Exception
+ {
+ checkFailoverNeed (ctx);
+ return ctx.proceed();
+ }
+
+ protected void checkFailoverNeed (InvocationContext ctx)
+ throws Exception
+ {
+ if(ctx.getMethod().getName().equals("setUpFailover"))
+ {
+ return;
+ }
+
+ String failover = (String)System.getProperty ("JBossCluster-DoFail");
+ boolean doFail = false;
+
+ if (failover != null)
+ {
+ String strFailover = failover;
+ if (strFailover.equalsIgnoreCase ("true"))
+ {
+ doFail = true;
+ }
+ else if (strFailover.equalsIgnoreCase ("once"))
+ {
+ doFail = true;
+ System.setProperty ("JBossCluster-DoFail", "false");
+ }
+ }
+
+ if (doFail)
+ {
+ GenericClusteringException e = new GenericClusteringException
+ (GenericClusteringException.COMPLETED_NO, "Test failover from ejb interceptor", false);
+
+ log.debug ("WE FAILOVER IN EJB INTERCEPTOR (explicit failover)!", e);
+
+ throw e;
+ }
+ }
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStateful.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStateful.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStateful.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree921;
+
+/**
+ * @author carlo
+ *
+ */
+public interface MyStateful
+{
+
+ void done();
+
+ String getDescription();
+
+ void remove(Person p);
+
+ void save(Person p);
+
+ void setDescription(String s);
+
+ void setUpFailover(String failover);
+
+ Person update(Person p);
+
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStatefulBean.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStatefulBean.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/MyStatefulBean.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree921;
+
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.interceptor.Interceptors;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.annotation.Clustered;
+import org.jboss.logging.Logger;
+
+/**
+ * @author carlo
+ *
+ */
+ at Clustered
+ at Stateful
+ at Remote(MyStateful.class)
+ at Interceptors({ExplicitFailoverInterceptor.class})
+public class MyStatefulBean implements MyStateful
+{
+ private static final Logger log = Logger.getLogger(MyStatefulBean.class);
+
+ @PersistenceContext(type=PersistenceContextType.EXTENDED)
+ private EntityManager em;
+
+ private String description;
+
+ @Remove
+ public void done()
+ {
+
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ @PostActivate
+ protected void postActivate()
+ {
+ log.info("postActivate");
+ }
+
+ @PrePassivate
+ protected void prePassivate()
+ {
+ log.info("prePassivate");
+ }
+
+ public void remove(Person p)
+ {
+ em.remove(p);
+ }
+
+ public void save(Person p)
+ {
+ em.persist(p);
+ }
+
+ public void setDescription(String s)
+ {
+ this.description = s;
+ }
+
+ public void setUpFailover(String failover)
+ {
+ // To setup the failover property
+ log.info("Setting up failover property: " +failover);
+ System.setProperty ("JBossCluster-DoFail", failover);
+ }
+
+ public Person update(Person p)
+ {
+ return em.merge(p);
+ }
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/Person.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/Person.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/Person.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.ejb3.clusteredsession.ejbthree921;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * @author carlo
+ *
+ */
+ at Entity
+public class Person implements Serializable
+{
+ private static final long serialVersionUID = 1272038160166897327L;
+
+ private Long id;
+ private String name;
+
+ public Person()
+ {
+
+ }
+
+ public Person(String name)
+ {
+ this.name = name;
+ }
+
+ @Id
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Added: branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/unit/PersistenceContextReplicationTestCase.java
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/unit/PersistenceContextReplicationTestCase.java (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/cluster/ejb3/clusteredsession/ejbthree921/unit/PersistenceContextReplicationTestCase.java 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.cluster.ejb3.clusteredsession.ejbthree921.unit;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921.MyStateful;
+import org.jboss.test.cluster.ejb3.clusteredsession.ejbthree921.Person;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class PersistenceContextReplicationTestCase extends JBossClusteredTestCase
+{
+
+ public PersistenceContextReplicationTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected InitialContext getInitialContext(int node) throws Exception {
+ // Connect to the server0 JNDI
+ String[] urls = getNamingURLs();
+ Properties env1 = new Properties();
+ env1.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ env1.setProperty(Context.PROVIDER_URL, urls[node]);
+ return new InitialContext(env1);
+ }
+
+ public void test1() throws Exception
+ {
+ MyStateful stateful = (MyStateful) getInitialContext(0).lookup("MyStatefulBean/remote");
+ Person p = new Person("Brian");
+ stateful.save(p);
+ String expected = "Changing SFSB state";
+ stateful.setDescription(expected);
+ stateful.setUpFailover("once");
+ try
+ {
+ String actual = stateful.getDescription();
+ assertEquals(expected, actual);
+ }
+ catch(Exception e)
+ {
+ Throwable cause = e;
+ while(cause.getCause() != null) cause = cause.getCause();
+ throw (Exception) cause;
+ }
+ stateful.remove(p);
+ stateful.done();
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(PersistenceContextReplicationTestCase.class, "ejbthree921.jar");
+ }
+
+}
Added: branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1136/jboss-beans.xml
===================================================================
--- branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1136/jboss-beans.xml (rev 0)
+++ branches/infinispan-int/testsuite/src/resources/cluster/ejb3/clusteredsession/ejbthree1136/jboss-beans.xml 2010-10-19 17:52:06 UTC (rev 108669)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <bean name="SFSBCacheManipulator" class="org.jboss.test.cluster.ejb3.clusteredsession.ejbthree1136.SFSBCacheManipulator">
+ <property name="cacheContainerRegistry"><inject bean="CacheContainerRegistry"/></property>
+ <property name="cacheContainerName">sfsb-cache</property>
+ <property name="cacheName">jar=ejbthree1136-bean.jar,name=DoNothingBean,service=EJB3</property>
+ </bean>
+</deployment>
More information about the jboss-cvs-commits
mailing list