DonalEvans commented on a change in pull request #7339:
URL: https://github.com/apache/geode/pull/7339#discussion_r803923418



##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/RemoteTransactionDUnitTest.java
##########
@@ -1872,12 +1858,8 @@ public Object call() {
         getCache().getTxManager().begin();
         Region r = getCache().getRegion(CUSTOMER);
         r.put(new CustId(8), new Customer("name8", "address8"));
-        try {
-          getCache().getTxManager().commit();
-          fail("expected exception that was not thrown");
-        } catch (Exception e) {
-          assertThat("AssertionError").isEqualTo(e.getCause().getMessage());
-        }

Review comment:
       I think I understand what's happening here now. The "AssertionError" 
message is actually from the `TransactionWriterException` thrown in the 
`beforeCommit()` method just above this, and it's that exception that we're 
trying to assert on. To make things clearer, maybe the message for the 
exception could be extracted to a variable and changed to something generic 
like "exception message" and we could assert on that, rather than using 
hard-coded strings in both places.
   
   We could also improve the assertions a bit by having them be more explicit:
   ```
   assertThatThrownBy(() -> getCache().getTxManager().commit())
       .isInstanceOf(CommitConflictException.class)
       .getCause()
       .isInstanceOf(TransactionWriterException.class)
       .hasMessage(exceptionMessage);
   ```




-- 
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: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to