Package org.jboss.test.jca.adapter

Examples of org.jboss.test.jca.adapter.TestConnection


   public void testLazyUserTransactionRollback() throws Exception
   {
      ccm.pushMetaAwareObject(this, null);
      try
      {
         TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
         assertNotNull(c);
         try
         {
            assertEquals(TestManagedConnection.LOCAL_NONE, c.getLocalState());
            ut.begin();
            try
            {
               assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
            }
            finally
            {
               ut.rollback();
               assertEquals(TestManagedConnection.LOCAL_ROLLEDBACK, c.getLocalState());
            }
         }
         finally
         {
            c.close();
            assertEquals(TestManagedConnection.LOCAL_ROLLEDBACK, c.getLocalState());
         }
      }
      finally
      {
         ccm.popMetaAwareObject(null);
View Full Code Here


   }

   public void testGetConnection() throws Exception
   {
      log.info("testGetConnection");
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
      assertTrue("Connection is null", c != null);
      c.close();
   }
View Full Code Here

   public void testEnlistInExistingTx() throws Exception
   {
      log.info("testEnlistInExistingTx");
      ut.begin();
      TestConnection c = null;
      try
      {
         c = (TestConnection)cm.allocateConnection(mcf, cri);
         try
         {
            assertTrue("Connection not enlisted in tx!", c.isInTx());
         }
         finally
         {
            c.close();
         }
         assertTrue("Connection still enlisted in tx!", !c.isInTx());
      }
      finally
      {
         if (TxUtils.isActive(ut))
            ut.commit();
         else
            ut.rollback();
      }
      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

      Object key = this;
      Set unshared = new HashSet();
      ccm.pushMetaAwareObject(key, unshared);
      try
      {
         TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
         try
         {
            assertTrue("Connection already enlisted in tx!", !c.isInTx());
            ut.begin();
            try
            {
               assertTrue("Connection not enlisted in tx!", c.isInTx());
            }
            finally
            {
               if (TxUtils.isActive(ut))
                  ut.commit();
               else
                  ut.rollback();
            }
            assertTrue("Connection still enlisted in tx!", !c.isInTx());
         }
         finally
         {
            c.close();
         }
      }
      finally
      {
         ccm.popMetaAwareObject(unshared);
View Full Code Here

      Object key2 = new Object();
      Set unshared = new HashSet();
      ccm.pushMetaAwareObject(key1, unshared);
      try
      {
         TestConnection c = null;
         ut.begin();
         try
         {
            ccm.pushMetaAwareObject(key2, unshared);
            try
            {
               c = (TestConnection)cm.allocateConnection(mcf, cri);
               assertTrue("Connection not enlisted in tx!", c.isInTx());
            }
            finally
            {
               ccm.popMetaAwareObject(unshared);//key2
            }
         }
         finally
         {
            if (TxUtils.isActive(ut))
               ut.commit();
            else
               ut.rollback();
         }
         ut.begin();
         try
         {
            ccm.pushMetaAwareObject(key2, unshared);
            try
            {
               assertTrue("Connection not enlisted in tx!", c.isInTx());
            }
            finally
            {
               ccm.popMetaAwareObject(unshared);//key2
            }
         }
         finally
         {
            if (TxUtils.isActive(ut))
               ut.commit();
            else
               ut.rollback();
         }
         assertTrue("Connection still enlisted in tx!", !c.isInTx());
         ccm.pushMetaAwareObject(key2, unshared);
         try
         {
            if (c != null)
               c.close();
         }
         finally
         {
            ccm.popMetaAwareObject(unshared);//key2
         }
View Full Code Here

  public void testBrokenConnectionAndTrackByTx() throws Exception
  {
     log.info("testBrokenConnectionAndTrackByTx");
     cm.setTrackConnectionByTx(true);
     ut.begin();
     TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
     c.fireConnectionError();
     try
     {
        c.close();
     }
     catch (Exception ignored)
     {
     }
     try
     {
        ut.commit();
        fail("Should not be here");
     }
     catch (RollbackException expected)
     {
     }
     assertTrue("Connection still enlisted in tx!", !c.isInTx());
  }
View Full Code Here

 
  public void testFailedStartTx() throws Exception
  {
     TestManagedConnection.setFailInStart(false, XAException.XAER_RMFAIL);
     tm.begin();
     TestConnection conn = null;
     TestConnection conn2 = null;
    
     try
     {
        assertTrue("Connection in pool!", cm.getPoolingStrategy().getConnectionCount() == 0);
        conn = (TestConnection)cm.allocateConnection(mcf, cri);
View Full Code Here

  public void testFailedEndTx() throws Exception
  {
     TestManagedConnection.setFailInStart(false, XAException.XAER_RMFAIL);
     TestManagedConnection.setFailInEnd(false, XAException.XAER_RMFAIL);
     tm.begin();
     TestConnection conn = null;
     TestConnection conn2 = null;
    
     try
     {
        assertTrue("Connection in pool!", cm.getPoolingStrategy().getConnectionCount() == 0);
        conn = (TestConnection)cm.allocateConnection(mcf, cri);
       
        //One should have been created
        assertTrue(cm.getPoolingStrategy().getConnectionCount() == 1);
        conn.close();

        TestManagedConnection.setFailInEnd(true, XAException.XAER_RMFAIL);
       
        conn2 = (TestConnection)cm.allocateConnection(mcf, cri);
        conn2.close();
        tm.commit();
       
        fail("Should not be here.");
    
     }
     catch (Throwable e)
     {
     }     
    
     TestManagedConnection.setFailInEnd(false, 0);
     TestManagedConnection.setFailInStart(false, 0);

     assertTrue(conn2.getMCIsNull());    
     assertTrue("Connection count" + cm.getPoolingStrategy().getConnectionCount(), cm.getPoolingStrategy().getConnectionCount() == 0);
     assertTrue("Failed endTx should destroy Connection", cm.getPoolingStrategy().getConnectionDestroyedCount() > 0);

  }
View Full Code Here

      log.info("----------------------");
      log.info("testAllocateConnection");
      log.info("----------------------");

      tm.begin();
      TestConnection c = null;
      try
      {
         c = (TestConnection)cm.allocateConnection(mcf, cri);
         try
         {
            assertTrue("Connection not enlisted in tx!", c.isInTx());
         }
         finally
         {
            c.close();
         }
      }
      finally
      {
         Transaction tx = tm.getTransaction();
         if (tx != null)
         {
            if (TxUtils.isActive(tx))
               tm.commit();
            else
               tm.rollback();
         }
         else
            fail("Transaction is null");
      }
      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

      log.info("-------------------------------------------");

      tm.begin();
      try
      {
         TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
         c.close();
      }
      finally
      {
         Transaction tx = tm.getTransaction();
         if (tx != null)
View Full Code Here

TOP

Related Classes of org.jboss.test.jca.adapter.TestConnection

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.