16
16
17
17
package com .google .cloud .spanner .connection .it ;
18
18
19
+ import static com .google .cloud .spanner .testing .EmulatorSpannerHelper .isUsingEmulator ;
19
20
import static org .hamcrest .CoreMatchers .equalTo ;
20
21
import static org .hamcrest .CoreMatchers .is ;
21
22
import static org .hamcrest .MatcherAssert .assertThat ;
@@ -488,9 +489,7 @@ public void testAbortWithResultSetFullyConsumed() {
488
489
489
490
@ Test
490
491
public void testAbortWithConcurrentInsert () {
491
- assumeFalse (
492
- "concurrent transactions are not supported on the emulator" ,
493
- env .getTestHelper ().isEmulator ());
492
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
494
493
AbortInterceptor interceptor = new AbortInterceptor (0 );
495
494
try (ITConnection connection =
496
495
createConnection (interceptor , new CountTransactionRetryListener ())) {
@@ -525,9 +524,7 @@ public void testAbortWithConcurrentInsert() {
525
524
526
525
@ Test
527
526
public void testAbortWithConcurrentDelete () {
528
- assumeFalse (
529
- "concurrent transactions are not supported on the emulator" ,
530
- env .getTestHelper ().isEmulator ());
527
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
531
528
AbortInterceptor interceptor = new AbortInterceptor (0 );
532
529
// first insert two test records
533
530
try (ITConnection connection = createConnection ()) {
@@ -566,9 +563,7 @@ public void testAbortWithConcurrentDelete() {
566
563
567
564
@ Test
568
565
public void testAbortWithConcurrentUpdate () {
569
- assumeFalse (
570
- "concurrent transactions are not supported on the emulator" ,
571
- env .getTestHelper ().isEmulator ());
566
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
572
567
AbortInterceptor interceptor = new AbortInterceptor (0 );
573
568
// first insert two test records
574
569
try (ITConnection connection = createConnection ()) {
@@ -612,9 +607,7 @@ public void testAbortWithConcurrentUpdate() {
612
607
*/
613
608
@ Test
614
609
public void testAbortWithUnseenConcurrentInsert () {
615
- assumeFalse (
616
- "concurrent transactions are not supported on the emulator" ,
617
- env .getTestHelper ().isEmulator ());
610
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
618
611
AbortInterceptor interceptor = new AbortInterceptor (0 );
619
612
try (ITConnection connection =
620
613
createConnection (interceptor , new CountTransactionRetryListener ())) {
@@ -662,9 +655,7 @@ public void testAbortWithUnseenConcurrentInsert() {
662
655
*/
663
656
@ Test
664
657
public void testAbortWithUnseenConcurrentInsertAbortOnNext () {
665
- assumeFalse (
666
- "concurrent transactions are not supported on the emulator" ,
667
- env .getTestHelper ().isEmulator ());
658
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
668
659
// no calls to next(), this should succeed
669
660
assertThat (testAbortWithUnseenConcurrentInsertAbortOnNext (0 ) >= 1 , is (true ));
670
661
// 1 call to next() should also succeed, as there were 2 records in the original result set
@@ -686,9 +677,7 @@ public void testAbortWithUnseenConcurrentInsertAbortOnNext() {
686
677
687
678
private int testAbortWithUnseenConcurrentInsertAbortOnNext (int callsToNext )
688
679
throws AbortedDueToConcurrentModificationException {
689
- assumeFalse (
690
- "concurrent transactions are not supported on the emulator" ,
691
- env .getTestHelper ().isEmulator ());
680
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
692
681
int retries = 0 ;
693
682
clearTable ();
694
683
clearStatistics ();
@@ -748,9 +737,7 @@ private int testAbortWithUnseenConcurrentInsertAbortOnNext(int callsToNext)
748
737
*/
749
738
@ Test
750
739
public void testAbortWithConcurrentInsertAndContinue () {
751
- assumeFalse (
752
- "concurrent transactions are not supported on the emulator" ,
753
- env .getTestHelper ().isEmulator ());
740
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
754
741
AbortInterceptor interceptor = new AbortInterceptor (0 );
755
742
try (ITConnection connection =
756
743
createConnection (interceptor , new CountTransactionRetryListener ())) {
@@ -960,9 +947,7 @@ protected boolean shouldAbort(String statement, ExecutionStep step) {
960
947
*/
961
948
@ Test
962
949
public void testNestedAbortWithConcurrentInsert () {
963
- assumeFalse (
964
- "concurrent transactions are not supported on the emulator" ,
965
- env .getTestHelper ().isEmulator ());
950
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
966
951
AbortInterceptor interceptor =
967
952
new AbortInterceptor (0 ) {
968
953
private boolean alreadyAborted = false ;
@@ -1025,9 +1010,7 @@ protected boolean shouldAbort(String statement, ExecutionStep step) {
1025
1010
*/
1026
1011
@ Test
1027
1012
public void testAbortWithDifferentUpdateCount () {
1028
- assumeFalse (
1029
- "concurrent transactions are not supported on the emulator" ,
1030
- env .getTestHelper ().isEmulator ());
1013
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1031
1014
AbortInterceptor interceptor = new AbortInterceptor (0 );
1032
1015
// first insert two test records
1033
1016
try (ITConnection connection = createConnection ()) {
@@ -1074,8 +1057,7 @@ public void testAbortWithDifferentUpdateCount() {
1074
1057
@ Test
1075
1058
public void testAbortWithExceptionOnSelect () {
1076
1059
assumeFalse (
1077
- "resume after error in transaction is not supported on the emulator" ,
1078
- env .getTestHelper ().isEmulator ());
1060
+ "resume after error in transaction is not supported on the emulator" , isUsingEmulator ());
1079
1061
AbortInterceptor interceptor = new AbortInterceptor (0 );
1080
1062
// first insert two test records
1081
1063
try (ITConnection connection = createConnection ()) {
@@ -1125,9 +1107,7 @@ public void testAbortWithExceptionOnSelect() {
1125
1107
*/
1126
1108
@ Test
1127
1109
public void testAbortWithExceptionOnSelectAndConcurrentModification () {
1128
- assumeFalse (
1129
- "concurrent transactions are not supported on the emulator" ,
1130
- env .getTestHelper ().isEmulator ());
1110
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1131
1111
boolean abortedDueToConcurrentModification = false ;
1132
1112
AbortInterceptor interceptor = new AbortInterceptor (0 );
1133
1113
// first insert two test records
@@ -1195,9 +1175,7 @@ public void testAbortWithExceptionOnSelectAndConcurrentModification() {
1195
1175
*/
1196
1176
@ Test
1197
1177
public void testAbortWithExceptionOnInsertAndConcurrentModification () {
1198
- assumeFalse (
1199
- "concurrent transactions are not supported on the emulator" ,
1200
- env .getTestHelper ().isEmulator ());
1178
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1201
1179
boolean abortedDueToConcurrentModification = false ;
1202
1180
AbortInterceptor interceptor = new AbortInterceptor (0 );
1203
1181
// first insert two test records
@@ -1264,9 +1242,7 @@ public void testAbortWithExceptionOnInsertAndConcurrentModification() {
1264
1242
*/
1265
1243
@ Test
1266
1244
public void testAbortWithDroppedTableConcurrentModification () {
1267
- assumeFalse (
1268
- "concurrent transactions are not supported on the emulator" ,
1269
- env .getTestHelper ().isEmulator ());
1245
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1270
1246
boolean abortedDueToConcurrentModification = false ;
1271
1247
AbortInterceptor interceptor = new AbortInterceptor (0 );
1272
1248
// first insert two test records
@@ -1329,9 +1305,7 @@ public void testAbortWithDroppedTableConcurrentModification() {
1329
1305
*/
1330
1306
@ Test
1331
1307
public void testAbortWithInsertOnDroppedTableConcurrentModification () {
1332
- assumeFalse (
1333
- "concurrent transactions are not supported on the emulator" ,
1334
- env .getTestHelper ().isEmulator ());
1308
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1335
1309
boolean abortedDueToConcurrentModification = false ;
1336
1310
AbortInterceptor interceptor = new AbortInterceptor (0 );
1337
1311
// first insert two test records
@@ -1391,9 +1365,7 @@ public void testAbortWithInsertOnDroppedTableConcurrentModification() {
1391
1365
*/
1392
1366
@ Test
1393
1367
public void testAbortWithCursorHalfwayDroppedTableConcurrentModification () {
1394
- assumeFalse (
1395
- "concurrent transactions are not supported on the emulator" ,
1396
- env .getTestHelper ().isEmulator ());
1368
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1397
1369
boolean abortedDueToConcurrentModification = false ;
1398
1370
AbortInterceptor interceptor = new AbortInterceptor (0 );
1399
1371
// first insert two test records
@@ -1546,9 +1518,7 @@ public void testRetryHighAbortRate() {
1546
1518
1547
1519
@ Test
1548
1520
public void testAbortWithConcurrentInsertOnEmptyTable () {
1549
- assumeFalse (
1550
- "concurrent transactions are not supported on the emulator" ,
1551
- env .getTestHelper ().isEmulator ());
1521
+ assumeFalse ("concurrent transactions are not supported on the emulator" , isUsingEmulator ());
1552
1522
AbortInterceptor interceptor = new AbortInterceptor (0 );
1553
1523
try (ITConnection connection =
1554
1524
createConnection (interceptor , new CountTransactionRetryListener ())) {
0 commit comments