Inject Java Properties in Java EE Using CDI

The aim of this post is to show you how, using CDI, you can inject Java properties entries (those in *.properties files) directly into your Java class. This is somewhat similar to the Spring’s @Value annotation I needed in my plain Java EE project. The whole code can be found on GitHub so feel free to clone it, use it or make any changes you like. Context Ok, so basically in a Java EE environment we already have a way to define some properties that are deployment-specific – it’s the <env-entry> element in the descriptor....

June 17, 2012 · 12 min

Maven Surefire -- Integration tests recognition

By default, Maven’s test plugin Surefire doesn’t scan files for @Test annotations, but rather takes only the files which class names ends with “Test” or “TestCase”. I use both: unit tests and integration tests. I execute the latter using Arquillian framework, so it looks just like pure JUnit test. However, I prefer to name them with the “IT” suffix which means that they’re no longer recognized by Surefire plugin as test files....

February 28, 2012 · 1 min

Arquillian, ShrinkWrap and archive filename

When you create a deployment using Arquillian (great test runner for testing your Java EE code in the container of your choice: jBoss, Glassfish, OpenEJB, … either in embedded, managed or remote mode) remember that the name of the deployment archive file is the exact filename that will be executed in the container. It does make a difference if you use *.war or *.jar for your deployment, so beware the following construct if it’s not exactly what you intended to do:...

June 13, 2011 · 1 min