I'm trying to do the simplest possible test, and have a stateless bean called
GreeterBean, with its @Name set to greeter, with a getHello() method that returns
"Hello, world!", so I can plug it into a page as #{greeter.hello}. This works
perfectly. My troubles come when trying to write a test for it.
| public class GreeterTest extends SeamTest {
|
| @Test
| public void testGreeterHello() {
| Greeter g = (Greeter) Component.getInstance("greeter", true);
| assert g.getHello().equals("Hello, world!");
| }
| }
|
Unfortunately, this fails, and I don't mean the test, but Component.getInstance dies
with a NPE because Contexts.getApplicationContext() returns null. I notice there's a
MockApplication class lying around, but I'm stumped on how to actually use it, and the
docs are rather sparse on the subject.
I tried dispensing with mocks and just going with embedded ejb3, but that's been a
frightful experience, also replete with java's favorite catch-all error, the NPE (I
curse the very invention of null). I found that I could make my embedded ejb3 test work
if I commented out @Name, but obviously this doesn't constitute much of a test. I
don't have the TB handy at the moment since I've deleted my embedded ejb3 launch
configuration, but IIRC, it was croaking somewhere in the PostConstruct method of some
long interceptor call chain.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3968485#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...