[Jboss-cvs] JBossAS SVN: r56460 - branches/JBoss_4_0_3_SP1_JBAS_3511/testsuite/src/main/org/jboss/test/jca/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 30 15:06:21 EDT 2006


Author: weston.price at jboss.com
Date: 2006-08-30 15:06:20 -0400 (Wed, 30 Aug 2006)
New Revision: 56460

Added:
   branches/JBoss_4_0_3_SP1_JBAS_3511/testsuite/src/main/org/jboss/test/jca/test/JmsASFUnitTestCase.java
Log:
[JBAS-3511] Test modfications to support new ASF handling.

Added: branches/JBoss_4_0_3_SP1_JBAS_3511/testsuite/src/main/org/jboss/test/jca/test/JmsASFUnitTestCase.java
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS_3511/testsuite/src/main/org/jboss/test/jca/test/JmsASFUnitTestCase.java	2006-08-30 19:05:38 UTC (rev 56459)
+++ branches/JBoss_4_0_3_SP1_JBAS_3511/testsuite/src/main/org/jboss/test/jca/test/JmsASFUnitTestCase.java	2006-08-30 19:06:20 UTC (rev 56460)
@@ -0,0 +1,160 @@
+   package org.jboss.test.jca.test;
+
+import java.util.Set;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+public class JmsASFUnitTestCase extends JBossTestCase
+{
+   private static final String MDB_QUERY = "jboss.j2ee:binding=message-driven-bean,*";
+   
+   public JmsASFUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testRecycleLazy() throws Exception
+   {
+      MBeanServerConnection server = super.getServer();
+      ObjectName name = new ObjectName(MDB_QUERY);
+      Set result = server.queryMBeans(name, null);
+      ObjectInstance instance = (ObjectInstance)result.iterator().next();
+      ObjectName ejb = instance.getObjectName();
+         
+      AttributeList attList = new AttributeList();
+      attList.add(new Attribute("RecycleIdleSessions", Boolean.TRUE));
+      attList.add(new Attribute("IdleTimeOutMinutes", Long.valueOf(1)));
+      server.setAttributes(ejb, attList);
+      
+      server.invoke(ejb, "stop", null, null);
+      Thread.sleep(5000);
+      server.invoke(ejb, "start", null, null);
+   
+      Integer current = (Integer)server.getAttribute(ejb, "CurrentSessionCount");
+      Integer maxSize = (Integer)server.getAttribute(ejb, "MaxPoolSize");
+      assertTrue("Current should be max", current.intValue() != maxSize.intValue());
+   
+   }
+
+   public void testRecycleNonLazy() throws Exception
+   {
+      
+      MBeanServerConnection server = super.getServer();
+      ObjectName name = new ObjectName(MDB_QUERY);
+      Set result = server.queryMBeans(name, null);
+      ObjectInstance instance = (ObjectInstance)result.iterator().next();
+      ObjectName ejb = instance.getObjectName();
+         
+      AttributeList attList = new AttributeList();
+      attList.add(new Attribute("RecycleIdleSessions", Boolean.TRUE));
+      attList.add(new Attribute("IdleTimeOutMinutes", Long.valueOf(1)));
+      server.setAttributes(ejb, attList);
+      
+      server.invoke(ejb, "stop", null, null);
+      Thread.sleep(5000);
+      server.invoke(ejb, "start", null, null);
+      
+      Integer current = (Integer)server.getAttribute(ejb, "CurrentSessionCount");
+      Integer maxSize = (Integer)server.getAttribute(ejb, "MaxPoolSize");
+      assertTrue("Current should be max", current.intValue() == maxSize.intValue());
+      Long idle = (Long)server.getAttribute(ejb, "IdleTimeOutMinutes");
+      
+      //Sleep for the time
+      Thread.currentThread().sleep(idle.intValue() * 1000 * 60);
+      
+      Integer recycled = (Integer)server.getAttribute(ejb, "SessionTimedOutCount");
+      current = (Integer)server.getAttribute(ejb, "CurrentSessionCount");
+      assertTrue("Sessions should be timed out", recycled.intValue() > 0 && current.intValue() != maxSize.intValue());
+   }
+
+   public void testLazyInitialization() throws Exception
+   {
+      MBeanServerConnection server = super.getServer();
+      ObjectName name = new ObjectName(MDB_QUERY);
+      Set result = server.queryMBeans(name, null);
+      ObjectInstance instance = (ObjectInstance)result.iterator().next();
+      ObjectName ejb = instance.getObjectName();
+      
+      Attribute latt = new Attribute("LazyInitialization", Boolean.TRUE);
+      server.setAttribute(ejb, latt);
+      
+      server.invoke(ejb, "stop", null, null);
+      Thread.sleep(5000);
+      server.invoke(ejb, "start", null, null);
+      
+      Boolean lazy = (Boolean)server.getAttribute(ejb, "LazyInitialization");
+      assertTrue("Default deployment is lazy initialization false.", lazy.booleanValue());
+  
+      Integer current = (Integer)server.getAttribute(ejb, "CurrentSessionCount");
+      Integer maxSize = (Integer)server.getAttribute(ejb, "MaxPoolSize");
+      Integer minSize = (Integer)server.getAttribute(ejb, "MinPoolSize");
+
+      assertTrue("Lazy init, current and max should not be the same", current.intValue() != maxSize.intValue());
+      assertTrue("Current size and min size should be the same", current.intValue() == minSize.intValue());
+      
+      Integer recycled = (Integer)server.getAttribute(ejb, "SessionTimedOutCount");
+      
+      assertTrue("No sessions should be timed out", recycled.intValue() == 0);
+      
+      
+      
+   
+   }
+   
+   public void testBasicDeploy() throws Exception
+   {
+   
+     
+      
+      MBeanServerConnection server = super.getServer();
+      ObjectName name = new ObjectName(MDB_QUERY);
+      Set result = server.queryMBeans(name, null);
+      ObjectInstance instance = (ObjectInstance)result.iterator().next();
+      ObjectName ejb = instance.getObjectName();
+      
+      Boolean lazy = (Boolean)server.getAttribute(ejb, "LazyInitialization");
+      
+      assertFalse("Default deployment is lazy initialization false.", lazy.booleanValue());
+      
+      Boolean recycle = (Boolean)server.getAttribute(ejb, "RecycleIdleSessions");
+      
+      assertFalse("Default recycle is false", recycle.booleanValue());
+      
+      Integer current = (Integer)server.getAttribute(ejb, "CurrentSessionCount");
+      Integer maxSize = (Integer)server.getAttribute(ejb, "MaxPoolSize");
+  
+      assertTrue("Default current size and maxSize shold be the same.", current.intValue() == maxSize.intValue());
+      
+      Integer recycled = (Integer)server.getAttribute(ejb, "SessionTimedOutCount");
+      
+      assertTrue("No sessions should be timed out", recycled.intValue() == 0);
+      
+      Boolean alwaysConnect = (Boolean)server.getAttribute(ejb, "AlwaysReconnect");
+      
+      assertFalse("Always reconnect should be false by default", alwaysConnect.booleanValue());
+      
+      
+      
+   }
+   
+   protected void setUp() throws Exception
+   {
+      deploy("jca-asf-ejb.jar");
+      
+   }
+   
+   protected void tearDown() throws Exception
+   {
+      undeploy("jca-asf-ejb.jar");
+      
+   }
+}




More information about the jboss-cvs-commits mailing list