[jboss-svn-commits] JBoss Common SVN: r4641 - in arquillian/trunk/containers/reloaded: src/main/java/org/jboss/arquillian/container/reloaded and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 30 12:44:20 EDT 2010
Author: aslak
Date: 2010-06-30 12:44:19 -0400 (Wed, 30 Jun 2010)
New Revision: 4641
Added:
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/JBossReloadedConfiguration.java
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedContainer.java
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedTestEnricher.java
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/LifecyclePojo.java
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedIntegrationTestCase.java
Removed:
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/JBossReloadedConfiguration.java
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java
Modified:
arquillian/trunk/containers/reloaded/pom.xml
arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
Log:
ARQ-200 Renamed Reloaded 1 Embedded Container package
Modified: arquillian/trunk/containers/reloaded/pom.xml
===================================================================
--- arquillian/trunk/containers/reloaded/pom.xml 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/pom.xml 2010-06-30 16:44:19 UTC (rev 4641)
@@ -15,9 +15,9 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-reloaded</artifactId>
- <name>Arquillian Container JBoss Reloaded</name>
- <description>JBoss Reloaded Integration for the Arquillian Project</description>
+ <artifactId>arquillian-reloaded-embedded-1</artifactId>
+ <name>Arquillian Container JBoss Reloaded Embedded 1.x</name>
+ <description>JBoss Reloaded 1.x Embedded integration for the Arquillian Project</description>
<!-- Properties -->
Deleted: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/JBossReloadedConfiguration.java
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/JBossReloadedConfiguration.java 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/JBossReloadedConfiguration.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.container.reloaded;
-
-import org.jboss.arquillian.spi.ContainerConfiguration;
-import org.jboss.arquillian.spi.ContainerProfile;
-
-/**
- * JBossReloadedConfiguration
- *
- * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JBossReloadedConfiguration implements ContainerConfiguration
-{
-
- public ContainerProfile getContainerProfile()
- {
- return ContainerProfile.STANDALONE;
- }
-
-}
Deleted: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1,179 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.container.reloaded;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.List;
-
-import org.jboss.arquillian.protocol.local.LocalMethodExecutor;
-import org.jboss.arquillian.spi.Configuration;
-import org.jboss.arquillian.spi.ContainerMethodExecutor;
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.DeployableContainer;
-import org.jboss.arquillian.spi.DeploymentException;
-import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
-import org.jboss.bootstrap.api.lifecycle.LifecycleState;
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.bootstrap.api.mc.server.MCServerFactory;
-import org.jboss.logging.Logger;
-import org.jboss.reloaded.api.ReloadedDescriptors;
-import org.jboss.reloaded.shrinkwrap.api.ShrinkWrapDeployer;
-import org.jboss.reloaded.shrinkwrap.api.ShrinkWrapReloadedDescriptors;
-import org.jboss.shrinkwrap.api.Archive;
-
-/**
- * {@link DeployableContainer} implementation to integrate the
- * lifecycle and deployment of {@link MCServer} with
- * Arquillian.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ReloadedContainer implements DeployableContainer
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(ReloadedContainer.class);
-
- /**
- * MC bean name of the {@link ShrinkWrapDeployer}
- */
- private static final String NAME_MC_SHRINKWRAP_DEPLOYER = "ShrinkWrapDeployer";
-
- /**
- * Name of the system property signaling JBossXB to ignore order
- */
- private static final String NAME_SYSPROP_JBOSSXB_IGNORE_ORDER = "xb.builder.useUnorderedSequence";
-
- /**
- * Value to set for JBossXB ordering
- */
- private static final String VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER = "true";
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- public void setup(final Context context,final Configuration configuration)
- {
- //configuration.getContainerConfig(JBossReloadedConfiguration.class);
- }
-
- public ContainerMethodExecutor deploy(final Context context, final Archive<?> archive) throws DeploymentException
- {
- // Deploy
- try
- {
- context.get(ShrinkWrapDeployer.class).deploy(archive);
- }
- catch (org.jboss.deployers.spi.DeploymentException e)
- {
- // Translate the exception and wrap
- throw new DeploymentException("Encountered error while deploying " + archive.toString(), e);
- }
-
- // Return
- return new LocalMethodExecutor();
- }
-
- public void start(Context context) throws LifecycleException
- {
- // Set up JBossXB
- AccessController.doPrivileged(new PrivilegedAction<Void>()
- {
- public Void run()
- {
- // Must use unordered sequence else JBossXB will explode
- System.setProperty(NAME_SYSPROP_JBOSSXB_IGNORE_ORDER, VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER);
- return null;
- }
- });
-
- // Create the Server
- final MCServer server = MCServerFactory.createServer();
-
- // Add the required bootstrap descriptors
- final List<BootstrapDescriptor> descriptors = server.getConfiguration().getBootstrapDescriptors();
- descriptors.add(ReloadedDescriptors.getClassLoadingDescriptor());
- descriptors.add(ReloadedDescriptors.getVdfDescriptor());
- descriptors.add(ReloadedDescriptors.getThreadsDescriptor());
- descriptors.add(ShrinkWrapReloadedDescriptors.getTempFileProviderDescriptor());
- descriptors.add(ShrinkWrapReloadedDescriptors.getShrinkWrapDeployerDescriptor());
-
- // Start the server
- try
- {
- server.start();
- }
- catch (final Exception e)
- {
- throw new LifecycleException("Error in starting the Microcontainer server " + server, e);
- }
-
- // Get the ShrinkWrapDeployer
- final ShrinkWrapDeployer deployer = (ShrinkWrapDeployer) server.getKernel().getController().getInstalledContext(
- NAME_MC_SHRINKWRAP_DEPLOYER).getTarget();
-
- context.add(MCServer.class, server);
- context.add(ShrinkWrapDeployer.class, deployer);
- }
-
- public void stop(final Context context) throws LifecycleException
- {
- final MCServer server = context.get(MCServer.class);
- // If we've got a server
- if (server != null && server.getState().equals(LifecycleState.STARTED))
- {
- // Bring it down
- try
- {
- server.stop();
- }
- catch (final Exception e)
- {
- throw new LifecycleException("Error in stopping the Microcontainer server " + server, e);
- }
- }
- }
-
- public void undeploy(Context context, final Archive<?> archive) throws DeploymentException
- {
- // Undeploy
- try
- {
- context.get(ShrinkWrapDeployer.class).undeploy(archive);
- }
- catch (org.jboss.deployers.spi.DeploymentException e)
- {
- // Translate the exception and wrap
- throw new DeploymentException("Encountered error while undeploying " + archive.toString(), e);
- }
-
- }
-}
Deleted: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.container.reloaded;
-
-import java.lang.reflect.Method;
-
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.TestEnricher;
-import org.jboss.arquillian.spi.event.container.BeforeUnDeploy;
-import org.jboss.arquillian.spi.event.container.ContainerEvent;
-import org.jboss.arquillian.spi.event.suite.EventHandler;
-import org.jboss.beans.info.spi.BeanAccessMode;
-import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.kernel.spi.dependency.KernelController;
-
-/**
- * {@link TestEnricher} implementation which provides all injection
- * and service features of the Microcontainer to the test instance
- * by installing it into MC.
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class ReloadedTestEnricher implements TestEnricher
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * MC Bind name under which the test will be installed
- * TODO: Should be private, this wider access is needed by the {@link ReloadedContainer}
- * @see http://community.jboss.org/thread/150796?tstart=0
- */
- static final String BIND_NAME_TEST = "org.jboss.arquillian.CurrentTest";
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations -----------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * {@inheritDoc}
- * @see org.jboss.arquillian.spi.TestEnricher#enrich(org.jboss.arquillian.spi.Context, java.lang.Object)
- */
- public void enrich(final Context context, final Object testCase)
- {
- // Obtain the server as set from the container
- final MCServer server = context.get(MCServer.class);
- assert server != null : "MC Server was not set by the container";
-
- // Get the Controller
- final KernelController controller = server.getKernel().getController();
-
- // Install the test instance itself into MC (so injections may be honored)
- final BeanMetaDataBuilder bmdb = BeanMetaDataBuilderFactory.createBuilder(BIND_NAME_TEST,
- testCase.getClass().getName()).setAccessMode(BeanAccessMode.ALL);
- try
- {
- controller.install(bmdb.getBeanMetaData(), testCase);
- context.getParentContext().register(BeforeUnDeploy.class, new TestCaseUnInstaller());
- }
- catch (final Throwable e)
- {
- throw new RuntimeException("Could not enrich " + testCase + " by installing the instance into MC", e);
- }
- }
-
- /**
- * {@inheritDoc}
- * @see org.jboss.arquillian.spi.TestEnricher#resolve(org.jboss.arquillian.spi.Context, java.lang.reflect.Method)
- */
- public Object[] resolve(final Context context, final Method method)
- {
- return new Object[method.getParameterTypes().length];
- }
-
- /**
- * Uninstall the installed test case from the MCServer before undeploying.
- *
- * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
- * @version $Revision: $
- */
- private static class TestCaseUnInstaller implements EventHandler<ContainerEvent>
- {
- public void callback(final Context context, final ContainerEvent event) throws Exception
- {
- context.get(MCServer.class).getKernel().getController().uninstall(ReloadedTestEnricher.BIND_NAME_TEST);
- }
- }
-}
Copied: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/JBossReloadedConfiguration.java (from rev 4638, arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/JBossReloadedConfiguration.java)
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/JBossReloadedConfiguration.java (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/JBossReloadedConfiguration.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.reloaded.embedded_1;
+
+import org.jboss.arquillian.spi.ContainerConfiguration;
+import org.jboss.arquillian.spi.ContainerProfile;
+
+/**
+ * JBossReloadedConfiguration
+ *
+ * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossReloadedConfiguration implements ContainerConfiguration
+{
+
+ public ContainerProfile getContainerProfile()
+ {
+ return ContainerProfile.STANDALONE;
+ }
+
+}
Copied: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedContainer.java (from rev 4638, arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java)
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedContainer.java (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedContainer.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.reloaded.embedded_1;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.List;
+
+import org.jboss.arquillian.protocol.local.LocalMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.bootstrap.api.descriptor.BootstrapDescriptor;
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.bootstrap.api.mc.server.MCServerFactory;
+import org.jboss.logging.Logger;
+import org.jboss.reloaded.api.ReloadedDescriptors;
+import org.jboss.reloaded.shrinkwrap.api.ShrinkWrapDeployer;
+import org.jboss.reloaded.shrinkwrap.api.ShrinkWrapReloadedDescriptors;
+import org.jboss.shrinkwrap.api.Archive;
+
+/**
+ * {@link DeployableContainer} implementation to integrate the
+ * lifecycle and deployment of {@link MCServer} with
+ * Arquillian.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ReloadedContainer implements DeployableContainer
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ReloadedContainer.class);
+
+ /**
+ * MC bean name of the {@link ShrinkWrapDeployer}
+ */
+ private static final String NAME_MC_SHRINKWRAP_DEPLOYER = "ShrinkWrapDeployer";
+
+ /**
+ * Name of the system property signaling JBossXB to ignore order
+ */
+ private static final String NAME_SYSPROP_JBOSSXB_IGNORE_ORDER = "xb.builder.useUnorderedSequence";
+
+ /**
+ * Value to set for JBossXB ordering
+ */
+ private static final String VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER = "true";
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ public void setup(final Context context,final Configuration configuration)
+ {
+ //configuration.getContainerConfig(JBossReloadedConfiguration.class);
+ }
+
+ public ContainerMethodExecutor deploy(final Context context, final Archive<?> archive) throws DeploymentException
+ {
+ // Deploy
+ try
+ {
+ context.get(ShrinkWrapDeployer.class).deploy(archive);
+ }
+ catch (org.jboss.deployers.spi.DeploymentException e)
+ {
+ // Translate the exception and wrap
+ throw new DeploymentException("Encountered error while deploying " + archive.toString(), e);
+ }
+
+ // Return
+ return new LocalMethodExecutor();
+ }
+
+ public void start(Context context) throws LifecycleException
+ {
+ // Set up JBossXB
+ AccessController.doPrivileged(new PrivilegedAction<Void>()
+ {
+ public Void run()
+ {
+ // Must use unordered sequence else JBossXB will explode
+ System.setProperty(NAME_SYSPROP_JBOSSXB_IGNORE_ORDER, VALUE_SYSPROP_JBOSSXB_IGNORE_ORDER);
+ return null;
+ }
+ });
+
+ // Create the Server
+ final MCServer server = MCServerFactory.createServer();
+
+ // Add the required bootstrap descriptors
+ final List<BootstrapDescriptor> descriptors = server.getConfiguration().getBootstrapDescriptors();
+ descriptors.add(ReloadedDescriptors.getClassLoadingDescriptor());
+ descriptors.add(ReloadedDescriptors.getVdfDescriptor());
+ descriptors.add(ReloadedDescriptors.getThreadsDescriptor());
+ descriptors.add(ShrinkWrapReloadedDescriptors.getTempFileProviderDescriptor());
+ descriptors.add(ShrinkWrapReloadedDescriptors.getShrinkWrapDeployerDescriptor());
+
+ // Start the server
+ try
+ {
+ server.start();
+ }
+ catch (final Exception e)
+ {
+ throw new LifecycleException("Error in starting the Microcontainer server " + server, e);
+ }
+
+ // Get the ShrinkWrapDeployer
+ final ShrinkWrapDeployer deployer = (ShrinkWrapDeployer) server.getKernel().getController().getInstalledContext(
+ NAME_MC_SHRINKWRAP_DEPLOYER).getTarget();
+
+ context.add(MCServer.class, server);
+ context.add(ShrinkWrapDeployer.class, deployer);
+ }
+
+ public void stop(final Context context) throws LifecycleException
+ {
+ final MCServer server = context.get(MCServer.class);
+ // If we've got a server
+ if (server != null && server.getState().equals(LifecycleState.STARTED))
+ {
+ // Bring it down
+ try
+ {
+ server.stop();
+ }
+ catch (final Exception e)
+ {
+ throw new LifecycleException("Error in stopping the Microcontainer server " + server, e);
+ }
+ }
+ }
+
+ public void undeploy(Context context, final Archive<?> archive) throws DeploymentException
+ {
+ // Undeploy
+ try
+ {
+ context.get(ShrinkWrapDeployer.class).undeploy(archive);
+ }
+ catch (org.jboss.deployers.spi.DeploymentException e)
+ {
+ // Translate the exception and wrap
+ throw new DeploymentException("Encountered error while undeploying " + archive.toString(), e);
+ }
+
+ }
+}
Copied: arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedTestEnricher.java (from rev 4638, arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java)
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedTestEnricher.java (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedTestEnricher.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.reloaded.embedded_1;
+
+import java.lang.reflect.Method;
+
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.spi.event.container.BeforeUnDeploy;
+import org.jboss.arquillian.spi.event.container.ContainerEvent;
+import org.jboss.arquillian.spi.event.suite.EventHandler;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.kernel.spi.dependency.KernelController;
+
+/**
+ * {@link TestEnricher} implementation which provides all injection
+ * and service features of the Microcontainer to the test instance
+ * by installing it into MC.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ReloadedTestEnricher implements TestEnricher
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * MC Bind name under which the test will be installed
+ * TODO: Should be private, this wider access is needed by the {@link ReloadedContainer}
+ * @see http://community.jboss.org/thread/150796?tstart=0
+ */
+ static final String BIND_NAME_TEST = "org.jboss.arquillian.CurrentTest";
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.TestEnricher#enrich(org.jboss.arquillian.spi.Context, java.lang.Object)
+ */
+ public void enrich(final Context context, final Object testCase)
+ {
+ // Obtain the server as set from the container
+ final MCServer server = context.get(MCServer.class);
+ assert server != null : "MC Server was not set by the container";
+
+ // Get the Controller
+ final KernelController controller = server.getKernel().getController();
+
+ // Install the test instance itself into MC (so injections may be honored)
+ final BeanMetaDataBuilder bmdb = BeanMetaDataBuilderFactory.createBuilder(BIND_NAME_TEST,
+ testCase.getClass().getName()).setAccessMode(BeanAccessMode.ALL);
+ try
+ {
+ controller.install(bmdb.getBeanMetaData(), testCase);
+ context.getParentContext().register(BeforeUnDeploy.class, new TestCaseUnInstaller());
+ }
+ catch (final Throwable e)
+ {
+ throw new RuntimeException("Could not enrich " + testCase + " by installing the instance into MC", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.TestEnricher#resolve(org.jboss.arquillian.spi.Context, java.lang.reflect.Method)
+ */
+ public Object[] resolve(final Context context, final Method method)
+ {
+ return new Object[method.getParameterTypes().length];
+ }
+
+ /**
+ * Uninstall the installed test case from the MCServer before undeploying.
+ *
+ * @author <a href="mailto:aknutsen at redhat.com">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+ private static class TestCaseUnInstaller implements EventHandler<ContainerEvent>
+ {
+ public void callback(final Context context, final ContainerEvent event) throws Exception
+ {
+ context.get(MCServer.class).getKernel().getController().uninstall(ReloadedTestEnricher.BIND_NAME_TEST);
+ }
+ }
+}
Modified: arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.ContainerConfiguration 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1 +1 @@
-org.jboss.arquillian.container.reloaded.JBossReloadedConfiguration
\ No newline at end of file
+org.jboss.arquillian.container.reloaded.embedded_1.JBossReloadedConfiguration
\ No newline at end of file
Modified: arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1 +1 @@
-org.jboss.arquillian.container.reloaded.ReloadedContainer
\ No newline at end of file
+org.jboss.arquillian.container.reloaded.embedded_1.ReloadedContainer
\ No newline at end of file
Modified: arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
===================================================================
--- arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1 +1 @@
-org.jboss.arquillian.container.reloaded.ReloadedTestEnricher
\ No newline at end of file
+org.jboss.arquillian.container.reloaded.embedded_1.ReloadedTestEnricher
\ No newline at end of file
Deleted: arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java
===================================================================
--- arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.container.reloaded;
-
-import org.jboss.beans.metadata.api.annotations.Start;
-import org.jboss.beans.metadata.api.annotations.Stop;
-
-/**
- * Simple POJO with lifecycle operations to set state
- * in for testing
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class LifecyclePojo
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Possible states for this POJO
- */
- enum State {
- STARTED, STOPPED;
- }
-
- /**
- * State flag so the test can see that we've been deployed
- */
- State state = State.STOPPED;
-
- //-------------------------------------------------------------------------------------||
- // Lifecycle Methods ------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Lifecycle start callback
- * @throws Exception
- */
- @Start
- public void start() throws Exception
- {
- state = State.STARTED;
- }
-
- /**
- * Lifecycle stop callback
- * @throws Exception
- */
- @Stop
- public void stop() throws Exception
- {
- state = State.STOPPED;
- }
-}
Deleted: arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java
===================================================================
--- arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java 2010-06-30 15:39:27 UTC (rev 4640)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.container.reloaded;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.logging.Logger;
-
-import org.jboss.arquillian.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.bootstrap.api.mc.server.MCServer;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.Asset;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests that deployments into the {@link MCServer}
- * and Virtual Deployment Framework (ie. JBoss Reloaded)
- * work through the Arquillian lifecycle
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
- at RunWith(Arquillian.class)
-public class ReloadedIntegrationTestCase
-{
-
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Logger
- */
- private static final Logger log = Logger.getLogger(ReloadedIntegrationTestCase.class.getName());
-
- /**
- * Define the deployment
- */
- @Deployment
- public static JavaArchive createDeployment()
- {
- // Construct a test JAR to install the Lifecycle POJO
- final Asset deploymentXmlAsset = new Asset()
- {
-
- public InputStream openStream()
- {
- return new ByteArrayInputStream(new String(
- "<deployment xmlns=\"urn:jboss:bean-deployer:2.0\"><bean name=\"LifecyclePojo\" class=\""
- + LifecyclePojo.class.getName() + "\" /></deployment>").getBytes());
- }
- };
- final JavaArchive testJar = ShrinkWrap.create("pojo.jar", JavaArchive.class).addClass(LifecyclePojo.class).add(
- deploymentXmlAsset, ArchivePaths.create("pojo-jboss-beans.xml"));
- log.info(testJar.toString(true));
- return testJar;
- }
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * POJO to be injected (as installed from MC)
- */
- @Inject
- private LifecyclePojo pojo;
-
- //-------------------------------------------------------------------------------------||
- // Tests ------------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Ensures injection into the test case takes place as expected
- */
- @Test
- public void pojoInstalledAndInjected()
- {
- Assert.assertNotNull("POJO should have been injected from MC", pojo);
- Assert.assertEquals("MC Should have activated POJO in STARTED state", LifecyclePojo.State.STARTED, pojo.state);
- log.info(pojo + " is in state: " + pojo.state);
- }
-
-}
Copied: arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/LifecyclePojo.java (from rev 4638, arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java)
===================================================================
--- arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/LifecyclePojo.java (rev 0)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/LifecyclePojo.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.reloaded.embedded_1;
+
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+
+/**
+ * Simple POJO with lifecycle operations to set state
+ * in for testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class LifecyclePojo
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Possible states for this POJO
+ */
+ enum State {
+ STARTED, STOPPED;
+ }
+
+ /**
+ * State flag so the test can see that we've been deployed
+ */
+ State state = State.STOPPED;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle Methods ------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle start callback
+ * @throws Exception
+ */
+ @Start
+ public void start() throws Exception
+ {
+ state = State.STARTED;
+ }
+
+ /**
+ * Lifecycle stop callback
+ * @throws Exception
+ */
+ @Stop
+ public void stop() throws Exception
+ {
+ state = State.STOPPED;
+ }
+}
Copied: arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedIntegrationTestCase.java (from rev 4638, arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java)
===================================================================
--- arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedIntegrationTestCase.java (rev 0)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/embedded_1/ReloadedIntegrationTestCase.java 2010-06-30 16:44:19 UTC (rev 4641)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.reloaded.embedded_1;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.logging.Logger;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.bootstrap.api.mc.server.MCServer;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests that deployments into the {@link MCServer}
+ * and Virtual Deployment Framework (ie. JBoss Reloaded)
+ * work through the Arquillian lifecycle
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class ReloadedIntegrationTestCase
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(ReloadedIntegrationTestCase.class.getName());
+
+ /**
+ * Define the deployment
+ */
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ // Construct a test JAR to install the Lifecycle POJO
+ final Asset deploymentXmlAsset = new Asset()
+ {
+
+ public InputStream openStream()
+ {
+ return new ByteArrayInputStream(new String(
+ "<deployment xmlns=\"urn:jboss:bean-deployer:2.0\"><bean name=\"LifecyclePojo\" class=\""
+ + LifecyclePojo.class.getName() + "\" /></deployment>").getBytes());
+ }
+ };
+ final JavaArchive testJar = ShrinkWrap.create("pojo.jar", JavaArchive.class).addClass(LifecyclePojo.class).add(
+ deploymentXmlAsset, ArchivePaths.create("pojo-jboss-beans.xml"));
+ log.info(testJar.toString(true));
+ return testJar;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * POJO to be injected (as installed from MC)
+ */
+ @Inject
+ private LifecyclePojo pojo;
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures injection into the test case takes place as expected
+ */
+ @Test
+ public void pojoInstalledAndInjected()
+ {
+ Assert.assertNotNull("POJO should have been injected from MC", pojo);
+ Assert.assertEquals("MC Should have activated POJO in STARTED state", LifecyclePojo.State.STARTED, pojo.state);
+ log.info(pojo + " is in state: " + pojo.state);
+ }
+
+}
More information about the jboss-svn-commits
mailing list