Package org.jboss.test.jca.adapter

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


      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

      cm.setTrackConnectionByTx(true);

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

      // track-by-tx = true
      cm.setTrackConnectionByTx(true);

      tm.setTransactionTimeout(2);

      TestConnection c = null;
      try
      {
         tm.begin();

         assertEquals("1", 0, cm.getPoolingStrategy().getInUseConnectionCount());

         c = (TestConnection)cm.allocateConnection(mcf, cri);
        
         assertEquals("2", 1, cm.getPoolingStrategy().getInUseConnectionCount());
        
         Thread.sleep(2500L);
        
         Transaction tx = tm.getTransaction();
         if (tx != null && TxUtils.isActive(tx))
            fail("TX is still active");
        
         c.close();
         c = null;
        
         assertEquals("3", 0, cm.getPoolingStrategy().getInUseConnectionCount());
      }
      finally
      {
         if (c != null)
         {
            c.close();
            fail("Connection wasnt closed");
         }
        
         assertNotNull(tm);
           
View Full Code Here

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

      tm.begin();
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
      c.fireConnectionError();
      try
      {
         c.close();
      }
      catch (Exception ignored)
      {
      }

      try
      {
         tm.commit();
         fail("Should not be here");
      }
      catch (RollbackException expected)
      {
      }

      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

      // track-by-tx = true
      cm.setTrackConnectionByTx(true);

      tm.begin();
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
      c.fireConnectionError();
      try
      {
         c.close();
      }
      catch (Exception ignored)
      {
      }

      try
      {
         tm.commit();
         fail("Should not be here");
      }
      catch (RollbackException expected)
      {
      }

      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

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

      tm.begin();
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);

      try
      {
         c.simulateConnectionError();
         fail("No exception thrown");
      }
      catch (Exception expected)
      {
      }

      c.close();

      try
      {
         tm.commit();
         fail("Should not be here");
      }
      catch (RollbackException expected)
      {
      }

      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

      // track-by-tx = true
      cm.setTrackConnectionByTx(true);

      tm.begin();
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);

      try
      {
         c.simulateConnectionError();
         fail("No exception thrown");
      }
      catch (Exception expected)
      {
      }

      c.close();

      try
      {
         tm.commit();
         fail("Should not be here");
      }
      catch (RollbackException expected)
      {
      }

      assertTrue("Connection still enlisted in tx!", !c.isInTx());
   }
View Full Code Here

      ManagedConnectionPool mcp = getOnePool(2);
      BaseConnectionManager2 cm = getTxTrackCM(mcp);
      try
      {
         tm.begin();
         TestConnection c1 = allocate(cm, cri1);
         TestManagedConnection mc1 = c1.getMC();
         c1.close();
         TestConnection c2 = allocate(cm, cri1);
         TestManagedConnection mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should be equal in same transaction", mc1.equals(mc2));
         Transaction tx1 = tm.suspend();
         tm.begin();
         c2 = allocate(cm, cri1);
         mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should not be equal in a different transaction", mc1.equals(mc2) == false);
         tm.commit();
         c2 = allocate(cm, cri1);
         mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should not be equal outside a transaction", mc1.equals(mc2) == false);
         tm.resume(tx1);
         c2 = allocate(cm, cri1);
         mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should still be equal in same transaction", mc1.equals(mc2));
         tm.commit();
         assertTrue("All connections should be recycled", mcp.getAvailableConnectionCount() == 2);
      }
      finally
View Full Code Here

      ManagedConnectionPool mcp = getPoolByCri(2);
      BaseConnectionManager2 cm = getTxTrackCM(mcp);
      try
      {
         tm.begin();
         TestConnection c1 = allocate(cm, cri1);
         TestManagedConnection mc1 = c1.getMC();
         c1.close();
         TestConnection c2 = allocate(cm, cri1);
         TestManagedConnection mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should be equal in same transaction and criteria", mc1.equals(mc2));
         c2 = allocate(cm, cri2);
         mc2 = c2.getMC();
         c2.close();
         assertTrue("Connections should not be equal in same transaction but different criteria", mc1.equals(mc2) == false);
         tm.commit();
      }
      finally
      {
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.