Tag Archives: testing

EJBContainerRunner or test with EJBContainer easily

To test a EE application you have several solutions. One of them is to use EJBContainer.

EJBContainer container = EJBContainer.createEJBContainer(properties);
// do test

These steps are often in a test lifecycle (@BeforeClass/@AfterClass for JUnit for instance).

With OpenEJB you also have:

container.getContext().bind("inject", this);

This allows you to get injections (@Inject, @Resource, @PersistenceContext…) in the test class.

That’s nice but you can make it easier!

Continue reading

Test a particular CDI Extension with OpenEJB ApplicationComposer

OpenEJB ApplicationComposer is an old but very efficient way to test EE code. The idea is almost the same as with ShrinkWrap and Arquillian but with a big difference: it is performance oriented and embedded only. As a quick reminder to use the ApplicationComposer (either the JUnit runner or the abstract TestNG class) you just define a test class with a set of @Module methods declaring the in memory EE model (WebApp for web.xml, Beans for beans.xml, EjbJar for openejb-jar.xml, @Classes for scanned classes…) and standard @Test methods. Of course injections work in the test class. For instance:

Continue reading

Test FTP usage?

When depending on a FTP in production we often simulate it through a
local file in dev and sometimes in preprod. That’s great and avoid to
need a big infra in all environment but make ftp dependencies optional
before the prod…so you risk to clean them and miss them in prod.

To avoid it it is easy to test FTP through JUnit using MockFtp project.

Continue reading

Further in the JBatch test proposal!

Some days ago I wrote a post on how to test a JBatch batch more easily making it synchronous (+ few other features). BatchEE proposal goes today one step further allowing to test steps!

Continue reading

Arquillian and TomEE: deploy remotely without hacks!

Arquillian is a great way to deploy an application in a container to test it. However the framework itself doesn’t know if the container is local or remote. TomEE adapter (the bridge between arquillian and tomee) was supporting local deployment but remote one was quite hard and needed to workaround a bit arquillian which was not that fancy.

Since yesterday you can do it easily!

Continue reading

To few helper to test JBatch batches?

Recently BatchEE (Apache implementation of JBatch based on the Reference Implementation) got a test module. This is still “experimental” and can change but here is the first proposal.

Continue reading

TomEE Maven Plugin and integration tests (without arquillian)

Arquillian is great but some apps would prefer to use maven failsafe plugin to do their integration tests. If all your tests are client tests you can simply start the container and deploy the app before the tests are executed (pre-integration-test phase) and undeploy/stop the container after the test (post-integration-test phase). If it is not you can still write a servlet to execute the tests on the server side…wait, you are redoing Arquillian so maybe something is wrong in this case ;).

It is generally complicated/long to configure because you need to find how to start your container then to deploy an application on it etc…boring.

The solution is quite easy if you want to test against TomEE: the tomee maven plugin of course!

Continue reading