Search in sources :

Example 1 with TestErrorResponse

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

the class HotRodFunctionalTest method testPutOnTopologyCache.

public void testPutOnTopologyCache(Method m) {
    TestErrorResponse resp = ((TestErrorResponse) client().execute(0xA0, (byte) 0x01, HotRodServerConfiguration.TOPOLOGY_CACHE_NAME_PREFIX, k(m), 0, 0, v(m), 0, (byte) 1, 0));
    assertTrue(resp.msg.contains("CacheNotFoundException"));
    assertEquals("Status should have been 'ParseError' but instead was: " + resp.status, resp.status, ParseError);
    client().assertPut(m);
}
Also used : TestErrorResponse(org.infinispan.server.hotrod.test.TestErrorResponse)

Example 2 with TestErrorResponse

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

the class HotRodSingleClusteredTest method testPutOnPrivateCache.

public void testPutOnPrivateCache(Method m) {
    TestErrorResponse resp = (TestErrorResponse) hotRodClient.execute(0xA0, (byte) 0x01, hotRodServer.getConfiguration().topologyCacheName(), k(m), 0, 0, v(m), 0, (byte) 1, 0);
    assertTrue(resp.msg.contains("Remote requests are not allowed to private caches."));
    assertEquals("Status should have been 'ParseError' but instead was: " + resp.status, ParseError, resp.status);
    hotRodClient.assertPut(m);
}
Also used : TestErrorResponse(org.infinispan.server.hotrod.test.TestErrorResponse)

Example 3 with TestErrorResponse

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

the class TestWeakCounter method executeOp.

private CompletableFuture<Void> executeOp(CounterOp op) {
    TestResponse response = client.execute(op);
    CompletableFuture<Void> future = new CompletableFuture<>();
    switch(response.getStatus()) {
        case Success:
            future.complete(null);
            break;
        case OperationNotExecuted:
            future.complete(null);
            break;
        case KeyDoesNotExist:
            future.completeExceptionally(new IllegalStateException("Counter Not Found!"));
            break;
        case ServerError:
            future.completeExceptionally(new CounterException(((TestErrorResponse) response).msg));
            break;
        default:
            future.completeExceptionally(new Exception("unknown response " + response));
    }
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CounterValueTestResponse(org.infinispan.server.hotrod.counter.response.CounterValueTestResponse) TestResponse(org.infinispan.server.hotrod.test.TestResponse) TestErrorResponse(org.infinispan.server.hotrod.test.TestErrorResponse) CounterException(org.infinispan.counter.exception.CounterException) CounterException(org.infinispan.counter.exception.CounterException)

Example 4 with TestErrorResponse

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

the class TestStrongCounter method executeOp.

private <T> CompletableFuture<T> executeOp(CounterOp op, BiConsumer<CompletableFuture<T>, TestResponse> responseHandler, BooleanSupplier canReachUpperBound) {
    TestResponse response = client.execute(op);
    CompletableFuture<T> future = new CompletableFuture<>();
    switch(response.getStatus()) {
        case Success:
            responseHandler.accept(future, response);
            break;
        case OperationNotExecuted:
            responseHandler.accept(future, response);
            break;
        case KeyDoesNotExist:
            future.completeExceptionally(new IllegalStateException("Counter Not Found!"));
            break;
        case ServerError:
            future.completeExceptionally(new CounterException(((TestErrorResponse) response).msg));
            break;
        case NotExecutedWithPrevious:
            future.completeExceptionally(canReachUpperBound.getAsBoolean() ? new CounterOutOfBoundsException(format(FORMAT_MESSAGE, UPPER_BOUND)) : new CounterOutOfBoundsException(format(FORMAT_MESSAGE, LOWER_BOUND)));
            break;
        default:
            future.completeExceptionally(new Exception("unknown response " + response));
    }
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) COUNTER_RESET(org.infinispan.server.hotrod.HotRodOperation.COUNTER_RESET) COUNTER_GET(org.infinispan.server.hotrod.HotRodOperation.COUNTER_GET) TestResponse(org.infinispan.server.hotrod.test.TestResponse) CounterValueTestResponse(org.infinispan.server.hotrod.counter.response.CounterValueTestResponse) CounterOutOfBoundsException(org.infinispan.counter.exception.CounterOutOfBoundsException) TestErrorResponse(org.infinispan.server.hotrod.test.TestErrorResponse) CounterException(org.infinispan.counter.exception.CounterException) CounterException(org.infinispan.counter.exception.CounterException) CounterOutOfBoundsException(org.infinispan.counter.exception.CounterOutOfBoundsException)

Example 5 with TestErrorResponse

use of org.infinispan.server.hotrod.test.TestErrorResponse 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

TestErrorResponse (org.infinispan.server.hotrod.test.TestErrorResponse)7 TestResponse (org.infinispan.server.hotrod.test.TestResponse)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 CounterException (org.infinispan.counter.exception.CounterException)2 CounterValueTestResponse (org.infinispan.server.hotrod.counter.response.CounterValueTestResponse)2 XidImpl (org.infinispan.commons.tx.XidImpl)1 CounterOutOfBoundsException (org.infinispan.counter.exception.CounterOutOfBoundsException)1 COUNTER_GET (org.infinispan.server.hotrod.HotRodOperation.COUNTER_GET)1 COUNTER_RESET (org.infinispan.server.hotrod.HotRodOperation.COUNTER_RESET)1 HotRodClient (org.infinispan.server.hotrod.test.HotRodClient)1 TxResponse (org.infinispan.server.hotrod.test.TxResponse)1