Package org.jboss.test.cts.keys

Examples of org.jboss.test.cts.keys.AccountPK


      if (!testBeginSetrollbackonlyCommit())
         return false;

      // Create first instance
      try {
         bean1 = home.create(new AccountPK("UT_TestBean1"), "Ole1");
      } catch (Exception ex) {
         log.debug("failed", ex);
         return false;
      }

      // Single resource tests
      if (!testSingleRollback())
         return false;
      if (!testSingleCommit())
         return false;
      if (!testSingleSetrollbackonlyCommit())
         return false;

      // Can second instance be created in a tx that is rolled back?
      try {
         ut.begin();
         bean2 = home.create(new AccountPK("UT_TestBean2"), "Ole2");
         ut.rollback();
        
         // Should no longer exist
         boolean gotException = false;
         try {
            bean2.setPersonsName("Ole");
         } catch (Exception e) {
     log.info("IGNORE PREVIOUS NoSuchEntityException - it is intentional");
            gotException = true;
         }
         if (!gotException)
            throw new RuntimeException("Rollback didn't rollback create.");
      } catch (Exception ex) {
         log.debug("failed", ex);
         return false;
      }

      // Create second instance
      try {
         bean2 = home.create(new AccountPK("UT_TestBean2"), "Ole2");
      } catch (Exception ex) {
         log.debug("failed", ex);
         return false;
      }
View Full Code Here


      getLog().debug("+++ testLocalInterfacePassivation");
      StatefulSessionHome sessionHome = ( StatefulSessionHome ) ctx.lookup("ejbcts/StatefulSessionBean");
      StatefulSession sessionBean = sessionHome.create("testLocalInterfacePassivation");   

    getLog().debug("Creating local home");
      AccountPK pk = new AccountPK("123456789");
      sessionBean.createLocalEntity(pk, "jduke");

      getLog().debug("Creating a second session bean, forcing the first one to be passivated?");
      // The pool size has been set to 1 in the container
      // config, so creating another ASession here should
View Full Code Here

      StatefulSession bean = home.create("testRemoveSessionObject");   
      getLog().debug("OK, bean="+bean);
      getLog().debug("Call remove using a primary key");
      try
      {
         home.remove(new AccountPK("pk"));
         fail("[EJB 1.1, p42, section 5.3.2] Expected 'RemoveException' when remove-ing a session object, got NO exception");
      }
      catch(RemoveException e)
      {
         getLog().debug("Remove using a primary key failed as expected");
View Full Code Here

    */
   public void testBasicCmp()
         throws Exception
   {
      getLog().debug("+++ testBasicCmp()");
      AccountPK pk = new AccountPK("testBasicCmp");
      CtsCmp bean = home.create(pk, "testBasicCmp unitTest");
      String result = bean.getPersonsName();
      // Test response
      assertTrue(result.equals("testBasicCmp unitTest"));
      bean.remove();
View Full Code Here

      {
         InitialContext ctx = new InitialContext(env);
         Object ref = ctx.lookup("ejbcts/CMPBean");
         CtsCmpHome home = (CtsCmpHome)
               PortableRemoteObject.narrow(ref, CtsCmpHome.class);
         AccountPK pk1 = new AccountPK("bean1");
         CtsCmp bean1 = home.create(pk1, "testHomeFromRemoteNoDefaultJNDI");
         CtsCmpHome home2 = (CtsCmpHome) bean1.getEJBHome();
         AccountPK pk2 = new AccountPK("bean2");
         CtsCmp bean2 = home2.create(pk2, "testHomeFromRemoteNoDefaultJNDI");
         bean2.remove();
      }
      finally
      {
View Full Code Here

            try
            {
               ResultSet rs = ps.executeQuery();

               while (rs.next())
                  result.add(new AccountPK(rs.getString(1)));

               return result;
            }
            finally
            {
View Full Code Here

               ps.setString(1, guysName);

               ResultSet rs = ps.executeQuery();

               while (rs.next())
                  result.add(new AccountPK(rs.getString(1)));

               return result;
            }
            finally
            {
View Full Code Here

            ps = con.prepareStatement("SELECT accountNumber,name " +
               "FROM " + TABLE_NAME + " " +
               "WHERE accountNumber=?");
            try
            {
               AccountPK pk = (AccountPK) ctx.getPrimaryKey();

               ps.setString(1, pk.getKey());
               ResultSet rs = ps.executeQuery();

               if (rs.next() == false)
                  throw new NoSuchEntityException("Instance " + pk.getKey() +
                     " not found in database.");

               accountNumber = rs.getString(1);
               personsName = rs.getString(2);
            }
View Full Code Here

   public void testEntityIdentity() throws Exception
   {
      InitialContext ctx = new InitialContext();
      CtsCmpLocalHome home = (CtsCmpLocalHome) ctx.lookup("ejbcts/LocalCMPBean");
      AccountPK key1 = new AccountPK("1");
      CtsCmpLocal bean1 = null;
      try
      {
         bean1 = home.create(key1, "testEntityIdentity");
      }
      catch(DuplicateKeyException e)
      {
         bean1 = home.findByPrimaryKey(key1);
      }
      AccountPK key2 = new AccountPK("2");
      CtsCmpLocal bean2 = null;
      try
      {
         bean2 = home.create(key2, "testEntityIdentity");
      }
View Full Code Here

TOP

Related Classes of org.jboss.test.cts.keys.AccountPK

Copyright © 2018 www.massapicom. 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.