CDI and ApplicationComposer: finally easy to test deltaspike with AppComposer

OpenEJB/TomEE ApplicationComposer design is to describe a test application with an in memory model close to the xml EE one (Beans for beans.xml, EjbJar for ejb-jar.xml…).

But when it comes to CDI and since it was mainly designed for small apps it is hard to say “I have a CDI dependency/library”.

The more obvious use case is DeltaSpike!

To make it easier we added @Jars recently.

Idea is to list dependencies to include in the test.

Here a sample:

import org.apache.openejb.itest.failover.ejb.Calculator;
import org.apache.openejb.jee.WebApp;
import org.apache.openejb.junit.ApplicationComposer;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ejb.EJB;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class AppComposerJarsTest {
    public WebApp war() {
        return new WebApp();

    private Calculator calculator;

    public void externalBeanFound() {
        assertEquals(3, calculator.sum(1, 2));

This will add as dependency of the app all deltaspike-* jars.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s