[jboss-cvs] JBossAS SVN: r71629 - projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 2 13:12:24 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-04-02 13:12:24 -0400 (Wed, 02 Apr 2008)
New Revision: 71629

Added:
   projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockSessionSynchronization.java
Modified:
   projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContext.java
Log:
[EJBTHREE-1026] Add test of handling state changes in javax.ejb.SessionSynchronization callbacks

Modified: projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContext.java
===================================================================
--- projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContext.java	2008-04-02 17:09:58 UTC (rev 71628)
+++ projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockBeanContext.java	2008-04-02 17:12:24 UTC (rev 71629)
@@ -50,6 +50,7 @@
    private int postActivateCount;
    private Map<String, Object> children;
    private final Map<Object, Object> sharedState;
+   private int count;
    
    public MockBeanContext(String containerName, Map<Object, Object> sharedState)
    {
@@ -221,4 +222,16 @@
       log.trace(getId() + ": invokeModifying()");
       setModified(true);
    }
+   
+   public int getCount()
+   {
+      return count;
+   }
+   
+   public int increment()
+   {
+      count++;
+      setModified(true);
+      return count;
+   }
 }

Added: projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockSessionSynchronization.java
===================================================================
--- projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockSessionSynchronization.java	                        (rev 0)
+++ projects/ejb3/branches/cluster-dev/cache/src/test/java/org/jboss/ejb3/test/cache/mock/MockSessionSynchronization.java	2008-04-02 17:12:24 UTC (rev 71629)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.test.cache.mock;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Mocks the behavior of SessionSynchronizationInterceptor and a bean that
+ * implements javax.ejb.SessionSynchronization by modifying its internal state.
+ *  
+ * @author Brian Stansberry
+ *
+ */
+public class MockSessionSynchronization implements Synchronization
+{
+   private final MockBeanContext ctx;
+   private int count;
+   
+   public MockSessionSynchronization(MockBeanContext ctx)
+   {
+      this.ctx = ctx;
+   }
+   
+   public int getCount()
+   {
+      return count;
+   }
+   
+   public void beforeCompletion()
+   {
+      count = ctx.increment();
+   }
+
+   public void afterCompletion(int status)
+   {      
+   }
+
+}




More information about the jboss-cvs-commits mailing list