Skip to content

Commit 8ea9439

Browse files
committed
IGNITE-28000 Update ItThinClientTransactionTest
1 parent 42606a9 commit 8ea9439

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

modules/client/src/integrationTest/java/org/apache/ignite/internal/client/ItThinClientTransactionsTest.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
import static java.lang.String.format;
2121
import static java.util.Collections.emptyList;
2222
import static java.util.Comparator.comparing;
23+
import static org.apache.ignite.internal.IgniteExceptionTestUtils.publicException;
24+
import static org.apache.ignite.internal.IgniteExceptionTestUtils.publicExceptionWithHint;
2325
import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
2426
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrowWithCauseOrSuppressed;
2527
import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willSucceedFast;
2628
import static org.awaitility.Awaitility.await;
2729
import static org.hamcrest.MatcherAssert.assertThat;
28-
import static org.hamcrest.Matchers.containsString;
30+
import static org.hamcrest.Matchers.isA;
2931
import static org.hamcrest.Matchers.startsWith;
3032
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
3133
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -70,6 +72,7 @@
7072
import org.apache.ignite.internal.tx.TxState;
7173
import org.apache.ignite.internal.util.CollectionUtils;
7274
import org.apache.ignite.lang.ErrorGroups;
75+
import org.apache.ignite.lang.ErrorGroups.Common;
7376
import org.apache.ignite.lang.ErrorGroups.Transactions;
7477
import org.apache.ignite.lang.IgniteException;
7578
import org.apache.ignite.network.ClusterNode;
@@ -316,11 +319,14 @@ public boolean isReadOnly() {
316319
};
317320

318321
var ex = assertThrows(IgniteException.class, () -> kvView().put(tx, 1, "1"));
319-
320-
String expected = "Unsupported transaction implementation: "
321-
+ "'class org.apache.ignite.internal.client.ItThinClientTransactionsTest";
322-
323-
assertThat(ex.getMessage(), containsString(expected));
322+
assertThat(ex,
323+
publicException(
324+
IgniteException.class,
325+
Common.INTERNAL_ERR,
326+
format("Unsupported transaction implementation: 'class %s'", tx.getClass().getName()),
327+
emptyList()
328+
)
329+
);
324330
}
325331

326332
@Test
@@ -332,8 +338,14 @@ void testTransactionFromAnotherChannelThrows() {
332338
RecordView<Tuple> recordView = client2.tables().tables().get(0).recordView();
333339

334340
var ex = assertThrows(IgniteException.class, () -> recordView.upsert(tx, Tuple.create()));
335-
336-
assertThat(ex.getMessage(), containsString("Transaction belongs to a different client instance"));
341+
assertThat(ex,
342+
publicException(
343+
IgniteException.class,
344+
Common.INTERNAL_ERR,
345+
"Transaction belongs to a different client instance",
346+
emptyList()
347+
).withCause(isA(IllegalArgumentException.class))
348+
);
337349
}
338350
}
339351

@@ -366,8 +378,13 @@ void testUpdateInReadOnlyTxThrows() {
366378
Transaction tx = client().transactions().begin(new TransactionOptions().readOnly(true));
367379
var ex = assertThrows(TransactionException.class, () -> kvView.put(tx, 1, "2"));
368380

369-
assertThat(ex.getMessage(), containsString("Failed to enlist read-write operation into read-only transaction"));
370-
assertEquals(ErrorGroups.Transactions.TX_FAILED_READ_WRITE_OPERATION_ERR, ex.code());
381+
assertThat(ex,
382+
publicExceptionWithHint(
383+
TransactionException.class,
384+
ErrorGroups.Transactions.TX_FAILED_READ_WRITE_OPERATION_ERR,
385+
"Failed to enlist read-write operation into read-only transaction"
386+
)
387+
);
371388
}
372389

373390
@ParameterizedTest

0 commit comments

Comments
 (0)