J-Bakuli commented on code in PR #10318:
URL: https://github.com/apache/ignite/pull/10318#discussion_r1033308111


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/AtomicOperationsInTxTest.java:
##########
@@ -58,44 +61,76 @@ public class AtomicOperationsInTxTest extends 
GridCommonAbstractTest {
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
         super.beforeTestsStarted();
+    }
 
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
         startGrid(0);
     }
 
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+        stopGrid(0);
+    }
+
     /**
+     * Tests whether enabling atomic cache operations within transactions is 
allowed.
      * @throws Exception If failed.
      */
     @Test
+    @WithSystemProperty(key = IGNITE_ALLOW_ATOMIC_OPS_IN_TX, value = "false")
     public void testEnablingAtomicOperationDuringTransaction() throws 
Exception {
         GridTestUtils.assertThrows(log, (Callable<IgniteCache>)() -> {
             try (Transaction tx = grid(0).transactions().txStart()) {
                 return 
grid(0).cache(DEFAULT_CACHE_NAME).withAllowAtomicOpsInTx();
             }
         },
             IllegalStateException.class,
-            "Enabling atomic operations during active transaction is not 
allowed."
+            "Enabling atomic operations during active transaction is not 
allowed. Enable atomic operations before " +
+                    "transaction start."
         );
     }
 
     /**
+     * Tests whether allowing atomic cache operations before transaction 
starts does not cause exceptions.
+     * @throws Exception If failed.
+     */
+    @Test
+    @WithSystemProperty(key = IGNITE_ALLOW_ATOMIC_OPS_IN_TX, value = "true")
+    public void testAllowAtomicOperationsBeforeTransactionStarts() throws 
Exception {
+        try (Transaction tx = grid(0).transactions().txStart()) {
+            grid(0).cache(DEFAULT_CACHE_NAME).withAllowAtomicOpsInTx();
+        }
+    }
+
+    /**
+     * Tests that operations with atomic cache within transactions are not 
allowed if the system property
+     * {@link IgniteSystemProperties#IGNITE_ALLOW_ATOMIC_OPS_IN_TX 
IGNITE_ALLOW_ATOMIC_OPS_IN_TX} is not changed from
+     * the default {@code false} before transaction start. It is the default 
behaviour since 2.15.0.
      * @throws Exception If failed.
      */
     @Test
-    public void testAllowedAtomicOperations() throws Exception {
+    @WithSystemProperty(key = IGNITE_ALLOW_ATOMIC_OPS_IN_TX, value = "false")
+    public void testSetOfNonAtomicOperationsWithinTransactions() throws 
Exception {
         checkOperations(true);
     }
 
     /**
+     * Tests that operations with atomic cache within transactions are allowed 
if the system property
+     * {@link IgniteSystemProperties#IGNITE_ALLOW_ATOMIC_OPS_IN_TX 
IGNITE_ALLOW_ATOMIC_OPS_IN_TX} is changed to
+     * {@code true} before transaction start. Since 2.15.0 the default 
behaviour is set to {@code false}.
      * @throws Exception If failed.
      */
     @Test
-    public void testNotAllowedAtomicOperations() throws Exception {
-        checkOperations(false);
+    @WithSystemProperty(key = IGNITE_ALLOW_ATOMIC_OPS_IN_TX, value = "true")
+    public void testSetOfAtomicOperationsWithinTransactions() throws Exception 
{
+        checkOperations(true);

Review Comment:
   added 2 tests to check that, thank you



-- 
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]

Reply via email to