[Jboss-cvs] JBossAS SVN: r55116 - in projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller: support test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 3 11:51:24 EDT 2006


Author: adrian at jboss.org
Date: 2006-08-03 11:51:21 -0400 (Thu, 03 Aug 2006)
New Revision: 55116

Added:
   projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorControllerContext.java
   projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorDelegate.java
   projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ErrorControllerActionTestCase.java
Log:
Need xerces to run the kernel testsuite because of the JBossXB dependency

Added: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorControllerContext.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorControllerContext.java	2006-08-03 15:47:12 UTC (rev 55115)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorControllerContext.java	2006-08-03 15:51:21 UTC (rev 55116)
@@ -0,0 +1,150 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.dependency.controller.support;
+
+import java.util.HashMap;
+
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * An ErrorControllerContext.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.5 $
+ */
+public class ErrorControllerContext extends AbstractControllerContext
+{
+   private static final AbstractControllerContextActions actions;
+   
+   static
+   {
+      HashMap<ControllerState, ControllerContextAction> map = new HashMap<ControllerState, ControllerContextAction>();
+      map.put(ControllerState.DESCRIBED, new DescribeAction());
+      map.put(ControllerState.INSTANTIATED, new InstantiateAction());
+      map.put(ControllerState.CONFIGURED, new ConfigureAction());
+      map.put(ControllerState.CREATE, new CreateAction());
+      map.put(ControllerState.START, new StartAction());
+      map.put(ControllerState.INSTALLED, new InstallAction());
+      actions = new AbstractControllerContextActions(map);
+   }
+   
+   private ErrorDelegate delegate;
+   
+   public ErrorControllerContext(ErrorDelegate delegate)
+   {
+      this(delegate, actions);
+   }
+   
+   public ErrorControllerContext(ErrorDelegate delegate, AbstractControllerContextActions actions)
+   {
+      super(delegate.getName(), actions, delegate.dependencies);
+      setMode(delegate.mode);
+      this.delegate = delegate;
+   }
+   
+   public ErrorDelegate getDelegate()
+   {
+      return delegate;
+   }
+   
+   public static class DescribeAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.describeInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.describeUninstall();
+      }
+   }
+   
+   public static class InstantiateAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.instantiateInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.instantiateUninstall();
+      }
+   }
+   
+   public static class ConfigureAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.configureInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.configureUninstall();
+      }
+   }
+   
+   public static class CreateAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.createInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.createUninstall();
+      }
+   }
+   
+   public static class StartAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.startInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.startUninstall();
+      }
+   }
+   
+   public static class InstallAction implements ControllerContextAction
+   {
+      public void install(ControllerContext context) throws Throwable
+      {
+         ((ErrorControllerContext) context).delegate.installInstall();
+      }
+
+      public void uninstall(ControllerContext context)
+      {
+         ((ErrorControllerContext) context).delegate.installUninstall();
+      }
+   }
+}

