Exemplo n.º 1
0
  public void testInterceptors() throws Exception {
    InitialContext ctx = new InitialContext();
    InterceptedSLTest test =
        (InterceptedSLTest) ctx.lookup("initial-ejb3-test/InterceptedSLTestBean/local");
    int ret = test.testMethod(5);
    int expected = 3010;

    if (ret != expected)
      throw new Exception("return value was not " + expected + ", it was: " + ret);

    boolean exception = false;
    try {
      test.throwsThrowable(1);
    } catch (Throwable e) {
      exception = true;
    }
    if (!exception) throw new Exception("Exception was not thrown");
  }
Exemplo n.º 2
0
  public void testCallbacks() throws Exception {
    // Check the correct callbacks get invoked
    InitialContext ctx = new InitialContext();
    TestStatus status = (TestStatus) ctx.lookup("initial-ejb3-test/TestStatusBean/remote");
    status.clear();
    InterceptedSLTest test =
        (InterceptedSLTest) ctx.lookup("initial-ejb3-test/InterceptedSLTestBean/local");
    test.testMethod(5);
    // PostConstruct test is invalid, because you can't assume that postConstruct is called during
    // the lookup
    // the instance might already be available from a previous call or prefill of the pool.
    // if (!status.postConstruct()) throw new Exception("PostConstruct should be called for SLSB");
    if (status.prePassivate()) throw new Exception("PrePassivate should not be called for SLSB");
    if (status.postActivate()) throw new Exception("PostActivate should not be called for SLSB");

    // TODO: Figure out when destroy gets called
    // if (!status.preDestroy()) throw new Exception("PreDestroy should be called for SLSB");
  }