[jboss-cvs] JBossAS SVN: r105650 - in projects/jboss-jca/trunk: doc/userguide/en/modules and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 3 11:36:06 EDT 2010
Author: jesper.pedersen
Date: 2010-06-03 11:36:04 -0400 (Thu, 03 Jun 2010)
New Revision: 105650
Added:
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainerConfiguration.java
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCADeploymentPackager.java
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java
projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/package.html
projects/jboss-jca/trunk/embedded/src/main/resources/arquillian-manifest.mf
projects/jboss-jca/trunk/embedded/src/main/resources/services/
projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.ContainerConfiguration
projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeployableContainer
projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeploymentPackager
projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.TestEnricher
projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ArquillianTestCase.java
Modified:
projects/jboss-jca/trunk/build.xml
projects/jboss-jca/trunk/doc/userguide/en/modules/embedded.xml
projects/jboss-jca/trunk/embedded/build.xml
projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ShrinkWrapTestCase.java
projects/jboss-jca/trunk/ivy.settings.xml
projects/jboss-jca/trunk/ivy.xml
Log:
[JBJCA-345] Arquillian support for embedded
Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/build.xml 2010-06-03 15:36:04 UTC (rev 105650)
@@ -87,6 +87,7 @@
<property name="version.apache-logging" value="1.1.0.jboss"/>
<property name="version.apache-xerces" value="2.9.1"/>
<property name="version.apiviz" value="1.3.0.GA"/>
+ <property name="version.arquillian" value="1.0.0.Alpha2"/>
<property name="version.dom4j" value="1.6.1"/>
<property name="version.mockito" value="1.8.2"/>
<property name="version.eclipse-jdt" value="3.1.1"/>
@@ -115,7 +116,7 @@
<property name="version.jboss.papaki" value="1.0.0.Beta3"/>
<property name="version.jboss.reflect" value="2.0.2.GA"/>
<property name="version.jboss.security" value="2.1.0.20090318"/>
- <property name="version.jboss.shrinkwrap" value="1.0.0-alpha-6"/>
+ <property name="version.jboss.shrinkwrap" value="1.0.0-alpha-10"/>
<property name="version.jboss.slf4j" value="1.0.2.GA"/>
<property name="version.jboss.slf4j.logmanager" value="1.0.0.CR2"/>
<property name="version.jboss.stdio" value="1.0.0.CR3"/>
@@ -410,6 +411,7 @@
<class location="${target.dir}/jboss-jca-deployers-main.jar" />
<class location="${target.dir}/jboss-jca-deployers-rar.jar" />
<class location="${target.dir}/jboss-jca-embedded.jar" />
+ <class location="${target.dir}/jboss-jca-embedded-arquillian.jar" />
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-spec-api.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
@@ -439,6 +441,7 @@
<class location="${target.dir}/jboss-jca-deployers-main.jar" />
<class location="${target.dir}/jboss-jca-deployers-rar.jar" />
<class location="${target.dir}/jboss-jca-embedded.jar" />
+ <class location="${target.dir}/jboss-jca-embedded-arquillian.jar" />
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-spec-api.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
Modified: projects/jboss-jca/trunk/doc/userguide/en/modules/embedded.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en/modules/embedded.xml 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/doc/userguide/en/modules/embedded.xml 2010-06-03 15:36:04 UTC (rev 105650)
@@ -27,7 +27,7 @@
<section id="embedded_deployment">
<title>Deployment</title>
- <para>Current you will need all the JAR files located in the</para>
+ <para>Currently you will need all the JAR files located in the</para>
<programlisting>
$JBOSS_JCA_HOME/lib
@@ -60,6 +60,10 @@
import java.net.URL;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -67,9 +71,12 @@
public class MyTestCase
{
- /* Embedded */
+ /** Embedded */
private static EmbeddedJCA embedded;
+ /** JNDI prefix */
+ private static final String JNDI_PREFIX = "java:/eis/";
+
/**
* Simple test to verify deployment of myresourceadapter.rar
* @throws Throwable throwable exception
@@ -79,9 +86,15 @@
{
URL archive = getURL("myresourceadapter.rar");
+ Context context = null;
+
try
{
embedded.deploy(archive);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + "myresourceadapter");
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -90,6 +103,18 @@
finally
{
embedded.undeploy(archive);
+
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
}
}
@@ -124,10 +149,32 @@
<section id="embedded_usage_advanced">
<title>Advanced usage</title>
- <para>The code sample below shows an advanced usage of deploying a dynamic ShrinkWrap resource adapter archive
- into the JBoss JCA Embedded environment.</para>
+ <para>The JBoss JCA Embedded container environment supports the following open source
+ testing projects:</para>
- <programlisting>
+ <orderedlist>
+ <listitem>
+ <ulink url="http://www.jboss.org/community/wiki/ShrinkWrap">ShrinkWrap</ulink>
+ </listitem>
+ <listitem>
+ <ulink url="http://community.jboss.org/en/arquillian">Arquillian</ulink>
+ </listitem>
+ </orderedlist>
+
+ <para>These extensions allow the developer to use the embedded platform with greater ease
+ as there doesn't have to be a physical representation of the resource adapter archive located
+ to the disk.</para>
+
+ <para>The Arquillian integration furthermore allows the developer to leave all the embedded container
+ setup to the integration instead.</para>
+
+ <section id="embedded_usage_advanced_shrinkwrap">
+ <title>ShrinkWrap integration</title>
+
+ <para>The code sample below shows an advanced usage of deploying a dynamic ShrinkWrap resource adapter archive
+ into the JBoss JCA Embedded environment.</para>
+
+ <programlisting>
<![CDATA[
import org.jboss.jca.embedded.EmbeddedJCA;
import org.jboss.jca.embedded.rars.simple.MessageListener;
@@ -140,8 +187,12 @@
import java.util.UUID;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.jboss.logging.Logger;
-import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
@@ -154,11 +205,12 @@
{
private static Logger log = Logger.getLogger(ShrinkWrapTestCase.class);
- /*
- * Embedded
- */
+ /** Embedded */
private static EmbeddedJCA embedded;
+ /** JNDI prefix */
+ private static final String JNDI_PREFIX = "java:/eis/";
+
/**
* Basic ShrinkWrap ResourceAdapterArchive test case
* @exception Throwable Thrown if case of an error
@@ -166,12 +218,13 @@
@Test
public void testBasic() throws Throwable
{
- ResourceAdapterArchive raa =
- Archives.create(UUID.randomUUID().toString() + ".rar",
- ResourceAdapterArchive.class);
+ String deploymentName = UUID.randomUUID().toString();
+ ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class,
+ deploymentName + ".rar");
+
JavaArchive ja =
- Archives.create(UUID.randomUUID().toString() + ".jar", JavaArchive.class);
+ ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");
ja.addClasses(MessageListener.class, TestActivationSpec.class,
TestConnection.class, TestConnectionInterface.class,
@@ -181,9 +234,15 @@
raa.addLibrary(ja);
raa.addManifestResource("simple.rar/META-INF/ra.xml", "ra.xml");
+ Context context = null;
+
try
{
embedded.deploy(raa);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + deploymentName);
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -193,6 +252,18 @@
finally
{
embedded.undeploy(raa);
+
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
}
}
@@ -225,16 +296,153 @@
}
}
]]>
- </programlisting>
+ </programlisting>
+
+ <callout>
+ <note>Note that, the name for the <code>ResourceAdapterArchive</code> must end with the
+ <code>.rar</code> extension.</note>
+ </callout>
+
+ <para>See the <ulink url="http://www.jboss.org/community/wiki/ShrinkWrap">
+ ShrinkWrap</ulink> web site for a full description of the project and additional documentation.</para>
- <callout>
- <note>Note that, the name for the <code>ResourceAdapterArchive</code> must end with the
- <code>.rar</code> extension.</note>
- </callout>
+ </section>
- <para>See the <ulink url="http://www.jboss.org/community/wiki/ShrinkWrap">
- ShrinkWrap</ulink> web site for a full description of the project and additional documentation.</para>
+ <section id="embedded_usage_advanced_arquillian">
+ <title>Arquillian integration</title>
+ <para>The code sample below shows an advanced usage of deploying a dynamic ShrinkWrap resource adapter archive
+ into the JBoss JCA Embedded environment using Arquillian.</para>
+
+ <para>This setup allows the developer to skip the entire JBoss JCA Embedded container setup and handling of its
+ lifecycle methods.</para>
+
+ <programlisting>
+<![CDATA[
+package org.jboss.jca.embedded.unit;
+
+import org.jboss.jca.embedded.rars.simple.MessageListener;
+import org.jboss.jca.embedded.rars.simple.TestActivationSpec;
+import org.jboss.jca.embedded.rars.simple.TestConnection;
+import org.jboss.jca.embedded.rars.simple.TestConnectionFactory;
+import org.jboss.jca.embedded.rars.simple.TestConnectionInterface;
+import org.jboss.jca.embedded.rars.simple.TestConnectionManager;
+import org.jboss.jca.embedded.rars.simple.TestManagedConnection;
+import org.jboss.jca.embedded.rars.simple.TestManagedConnectionFactory;
+import org.jboss.jca.embedded.rars.simple.TestResourceAdapter;
+
+import java.util.UUID;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+
+/**
+ * Unit test for Arquillian integration
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+ at RunWith(Arquillian.class)
+public class ArquillianTestCase
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static Logger log = Logger.getLogger(ArquillianTestCase.class);
+
+ private static final String JNDI_PREFIX = "java:/eis/";
+ private static String deploymentName = null;
+
+ /**
+ * Define the deployment
+ * @return The deployment archive
+ */
+ @Deployment
+ public static ResourceAdapterArchive createDeployment()
+ {
+ deploymentName = UUID.randomUUID().toString();
+
+ ResourceAdapterArchive raa =
+ ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName + ".rar");
+
+ JavaArchive ja = ShrinkWrap.create(JavaArchive.class,
+ UUID.randomUUID().toString() + ".jar");
+ ja.addClasses(MessageListener.class, TestActivationSpec.class, TestConnection.class,
+ TestConnectionFactory.class, TestConnectionManager.class,
+ TestConnectionInterface.class, TestManagedConnection.class,
+ TestManagedConnectionFactory.class, TestResourceAdapter.class);
+
+ raa.addLibrary(ja);
+ raa.addManifestResource("simple.rar/META-INF/ra.xml", "ra.xml");
+
+ return raa;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Basic
+ * @exception Throwable Thrown if case of an error
+ */
+ @Test
+ public void testBasic() throws Throwable
+ {
+ Context context = null;
+
+ try
+ {
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + deploymentName);
+ assertNotNull(o);
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ fail(t.getMessage());
+ }
+ finally
+ {
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+}
+]]>
+ </programlisting>
+
+ <callout>
+ <note>Note that, the name for the <code>ResourceAdapterArchive</code> must end with the
+ <code>.rar</code> extension.</note>
+ </callout>
+
+ <para>See the <ulink url="http://community.jboss.org/en/arquillian">
+ Arquillian</ulink> web site for a full description of the project and additional documentation.</para>
+
+ </section>
+
</section>
</section>
Modified: projects/jboss-jca/trunk/embedded/build.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/build.xml 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/embedded/build.xml 2010-06-03 15:36:04 UTC (rev 105650)
@@ -61,7 +61,19 @@
<jar destfile="${target.dir}/jboss-jca-embedded.jar"
manifest="src/main/resources/embedded-manifest.mf"
basedir="${build.embedded.dir}/impl"
- excludes="**/*.java"/>
+ excludes="META-INF/services/**,**/arquillian/**,**/*.java"/>
+
+ <mkdir dir="${build.embedded.dir}/impl/META-INF"/>
+ <mkdir dir="${build.embedded.dir}/impl/META-INF/services"/>
+ <copy todir="${build.embedded.dir}/impl/META-INF/services">
+ <fileset dir="src/main/resources/services" includes="*"/>
+ </copy>
+
+ <jar destfile="${target.dir}/jboss-jca-embedded-arquillian.jar"
+ manifest="src/main/resources/arquillian-manifest.mf"
+ basedir="${build.embedded.dir}/impl"
+ includes="META-INF/**,**/arquillian/**"
+ excludes="**/*.xml,**/*.java"/>
</target>
<!-- =================================
Added: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainer.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.embedded.arquillian;
+
+import org.jboss.jca.embedded.EmbeddedJCA;
+
+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.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+/**
+ * Arquillian {@link DeployableContainer} adaptor for EmbeddedJCA
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class EmbeddedJCAContainer implements DeployableContainer
+{
+ /** EmbeddedJCA */
+ private EmbeddedJCA embedded;
+
+ /**
+ * Constructor
+ */
+ public EmbeddedJCAContainer()
+ {
+ this.embedded = null;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#deploy
+ */
+ @Override
+ public ContainerMethodExecutor deploy(final Context context, final Archive<?> archive) throws DeploymentException
+ {
+ if (archive == null)
+ throw new DeploymentException("Could not deploy a null application");
+
+ if (!(archive instanceof ResourceAdapterArchive))
+ throw new DeploymentException("Could not deploy a non resource adapter application");
+
+ try
+ {
+ embedded.deploy((ResourceAdapterArchive)archive);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy the application", e);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Could not deploy the application: " + t.getMessage());
+ }
+
+ // Invoke locally
+ return new LocalMethodExecutor();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#undeploy
+ */
+ @Override
+ public void undeploy(final Context context, final Archive<?> archive) throws DeploymentException
+ {
+ if (archive == null)
+ throw new DeploymentException("Could not undeploy a null application");
+
+ if (!(archive instanceof ResourceAdapterArchive))
+ throw new DeploymentException("Could not undeploy a non resource adapter application");
+
+ try
+ {
+ embedded.undeploy((ResourceAdapterArchive)archive);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not undeploy the application", e);
+ }
+ catch (Throwable t)
+ {
+ throw new DeploymentException("Could not undeploy the application: " + t.getMessage());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#start
+ */
+ @Override
+ public void setup(final Context context, final Configuration configuration)
+ {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#start
+ */
+ @Override
+ public void start(final Context context) throws LifecycleException
+ {
+ embedded = new EmbeddedJCA();
+ try
+ {
+ embedded.startup();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not start the EmbeddedJCA container", e);
+ }
+ catch (Throwable t)
+ {
+ throw new LifecycleException("Could not start the EmbeddedJCA container: " + t.getMessage());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#stop
+ */
+ @Override
+ public void stop(final Context context) throws LifecycleException
+ {
+ try
+ {
+ embedded.shutdown();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not stop the EmbeddedJCA container", e);
+ }
+ catch (Throwable t)
+ {
+ throw new LifecycleException("Could not stop the EmbeddedJCA container: " + t.getMessage());
+ }
+ embedded = null;
+ }
+}
Added: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainerConfiguration.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainerConfiguration.java (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCAContainerConfiguration.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.embedded.arquillian;
+
+import org.jboss.arquillian.spi.ContainerConfiguration;
+import org.jboss.arquillian.spi.ContainerProfile;
+
+/**
+ * {@link ContainerConfiguration} implementation specific to the EmbeddedJCA container
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class EmbeddedJCAContainerConfiguration implements ContainerConfiguration
+{
+ /**
+ * Constructor
+ */
+ public EmbeddedJCAContainerConfiguration()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ContainerProfile getContainerProfile()
+ {
+ return ContainerProfile.STANDALONE;
+ }
+}
Added: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCADeploymentPackager.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCADeploymentPackager.java (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCADeploymentPackager.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.embedded.arquillian;
+
+import java.util.Collection;
+
+import org.jboss.arquillian.spi.DeploymentPackager;
+import org.jboss.shrinkwrap.api.Archive;
+
+/**
+ * DeploymentPackager for EmbeddedJCA
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class EmbeddedJCADeploymentPackager implements DeploymentPackager
+{
+ /**
+ * Constructor
+ */
+ public EmbeddedJCADeploymentPackager()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeploymentPackager#generateDeployment
+ */
+ @Override
+ public Archive<?> generateDeployment(Archive<?> applicationArchive,
+ Collection<Archive<?>> auxiliaryArchives)
+ {
+ return applicationArchive;
+ }
+}
Added: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/EmbeddedJCATestEnricher.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.embedded.arquillian;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.TestEnricher;
+
+/**
+ * {@link TestEnricher} implementation specific to the EmbeddedJCA container
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class EmbeddedJCATestEnricher implements TestEnricher
+{
+ /**
+ * Constructor
+ */
+ public EmbeddedJCATestEnricher()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void enrich(final Context context, final Object testCase)
+ {
+ // Nothing for now
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] resolve(Context context, Method method)
+ {
+ return null;
+ }
+
+ /**
+ * Create a context
+ * @return The context
+ * @exception Exception Thrown if an error occurs
+ */
+ protected InitialContext createContext() throws Exception
+ {
+ Properties properties = new Properties();
+ properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
+ properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ return new InitialContext(properties);
+ }
+}
Added: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/package.html
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/package.html (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/arquillian/package.html 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,3 @@
+<body>
+This package contains the Arquillian integration for JCA/Embedded.
+</body>
Added: projects/jboss-jca/trunk/embedded/src/main/resources/arquillian-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/arquillian-manifest.mf (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/arquillian-manifest.mf 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Embedded / Arquillian
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1
Added: projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.ContainerConfiguration
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.ContainerConfiguration (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.ContainerConfiguration 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1 @@
+org.jboss.jca.embedded.arquillian.EmbeddedJCAContainerConfiguration
Added: projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeployableContainer (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeployableContainer 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1 @@
+org.jboss.jca.embedded.arquillian.EmbeddedJCAContainer
\ No newline at end of file
Added: projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeploymentPackager
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeploymentPackager (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.DeploymentPackager 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1 @@
+org.jboss.jca.embedded.arquillian.EmbeddedJCADeploymentPackager
\ No newline at end of file
Added: projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.TestEnricher
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.TestEnricher (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/services/org.jboss.arquillian.spi.TestEnricher 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1 @@
+org.jboss.jca.embedded.arquillian.EmbeddedJCATestEnricher
\ No newline at end of file
Added: projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ArquillianTestCase.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ArquillianTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ArquillianTestCase.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -0,0 +1,132 @@
+/*/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.embedded.unit;
+
+import org.jboss.jca.embedded.rars.simple.MessageListener;
+import org.jboss.jca.embedded.rars.simple.TestActivationSpec;
+import org.jboss.jca.embedded.rars.simple.TestConnection;
+import org.jboss.jca.embedded.rars.simple.TestConnectionFactory;
+import org.jboss.jca.embedded.rars.simple.TestConnectionInterface;
+import org.jboss.jca.embedded.rars.simple.TestConnectionManager;
+import org.jboss.jca.embedded.rars.simple.TestManagedConnection;
+import org.jboss.jca.embedded.rars.simple.TestManagedConnectionFactory;
+import org.jboss.jca.embedded.rars.simple.TestResourceAdapter;
+
+import java.util.UUID;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+
+/**
+ * Unit test for Arquillian integration
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+ at RunWith(Arquillian.class)
+public class ArquillianTestCase
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static Logger log = Logger.getLogger(ArquillianTestCase.class);
+
+ private static final String JNDI_PREFIX = "java:/eis/";
+ private static String deploymentName = null;
+
+ /**
+ * Define the deployment
+ * @return The deployment archive
+ */
+ @Deployment
+ public static ResourceAdapterArchive createDeployment()
+ {
+ deploymentName = UUID.randomUUID().toString();
+
+ ResourceAdapterArchive raa =
+ ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName + ".rar");
+
+ JavaArchive ja = ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");
+ ja.addClasses(MessageListener.class, TestActivationSpec.class, TestConnection.class,
+ TestConnectionFactory.class, TestConnectionManager.class,
+ TestConnectionInterface.class, TestManagedConnection.class,
+ TestManagedConnectionFactory.class, TestResourceAdapter.class);
+
+ raa.addLibrary(ja);
+ raa.addManifestResource("simple.rar/META-INF/ra.xml", "ra.xml");
+
+ return raa;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Basic
+ * @exception Throwable Thrown if case of an error
+ */
+ @Test
+ public void testBasic() throws Throwable
+ {
+ Context context = null;
+
+ try
+ {
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + deploymentName);
+ assertNotNull(o);
+ }
+ catch (Throwable t)
+ {
+ log.error(t.getMessage(), t);
+ fail(t.getMessage());
+ }
+ finally
+ {
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+}
Modified: projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ShrinkWrapTestCase.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ShrinkWrapTestCase.java 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/embedded/src/test/java/org/jboss/jca/embedded/unit/ShrinkWrapTestCase.java 2010-06-03 15:36:04 UTC (rev 105650)
@@ -35,8 +35,12 @@
import java.util.UUID;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.jboss.logging.Logger;
-import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
@@ -61,6 +65,8 @@
private static Logger log = Logger.getLogger(ShrinkWrapTestCase.class);
+ private static final String JNDI_PREFIX = "java:/eis/";
+
/*
* Embedded
*/
@@ -109,10 +115,14 @@
@Test
public void testBasic() throws Throwable
{
+ Context context = null;
+
+ String name = UUID.randomUUID().toString();
+
ResourceAdapterArchive raa =
- Archives.create(UUID.randomUUID().toString() + ".rar", ResourceAdapterArchive.class);
+ ShrinkWrap.create(ResourceAdapterArchive.class, name + ".rar");
- JavaArchive ja = Archives.create(UUID.randomUUID().toString() + ".jar", JavaArchive.class);
+ JavaArchive ja = ShrinkWrap.create(JavaArchive.class, UUID.randomUUID().toString() + ".jar");
ja.addClasses(MessageListener.class, TestActivationSpec.class, TestConnection.class,
TestConnectionFactory.class, TestConnectionManager.class,
TestConnectionInterface.class, TestManagedConnection.class,
@@ -124,6 +134,10 @@
try
{
embedded.deploy(raa);
+
+ context = new InitialContext();
+ Object o = context.lookup(JNDI_PREFIX + name);
+ assertNotNull(o);
}
catch (Throwable t)
{
@@ -132,6 +146,18 @@
}
finally
{
+ if (context != null)
+ {
+ try
+ {
+ context.close();
+ }
+ catch (NamingException ne)
+ {
+ // Ignore
+ }
+ }
+
embedded.undeploy(raa);
}
}
Modified: projects/jboss-jca/trunk/ivy.settings.xml
===================================================================
--- projects/jboss-jca/trunk/ivy.settings.xml 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/ivy.settings.xml 2010-06-03 15:36:04 UTC (rev 105650)
@@ -29,6 +29,8 @@
<ivy pattern="${ivy.cache.dir}/[module]/ivy-[revision].xml"/>
<artifact pattern="${ivy.cache.dir}/[module]/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>
+ <ibiblio name="nexus" m2compatible="true" usepoms="false" root="${nexus.repo}"
+ pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
<ibiblio name="jboss" m2compatible="true" usepoms="false" root="${jboss.repo}"
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
<ibiblio name="snapshots" m2compatible="true" usepoms="false" root="${snapshots.repo}" useMavenMetadata="true"
@@ -39,6 +41,7 @@
pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
<chain name="default" returnFirst="true">
<resolver ref="local"/>
+ <resolver ref="nexus"/>
<resolver ref="jboss"/>
<resolver ref="snapshots"/>
<resolver ref="central"/>
Modified: projects/jboss-jca/trunk/ivy.xml
===================================================================
--- projects/jboss-jca/trunk/ivy.xml 2010-06-03 15:34:24 UTC (rev 105649)
+++ projects/jboss-jca/trunk/ivy.xml 2010-06-03 15:36:04 UTC (rev 105650)
@@ -57,6 +57,11 @@
<dependency org="org.jboss" name="jboss-vfs" rev="${version.jboss.vfs}" conf="standalone->default"/>
<dependency org="org.jboss" name="jbossxb" rev="${version.jboss.xb}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss.apiviz" name="apiviz" rev="${version.apiviz}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.jboss.arquillian" name="arquillian-api" rev="${version.arquillian}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.jboss.arquillian" name="arquillian-impl-base" rev="${version.arquillian}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.jboss.arquillian" name="arquillian-junit" rev="${version.arquillian}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.jboss.arquillian" name="arquillian-spi" rev="${version.arquillian}" conf="standalone->default;sjc->*"/>
+ <dependency org="org.jboss.arquillian.protocol" name="arquillian-protocol-local" rev="${version.arquillian}" conf="standalone->default;sjc->*"/>
<dependency org="org.jboss.bootstrap" name="jboss-bootstrap" rev="${version.jboss.bootstrap}" conf="standalone->default"/>
<dependency org="org.jboss.cl" name="jboss-classloader" rev="${version.jboss.classloading}" conf="standalone->default"/>
<dependency org="org.jboss.cl" name="jboss-classloading" rev="${version.jboss.classloading}" conf="standalone->default"/>
More information about the jboss-cvs-commits
mailing list