Reputation: 1447
First off, here is my setup:
By default, I always set my beans to @Local for security purpose. I don't want to open doors to other application within the same container when there is no need for it.
Now, I am focusing on driving my development with tests (test driven development). So, I created a separate project (a kind of test project) for my tests in order to avoid coding my tests and installing tests instruments (EasyMock, jUnit, StrutsTest, etc.) in the same project as the application.
So... that means I set my beans to @Remote to be able to access them from my jUnit test classes.
My question is: Is there any way to switch from @Local to @Remote using a sort of conditional compiling/building? Having to set my beans back to Local everytime is quite cumbersome and boring. Every developer knows that refactoring brings problems so I am trying to find a proper way to manage my bean's visibility. Another idea would be from a property or XML file so I would only need to turn one thing on or off depending on my needs.
For every bean to test, I need to: - Set the interface to @Remote - Add the implements item for the remote interface in the session bean
Any idea?
Thank you very much
Charles
Upvotes: 1
Views: 361
Reputation: 4137
Another option instead of using embedded container
(JBoss embedded container is in pretty bad shape, I'm affraid :( )
is to use a tool like Arquilian which has a deployment API,
and can create a "mini enterprise application" generated via test code, to contain your EJBs and get them deployed on the application server.
Upvotes: 0
Reputation: 38615
If I understand well, you connect from your unit tests to the application server to access remote EJBs, right?
I haven't been working with EJB since a few years, but there are two ways to unit tests EJBs without remote communication:
Hope it helps.
Upvotes: 2