Package org.jboss.test.ejb3.singleton.unit

Source Code of org.jboss.test.ejb3.singleton.unit.SingletonUnitTestCase

/**
*
*/
package org.jboss.test.ejb3.singleton.unit;

import junit.framework.Test;

import org.jboss.test.JBossTestCase;
import org.jboss.test.ejb3.singleton.AccountManager;
import org.jboss.test.ejb3.singleton.AccountManagerBean;

/**
* SingletonUnitTestCase
*
* @author Jaikiran Pai
* @version $Revision: $
*/
public class SingletonUnitTestCase extends JBossTestCase
{

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

   public static Test suite() throws Exception
   {
      return getDeploySetup(SingletonUnitTestCase.class, "ejb31singleton.jar");
   }

   public void testSingletonBeanAccess() throws Exception
   {
      AccountManager accountManager = (AccountManager) this.getInitialContext().lookup(AccountManagerBean.JNDI_NAME);

      int initialBalance = accountManager.balance();
      assertEquals("Unexpected initial balance", 0, initialBalance);

      // credit
      accountManager.credit(100);

      AccountManager anotherAccountManagerInstance = (AccountManager) this.getInitialContext().lookup(
            AccountManagerBean.JNDI_NAME);
      int balanceAfterCredit = anotherAccountManagerInstance.balance();
      assertEquals("Unexpected balance after credit", 100, balanceAfterCredit);

      // debit
      anotherAccountManagerInstance.debit(50);

      int balanceAfterDebit = accountManager.balance();
      assertEquals("Unexpected balance after debit", 50, balanceAfterDebit);

   }
}
TOP

Related Classes of org.jboss.test.ejb3.singleton.unit.SingletonUnitTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.