/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.test.reference21_30.unit;

import javax.naming.*;

import org.jboss.ejb3.test.reference21_30.*;
import org.jboss.logging.Logger;

import javax.ejb.EJBException;

import junit.framework.Test;

import org.jboss.security.SecurityAssociation;
import org.jboss.security.SimplePrincipal;
import org.jboss.test.JBossTestCase;

/**
 * Test for EJB3.0/EJB2.1 references
 * 
 * @version <tt>$Revision: 1.1.2.6 $</tt>
 * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
 */
public class GlobalReferenceTestCase
    extends JBossTestCase {

   private static final Logger log = Logger
         .getLogger(GlobalReferenceTestCase.class);

   public GlobalReferenceTestCase(String name)
   {
      super(name);
   }

   public void testSession21() throws Exception
   {
      InitialContext jndiContext = new InitialContext();
 
      Session21Home home = (Session21Home) jndiContext.lookup("Session21");
      Session21 session = (Session21)home.create();
      String access = session.access();
      assertEquals("Session21", access);
      access = session.globalAccess30();
      assertEquals("Session30", access);
   }
   
   public void testSession30() throws Exception
   {
      InitialContext jndiContext = new InitialContext();
 
      Session30 session = (Session30) jndiContext.lookup("GlobalSession30");
      String access = session.access();
      assertEquals("Session30", access);
      access = session.globalAccess21();
      assertEquals("Session21", access);
   }

   protected void setUp() throws Exception
   {
   }

   public static Test suite() throws Exception
   {
   //   return new TestSuite(BankDeploymentDescriptorTestCase.class);
      return getDeploySetup(GlobalReferenceTestCase.class, "globalReference.ejb3,globalReference.jar");
   }

}
