Package com.arjuna.ats.internal.jta.transaction.arjunacore

Examples of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple


   public void testDeliveryCountUpdatedOnCloseXA() throws Exception
   {
      XAConnection xaConn = null;

      Connection conn = null;
      TransactionManager mgr = new TransactionManagerImple();

      Transaction toResume = null;

      Transaction tx = null;

      try
      {
         toResume = mgr.suspend();

         conn = getConnectionFactory().createConnection();

         // Send a message

         Session producerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = producerSess.createProducer(HornetQServerTestCase.queue1);

         TextMessage tm = producerSess.createTextMessage("message1");

         producer.send(tm);

         xaConn = ((XAConnectionFactory)getXAConnectionFactory()).createXAConnection();

         XASession consumerSess = xaConn.createXASession();
         MessageConsumer consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);
         xaConn.start();

         DummyXAResource res = new DummyXAResource();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         TextMessage rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(1, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertFalse(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(2, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(3, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         // Must close consumer first

         consumer.close();

         consumerSess.close();

         consumerSess = xaConn.createXASession();

         consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(4, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
      }
      finally
      {
         if (conn != null)
         {
            conn.close();
         }

         if (tx != null)
         {
            try
            {
               mgr.commit();
            }
            catch (Exception ignore)
            {
            }
         }
         if (xaConn != null)
         {
            xaConn.close();
         }

         if (toResume != null)
         {
            try
            {
               mgr.resume(toResume);
            }
            catch (Exception ignore)
            {
            }
         }
View Full Code Here


      queueControl.removeMessages(null);
   }

   protected TransactionManager newTransactionManager()
   {
      return new TransactionManagerImple();
   }
View Full Code Here

   public void testDeliveryCountUpdatedOnCloseXA() throws Exception
   {
      XAConnection xaConn = null;

      Connection conn = null;
      TransactionManager mgr = new TransactionManagerImple();

      Transaction toResume = null;

      Transaction tx = null;

      try
      {
         toResume = mgr.suspend();

         conn = getConnectionFactory().createConnection();

         // Send a message

         Session producerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = producerSess.createProducer(HornetQServerTestCase.queue1);

         TextMessage tm = producerSess.createTextMessage("message1");

         producer.send(tm);

         xaConn = ((XAConnectionFactory)getConnectionFactory()).createXAConnection();

         XASession consumerSess = xaConn.createXASession();
         MessageConsumer consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);
         xaConn.start();

         DummyXAResource res = new DummyXAResource();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         TextMessage rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(1, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertFalse(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(2, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(3, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         // Must close consumer first

         consumer.close();

         consumerSess.close();

         consumerSess = xaConn.createXASession();

         consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(4, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
      }
      finally
      {
         if (conn != null)
         {
            conn.close();
         }

         if (tx != null)
         {
            try
            {
               mgr.commit();
            }
            catch (Exception ignore)
            {
            }
         }
         if (xaConn != null)
         {
            xaConn.close();
         }

         if (toResume != null)
         {
            try
            {
               mgr.resume(toResume);
            }
            catch (Exception ignore)
            {
            }
         }
View Full Code Here

      return new InitialContext(ServerManagement.getJNDIEnvironment(serverid));
   }

   protected TransactionManager getTransactionManager()
   {
      return new TransactionManagerImple();
   }
View Full Code Here

   public void testDeliveryCountUpdatedOnCloseXA() throws Exception
   {
      XAConnection xaConn = null;

      Connection conn = null;
      TransactionManager mgr = new TransactionManagerImple();

      Transaction toResume = null;

      Transaction tx = null;

      try
      {
         toResume = mgr.suspend();

         conn = getConnectionFactory().createConnection();

         // Send a message

         Session producerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = producerSess.createProducer(HornetQServerTestCase.queue1);

         TextMessage tm = producerSess.createTextMessage("message1");

         producer.send(tm);

         xaConn = ((XAConnectionFactory)getXAConnectionFactory()).createXAConnection();

         XASession consumerSess = xaConn.createXASession();
         MessageConsumer consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);
         xaConn.start();

         DummyXAResource res = new DummyXAResource();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         TextMessage rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(1, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertFalse(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(2, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(3, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);

         mgr.rollback();

         // Must close consumer first

         consumer.close();

         consumerSess.close();

         consumerSess = xaConn.createXASession();

         consumer = consumerSess.createConsumer(HornetQServerTestCase.queue1);

         mgr.begin();

         tx = mgr.getTransaction();

         tx.enlistResource(res);

         tx.enlistResource(consumerSess.getXAResource());

         rm = (TextMessage)consumer.receive(1000);

         ProxyAssertSupport.assertNotNull(rm);

         ProxyAssertSupport.assertEquals(tm.getText(), rm.getText());

         ProxyAssertSupport.assertEquals(4, rm.getIntProperty("JMSXDeliveryCount"));

         ProxyAssertSupport.assertTrue(rm.getJMSRedelivered());

         tx.delistResource(res, XAResource.TMSUCCESS);

         tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
      }
      finally
      {
         if (conn != null)
         {
            conn.close();
         }

         if (tx != null)
         {
            try
            {
               mgr.commit();
            }
            catch (Exception ignore)
            {
            }
         }
         if (xaConn != null)
         {
            xaConn.close();
         }

         if (toResume != null)
         {
            try
            {
               mgr.resume(toResume);
            }
            catch (Exception ignore)
            {
            }
         }
View Full Code Here

      queueControl.removeMessages(null);
   }

   protected TransactionManager newTransactionManager()
   {
      return new TransactionManagerImple();
   }
View Full Code Here

    {
        final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
        final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
        final LastOnePhaseResource thirdResource = new LastOnePhaseResource() ;
       
        final TransactionManager tm = new TransactionManagerImple() ;
        tm.begin() ;
        try
        {
            final Transaction tx = tm.getTransaction() ;
            assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
            assertTrue("Second resource enlisted", tx.enlistResource(secondResource)) ;
            assertTrue("Third resource enlisted", tx.enlistResource(thirdResource)) ;
        }
        finally
        {
            tm.rollback() ;
        }
    }
View Full Code Here

        throws SystemException, NotSupportedException, RollbackException
    {
        final LastOnePhaseResource firstResource = new LastOnePhaseResource() ;
        final LastOnePhaseResource secondResource = new LastOnePhaseResource() ;
       
        final TransactionManager tm = new TransactionManagerImple() ;
        tm.begin() ;
        try
        {
            final Transaction tx = tm.getTransaction() ;
            assertTrue("First resource enlisted", tx.enlistResource(firstResource)) ;
            assertFalse("Second resource enlisted", tx.enlistResource(secondResource)) ;
        }
        finally
        {
            tm.rollback() ;
        }
    }
View Full Code Here

      queueControl.removeMessages(null);
   }

   protected TransactionManager newTransactionManager()
   {
      return new TransactionManagerImple();
   }
View Full Code Here

import junit.framework.TestCase;

public class TestSetTransactionTimeout extends TestCase {
  public void test() throws NotSupportedException,
      SystemException, IllegalStateException, RollbackException {
    javax.transaction.TransactionManager tm = new TransactionManagerImple();

    tm.begin();

    javax.transaction.Transaction theTransaction = tm.getTransaction();
    theTransaction.enlistResource(new XAResource() {

      public void commit(Xid arg0, boolean arg1) throws XAException {
        // TODO Auto-generated method stub

      }

      public void end(Xid arg0, int arg1) throws XAException {
        // TODO Auto-generated method stub

      }

      public void forget(Xid arg0) throws XAException {
        // TODO Auto-generated method stub

      }

      public int getTransactionTimeout() throws XAException {
        // TODO Auto-generated method stub
        return 0;
      }

      public boolean isSameRM(XAResource arg0) throws XAException {
        // TODO Auto-generated method stub
        return false;
      }

      public int prepare(Xid arg0) throws XAException {
        // TODO Auto-generated method stub
        return 0;
      }

      public Xid[] recover(int arg0) throws XAException {
        // TODO Auto-generated method stub
        return null;
      }

      public void rollback(Xid arg0) throws XAException {
        // TODO Auto-generated method stub

      }

      public boolean setTransactionTimeout(int arg0) throws XAException {
        throw new XAException("foo bar");
      }

      public void start(Xid arg0, int arg1) throws XAException {
        // TODO Auto-generated method stub

      }
    });
    tm.rollback();
  }
View Full Code Here

TOP

Related Classes of com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple

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.