[Jboss-cvs] JBossAS SVN: r56181 - in branches/MC_VDF_WORK/system-jmx/src: resources/tests/org/jboss/test/system/controller/lifecycle/test tests/org/jboss/test/system/controller/lifecycle/test tests/org/jboss/test/system/controller/support

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 23 11:26:23 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-08-23 11:26:18 -0400 (Wed, 23 Aug 2006)
New Revision: 56181

Added:
   branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_bad.xml
   branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_good.xml
   branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanService.java
   branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanServiceMBean.java
Modified:
   branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/lifecycle/test/LifecycleRedeployAfterErrorTest.java
Log:
Add test of contained mbean service creation

Added: branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_bad.xml
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_bad.xml	2006-08-23 14:38:41 UTC (rev 56180)
+++ branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_bad.xml	2006-08-23 15:26:18 UTC (rev 56181)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.ContainedMBeanService">
+      <attribute name="AString">ERRORINSTART</attribute>
+   </mbean>
+</server>
\ No newline at end of file

Added: branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_good.xml
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_good.xml	2006-08-23 14:38:41 UTC (rev 56180)
+++ branches/MC_VDF_WORK/system-jmx/src/resources/tests/org/jboss/test/system/controller/lifecycle/test/ErrorInContainedStartRedeployAfterError_good.xml	2006-08-23 15:26:18 UTC (rev 56181)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+   <mbean name="jboss.test:type=test" code="org.jboss.test.system.controller.support.ContainedMBeanService">
+   </mbean>
+</server>
\ No newline at end of file

Modified: branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/lifecycle/test/LifecycleRedeployAfterErrorTest.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/lifecycle/test/LifecycleRedeployAfterErrorTest.java	2006-08-23 14:38:41 UTC (rev 56180)
+++ branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/lifecycle/test/LifecycleRedeployAfterErrorTest.java	2006-08-23 15:26:18 UTC (rev 56181)
@@ -22,6 +22,7 @@
 package org.jboss.test.system.controller.lifecycle.test;
 
 import org.jboss.test.system.controller.AbstractControllerTest;
+import org.jboss.test.system.controller.support.ContainedMBeanServiceMBean;
 import org.jboss.test.system.controller.support.SimpleMBean;
 
 /**
@@ -56,4 +57,9 @@
    {
       redeployAfterUndeployFailure(SimpleMBean.OBJECT_NAME);
    }
+
+   public void testErrorInContainedStartRedeployAfterError() throws Exception
+   {
+      redeployAfterDeployFailure(ContainedMBeanServiceMBean.OBJECT_NAME, Error.class);
+   }
 }

Added: branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanService.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanService.java	2006-08-23 14:38:41 UTC (rev 56180)
+++ branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanService.java	2006-08-23 15:26:18 UTC (rev 56181)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.test.system.controller.support;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Hashtable;
+
+import javax.management.ObjectName;
+
+import org.jboss.system.ServiceMBeanSupport;
+
+/**
+ * An mbean that creates and starts mbeans outside of the SARDeployer.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ContainedMBeanService extends ServiceMBeanSupport
+   implements ContainedMBeanServiceMBean
+{
+   private String aString;
+   private ObjectName simpleName;
+   private Simple simpleMBean;
+
+   /** Pass through AString for the container SimpleMBean */
+   public String getAString()
+   {
+      return this.aString;
+   }
+   /** Pass through AString for the container SimpleMBean */
+   public void setAString(String string)
+   {
+      this.aString = string;
+   }
+
+   /**
+    * Create and register the contained SimpleMBean
+    */
+   @Override
+   protected void createService() throws Exception
+   {
+      simpleMBean = new Simple();
+      simpleMBean.setAString(aString);
+      Hashtable props = serviceName.getKeyPropertyList();
+      props.put("contained", "SimpleMBean");
+      simpleName = new ObjectName(serviceName.getDomain(), props);
+      server.registerMBean(simpleMBean, simpleName);
+      boolean expectError = "ERRORINCREATE".equals(aString);
+      // Invoke create on simpleName
+      Object[] params = {};
+      String[] signature = {};
+      server.invoke(simpleName, "create", params, signature);
+      if( expectError )
+         throw new Error("Did not see expected ERRORINCREATE from: "+simpleName);
+   }
+
+   @Override
+   protected void startService() throws Exception
+   {
+      if( simpleName != null )
+      {
+         // Invoke start on simpleName
+         boolean expectError = "ERRORINSTART".equals(aString);
+         Object[] params = {};
+         String[] signature = {};
+         server.invoke(simpleName, "start", params, signature);
+         if( expectError )
+            throw new Error("Did not see expected ERRORINSTART from: "+simpleName);
+      }
+   }
+
+   @Override
+   protected void stopService() throws Exception
+   {
+      if( simpleName != null )
+      {
+         boolean expectError = "ERRORINSTOP".equals(aString);
+         Object[] params = {};
+         String[] signature = {};
+         server.invoke(simpleName, "stop", params, signature);
+         if( expectError )
+            throw new Error("Did not see expected ERRORINSTOP from: "+simpleName);
+      }
+   }
+
+   @Override
+   protected void destroyService() throws Exception
+   {
+      if( simpleName != null )
+      {
+         boolean expectError = "ERRORINDESTROY".equals(aString);
+         Object[] params = {};
+         String[] signature = {};
+         try
+         {
+            server.invoke(simpleName, "destroy", params, signature);
+            if( expectError )
+               throw new Error("Did not see expected ERRORINDESTROY from: "+simpleName);
+         }
+         catch(Throwable e)
+         {
+            if( expectError == false )
+               throw new UndeclaredThrowableException(e);
+         }
+         server.unregisterMBean(simpleName);
+      }
+      simpleName = null;
+   }
+
+}

Added: branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanServiceMBean.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanServiceMBean.java	2006-08-23 14:38:41 UTC (rev 56180)
+++ branches/MC_VDF_WORK/system-jmx/src/tests/org/jboss/test/system/controller/support/ContainedMBeanServiceMBean.java	2006-08-23 15:26:18 UTC (rev 56181)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.test.system.controller.support;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceMBean;
+
+/**
+ * The mbean interface for ContainedMBeanService
+ *  
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ContainedMBeanServiceMBean extends ServiceMBean
+{
+   ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.test:type=test");
+
+   /** Pass through AString for the container SimpleMBean */
+   String getAString();
+   /** Pass through AString for the container SimpleMBean */
+   void setAString(String string);
+}




More information about the jboss-cvs-commits mailing list