I defined EJB as follows:
@Stateless
@LocalBean
public class Foo {
@Inject
private Boo boo;
public void doSomething() {
boo.doOther();
}
}
and
@Named
@RequestScope
public class Boo {
public void doOther() {
}
}
I would like to add FooEJB to the JUnit test class :
import org.junit.*
public class FooTest {
@EJB
private Foo foo;
@Test
public void doSomethingTest() {
foo.doSomething();
assertTrue(true);
}
}
... But this code returns NullPointerException.
What happened? How can I correctly identify this test using Java EE CDI ?
source
share