public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
      try {
        Object obj = ejbContext.lookup("jms");
        Assert.assertNotNull("The JMS ConnectionFactory is null", obj);
        Assert.assertTrue("Not an instance of ConnectionFactory", obj instanceof ConnectionFactory);
        ConnectionFactory connectionFactory = (ConnectionFactory) obj;
        testJmsConnection(connectionFactory.createConnection());

        obj = ejbContext.lookup("TopicCF");
        Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
        Assert.assertTrue(
            "Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
        TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
        testJmsConnection(topicConnectionFactory.createConnection());

        obj = ejbContext.lookup("QueueCF");
        Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
        Assert.assertTrue(
            "Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
        QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
        testJmsConnection(queueConnectionFactory.createConnection());
      } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupPersistenceUnit() throws TestFailureException {
    try {
      try {
        EntityManagerFactory emf = (EntityManagerFactory) ejbContext.lookup("persistence/TestUnit");
        Assert.assertNotNull("The EntityManagerFactory is null", emf);

      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
 public void lookupResource() throws TestFailureException {
   try {
     try {
       Object obj = ejbContext.lookup("datasource");
       Assert.assertNotNull("The DataSource is null", obj);
       Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
     } catch (Exception e) {
       Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
     }
   } catch (AssertionFailedError afe) {
     throw new TestFailureException(afe);
   }
 }
 public void lookupStatelessBusinessLocalBean() throws TestFailureException {
   try {
     try {
       BasicStatelessPojoBean object =
           (BasicStatelessPojoBean)
               ejbContext.lookup("stateless/beanReferences/stateless-business-localbean");
       Assert.assertNotNull("The EJB BusinessLocalBean is null", object);
     } catch (Exception e) {
       Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
     }
   } catch (AssertionFailedError afe) {
     throw new TestFailureException(afe);
   }
 }
  // =============================
  // Remote interface methods
  //
  public void lookupEntityBean() throws TestFailureException {
    try {
      try {
        BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateless/beanReferences/bmp_entity");
        Assert.assertNotNull("The EJBHome looked up is null", home);

        BasicBmpObject object = home.createObject("Enc Bean");
        Assert.assertNotNull("The EJBObject is null", object);
      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupPersistenceContext() throws TestFailureException {
    try {
      try {
        EntityManager em = (EntityManager) ejbContext.lookup("persistence/TestContext");
        Assert.assertNotNull("The EntityManager is null", em);

        // call a do nothing method to assure entity manager actually exists
        em.getFlushMode();
      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupCharacterEntry() throws TestFailureException {
    try {
      try {
        Character expected = new Character('D');
        Character actual = (Character) ejbContext.lookup("stateless/references/Character");

        Assert.assertNotNull("The Character looked up is null", actual);
        Assert.assertEquals(expected, actual);

      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupByteEntry() throws TestFailureException {
    try {
      try {
        Byte expected = new Byte((byte) 1);
        Byte actual = (Byte) ejbContext.lookup("stateless/references/Byte");

        Assert.assertNotNull("The Byte looked up is null", actual);
        Assert.assertEquals(expected, actual);

      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupShortEntry() throws TestFailureException {
    try {
      try {
        Short expected = new Short((short) 1);
        Short actual = (Short) ejbContext.lookup("stateless/references/Short");

        Assert.assertNotNull("The Short looked up is null", actual);
        Assert.assertEquals(expected, actual);

      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  public void lookupLongEntry() throws TestFailureException {
    try {
      try {
        Long expected = new Long(1L);
        Long actual = (Long) ejbContext.lookup("stateless/references/Long");

        Assert.assertNotNull("The Long looked up is null", actual);
        Assert.assertEquals(expected, actual);

      } catch (Exception e) {
        Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
      }
    } catch (AssertionFailedError afe) {
      throw new TestFailureException(afe);
    }
  }
  @PostConstruct
  private void init() {
    System.out.println("HelloSingleton::init()");

    System.out.println("myString = '" + myString + "'");
    if ((myString == null) || !(myString.equals("myString"))) {
      throw new RuntimeException("Invalid value " + myString + " for myString");
    }

    appName = (String) sessionCtx.lookup("java:app/AppName");
    moduleName = (String) sessionCtx.lookup("java:module/ModuleName");

    ORB orb1 = (ORB) sessionCtx.lookup("java:module/MORB1");
    ORB orb2 = (ORB) sessionCtx.lookup("java:module/env/MORB2");

    System.out.println("AppName = " + appName);
    System.out.println("ModuleName = " + moduleName);

    foo4 = (FooManagedBean) sessionCtx.lookup("java:module/somemanagedbean");
    foo5 = (FooManagedBean) sessionCtx.lookup("java:app/" + moduleName + "/somemanagedbean");
    foo6 = (Foo) sessionCtx.lookup("java:app/" + moduleName + "/somemanagedbean");
    foo7 = (FooManagedBean) sessionCtx.lookup("java:comp/env/foo2ref");
    foo8 = (Foo) sessionCtx.lookup("java:comp/env/foo3ref");
  }