Examples of TestConnection


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

 
  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

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

  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

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

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

      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

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

      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

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

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

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

      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

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

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

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

      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

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

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