[jboss-cvs] JBossAS SVN: r101608 - in projects/ejb-book/trunk/ch04-firstejb: src/test/java/org/jboss/ejb3/examples/ch04/firstejb and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Feb 27 17:21:25 EST 2010
Author: ALRubinger
Date: 2010-02-27 17:21:25 -0500 (Sat, 27 Feb 2010)
New Revision: 101608
Modified:
projects/ejb-book/trunk/ch04-firstejb/pom.xml
projects/ejb-book/trunk/ch04-firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorIntegrationTestCase.java
projects/ejb-book/trunk/ch04-firstejb/src/test/resources/jndi.properties
Log:
[EJBBOOK-20] Convert "firstejb" example to use Arquillian for integration testing
Modified: projects/ejb-book/trunk/ch04-firstejb/pom.xml
===================================================================
--- projects/ejb-book/trunk/ch04-firstejb/pom.xml 2010-02-27 22:11:02 UTC (rev 101607)
+++ projects/ejb-book/trunk/ch04-firstejb/pom.xml 2010-02-27 22:21:25 UTC (rev 101608)
@@ -39,6 +39,16 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-container-openejb</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ </dependency>
</dependencies>
@@ -48,6 +58,9 @@
<!-- Declare the "Integration Test" Profile -->
<id>it</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
<build>
@@ -68,10 +81,6 @@
</goals>
<configuration>
<skip>false</skip>
- <!-- Include jbossall-client.jar on the CP -->
- <additionalClasspathElements>
- <additionalClasspathElement>${jboss.home}/client/jbossall-client.jar</additionalClasspathElement>
- </additionalClasspathElements>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<printSummary>true</printSummary>
<forkMode>always</forkMode>
@@ -83,77 +92,6 @@
</executions>
</plugin>
- <!--
-
- Define the JBossAS Maven Control Plugin
- -->
- <plugin>
-
- <groupId>org.jboss.maven.plugins.jbossas</groupId>
- <artifactId>maven-jboss-as-control-plugin</artifactId>
- <version>0.1.2-SNAPSHOT</version>
-
- <!-- Executions -->
- <executions>
-
- <!--
-
- Start JBossAS with our new configuration
- -->
- <execution>
- <id>start-jbossas</id>
- <goals>
- <goal>start</goal>
- </goals>
- <phase>pre-integration-test</phase>
- <configuration>
- <jvmArgs>
- <jvmArg>-Xmx512M</jvmArg>
- </jvmArgs>
- <serverConfigName>default</serverConfigName>
- <jboss.test.run>true</jboss.test.run>
- </configuration>
- </execution>
-
- <!--
-
- Deploy into our custom JBossAS Configuration
- -->
- <execution>
- <id>deploy-test-slsb</id>
- <goals>
- <goal>deploy</goal>
- </goals>
- <phase>pre-integration-test</phase>
- <configuration>
- <serverConfigName>default</serverConfigName>
- <files>
- ${project.build.directory}/${project.build.finalName}.${project.packaging}
- </files>
- <jboss.test.run>true</jboss.test.run>
- </configuration>
- </execution>
-
- <!--
-
- Stop JBossAS
- -->
- <execution>
- <id>stop-jbossas</id>
- <goals>
- <goal>stop</goal>
- </goals>
- <phase>post-integration-test</phase>
- <configuration>
- <serverConfigName>default</serverConfigName>
- <jboss.test.run>true</jboss.test.run>
- </configuration>
- </execution>
-
- </executions>
-
- </plugin>
-
</plugins>
</build>
Modified: projects/ejb-book/trunk/ch04-firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorIntegrationTestCase.java
===================================================================
--- projects/ejb-book/trunk/ch04-firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorIntegrationTestCase.java 2010-02-27 22:11:02 UTC (rev 101607)
+++ projects/ejb-book/trunk/ch04-firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorIntegrationTestCase.java 2010-02-27 22:21:25 UTC (rev 101608)
@@ -22,12 +22,19 @@
package org.jboss.ejb3.examples.ch04.firstejb;
+import java.net.MalformedURLException;
+
import javax.naming.Context;
import javax.naming.InitialContext;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* CalculatorIntegrationTestCase
@@ -38,6 +45,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
+ at RunWith(Arquillian.class)
public class CalculatorIntegrationTestCase
{
// ---------------------------------------------------------------------------||
@@ -55,9 +63,9 @@
private static Context namingContext;
/**
- * The EJB 3.x remote business view of the CalculatorEJB
+ * The EJB 3.x local business view of the CalculatorEJB
*/
- private static CalculatorRemoteBusiness calcRemoteBusiness;
+ private static CalculatorLocalBusiness calcLocalBusiness;
/**
* Delegate for ensuring that the obtained Calculators are working as expected
@@ -67,9 +75,21 @@
/**
* JNDI Name of the Remote Business Reference
*/
- //TODO Use Global JNDI Syntax (not yet supported in JBoss EJB3)
- private static final String JNDI_NAME_CALC_REMOTE_BUSINESS = SimpleCalculatorBean.class.getSimpleName() + "/remote";
+ //TODO Use Global JNDI Syntax
+ private static final String JNDI_NAME_CALC_LOCAL_BUSINESS = ManyViewCalculatorBean.class.getSimpleName() + "Local";
+ /**
+ * Define the deployment
+ */
+ @Deployment
+ public static JavaArchive createDeployment() throws MalformedURLException
+ {
+ final JavaArchive archive = Archives.create("firstejb.jar", JavaArchive.class).addPackage(
+ CalculatorBeanBase.class.getPackage());
+ log.info(archive.toString(true));
+ return archive;
+ }
+
// ---------------------------------------------------------------------------||
// Lifecycle Methods ---------------------------------------------------------||
// ---------------------------------------------------------------------------||
@@ -84,7 +104,7 @@
namingContext = new InitialContext();
// Obtain EJB 3.x Business Reference
- calcRemoteBusiness = (CalculatorRemoteBusiness) namingContext.lookup(JNDI_NAME_CALC_REMOTE_BUSINESS);
+ calcLocalBusiness = (CalculatorLocalBusiness) namingContext.lookup(JNDI_NAME_CALC_LOCAL_BUSINESS);
// Create Assertion Delegate
assertionDelegate = new CalculatorAssertionDelegate();
@@ -103,7 +123,7 @@
{
// Test
log.info("Testing remote business reference...");
- assertionDelegate.assertAdditionSucceeds(calcRemoteBusiness);
+ assertionDelegate.assertAdditionSucceeds(calcLocalBusiness);
}
}
Modified: projects/ejb-book/trunk/ch04-firstejb/src/test/resources/jndi.properties
===================================================================
--- projects/ejb-book/trunk/ch04-firstejb/src/test/resources/jndi.properties 2010-02-27 22:11:02 UTC (rev 101607)
+++ projects/ejb-book/trunk/ch04-firstejb/src/test/resources/jndi.properties 2010-02-27 22:21:25 UTC (rev 101608)
@@ -1,4 +1,2 @@
-# JNDI Properties for Remote interaction with JBoss Application Server Naming Service
-java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
-java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
-java.naming.provider.url=jnp://localhost:1099
\ No newline at end of file
+# JNDI Properties for Local interaction with OpenEJB Naming Provider
+java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list