Author: julien(a)jboss.com
Date: 2007-10-08 09:26:57 -0400 (Mon, 08 Oct 2007)
New Revision: 8562
Added:
modules/test/trunk/mc/
modules/test/trunk/mc/build.bat
modules/test/trunk/mc/build.sh
modules/test/trunk/mc/build.xml
modules/test/trunk/mc/src/
modules/test/trunk/mc/src/main/
modules/test/trunk/mc/src/main/org/
modules/test/trunk/mc/src/main/org/jboss/
modules/test/trunk/mc/src/main/org/jboss/test/
modules/test/trunk/mc/src/main/org/jboss/test/unit/
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MCTestLifeCycleTests.java
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MyService.java
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java
modules/test/trunk/mc/src/main/org/jboss/unit/
modules/test/trunk/mc/src/main/org/jboss/unit/mc/
modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java
modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestProvider.java
modules/test/trunk/mc/src/main/org/jboss/unit/mc/TestCaseFactory.java
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java
modules/test/trunk/mc/src/resources/
modules/test/trunk/mc/src/resources/test/
modules/test/trunk/mc/src/resources/test/blah/
modules/test/trunk/mc/src/resources/test/blah/toto.xml
Log:
commited initial mc integration with jboss unit
Added: modules/test/trunk/mc/build.bat
===================================================================
--- modules/test/trunk/mc/build.bat (rev 0)
+++ modules/test/trunk/mc/build.bat 2007-10-08 13:26:57 UTC (rev 8562)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 1829 2006-03-05 13:20:08Z julien $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: modules/test/trunk/mc/build.bat
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/mc/build.sh
===================================================================
--- modules/test/trunk/mc/build.sh (rev 0)
+++ modules/test/trunk/mc/build.sh 2007-10-08 13:26:57 UTC (rev 8562)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 1829 2006-03-05 13:20:08Z julien $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools'
module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: modules/test/trunk/mc/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/mc/build.xml
===================================================================
--- modules/test/trunk/mc/build.xml (rev 0)
+++ modules/test/trunk/mc/build.xml 2007-10-08 13:26:57 UTC (rev 8562)
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!-- $Id: build.xml 7954 2007-08-16 14:51:00Z julien(a)jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at
http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and
|-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable"
depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+ <path id="library.classpath">
+ <path refid="apache.log4j.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss/common.core.classpath"/>
+ <path refid="jboss/common.logging.spi.classpath"/>
+ </path>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ <path refid="jboss.unit.classpath"/>
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="false"/>
+ <property name="javadoc.protected" value="false"/>
+ <property name="javadoc.packages"
value="org.jboss.unit.*"/>
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="compile">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/jboss-unit-mc-lib.jar">
+ <fileset dir="${build.classes}">
+ <exclude name="org/jboss/test/**"/>
+ </fileset>
+ </jar>
+
+ <jar jarfile="${build.lib}/jboss-unit-mc-test.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/**"/>
+ </fileset>
+ </jar>
+
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <target name="test" depends="output">
+
+ <java classname="org.jboss.test.unit.mc.MCTestLifeCycleTests"
fork="true">
+<!--
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=7878,server=y,suspend=y"/>
+-->
+ <classpath>
+
+ <path location="${build.lib}/jboss-unit-mc-lib.jar"/>
+ <path location="${build.lib}/jboss-unit-mc-test.jar"/>
+ <path location="${build.resources}/test"/>
+
+ <path refid="jboss.unit.classpath"/>
+
+ <path refid="apache.log4j.classpath"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss/common.core.classpath"/>
+ <path refid="jboss/common.logging.spi.classpath"/>
+ <path refid="jboss.aop.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="javassist.javassist.classpath"/>
+ <path refid="trove.trove.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+
+ </classpath>
+ </java>
+
+ </target>
+
+</project>
Property changes on: modules/test/trunk/mc/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MCTestLifeCycleTests.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MCTestLifeCycleTests.java
(rev 0)
+++
modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MCTestLifeCycleTests.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+import org.jboss.unit.driver.impl.pojo.POJOTestSuiteDriver;
+import org.jboss.unit.TestId;
+import org.jboss.unit.driver.command.StartTestCommand;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MCTestLifeCycleTests
+{
+
+ public static void main(String[] args) throws Exception
+ {
+
+ POJOTestSuiteDriver driver = new POJOTestSuiteDriver(SomeTest.class);
+
+ Map<String,String> parametrization = new HashMap<String, String>();
+ parametrization.put("dataSourceName", "hsqldb");
+
+ driver.invoke(new TestId("myTest"), new
StartTestCommand(parametrization));
+ }
+
+}
Added: modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MyService.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MyService.java
(rev 0)
+++ modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/MyService.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MyService
+{
+
+ private String dataSourceName;
+
+ public String getDataSourceName()
+ {
+ return dataSourceName;
+ }
+
+ public void setDataSourceName(String dataSourceName)
+ {
+ this.dataSourceName = dataSourceName;
+ }
+
+ public void start()
+ {
+ System.out.println("MyService start for data source " + dataSourceName);
+ }
+
+ public void stop()
+ {
+ System.out.println("MyService stop");
+ }
+
+}
Added: modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java
(rev 0)
+++ modules/test/trunk/mc/src/main/org/jboss/test/unit/mc/SomeTest.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.unit.mc.api.annotations.Bootstrap;
+import org.jboss.beans.metadata.plugins.annotations.Inject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Bootstrap(id="/blah/toto.xml")
+public class SomeTest
+{
+
+ /** . */
+ private MyService service;
+
+ public MyService getService()
+ {
+ return service;
+ }
+
+ @Inject(bean="MyService")
+ public void setService(MyService service)
+ {
+ this.service = service;
+ }
+
+ public String getDataSourceName()
+ {
+ return "hsqldb";
+ }
+
+ public void start()
+ {
+ System.out.println("SomeTest start with service " + service);
+ System.out.println("SomeTest start with service " + service);
+ System.out.println("SomeTest start with service " + service);
+ System.out.println("SomeTest start with service " + service);
+ System.out.println("SomeTest start with service " + service);
+ System.out.println("SomeTest start with service " + service);
+ }
+
+ @Test
+ public void myTest()
+ {
+
+ }
+}
Added: modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java
(rev 0)
+++ modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestLifeCycle.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,178 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+import org.jboss.unit.spi.pojo.TestLifeCycle;
+import org.jboss.unit.spi.pojo.TestCaseLifeCycleException;
+import org.jboss.unit.spi.pojo.TestCase;
+import org.jboss.unit.mc.api.annotations.Bootstrap;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+
+import java.util.Map;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MCTestLifeCycle extends BasicBootstrap implements TestLifeCycle
+{
+
+ /** . */
+ private TestLifeCycle delegate;
+
+ /** . */
+ private BeanXMLDeployer beanDeployer;
+
+ /** . */
+ private KernelDeployment deployment;
+
+ public MCTestLifeCycle(TestLifeCycle delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public TestCase newTestCase(String name) throws TestCaseLifeCycleException
+ {
+ return delegate.newTestCase(name);
+ }
+
+ public void testCaseParametrize(TestCase testCase, Map<String, String>
parametrization) throws TestCaseLifeCycleException
+ {
+ delegate.testCaseParametrize(testCase, parametrization);
+ }
+
+ public void testCaseCreate(TestCase testCase) throws TestCaseLifeCycleException
+ {
+ Class<? extends Object> testClass = testCase.getPOJO().getClass();
+
+ //
+ Bootstrap blah = testClass.getAnnotation(Bootstrap.class);
+ if (blah == null)
+ {
+ throw new TestCaseLifeCycleException("No Bootstrap annotation
found");
+ }
+
+ URL url = testClass.getResource(blah.id());
+ if (url == null)
+ {
+ throw new TestCaseLifeCycleException("No URL found for bean xml " +
blah.id());
+ }
+
+ System.out.println("url = " + url);
+ System.out.println("url = " + url);
+ System.out.println("url = " + url);
+
+ // setup MC
+ run();
+
+ try
+ {
+ AbstractBeanMetaData bmd = new AbstractBeanMetaData("TestCase",
testClass.getName());
+ AbstractConstructorMetaData cmd = new AbstractConstructorMetaData();
+ bmd.setConstructor(cmd);
+ TestCaseFactory factory = new TestCaseFactory(testCase.getPOJO());
+ AbstractValueMetaData vmd = new AbstractValueMetaData(factory);
+ cmd.setFactory(vmd);
+ cmd.setFactoryMethod("getTestCase");
+ getKernel().getController().install(bmd);
+ }
+ catch (Throwable throwable)
+ {
+ // Perform some MC throwable unwrap
+ if (deployment != null)
+ {
+ // This may be MC saying that something went wrong
+ if (throwable instanceof IllegalStateException)
+ {
+ // log.error("Test runtime context startup failed", throwable);
+ for (KernelControllerContext kernelControllerContext :
deployment.getInstalledContexts())
+ {
+ Throwable t = kernelControllerContext.getError();
+ if (t != null)
+ {
+ throwable = t;
+ break;
+ }
+ }
+ }
+
+ // Undeploy all beans
+ if (deployment != null)
+ {
+ beanDeployer.undeploy(deployment);
+ }
+ }
+
+ //
+ throw new TestCaseLifeCycleException(throwable);
+ }
+
+ try
+ {
+ beanDeployer = new BeanXMLDeployer(getKernel());
+
+ //
+ deployment = beanDeployer.deploy(url);
+
+ //
+ beanDeployer.validate(deployment);
+ }
+ catch (Throwable throwable)
+ {
+ throw new TestCaseLifeCycleException(throwable);
+ }
+
+ //
+ delegate.testCaseCreate(testCase);
+ }
+
+ public void testCaseInvoke(TestCase testCase) throws TestCaseLifeCycleException
+ {
+ delegate.testCaseInvoke(testCase);
+ }
+
+ public void testCaseDestroy(TestCase testCase)
+ {
+ try
+ {
+ delegate.testCaseDestroy(testCase);
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+
+ // Clean up MC
+ if (deployment != null)
+ {
+ beanDeployer.undeploy(deployment);
+ }
+ }
+}
Added: modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestProvider.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestProvider.java
(rev 0)
+++ modules/test/trunk/mc/src/main/org/jboss/unit/mc/MCTestProvider.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+import org.jboss.unit.spi.pojo.TestProvider;
+import org.jboss.unit.spi.pojo.TestSuiteDescriptor;
+import org.jboss.unit.spi.pojo.TestProviderSupport;
+import org.jboss.unit.spi.pojo.TestLifeCycle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MCTestProvider implements TestProvider
+{
+
+ /** . */
+ private TestProviderSupport delegate;
+
+ /** . */
+ private MCTestLifeCycle lifeCycle;
+
+ public MCTestProvider(Class testClass)
+ {
+ this.delegate = new TestProviderSupport(testClass);
+ this.lifeCycle = new MCTestLifeCycle(delegate.getLifeCycle());
+ }
+
+ public TestSuiteDescriptor getDescriptor()
+ {
+ return delegate.getDescriptor();
+ }
+
+ public TestLifeCycle getLifeCycle()
+ {
+ return lifeCycle;
+ }
+}
Added: modules/test/trunk/mc/src/main/org/jboss/unit/mc/TestCaseFactory.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/unit/mc/TestCaseFactory.java
(rev 0)
+++ modules/test/trunk/mc/src/main/org/jboss/unit/mc/TestCaseFactory.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestCaseFactory
+{
+
+ /** . */
+ private final Object testCase;
+
+ public TestCaseFactory(Object testCase)
+ {
+ this.testCase = testCase;
+ }
+
+ public Object getTestCase()
+ {
+ return testCase;
+ }
+}
Added: modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java
===================================================================
--- modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java
(rev 0)
+++
modules/test/trunk/mc/src/main/org/jboss/unit/mc/api/annotations/Bootstrap.java 2007-10-08
13:26:57 UTC (rev 8562)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, 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.unit.mc.api.annotations;
+
+import org.jboss.unit.spi.pojo.annotations.Provider;
+import org.jboss.unit.mc.MCTestProvider;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Annotate
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+(a)Provider(MCTestProvider.class)
+public @interface Bootstrap
+{
+ String id();
+}
Added: modules/test/trunk/mc/src/resources/test/blah/toto.xml
===================================================================
--- modules/test/trunk/mc/src/resources/test/blah/toto.xml (rev
0)
+++ modules/test/trunk/mc/src/resources/test/blah/toto.xml 2007-10-08 13:26:57 UTC (rev
8562)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<deployment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer:2.0
bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="MyService"
class="org.jboss.test.unit.mc.MyService">
+ <property name="dataSourceName"><inject
bean="TestCase" property="dataSourceName"
state="Instantiated"/></property>
+ </bean>
+
+</deployment>