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