Package bitronix.tm.resource.jms

Examples of bitronix.tm.resource.jms.PoolingConnectionFactory


        TransactionManagerServices.getTransactionManager();

        MockXAConnectionFactory.setStaticCloseXAConnectionException(null);
        MockXAConnectionFactory.setStaticCreateXAConnectionException(null);

        pcf = new PoolingConnectionFactory();
        pcf.setMinPoolSize(1);
        pcf.setMaxPoolSize(2);
        pcf.setMaxIdleTime(1);
        pcf.setClassName(MockXAConnectionFactory.class.getName());
        pcf.setUniqueName("pcf");
View Full Code Here


    }

    public void testInitFailure() throws Exception {
        pcf.close();

        pcf = new PoolingConnectionFactory();
        pcf.setMinPoolSize(0);
        pcf.setMaxPoolSize(2);
        pcf.setMaxIdleTime(1);
        pcf.setClassName(MockXAConnectionFactory.class.getName());
        pcf.setUniqueName("pcf");
View Full Code Here

    public void testPoolNotStartingTransactionManager() throws Exception {
        // make sure TM is not running
        TransactionManagerServices.getTransactionManager().shutdown();

        PoolingConnectionFactory pcf = new PoolingConnectionFactory();
        pcf.setMinPoolSize(1);
        pcf.setMaxPoolSize(2);
        pcf.setMaxIdleTime(1);
        pcf.setClassName(MockXAConnectionFactory.class.getName());
        pcf.setUniqueName("pcf2");
        pcf.setAllowLocalTransactions(true);
        pcf.setAcquisitionTimeout(1);
        pcf.init();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        Connection c = pcf.createConnection();
        Session s = c.createSession(false, 0);
        Queue q = s.createQueue("q");
        MessageProducer mp = s.createProducer(q);
        mp.send(s.createTextMessage("test123"));
        mp.close();
        s.close();
        c.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());

        pcf.close();

        assertFalse(TransactionManagerServices.isTransactionManagerRunning());
    }
View Full Code Here

     }

     public void testRegisterTwoLrcJms() throws Exception {
         BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();

         PoolingConnectionFactory pcf = new PoolingConnectionFactory();
         pcf.setClassName(LrcXAConnectionFactory.class.getName());
         pcf.setUniqueName("pcf_lrc");
         pcf.setMaxPoolSize(1);
         pcf.getDriverProperties().setProperty("connectionFactoryClassName", MockConnectionFactory.class.getName());
         pcf.init();

         PoolingDataSource lrcDs2 = new PoolingDataSource();
         lrcDs2.setClassName(LrcXADataSource.class.getName());
         lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc");
         lrcDs2.setMinPoolSize(POOL_SIZE);
         lrcDs2.setMaxPoolSize(POOL_SIZE);
         lrcDs2.setAllowLocalTransactions(true);
         lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName());
         lrcDs2.getDriverProperties().setProperty("url", "");
         lrcDs2.init();

         tm.begin();

         javax.jms.Connection c = pcf.createConnection();
         javax.jms.Session s = c.createSession(true, 0);
         javax.jms.MessageProducer p = s.createProducer(null);
         p.send(null);
         c.close();

         Connection c2 = lrcDs2.getConnection();
         try {
             c2.createStatement();
             fail("expected SQLException");
         } catch (SQLException ex) {
           assertTrue(ex.getMessage().startsWith("error enlisting a JdbcConnectionHandle of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on Mock for Connection"));
             assertTrue(ex.getCause().getMessage().startsWith("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pcf_lrc XAResource=a JMS LrcXAResource in state STARTED of session Mock for Session"));
         }
         c2.close();

         tm.commit();

         lrcDs2.close();
         pcf.close();
     }
View Full Code Here

        Map dataSources = loader.getResources();

        assertEquals(1, dataSources.size());
        String uniqueName = (String) dataSources.keySet().iterator().next();
        assertEquals("mq1", uniqueName);
        PoolingConnectionFactory pcf = (PoolingConnectionFactory) dataSources.get(uniqueName);
        assertEquals("bitronix.tm.mock.resource.jms.MockXAConnectionFactory", pcf.getClassName());
        assertEquals("mq1", pcf.getUniqueName());
        assertEquals(123, pcf.getMaxPoolSize());
        assertEquals(1, pcf.getDriverProperties().size());

    }
