# taskana-cdi
this module is for EJB deployments.
## Testing procedure
1. deploy wildfly server locally
2. replace h2 with latest version
3. start wildfly
4. deploy ear
5. test application
### deploy wildfly server locally
we extract the wildfly server into the target directory via maven configuration
```xml
org.apache.maven.plugins
maven-dependency-plugin
${version.maven.dependency}
unpack-wildfly
process-test-classes
unpack
org.wildfly
wildfly-dist
${version.wildfly}
zip
false
${project.build.directory}
.
.
.
```
### 2. replace h2 with latest version
for our tests we need the latest h2 version, so we need to replace the h2 jar in wildfly.
this happens in 2 steps.
first extract the dependency into the correct directory
```xml
org.apache.maven.plugins
maven-dependency-plugin
${version.maven.dependency}
.
.
.
copy-latest-h2-db-driver
process-test-classes
copy
com.h2database
h2
${project.build.directory}/wildfly-${version.wildfly}/modules/system/layers/base/com/h2database/h2/main
```
second step is to copy the `src/test/resources/module.xml` to required directory
```xml
org.apache.maven.plugins
maven-resources-plugin
${version.maven.resources}
copy-h2-module-xml
process-test-classes
copy-resources
${project.build.directory}/wildfly-${version.wildfly}/modules/system/layers/base/com/h2database/h2/main
src/test/resources
module.xml
```
### 3. start wildfly
starting and stopping wildfly happens with [arquillian](https://arquillian.org/)
```java
@RunWith(Arquillian.class)
public class TaskanaProducersTest {}
```
the file `src/test/resources/arquillian.xml` contains additional server start settings. change vm settings here for remote debugging.
the file `src/test/resources/int-test-standalone.xml` conatins the wildfly server config. Here are the datasources configured, for example.
### 4. deploy ear
create the ear deployment happens inside the testcase
```java
@Deployment(testable = false)
public static Archive> createDeployment() throws Exception {
EnterpriseArchive deployment = ShrinkWrap.create(EnterpriseArchive.class, "taskana.ear");
File[] libs =
Maven.resolver()
.loadPomFromFile("pom.xml")
.importRuntimeAndTestDependencies()
.resolve()
.withTransitivity()
.asFile();
deployment.addAsLibraries(libs);
JavaArchive ejbModule = ShrinkWrap.create(JavaArchive.class, "taskana.jar");
ejbModule.addClasses(TaskanaProducers.class, TaskanaEjb.class);
ejbModule.addAsResource("taskana.properties");
deployment.addAsModule(ejbModule);
WebArchive webArchive =
ShrinkWrap.create(WebArchive.class, "taskana.war")
.addClasses(TaskanaCdiTestRestController.class, RestApplication.class)
.addAsWebInfResource("beans.xml")
.addAsWebInfResource("int-test-jboss-web.xml", "jboss-web.xml");
deployment.addAsModule(webArchive);
deployment.addAsManifestResource("beans.xml");
return deployment;
}
```