Prevent TomEE Remote Adapter to create a data folder

When you write tests using TomEE Arquillian Remote Adapter you can discover a data directory was created. Here is the little tip to avoid it.

First this is because TomEE has default datasources (one JTA and one not JTA). Since TomEE can be used in “other environments” than testing (production, staging…) these datasources are using file storage instead of memory one.

Note: seems JEE 7 will bring default resources (datasource, connection factory…) in standard location(s) 🙂

So here is the tip: override the url of these datasources to make them being memory databases.

These datasources are called:

  • My DataSource
  • My Unmanaged DataSource

You have several ways to override these datasource configurations but the easier is to use the properties attribute of the arquillian configuration of the adapter like it:

<container qualifier="tomee-remote">
    <property name="httpPort">-1</property>
    <property name="ajpPort">-1</property>
    <property name="stopPort">-1</property>
    <property name="dir">target/apache-tomee-remote</property>
    <property name="appWorkingDir">target/arquillian-test-working-dir</property>
    <property name="properties">
        My\ DataSource.JdbcUrl = jdbc:hsqldb:mem:hsqldb
        My\ Unmanaged\ DataSource.JdbcUrl = jdbc:hsqldb:mem:hsqldb

This tip works for all resources. Another one which can be useful is to force ActiveMQ broker to not be persistent. This can be done adding the property:

Default\ JMS\ Resource\ Adapter.BrokerXmlConfig = broker:(tcp://localhost:61616)?useJmx=false&broker.persistent=false

Note: think to use &amp; instead & in this snippet if you set it in arquillian.xml

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