@@ -118,10 +118,11 @@ public void testRetryTimeoutEnforcedTransientTransactionError() {
118118 }));
119119 fail ("Test should have thrown an exception." );
120120 } catch (Exception e ) {
121- assertInstanceOf (MongoTimeoutException .class , e );
122- MongoException cause = (MongoException ) e .getCause ();
121+ MongoTimeoutException exception = assertInstanceOf (MongoTimeoutException .class , e );
122+ assertTrue (exception .hasErrorLabel (MongoException .TRANSIENT_TRANSACTION_ERROR_LABEL ));
123+ MongoException cause = assertInstanceOf (MongoException .class , exception .getCause ());
123124 assertEquals (errorMessage , cause .getMessage ());
124- assertTrue (cause .getErrorLabels (). contains (MongoException .TRANSIENT_TRANSACTION_ERROR_LABEL ));
125+ assertTrue (cause .hasErrorLabel (MongoException .TRANSIENT_TRANSACTION_ERROR_LABEL ));
125126 }
126127 }
127128
@@ -145,10 +146,11 @@ public void testRetryTimeoutEnforcedUnknownTransactionCommit() {
145146 }));
146147 fail ("Test should have thrown an exception." );
147148 } catch (Exception e ) {
148- assertInstanceOf (MongoNodeIsRecoveringException .class , e .getCause ());
149- MongoNodeIsRecoveringException cause = (MongoNodeIsRecoveringException ) e .getCause ();
149+ MongoTimeoutException exception = assertInstanceOf (MongoTimeoutException .class , e );
150+ assertTrue (exception .hasErrorLabel (MongoException .UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL ));
151+ MongoNodeIsRecoveringException cause = assertInstanceOf (MongoNodeIsRecoveringException .class , exception .getCause ());
150152 assertEquals (91 , cause .getCode ());
151- assertTrue (cause .getErrorLabels (). contains (MongoException .UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL ));
153+ assertTrue (cause .hasErrorLabel (MongoException .UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL ));
152154 } finally {
153155 failPointAdminDb .runCommand (Document .parse ("{'configureFailPoint': 'failCommand', 'mode': 'off'}" ));
154156 }
@@ -176,11 +178,11 @@ public void testRetryTimeoutEnforcedTransientTransactionErrorOnCommit() {
176178 }));
177179 fail ("Test should have thrown an exception." );
178180 } catch (Exception e ) {
179- assertEquals (- 4 , (( MongoException ) e ). getCode () );
180- assertInstanceOf ( MongoCommandException . class , e . getCause ( ));
181- MongoCommandException cause = (MongoCommandException ) e .getCause ();
181+ MongoTimeoutException exception = assertInstanceOf ( MongoTimeoutException . class , e );
182+ assertTrue ( exception . hasErrorLabel ( MongoException . TRANSIENT_TRANSACTION_ERROR_LABEL ));
183+ MongoCommandException cause = assertInstanceOf (MongoCommandException . class , exception .getCause () );
182184 assertEquals (251 , cause .getCode ());
183- assertTrue (cause .getErrorLabels (). contains (MongoException .TRANSIENT_TRANSACTION_ERROR_LABEL ));
185+ assertTrue (cause .hasErrorLabel (MongoException .TRANSIENT_TRANSACTION_ERROR_LABEL ));
184186 } finally {
185187 failPointAdminDb .runCommand (Document .parse ("{'configureFailPoint': 'failCommand', 'mode': 'off'}" ));
186188 }
0 commit comments