Example #1
0
 public void statefulTest() throws Exception {
   InitialContext ctx = new InitialContext();
   StatefulTestLocal test =
       (StatefulTestLocal) ctx.lookup("initial-ejb3-test/StatefulTestBean/local");
   test.setState("hello world");
   if (!test.getState().equals("hello world")) throw new Exception("state was not retained");
 }
Example #2
0
  public void testSFSBCollocation() throws Exception {
    InitialContext ctx = new InitialContext();
    StatefulTestLocal local =
        (StatefulTestLocal) ctx.lookup("initial-ejb3-test/StatefulTestBean/local");
    StatefulTestRemote remote =
        (StatefulTestRemote) ctx.lookup("initial-ejb3-test/StatefulTestBean/remote");

    if (local.getObject() != StatefulTestBean.obj)
      throw new RuntimeException("Local call not equal");
    if (local.getObject() == remote.getObject())
      throw new RuntimeException("Remote should not be equal");
    Map map = remote.getObject();
    map.put("hello", "world");

    Object obj = local.echo(map);
    if (obj != map) throw new RuntimeException("argument and return should be the same");
    map = (Map) obj;
    if (!map.containsKey("hello")) throw new RuntimeException("not good return");

    obj = remote.echo(map);
    if (obj == map) throw new RuntimeException("argument and return should not be the same");

    map = (Map) obj;
    if (!map.containsKey("hello")) throw new RuntimeException("not good return");
  }