[jboss-svn-commits] JBoss Common SVN: r4260 - in arquillian/trunk/containers: reloaded and 19 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Apr 16 02:36:59 EDT 2010
Author: ALRubinger
Date: 2010-04-16 02:36:59 -0400 (Fri, 16 Apr 2010)
New Revision: 4260
Added:
arquillian/trunk/containers/reloaded/
arquillian/trunk/containers/reloaded/pom.xml
arquillian/trunk/containers/reloaded/src/
arquillian/trunk/containers/reloaded/src/main/
arquillian/trunk/containers/reloaded/src/main/java/
arquillian/trunk/containers/reloaded/src/main/java/org/
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/
arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/
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/main/resources/
arquillian/trunk/containers/reloaded/src/main/resources/META-INF/
arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/
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
arquillian/trunk/containers/reloaded/src/test/
arquillian/trunk/containers/reloaded/src/test/java/
arquillian/trunk/containers/reloaded/src/test/java/org/
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/
arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/
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
arquillian/trunk/containers/reloaded/src/test/resources/
arquillian/trunk/containers/reloaded/src/test/resources/log4j.xml
Modified:
arquillian/trunk/containers/pom.xml
Log:
[ARQ-103] Create a JBoss Reloaded ARQ Container
Modified: arquillian/trunk/containers/pom.xml
===================================================================
--- arquillian/trunk/containers/pom.xml 2010-04-16 06:01:28 UTC (rev 4259)
+++ arquillian/trunk/containers/pom.xml 2010-04-16 06:36:59 UTC (rev 4260)
@@ -33,6 +33,7 @@
<module>glassfish-embedded-30</module>
<module>weld-embedded</module>
<module>openejb</module>
+ <module>reloaded</module>
</modules>
Property changes on: arquillian/trunk/containers/reloaded
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
target-eclipse
bin
.settings
.classpath
.project
Added: arquillian/trunk/containers/reloaded/pom.xml
===================================================================
--- arquillian/trunk/containers/reloaded/pom.xml (rev 0)
+++ arquillian/trunk/containers/reloaded/pom.xml 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../build/pom.xml</relativePath>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- 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>
+
+
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versioning -->
+ <version.org.jboss.reloaded>0.1.2-SNAPSHOT</version.org.jboss.reloaded>
+ <version.org.jboss.threads>2.0.0.CR4</version.org.jboss.threads>
+
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!--
+ org.jboss.arquillian
+ -->
+ <dependency>
+ <groupId>org.jboss.arquillian.protocol</groupId>
+ <artifactId>arquillian-protocol-local</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.packager</groupId>
+ <artifactId>arquillian-packager-applicationarchive</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.testenricher</groupId>
+ <artifactId>arquillian-testenricher-ejb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!--
+ External Projects
+ -->
+ <dependency>
+ <groupId>org.jboss.reloaded</groupId>
+ <artifactId>jboss-reloaded-vdf-bootstrap-minimal</artifactId>
+ <version>${version.org.jboss.reloaded}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.threads</groupId>
+ <artifactId>jboss-threads</artifactId>
+ <version>${version.org.jboss.threads}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-extension-vfs3</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
+
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedContainer.java 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1,218 @@
+/*
+ * 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.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.arquillian.spi.TestEnricher;
+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";
+
+ /**
+ * Put the {@link MCServer} into Thread scope such that we might access it from the
+ * {@link ReloadedTestEnricher}; hacky, but there's no way to create a {@link TestEnricher}
+ * with construction arguments.
+ */
+ static final ThreadLocal<MCServer> MC_SERVER = new ThreadLocal<MCServer>();
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Microcontainer Server into which deployments will be made
+ */
+ private MCServer server;
+
+ /**
+ * Deployer capable of processing ShrinkWrap {@link Archive}s
+ */
+ private ShrinkWrapDeployer deployer;
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#deploy(org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public ContainerMethodExecutor deploy(final Archive<?> archive) throws DeploymentException
+ {
+ // Deploy
+ try
+ {
+ deployer.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();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#start()
+ */
+ @Override
+ public void start() 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();
+ this.server = server;
+ MC_SERVER.set(server);
+
+ // Add the required bootstrap descriptors
+ final List<BootstrapDescriptor> descriptors = server.getConfiguration().getBootstrapDescriptors();
+ descriptors.add(ReloadedDescriptors.getClassLoadingDescriptor());
+ descriptors.add(ReloadedDescriptors.getVdfDescriptor());
+ 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();
+ this.deployer = deployer;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#stop()
+ */
+ @Override
+ public void stop() throws LifecycleException
+ {
+ // 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);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#undeploy(org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void undeploy(final Archive<?> archive) throws DeploymentException
+ {
+ //TODO Remove this hack
+ // http://community.jboss.org/thread/150796?tstart=0
+ /*
+ * Here we have to remove the test instance which was installed into MC during enrichment.
+ * Should instead be done during a test enricher teardown (a la the opposite lifecycle event
+ * in the same component).
+ */
+ server.getKernel().getController().uninstall(ReloadedTestEnricher.BIND_NAME_TEST);
+
+ // Undeploy
+ try
+ {
+ deployer.undeploy(archive);
+ }
+ catch (org.jboss.deployers.spi.DeploymentException e)
+ {
+ // Translate the exception and wrap
+ throw new DeploymentException("Encountered error while undeploying " + archive.toString(), e);
+ }
+
+ }
+}
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/java/org/jboss/arquillian/container/reloaded/ReloadedTestEnricher.java 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1,78 @@
+/*
+ * 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.arquillian.spi.TestEnricher;
+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(java.lang.Object)
+ */
+ @Override
+ public void enrich(final Object testCase)
+ {
+ // Obtain the server as set from the container
+ final MCServer server = ReloadedContainer.MC_SERVER.get();
+ 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());
+ try
+ {
+ controller.install(bmdb.getBeanMetaData(), testCase);
+ }
+ catch (final Throwable e)
+ {
+ throw new RuntimeException("Could not enrich " + testCase + " by installing the instance into MC", e);
+ }
+
+ }
+}
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.reloaded.ReloadedContainer
\ No newline at end of file
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1 @@
+org.jboss.arquillian.container.reloaded.ReloadedTestEnricher
\ No newline at end of file
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/LifecyclePojo.java 2010-04-16 06:36:59 UTC (rev 4260)
@@ -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;
+
+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;
+ }
+}
Added: 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 (rev 0)
+++ arquillian/trunk/containers/reloaded/src/test/java/org/jboss/arquillian/container/reloaded/ReloadedIntegrationTestCase.java 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1,118 @@
+/*
+ * 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.Archives;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests that EJB 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()
+ {
+
+ @Override
+ 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 = Archives.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)
+ */
+ 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);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Accessors / Mutators ---------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Sets the {@link LifecyclePojo} from MC
+ */
+ @Inject
+ public void setPojo(final LifecyclePojo pojo)
+ {
+ assert pojo != null : "POJO should not be null";
+ this.pojo = pojo;
+ }
+
+}
Added: arquillian/trunk/containers/reloaded/src/test/resources/log4j.xml
===================================================================
--- arquillian/trunk/containers/reloaded/src/test/resources/log4j.xml (rev 0)
+++ arquillian/trunk/containers/reloaded/src/test/resources/log4j.xml 2010-04-16 06:36:59 UTC (rev 4260)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <param name="File" value="target/test.log"/>
+ <param name="Threshold" value="INFO"/>
+ <param name="Append" value="false"/>
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ <category name="org.jboss.arquillian">
+ <priority value="ALL"/>
+ </category>
+ <category name="org.jboss.reloaded">
+ <priority value="DEBUG"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
More information about the jboss-svn-commits
mailing list