Added: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorDelegate.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorDelegate.java	2006-08-03 15:47:12 UTC (rev 55115)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/support/ErrorDelegate.java	2006-08-03 15:51:21 UTC (rev 55116)
@@ -0,0 +1,144 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.dependency.controller.support;
+
+import org.jboss.dependency.plugins.AbstractDependencyInfo;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.DependencyItem;
+
+/**
+ * An ErrorDelegate.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class ErrorDelegate
+{
+   private Object name;
+   
+   private int failWhen;
+
+   public ControllerMode mode = ControllerMode.MANUAL;
+   
+   public AbstractDependencyInfo dependencies = new AbstractDependencyInfo();
+
+   public static final int FAIL_IN_DESCRIBE = 1;
+   public static final int FAIL_IN_INSTANTIATE = 2;
+   public static final int FAIL_IN_CONFIGURE = 3;
+   public static final int FAIL_IN_CREATE = 4;
+   public static final int FAIL_IN_START = 5;
+   public static final int FAIL_IN_INSTALL = 6;
+   public static final int FAIL_IN_UNDESCRIBE = -1;
+   public static final int FAIL_IN_UNINSTANTIATE = -2;
+   public static final int FAIL_IN_UNCONFIGURE = -3;
+   public static final int FAIL_IN_UNCREATE = -4;
+   public static final int FAIL_IN_UNSTART = -5;
+   public static final int FAIL_IN_UNINSTALL = -6;
+   
+   public ErrorDelegate(Object name, int failWhen)
+   {
+      this.name = name;
+      this.failWhen = failWhen;
+   }
+   
+   public Object getName()
+   {
+      return name;
+   }
+   
+   public void describeInstall()
+   {
+      if (failWhen == FAIL_IN_DESCRIBE)
+         throw new Error("Fail");
+   }
+   
+   public void describeUninstall()
+   {
+      if (failWhen == FAIL_IN_UNDESCRIBE)
+         throw new Error("Fail");
+   }
+   
+   public void instantiateInstall()
+   {
+      if (failWhen == FAIL_IN_INSTANTIATE)
+         throw new Error("Fail");
+   }
+   
+   public void instantiateUninstall()
+   {
+      if (failWhen == FAIL_IN_UNINSTANTIATE)
+         throw new Error("Fail");
+   }
+   
+   public void configureInstall()
+   {
+      if (failWhen == FAIL_IN_CONFIGURE)
+         throw new Error("Fail");
+   }
+   
+   public void configureUninstall()
+   {
+      if (failWhen == FAIL_IN_UNCONFIGURE)
+         throw new Error("Fail");
+   }
+   
+   public void createInstall()
+   {
+      if (failWhen == FAIL_IN_CREATE)
+         throw new Error("Fail");
+   }
+   
+   public void createUninstall()
+   {
+      if (failWhen == FAIL_IN_UNCREATE)
+         throw new Error("Fail");
+   }
+   
+   public void startInstall()
+   {
+      if (failWhen == FAIL_IN_START)
+         throw new Error("Fail");
+   }
+   
+   public void startUninstall()
+   {
+      if (failWhen == FAIL_IN_UNSTART)
+         throw new Error("Fail");
+   }
+   
+   public void installInstall()
+   {
+      if (failWhen == FAIL_IN_INSTALL)
+         throw new Error("Fail");
+   }
+   
+   public void installUninstall()
+   {
+      if (failWhen == FAIL_IN_UNINSTALL)
+         throw new Error("Fail");
+   }
+   
+   public void addDependency(DependencyItem dependency)
+   {
+      dependencies.addIDependOn(dependency);
+   }
+}

Added: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ErrorControllerActionTestCase.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ErrorControllerActionTestCase.java	2006-08-03 15:47:12 UTC (rev 55115)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/ErrorControllerActionTestCase.java	2006-08-03 15:51:21 UTC (rev 55116)
@@ -0,0 +1,101 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.dependency.controller.test;
+
+import junit.framework.Test;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.dependency.controller.support.ErrorControllerContext;
+import org.jboss.test.dependency.controller.support.ErrorDelegate;
+
+/**
+ * ErrorControllerActionTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ErrorControllerActionTestCase extends AbstractDependencyTest
+{
+   public static Test suite()
+   {
+      return suite(ErrorControllerActionTestCase.class);
+   }
+   
+   public ErrorControllerActionTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testFailInDescribe() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_DESCRIBE);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.DESCRIBED, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+   
+   public void testFailInInstantiate() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_INSTANTIATE);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.INSTANTIATED, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+   
+   public void testFailInConfigure() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_CONFIGURE);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.CONFIGURED, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+   
+   public void testFailInCreate() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_CREATE);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.CREATE, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+   
+   public void testFailInStart() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_START);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.START, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+   
+   public void testFailInInstall() throws Throwable
+   {
+      ErrorDelegate delegate = new ErrorDelegate("test", ErrorDelegate.FAIL_IN_INSTALL);
+      ErrorControllerContext context = new ErrorControllerContext(delegate);
+      assertInstall(context, ControllerState.NOT_INSTALLED);
+      assertChange(context, ControllerState.INSTALLED, ControllerState.ERROR);
+      assertUninstall(context);
+   }
+}




More information about the jboss-cvs-commits mailing list