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

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


    FileHelper.delete( tempDirectory );
  }

  @Test
  public void testJBossTS() throws Exception {
    TransactionManagerImple tm = new TransactionManagerImple();
    tm.begin();
    EntityManager em = factory.createEntityManager();
    Tweet tweet = new Tweet( "Spice is the essence of life" );
    em.persist( tweet );
    tm.commit();
    em.close();

    tm.begin();
    em = factory.createEntityManager();
    FullTextEntityManager ftem = Search.getFullTextEntityManager( em );
    final QueryBuilder builder = ftem.getSearchFactory().buildQueryBuilder().forEntity( Tweet.class ).get();
    final Query query = builder
        .keyword()
        .onField( "text" )
        .matching( "spice" )
        .createQuery();

    ftem.createFullTextQuery( query, Tweet.class ).getResultList();
    final List resultList = em.createQuery( "from " + Tweet.class.getName() ).getResultList();
    Assert.assertEquals( 1, resultList.size() );
    for ( Object o : resultList ) {
      em.remove( o );
    }
    tm.commit();

    em.close();
  }
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

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

   protected TransactionManager getTransactionManager()
   {
      return new TransactionManagerImple();
   }
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.