[jboss-svn-commits] JBoss Common SVN: r4066 - in arquillian/trunk: container-openejb and 17 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Feb 27 16:15:53 EST 2010
Author: ALRubinger
Date: 2010-02-27 16:15:52 -0500 (Sat, 27 Feb 2010)
New Revision: 4066
Added:
arquillian/trunk/container-openejb/
arquillian/trunk/container-openejb/pom.xml
arquillian/trunk/container-openejb/src/
arquillian/trunk/container-openejb/src/main/
arquillian/trunk/container-openejb/src/main/java/
arquillian/trunk/container-openejb/src/main/java/org/
arquillian/trunk/container-openejb/src/main/java/org/jboss/
arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/
arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/
arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBContainer.java
arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBTestEnricher.java
arquillian/trunk/container-openejb/src/main/resources/
arquillian/trunk/container-openejb/src/main/resources/META-INF/
arquillian/trunk/container-openejb/src/main/resources/META-INF/services/
arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
arquillian/trunk/container-openejb/src/test/
arquillian/trunk/container-openejb/src/test/java/
arquillian/trunk/container-openejb/src/test/java/org/
arquillian/trunk/container-openejb/src/test/java/org/jboss/
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/OpenEJBIntegrationTestCase.java
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoBean.java
arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoLocalBusiness.java
arquillian/trunk/container-openejb/src/test/resources/
Modified:
arquillian/trunk/pom.xml
Log:
[ARQ-76] Add new module for initial OpenEJB integration
Property changes on: arquillian/trunk/container-openejb
___________________________________________________________________
Name: svn:ignore
+ target
eclipse-target
bin
.settings
.classpath
.project
Added: arquillian/trunk/container-openejb/pom.xml
===================================================================
--- arquillian/trunk/container-openejb/pom.xml (rev 0)
+++ arquillian/trunk/container-openejb/pom.xml 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,64 @@
+<?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 -->
+ <artifactId>arquillian-container-openejb</artifactId>
+ <name>Arquillian Container OpenEJB</name>
+ <description>OpenEJB Integration for the Arquillian Project</description>
+
+
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versioning -->
+ <version.org.apache.openejb_openejb.core>3.1.2</version.org.apache.openejb_openejb.core>
+
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!--
+ org.jboss.arquillian
+ -->
+ <dependency>
+ <groupId>org.jboss.arquillian</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>
+
+ <!--
+ External Projects
+ -->
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-extension-openejb</artifactId>
+ <version>${version.shrinkwrap_shrinkwrap}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version.org.apache.openejb_openejb.core}</version>
+ </dependency>
+
+ </dependencies>
+</project>
+
Added: arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBContainer.java
===================================================================
--- arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBContainer.java (rev 0)
+++ arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBContainer.java 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,166 @@
+/*
+ * 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.openejb;
+
+import java.util.logging.Logger;
+
+import org.apache.openejb.NoSuchApplicationException;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.UndeployException;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+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.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.openejb.config.ShrinkWrapConfigurationFactory;
+
+/**
+ * Arquillian {@link DeployableContainer} adaptor
+ * for a target OpenEJB environment; responible
+ * for lifecycle and deployment operations
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class OpenEJBContainer implements DeployableContainer
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(OpenEJBContainer.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * OpenEJB Assembler
+ */
+ private Assembler assembler;
+
+ /**
+ * OpenEJB Configuration backing the Container
+ */
+ private ShrinkWrapConfigurationFactory config;
+
+ /**
+ * The deployment
+ */
+ private AppInfo deployment;
+
+ //-------------------------------------------------------------------------------------||
+ // 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 as an archive
+ final AppInfo appInfo;
+ try
+ {
+ appInfo = config.configureApplication(archive);
+ this.deployment = appInfo;
+ }
+ catch (final OpenEJBException e)
+ {
+ throw new DeploymentException("Could not configure application in OpenEJB", e);
+ }
+ try
+ {
+ assembler.createApplication(appInfo);
+ }
+ catch (final Exception ne)
+ {
+ throw new DeploymentException("Could not create the application", ne);
+ }
+
+ // Invoke locally
+ return new LocalMethodExecutor();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#start()
+ */
+ @Override
+ public void start() throws LifecycleException
+ {
+ final ShrinkWrapConfigurationFactory config = new ShrinkWrapConfigurationFactory();
+ final Assembler assembler = new Assembler();
+ try
+ {
+ // These two objects pretty much encompass all the EJB Container
+ assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+ assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+ }
+ catch (final OpenEJBException e)
+ {
+ throw new LifecycleException("Could not configure the OpenEJB Container", e);
+ }
+
+ // Set
+ this.assembler = assembler;
+ this.config = new ShrinkWrapConfigurationFactory();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#stop()
+ */
+ @Override
+ public void stop() throws LifecycleException
+ {
+ assembler.destroy();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.DeployableContainer#undeploy(org.jboss.shrinkwrap.api.Archive)
+ */
+ @Override
+ public void undeploy(final Archive<?> archive) throws DeploymentException
+ {
+ // Undeploy the archive
+ try
+ {
+ assembler.destroyApplication(deployment.jarPath);
+ }
+ catch (final UndeployException e)
+ {
+ throw new DeploymentException("Error in undeployment of " + archive.getName(), e);
+ }
+ catch (final NoSuchApplicationException e)
+ {
+ throw new DeploymentException("Application was not deployed; cannot undeploy: " + archive.getName(), e);
+ }
+ }
+}
Added: arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBTestEnricher.java
===================================================================
--- arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBTestEnricher.java (rev 0)
+++ arquillian/trunk/container-openejb/src/main/java/org/jboss/arquillian/openejb/OpenEJBTestEnricher.java 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,57 @@
+/*
+ * 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.openejb;
+
+import java.util.logging.Logger;
+
+import org.jboss.arquillian.spi.TestEnricher;
+
+/**
+ * {@link TestEnricher} implementation specific to the OpenEJB
+ * Container
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class OpenEJBTestEnricher implements TestEnricher
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(OpenEJBTestEnricher.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.arquillian.spi.TestEnricher#enrich(java.lang.Object)
+ */
+ @Override
+ public void enrich(final Object testCase)
+ {
+ log.fine("Enriching: " + testCase);
+ // NOOP for now
+ }
+
+}
Added: arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer (rev 0)
+++ arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1 @@
+org.jboss.arquillian.openejb.OpenEJBContainer
\ No newline at end of file
Added: arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher
===================================================================
--- arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher (rev 0)
+++ arquillian/trunk/container-openejb/src/main/resources/META-INF/services/org.jboss.arquillian.spi.TestEnricher 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1 @@
+org.jboss.arquillian.openejb.OpenEJBTestEnricher
\ No newline at end of file
Added: arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/OpenEJBIntegrationTestCase.java
===================================================================
--- arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/OpenEJBIntegrationTestCase.java (rev 0)
+++ arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/OpenEJBIntegrationTestCase.java 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,117 @@
+/*
+ * 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.openejb;
+
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import javax.ejb.EJB;
+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.arquillian.openejb.ejb.EchoBean;
+import org.jboss.arquillian.openejb.ejb.EchoLocalBusiness;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests that EJB deployments into the OpenEJB server
+ * work through the Arquillian lifecycle
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class OpenEJBIntegrationTestCase
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(OpenEJBIntegrationTestCase.class.getName());
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Define the deployment
+ */
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ return Archives.create("slsb.jar", JavaArchive.class).addClasses(EchoLocalBusiness.class, EchoBean.class);
+ }
+
+ /**
+ * The EJB proxy used for invocations
+ */
+ @EJB
+ // TODO Support this injection
+ private EchoLocalBusiness bean;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Looks up the EJB proxy in JNDI
+ * @deprecated Once Arquillian supports injection
+ */
+ @Deprecated
+ @Before
+ public void lookupBean() throws NamingException
+ {
+ final Properties properties = new Properties();
+ properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
+ bean = (EchoLocalBusiness) new InitialContext(properties).lookup(EchoBean.class.getSimpleName() + "Local");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures the {@link EchoBean} returns the expected
+ * response via pass-by-reference semantics
+ */
+ @Test
+ public void testEchoBean()
+ {
+ // Define the input and expected outcome
+ final String expected = "Word up.";
+
+ // Invoke upon the proxy
+ final String received = bean.echo(expected);
+
+ // Test
+ Assert.assertEquals("Expected output was not equal by value", expected, received);
+ Assert.assertTrue("Expected output was not equal by reference", expected == received);
+ log.info("Got expected result from EJB: " + received);
+ }
+}
Added: arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoBean.java
===================================================================
--- arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoBean.java (rev 0)
+++ arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoBean.java 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.ejb;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+/**
+ * Implementation class of an EJB which returns request parameters
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Local(EchoLocalBusiness.class)
+public class EchoBean implements EchoLocalBusiness
+{
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.apache.openejb.assembler.classic.ejb.EchoLocalBusiness#echo(java.lang.String)
+ */
+ @Override
+ public String echo(final String value)
+ {
+ return value;
+ }
+}
Added: arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoLocalBusiness.java
===================================================================
--- arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoLocalBusiness.java (rev 0)
+++ arquillian/trunk/container-openejb/src/test/java/org/jboss/arquillian/openejb/ejb/EchoLocalBusiness.java 2010-02-27 21:15:52 UTC (rev 4066)
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.ejb;
+
+/**
+ * Local business interface of an EJB which echos a sent message
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface EchoLocalBusiness
+{
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Returns the specified reference unaltered
+ * @param value
+ * @return
+ */
+ String echo(String value);
+}
Modified: arquillian/trunk/pom.xml
===================================================================
--- arquillian/trunk/pom.xml 2010-02-25 08:54:59 UTC (rev 4065)
+++ arquillian/trunk/pom.xml 2010-02-27 21:15:52 UTC (rev 4066)
@@ -66,6 +66,7 @@
<module>container-glassfish-embedded</module>
<module>container-weld-embedded</module>
+ <module>container-openejb</module>
<!-- Demo / Test Suite -->
<module>demo</module>
More information about the jboss-svn-commits
mailing list