1
我在MyEclipse 10.0中使用了WAS 8.0,EJB 3.1,CDI和EJB可嵌入容器。還有beans.xml定義和可嵌入的容器jar在classpath中。在測試類中的EJB引用(課程)上獲取運行時空值。JUnit測試用例中@EJB注入的空值
公共類CourseTest延伸測試用例{
@EJB
private Course course;
@Before
public void setUp() throws Exception {
EJBContainer.createEJBContainer().getContext().bind("inject", this);
}
@Test
public void test() {
// Was the EJB injected?
assertTrue(course != null);