Arquillian OpenEJB embedded adaptor supports @ArquillianResource URL


Arquillian provides some specific injections. The most known of them is probably:

@ArquillianResource
private URL url;

It globally provides you the context url of your web application.

For embedded adapters it doesn’t make a lot of sense to support it (and all your tests are executed “in” the container).

OpenEJB embedded adapter is a bit particular because it doesn’t support a full servlet container features but some part of them only. Its main supported features are (very) basic servlets/listeners, ejbd (remote ejb protocol), JAX-WS and of course JAX-RS.

Personally i find the last one THE very interesting one but when you start writing your arquillian tests you quickly miss the webapp context and @ArquillianResource was not supported at all until version 4.5.2.

Since this morning the snapshot allows you to write your tests as usual:

@RunWith(Arquillian.class)
public class JediRouterBuilderTest {
    @Deployment(testable = false)
    public static WebArchive war() {
        return ShrinkWrap.create(WebArchive.class, "foo.war")
                .addXXX(...);
    }

    @ArquillianResource
    private URL url;

    @Test
    public void mytest() {
        // rest client using url, asserts...
    }
}

And the test is still very fast!

Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s