On Mar 4, 2008, at 11:17 PM, Manu George wrote:
What about this including a few mojos for doing container driven
testing? I am not very conversant with how you can do container driven
testing in openejb (need to read alexander's articles). However a
maven plugin using which your ejbs will be tested during the build
process would be nice option to have.
Pretty much all the examples we have use container driven testing.
The only one that doesn't is examples/webapps/ejb-examples/. Most
have ant and maven build files.
The basic maven howto is this:
Step 1: Add this to your pom.xml
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>3.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Step 2: Add an ejb-jar.xml file
Make sure you have an src/main/resources/META-INF/ejb-jar.xml. A
simple one need only contain "<ejb-jar/>".
Step 3: Test Setup
protected void setUp() throws Exception {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
initialContext = new InitialContext(properties);
}
Done. That really is all there is to it. And, yes, I'm serious :)
And, yes, that is very cool. And, no, no other vendor does it quite
that simply -- they all need plugins ;) You can configure nearly
anything in the entire container (pool sizes, datasources, topics,
queues, etc.) via the InitialContext properties so you can setup
things exactly how you want them for that exact set of tests.
The same process works for any build system or IDE or any app. The
biggest variance will be Step #1, i.e. adding OpenEJB to the
classpath, everything else is always the same.
If you're a maven user you can generate an eclipse or intellij project
will already be setup and ready to go. If you're an ant user you have
to create your IDE's classpath by hand and it maybe frustrating
getting all the right jars in your IDE. It would be cool if there was
one big openejb jar that had all our deps in it for to make that easier.
Regardless of how simple it is and how it can be done in any
environment without a plugin, I'm not opposed to the idea of having
openejb plugins for various environments. We might find ways to make
it even simpler or new things to offer people.
-David