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