예제 #1
0
  @Test
  public void testEJBWiringWithMockito() {

    EJB3InnerServiceInterface anInterface = Mockito.mock(EJB3InnerServiceInterface.class);
    Mockito.when(anInterface.findSomething(12L)).thenReturn("Something Deep From Mock");
    containerLifeCycleTestUtil.registerServiceInstance(
        EJB3InnerServiceInterface.class, anInterface);

    EJB3ServiceInterface serviceInterface =
        containerLifeCycleTestUtil.getService(EJB3ServiceInterface.class);
    String something = serviceInterface.findSomething(12L);
    assertEquals("Something", something);

    String somethingDeep = serviceInterface.findSomethingDeep(12L);
    assertEquals("Something Deep From Mock", somethingDeep);
  }
예제 #2
0
 @Test
 public void testEJBEntityManagerInjectionCreate2() {
   SomeData someData = new SomeData();
   someData.setName("The Name");
   someData.setId(13L);
   someData = ejb3InnerServiceInterface.createSomethingForEntityManager(someData);
   assertEquals("The Name", someData.getName());
 }
예제 #3
0
 @Test
 public void testEJBEntityManagerInjection() {
   String something = ejb3InnerServiceInterface.findSomethingFromEntityManager(12L);
   assertEquals("The Name", something);
 }
예제 #4
0
 @Test
 public void testEJBTypedResourceInjection() {
   String something = ejb3InnerServiceInterface.findSomethingFromDataSource2(12L);
   assertEquals("The Name", something);
 }