Package org.jboss.test.jca.adapter

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


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

   public boolean testUserTxJndi()
   {
      try
      {
         TestConnectionFactory tcf = (TestConnectionFactory)new InitialContext().lookup("java:/JBossTestCF");
         TestConnection tc = (TestConnection)tcf.getConnection();
         UserTransaction ut = (UserTransaction)new InitialContext().lookup("UserTransaction");
         ut.begin();
         boolean result = tc.isInTx();
         log.info("Jndi test, inTx: " + result);
         ut.commit();
         tc.close();
         return result;
      }
      catch (Exception e)
      {
         throw new EJBException(e.getMessage());
View Full Code Here

   public boolean testUserTxSessionCtx()
   {
      try
      {
         TestConnectionFactory tcf = (TestConnectionFactory)new InitialContext().lookup("java:/JBossTestCF");
         TestConnection tc = (TestConnection)tcf.getConnection();
         UserTransaction ut = ctx.getUserTransaction();
         ut.begin();
         boolean result = tc.isInTx();
         log.info("ctx test, inTx: " + result);
         ut.commit();
         tc.close();
         return result;
      }
      catch (Exception e)
      {
         throw new EJBException(e.getMessage());
View Full Code Here

         ConnectionFactory cf1 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF");
         ConnectionFactory cf2 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF2");
         Connection c1 = cf1.getConnection();
         try
         {
            TestConnection c2 = (TestConnection) cf2.getConnection();
            try
            {
               c2.setFailInPrepare(true, XAException.XA_RBROLLBACK);
            }
            finally
            {
               c2.close();
            }
         }
         finally
         {
            c1.close();
View Full Code Here

      try
      {

         InitialContext ctx = new InitialContext();
         ConnectionFactory cf1 = (ConnectionFactory) ctx.lookup("java:/JBossTestCF");
         TestConnection c1 = (TestConnection) cf1.getConnection();
         try
         {
            c1.setFailInCommit(true, XAException.XAER_RMERR);

         }
         finally
         {
            c1.close();
         }

      }
      catch (Exception e)
      {
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.