Search in sources :

Example 1 with TxResponse

use of org.infinispan.server.hotrod.test.TxResponse in project infinispan by infinispan.

the class ServerConfigurationTest method doCorrectConfigurationTest.

private void doCorrectConfigurationTest(String cacheName, ConfigurationBuilder builder) {
    cacheManagers.forEach(cm -> cm.defineConfiguration(cacheName, builder.build()));
    waitForClusterToForm(cacheName);
    HotRodClient client = createClient(cacheName);
    XidImpl xid = XidImpl.create(-1, new byte[] { 2 }, new byte[] { 3 });
    try {
        TxResponse response = (TxResponse) client.prepareTx(xid, false, Collections.emptyList());
        assertEquals(XAResource.XA_RDONLY, response.xaCode);
        response = (TxResponse) client.commitTx(xid);
        assertEquals(XAException.XAER_NOTA, response.xaCode);
        response = (TxResponse) client.rollbackTx(xid);
        assertEquals(XAException.XAER_NOTA, response.xaCode);
        assertServerTransactionTableEmpty(cacheName);
    } finally {
        HotRodTestingUtil.killClient(client);
    }
}
Also used : XidImpl(org.infinispan.commons.tx.XidImpl) HotRodClient(org.infinispan.server.hotrod.test.HotRodClient) TxResponse(org.infinispan.server.hotrod.test.TxResponse)

Example 2 with TxResponse

use of org.infinispan.server.hotrod.test.TxResponse in project infinispan by infinispan.

the class ServerConfigurationTest method doWrongConfigurationTest.

private void doWrongConfigurationTest(String cacheName, ConfigurationBuilder builder, String errorMsg) {
    cacheManagers.forEach(cm -> cm.defineConfiguration(cacheName, builder.build()));
    waitForClusterToForm(cacheName);
    HotRodClient client = createClient(cacheName);
    XidImpl xid = XidImpl.create(-1, new byte[] { 2 }, new byte[] { 3 });
    try {
        TestErrorResponse response = (TestErrorResponse) client.prepareTx(xid, false, Collections.emptyList());
        assertEquals(errorMsg, response.msg);
        TxResponse response2 = (TxResponse) client.commitTx(xid);
        assertEquals(XAException.XAER_NOTA, response2.xaCode);
        response2 = (TxResponse) client.rollbackTx(xid);
        assertEquals(XAException.XAER_NOTA, response2.xaCode);
        assertServerTransactionTableEmpty(cacheName);
    } finally {
        HotRodTestingUtil.killClient(client);
    }
}
Also used : XidImpl(org.infinispan.commons.tx.XidImpl) TestErrorResponse(org.infinispan.server.hotrod.test.TestErrorResponse) HotRodClient(org.infinispan.server.hotrod.test.HotRodClient) TxResponse(org.infinispan.server.hotrod.test.TxResponse)

Aggregations

XidImpl (org.infinispan.commons.tx.XidImpl)2 HotRodClient (org.infinispan.server.hotrod.test.HotRodClient)2 TxResponse (org.infinispan.server.hotrod.test.TxResponse)2 TestErrorResponse (org.infinispan.server.hotrod.test.TestErrorResponse)1