timoninmaxim commented on code in PR #11713:
URL: https://github.com/apache/ignite/pull/11713#discussion_r1895614589
##########
modules/core/src/test/java/org/apache/ignite/internal/client/thin/ThinClientNonTransactionalOperationsInTxTest.java:
##########
@@ -90,9 +93,58 @@ private void checkThinClientCacheOperation(IgniteClient
client, Consumer<ClientC
}
return null;
- }, CacheException.class,
NON_TRANSACTIONAL_CLIENT_CACHE_CLEAR_IN_TX_ERROR_MESSAGE);
+ }, CacheException.class,
String.format(NON_TRANSACTIONAL_CLIENT_CACHE_IN_TX_ERROR_MESSAGE,
checkClearAsync(async)));
assertTrue(cache.containsKey(1));
assertFalse(cache.containsKey(2));
}
+
+ /** */
+ private String checkClearAsync(boolean async) {
+ return async ? "clearAsync" : "clear";
+ }
+
+ /** */
+ @Test
+ public void testThinClientCacheRemove() throws Exception {
+ startGrid(0);
+
+ try (IgniteClient client = Ignition.startClient(new
ClientConfiguration().setAddresses(Config.SERVER))) {
+
+ checkThinClientCacheRemoveOperation(client, false, cache ->
cache.removeAll());
+
+ checkThinClientCacheRemoveOperation(client, true, cache ->
cache.removeAllAsync());
+ }
+ }
+
+ /**
+ * It should throw exception.
+ *
+ * @param client IgniteClient.
+ * @param async Async flag.
+ * @param op Operation.
+ */
+ private void checkThinClientCacheRemoveOperation(IgniteClient client,
boolean async, Consumer<ClientCache<Object, Object>> op) {
+ ClientCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME);
+
+ cache.put(1, 1);
+
+ GridTestUtils.assertThrows(log, (Callable<Void>)() -> {
+ try (ClientTransaction tx =
client.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
+ cache.put(2, 2);
+
+ op.accept(cache);
+ }
+
+ return null;
+ }, CacheException.class,
String.format(NON_TRANSACTIONAL_CLIENT_CACHE_IN_TX_ERROR_MESSAGE,
checkRemoveAsync(async)));
+
+ assertTrue(cache.containsKey(1));
+ assertFalse(cache.containsKey(2));
+ }
+
+ /** */
+ private String checkRemoveAsync(boolean async) {
+ return async ? "removeAllAsync" : "removeAll";
Review Comment:
Let's inline this method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]