[jboss-cvs] JBossAS SVN: r87445 - in projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test: ejbthree1807 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 16 13:19:46 EDT 2009


Author: bstansberry at jboss.com
Date: 2009-04-16 13:19:45 -0400 (Thu, 16 Apr 2009)
New Revision: 87445

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecter.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecterBean.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/RemovalTaskFailureUnitTestCase.java
Log:
[EJBTHREE-1807] Test that removal failures don't disrupt timeout removal of other beans

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecter.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecter.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecter.java	2009-04-16 17:19:45 UTC (rev 87445)
@@ -0,0 +1,32 @@
+/*
+ * 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.ejbthree1807;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public interface RemoveRejecter
+{
+   void setRejectRemove(boolean reject);
+}


Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecter.java
___________________________________________________________________
Name: svn:keywords
   + 

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecterBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecterBean.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecterBean.java	2009-04-16 17:19:45 UTC (rev 87445)
@@ -0,0 +1,73 @@
+/*
+ * 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.ejbthree1807;
+
+import javax.annotation.PreDestroy;
+import javax.ejb.Remote;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.annotation.Cache;
+import org.jboss.ejb3.annotation.CacheConfig;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.logging.Logger;
+
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+ at Stateful(name = "RemoveRejecterBean")
+ at Remote(RemoveRejecter.class)
+ at RemoteBinding(jndiBinding = "RemoveRejecter")
+ at CacheConfig(name = "jboss.cache:service=EJB3SFSBClusteredCache", maxSize = 1000, idleTimeoutSeconds = 0, removalTimeoutSeconds = 1)
+ at Cache("StatefulTreeCache")
+public class RemoveRejecterBean implements RemoveRejecter
+{
+   private static final Logger log = Logger.getLogger(RemoveRejecterBean.class);
+   
+   private boolean reject;
+   
+   
+   @PreDestroy
+   public void remove()
+   {
+      if (reject)
+      {
+         reject = false;
+         log.info("Rejecting remove");
+         throw new RuntimeException("Remove rejected");
+      }
+      else
+      {
+         log.info("Allowing remove");
+      }
+   }
+
+
+   public void setRejectRemove(boolean reject)
+   {
+      this.reject = reject;      
+   }
+
+}


Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/RemoveRejecterBean.java
___________________________________________________________________
Name: svn:keywords
   + 

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/RemovalTaskFailureUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/RemovalTaskFailureUnitTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/RemovalTaskFailureUnitTestCase.java	2009-04-16 17:19:45 UTC (rev 87445)
@@ -0,0 +1,102 @@
+/*
+ * 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.ejb3.test.ejbthree1807.unit;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1807.RemoveRejecter;
+import org.jboss.logging.Logger;
+import org.jboss.security.client.SecurityClient;
+import org.jboss.security.client.SecurityClientFactory;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author Brian Stansberry
+ */
+public class RemovalTaskFailureUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(RemovalTaskFailureUnitTestCase.class);
+   
+   private SecurityClient client = null;
+
+   public RemovalTaskFailureUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      this.client = SecurityClientFactory.getSecurityClient();
+      client.setSimple("somebody", "password");
+      client.login();
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(RemovalTaskFailureUnitTestCase.class, "ejbthree1807.jar");
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      if(client == null)
+         return;
+      client.logout();
+      client = null;
+      
+      super.tearDown();
+   }
+   
+   public void testRemovalTaskFailureHandling() throws Exception
+   {
+      RemoveRejecter allow = (RemoveRejecter)getInitialContext().lookup("RemoveRejecter");
+      assertNotNull(allow);
+      allow.setRejectRemove(false);
+      RemoveRejecter reject = (RemoveRejecter)getInitialContext().lookup("RemoveRejecter");
+      assertNotNull(reject);
+      allow.setRejectRemove(true);
+      MBeanServerConnection server = getServer();
+      
+      ObjectName testerName = new ObjectName("jboss.j2ee:jar=ejbthree1807.jar,name=RemoveRejecterBean,service=EJB3");
+      int cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(2, cacheSize);
+      int totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
+      assertEquals(2, totalSize);
+      
+      // Allow removal to run twice
+      Thread.sleep(3 * 1000);
+      cacheSize = (Integer)server.getAttribute(testerName, "CacheSize");
+      assertEquals(0, cacheSize);
+      totalSize = (Integer)server.getAttribute(testerName, "TotalSize");
+      assertEquals(0, totalSize);
+      
+      int removeCount = (Integer)server.getAttribute(testerName, "RemoveCount");
+      assertEquals(2, removeCount);
+   }   
+}


Property changes on: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1807/unit/RemovalTaskFailureUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
   + 




More information about the jboss-cvs-commits mailing list