Examples of TestConnection


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

   }

   public void testJTATransactionRollback() throws Exception
   {
      tm.begin();
      TestConnection c = null;
      try
      {
         c = (TestConnection)cm.allocateConnection(mcf, cri);
         assertNotNull(c);
         try
         {
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
         finally
         {
            c.close();
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
      }
      finally
      {
         tm.rollback();
         if (c != null)
            assertEquals(TestManagedConnection.LOCAL_ROLLEDBACK, c.getLocalState());
      }
   }
View Full Code Here

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

   }

   public void testUserTransactionCommit() throws Exception
   {
      ut.begin();
      TestConnection c = null;
      try
      {
         c = (TestConnection)cm.allocateConnection(mcf, cri);
         assertNotNull(c);
         try
         {
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
         finally
         {
            c.close();
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
      }
      finally
      {
         ut.commit();
         if (c != null)
            assertEquals(TestManagedConnection.LOCAL_COMMITTED, c.getLocalState());
      }
   }
View Full Code Here

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

   }

   public void testUserTransactionRollback() throws Exception
   {
      ut.begin();
      TestConnection c = null;
      try
      {
         c = (TestConnection)cm.allocateConnection(mcf, cri);
         assertNotNull(c);
         try
         {
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
         finally
         {
            c.close();
            assertEquals(TestManagedConnection.LOCAL_TRANSACTION, c.getLocalState());
         }
      }
      finally
      {
         ut.rollback();
         if (c != null)
            assertEquals(TestManagedConnection.LOCAL_ROLLEDBACK, c.getLocalState());
      }
   }
View Full Code Here

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

   public void testLazyUserTransactionCommit() 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.commit();
               assertEquals(TestManagedConnection.LOCAL_COMMITTED, c.getLocalState());
            }
         }
         finally
         {
            c.close();
            assertEquals(TestManagedConnection.LOCAL_COMMITTED, c.getLocalState());
         }
      }
      finally
      {
         ccm.popMetaAwareObject(null);
View Full Code Here

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

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

   }

   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

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

   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

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

      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

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

      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

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

  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
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.