示例#1
0
  /**
   * Test a basic invocation on a SLSB.
   *
   * @throws Exception
   */
  @Test
  public void testSLSB() throws Exception {
    Context ctx = new InitialContext();
    SimpleStatelessSessionLocal localBean =
        (SimpleStatelessSessionLocal)
            ctx.lookup(
                "java:global/ejb3-slsb-example/"
                    + SimpleStatelessSessionBean.class.getSimpleName()
                    + "!"
                    + SimpleStatelessSessionLocal.class.getName());
    String message = "Zzzzzzzz.....!";
    String echo = localBean.echo(message);
    String expectedEcho =
        SimpleInterceptor.class.getSimpleName()
            + "#"
            + SimpleStatelessSessionBean.class.getSimpleName()
            + "#"
            + "Echo "
            + message
            + " -- (1:Other, 2:Other, 3:Other)";

    Assert.assertEquals("Unexpected echo message received from stateless bean", expectedEcho, echo);
  }
示例#2
0
  public static void main(String[] args) throws Exception {
    DeploymentUtils utils = new DeploymentUtils();
    try {
      utils.addDeployment("ejb3-rar.rar", SimpleQueueResourceAdapter.class.getPackage());
      utils.addDeployment("ejb3-mdb.jar", PostmanPatMDB.class.getPackage());
      utils.addDeployment("ejb3-example.jar", SimpleStatelessSessionBean.class.getPackage());
      utils.addDeployment("ejb3-mbean.sar", Test.class.getPackage());
      utils.deploy();

      MBeanServerConnection mbeanServer = utils.getConnection();

      SimpleStatelessSessionLocal bean =
          createProxy(
              mbeanServer,
              "java:global/ejb3-example/SimpleStatelessSessionBean!"
                  + SimpleStatelessSessionLocal.class.getName(),
              SimpleStatelessSessionLocal.class);
      String msg = bean.echo("Hello world");
      System.out.println(msg);

      exec(mbeanServer, ExerciseStateful.class);

      String singletonBeanJndiName =
          "java:global/ejb3-example/SimpleSingletonBean!" + SimpleSingletonLocal.class.getName();
      workOnSingletoBean(mbeanServer, singletonBeanJndiName, 100, 10);

      exec(mbeanServer, ExerciseBMT.class);

      exec(mbeanServer, ExerciseEchoService.class);

      exec(mbeanServer, ExercisePatClifton.class);
    } finally {
      utils.undeploy();
      safeClose(utils);
    }
  }