View Full Code Here

    protected static final int POOL_SIZE = 5;
    protected static final String CONNECTION_FACTORY1_NAME = "pcf1";
    protected static final String CONNECTION_FACTORY2_NAME = "pcf2";

    protected void setUp() throws Exception {
        poolingConnectionFactory1 = new PoolingConnectionFactory();
        poolingConnectionFactory1.setClassName(MockXAConnectionFactory.class.getName());
        poolingConnectionFactory1.setUniqueName(CONNECTION_FACTORY1_NAME);
        poolingConnectionFactory1.setAcquisitionTimeout(5);
        poolingConnectionFactory1.setMinPoolSize(POOL_SIZE);
        poolingConnectionFactory1.setMaxPoolSize(POOL_SIZE);
        poolingConnectionFactory1.init();

        poolingConnectionFactory2 = new PoolingConnectionFactory();
        poolingConnectionFactory2.setClassName(MockXAConnectionFactory.class.getName());
        poolingConnectionFactory2.setUniqueName(CONNECTION_FACTORY2_NAME);
        poolingConnectionFactory2.setAcquisitionTimeout(5);
        poolingConnectionFactory2.setMinPoolSize(POOL_SIZE);
        poolingConnectionFactory2.setMaxPoolSize(POOL_SIZE);
View Full Code Here

     }

     public void testRegisterTwoLrcJms() throws Exception {
         BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();

         PoolingConnectionFactory pcf = new PoolingConnectionFactory();
         pcf.setClassName(LrcXAConnectionFactory.class.getName());
         pcf.setUniqueName("pcf_lrc");
         pcf.setMaxPoolSize(1);
         pcf.getDriverProperties().setProperty("connectionFactoryClassName", MockConnectionFactory.class.getName());
         pcf.init();

         PoolingDataSource lrcDs2 = new PoolingDataSource();
         lrcDs2.setClassName(LrcXADataSource.class.getName());
         lrcDs2.setUniqueName(DATASOURCE2_NAME + "_lrc");
         lrcDs2.setMinPoolSize(POOL_SIZE);
         lrcDs2.setMaxPoolSize(POOL_SIZE);
         lrcDs2.setAllowLocalTransactions(true);
         lrcDs2.getDriverProperties().setProperty("driverClassName", MockDriver.class.getName());
         lrcDs2.getDriverProperties().setProperty("url", "");
         lrcDs2.init();

         tm.begin();

         javax.jms.Connection c = pcf.createConnection();
         javax.jms.Session s = c.createSession(true, 0);
         javax.jms.MessageProducer p = s.createProducer(null);
         p.send(null);
         c.close();

         Connection c2 = lrcDs2.getConnection();
         try {
             c2.createStatement();
             fail("expected SQLException");
         } catch (SQLException ex) {
           assertTrue(ex.getMessage().startsWith("error enlisting a ConnectionJavaProxy of a JdbcPooledConnection from datasource pds2_lrc in state ACCESSIBLE with usage count 1 wrapping a JDBC LrcXAConnection on a JDBC LrcConnectionJavaProxy on Mock"));
             assertTrue(ex.getCause().getMessage().startsWith("cannot enlist more than one non-XA resource, tried enlisting an XAResourceHolderState with uniqueName=pds2_lrc XAResource=a JDBC LrcXAResource in state NO_TX with XID null, already enlisted: an XAResourceHolderState with uniqueName=pcf_lrc XAResource=a JMS LrcXAResource in state STARTED of session Mock for Session"));
         }
         c2.close();

         tm.commit();

         lrcDs2.close();
         pcf.close();
     }
View Full Code Here

    protected static final int POOL_SIZE = 5;
    protected static final String CONNECTION_FACTORY1_NAME = "pcf1";
    protected static final String CONNECTION_FACTORY2_NAME = "pcf2";

    protected void setUp() throws Exception {
        poolingConnectionFactory1 = new PoolingConnectionFactory();
        poolingConnectionFactory1.setClassName(MockXAConnectionFactory.class.getName());
        poolingConnectionFactory1.setUniqueName(CONNECTION_FACTORY1_NAME);
        poolingConnectionFactory1.setAcquisitionTimeout(5);
        poolingConnectionFactory1.setMinPoolSize(POOL_SIZE);
        poolingConnectionFactory1.setMaxPoolSize(POOL_SIZE);
        poolingConnectionFactory1.init();

        poolingConnectionFactory2 = new PoolingConnectionFactory();
        poolingConnectionFactory2.setClassName(MockXAConnectionFactory.class.getName());
        poolingConnectionFactory2.setUniqueName(CONNECTION_FACTORY2_NAME);
        poolingConnectionFactory2.setAcquisitionTimeout(5);
        poolingConnectionFactory2.setMinPoolSize(POOL_SIZE);
        poolingConnectionFactory2.setMaxPoolSize(POOL_SIZE);
View Full Code Here

        TransactionManagerServices.getTransactionManager();

        MockXAConnectionFactory.setStaticCloseXAConnectionException(null);
        MockXAConnectionFactory.setStaticCreateXAConnectionException(null);

        pcf = new PoolingConnectionFactory();
        pcf.setMinPoolSize(1);
        pcf.setMaxPoolSize(2);
        pcf.setMaxIdleTime(1);
        pcf.setClassName(MockXAConnectionFactory.class.getName());
        pcf.setUniqueName("pcf");
View Full Code Here

    }

    public void testInitFailure() throws Exception {
        pcf.close();

        pcf = new PoolingConnectionFactory();
        pcf.setMinPoolSize(0);
        pcf.setMaxPoolSize(2);
        pcf.setMaxIdleTime(1);
        pcf.setClassName(MockXAConnectionFactory.class.getName());
        pcf.setUniqueName("pcf");
View Full Code Here

TOP

Related Classes of bitronix.tm.resource.jms.PoolingConnectionFactory

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.