Examples of TestConnection


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

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

      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

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

      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

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

      }
   }
  
   public void doOnePool(BaseConnectionManager2 cm) throws Exception
   {
      TestConnection c1 = allocate(cm, cri1);
      TestManagedConnection mc1 = c1.getMC();
      c1.close();
      TestConnection c2 = allocate(cm, cri1);
      TestManagedConnection mc2 = c2.getMC();
      c2.close();
      assertEquals("Should get the same connection for same criteria", mc1, mc2);
      c2 = allocate(cm, cri2);
      mc2 = c2.getMC();
      c2.close();
      assertEquals("Should get the same connection for different cri", mc1, mc2);
   }
View Full Code Here

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

      super.tearDown();
   }

   public void testSimple() throws Exception
   {
      TestConnection c = (TestConnection)cm.allocateConnection(mcf, cri);
      assertNotNull(c);
      c.close();
   }
View Full Code Here

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

      c.close();
   }

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

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

      }
   }

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

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

      }
   }

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

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

   }

   public void testJTATransactionCommit() 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.commit();
         if (c != null)
            assertEquals(TestManagedConnection.LOCAL_COMMITTED, c.getLocalState());
      }
   }
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.