Java Reference
In-Depth Information
Simple enough, right? Believe it or not, that's all you need to do for Arquillian. Now let's
see what's needed to configure GlassFish and Derby.
GlassFish and Derby
Just like section 15.3 on integration testing using the embedded EJBContainer directly,
you need to configure GlassFish because it's the GlassFish implementation of EJBCon-
tainer that you'll be using. For the Arquillian integration test, you need to provide the
src/test/glassfish/glassfish-resources.xml file. This file defines a jdbc-connection-
pool for GlassFish and binds it in JNDI to jdbc/chapter15-ejb-arquillian :
<!DOCTYPE resources PUBLIC
"-//GlassFish.org//DTD GlassFish Application Server 3.1
Resource Definitions//EN"
"http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource pool-name="ArquillianEmbeddedDerbyPool"
jndi-name=" jdbc/chapter15-ejb-arquillian "/>
<jdbc-connection-pool name="ArquillianEmbeddedDerbyPool"
res-type="javax.sql.DataSource"
datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
is-isolation-level-guaranteed="false">
<property name="databaseName"
value="target/derby/arquillian-integration-test"/>
<property name="createDatabase" value="create"/>
</jdbc-connection-pool>
</resources>
Notice that configuring GlassFish when using Arquillian is much different than when direc-
tly using the embedded EJBContainer . Using EJBContainer , you basically brought
in the configuration for an entire GlassFish domain. Using Arquillian, you're specifying
only the resources you want, which in this case is only a database connection pool to Derby.
The last technology you need to configure is JPA. Let's take a look at the JPA configuration
now.
JPA
JPA is configured with src/test/resources/META-INF/persistence.xml. It's basically
identical to its configuration in section 15.3 on integration testing using the embedded
EJBContainer directly. The only difference is the JNDI lookup value for the data
source. The Arquillian integration test binds it in JNDI to jdbc/chapter15-ejb-ar-
quillian , so persistence.xml reflects this:
Search WWH ::




Custom Search