@@ -143,18 +143,27 @@ public abstract class SpecTestCase implements RemoteStoreCallback {
143
143
// this tag and they'll all be run (but all others won't).
144
144
private static final String EXCLUSIVE_TAG = "exclusive" ;
145
145
146
- // The name of a Java system property ({@link System#getProperty(String)}) whose value is a filter
147
- // that specifies which tests to execute. The value of this property is a regular expression that
148
- // is matched against the name of each test. Using this property is an alternative to setting the
149
- // {@link #EXCLUSIVE_TAG} tag, which requires modifying the JSON file. To use this property,
150
- // specify -DspecTestFilter=<Regex> to the Java runtime, replacing <Regex> with a regular
151
- // expression; a test will be executed if and only if its name matches this regular expression.
152
- // In this context, a test's "name" is the result of appending its "itName" to its "describeName",
146
+ // The name of a Java system property ({@link System#getProperty(String)}) whose
147
+ // value is a filter
148
+ // that specifies which tests to execute. The value of this property is a
149
+ // regular expression that
150
+ // is matched against the name of each test. Using this property is an
151
+ // alternative to setting the
152
+ // {@link #EXCLUSIVE_TAG} tag, which requires modifying the JSON file. To use
153
+ // this property,
154
+ // specify -DspecTestFilter=<Regex> to the Java runtime, replacing <Regex> with
155
+ // a regular
156
+ // expression; a test will be executed if and only if its name matches this
157
+ // regular expression.
158
+ // In this context, a test's "name" is the result of appending its "itName" to
159
+ // its "describeName",
153
160
// separated by a space character.
154
161
private static final String TEST_FILTER_PROPERTY = "specTestFilter" ;
155
162
156
- // Tags on tests that should be excluded from execution, useful to allow the platforms to
157
- // temporarily diverge or for features that are designed to be platform specific (such as
163
+ // Tags on tests that should be excluded from execution, useful to allow the
164
+ // platforms to
165
+ // temporarily diverge or for features that are designed to be platform specific
166
+ // (such as
158
167
// 'multi-client').
159
168
private static final Set <String > DISABLED_TAGS =
160
169
RUN_BENCHMARK_TESTS
@@ -233,7 +242,8 @@ public abstract class SpecTestCase implements RemoteStoreCallback {
233
242
234
243
public static void info (String line ) {
235
244
if (DEBUG ) {
236
- // Print log information out directly to cut down on logger-related cruft like the extra
245
+ // Print log information out directly to cut down on logger-related cruft like
246
+ // the extra
237
247
// line for the date and class method which are always SpecTestCase+info
238
248
System .err .println (line );
239
249
} else {
@@ -632,7 +642,8 @@ private void doWatchRemove(JSONObject watchRemoveSpec) throws Exception {
632
642
new WatchTargetChange (
633
643
WatchTargetChangeType .Removed , targetIds , WatchStream .EMPTY_RESUME_TOKEN , error );
634
644
writeWatchChange (change , SnapshotVersion .NONE );
635
- // Unlike web, the MockDatastore detects a watch removal with cause and will remove active
645
+ // Unlike web, the MockDatastore detects a watch removal with cause and will
646
+ // remove active
636
647
// targets
637
648
}
638
649
@@ -675,14 +686,12 @@ private void doWatchEntity(JSONObject watchEntity) throws Exception {
675
686
}
676
687
677
688
private void doWatchFilter (JSONObject watchFilter ) throws Exception {
678
- List <Integer > targets =
679
- watchFilter .has ("targetIds" )
680
- ? parseIntList (watchFilter .getJSONArray ("targetIds" ))
681
- : Collections .emptyList ();
689
+ List <Integer > targets = parseIntList (watchFilter .getJSONArray ("targetIds" ));
690
+
682
691
Assert .hardAssert (
683
692
targets .size () == 1 , "ExistenceFilters currently support exactly one target only." );
684
693
685
- int keyCount = watchFilter .has ( "keys" ) ? watchFilter . getJSONArray ("keys" ).length () : 0 ;
694
+ int keyCount = watchFilter .getJSONArray ("keys" ).length ();
686
695
BloomFilter bloomFilterProto =
687
696
watchFilter .has ("bloomFilter" )
688
697
? parseBloomFilter (watchFilter .getJSONObject ("bloomFilter" ))
@@ -701,7 +710,8 @@ private void doWatchReset(JSONArray targetIds) throws Exception {
701
710
}
702
711
703
712
private void doWatchSnapshot (JSONObject watchSnapshot ) throws Exception {
704
- // The client will only respond to watchSnapshots if they are on a target change with an empty
713
+ // The client will only respond to watchSnapshots if they are on a target change
714
+ // with an empty
705
715
// set of target IDs.
706
716
List <Integer > targets =
707
717
watchSnapshot .has ("targetIds" )
@@ -724,7 +734,8 @@ private void doWatchStreamClose(JSONObject spec) throws Exception {
724
734
Status status =
725
735
Status .fromCodeValue (error .getInt ("code" )).withDescription (error .getString ("message" ));
726
736
queue .runSync (() -> datastore .failWatchStream (status ));
727
- // Unlike web, stream should re-open synchronously (if we have active listeners).
737
+ // Unlike web, stream should re-open synchronously (if we have active
738
+ // listeners).
728
739
if (!this .queryListeners .isEmpty ()) {
729
740
assertTrue ("Watch stream is open" , datastore .isWatchStreamOpen ());
730
741
}
@@ -740,7 +751,7 @@ private void doWriteAck(JSONObject writeAckSpec) throws Exception {
740
751
validateNextWriteSent (write .first );
741
752
742
753
MutationResult mutationResult =
743
- new MutationResult (version (version ), /*transformResults=*/ Collections .emptyList ());
754
+ new MutationResult (version (version ), /* transformResults= */ Collections .emptyList ());
744
755
queue .runSync (() -> datastore .ackWrite (version (version ), singletonList (mutationResult )));
745
756
}
746
757
@@ -865,7 +876,8 @@ private void doStep(JSONObject step) throws Exception {
865
876
} else if (step .has ("watchStreamClose" )) {
866
877
doWatchStreamClose (step .getJSONObject ("watchStreamClose" ));
867
878
} else if (step .has ("watchProto" )) {
868
- // watchProto isn't yet used, and it's unclear how to create arbitrary protos from JSON.
879
+ // watchProto isn't yet used, and it's unclear how to create arbitrary protos
880
+ // from JSON.
869
881
throw Assert .fail ("watchProto is not yet supported." );
870
882
} else if (step .has ("writeAck" )) {
871
883
doWriteAck (step .getJSONObject ("writeAck" ));
@@ -882,9 +894,12 @@ private void doStep(JSONObject step) throws Exception {
882
894
doDisableNetwork ();
883
895
}
884
896
} else if (step .has ("changeUser" )) {
885
- // NOTE: JSONObject.getString("foo") where "foo" is mapped to null will return "null".
886
- // Explicitly testing for isNull here allows the null value to be preserved. This is important
887
- // because the unauthenticated user is represented as having a null uid as a value for
897
+ // NOTE: JSONObject.getString("foo") where "foo" is mapped to null will return
898
+ // "null".
899
+ // Explicitly testing for isNull here allows the null value to be preserved.
900
+ // This is important
901
+ // because the unauthenticated user is represented as having a null uid as a
902
+ // value for
888
903
// "changeUser".
889
904
String uid = step .isNull ("changeUser" ) ? null : step .getString ("changeUser" );
890
905
doChangeUser (uid );
@@ -1027,8 +1042,10 @@ private void validateExpectedState(@Nullable JSONObject expectedState) throws JS
1027
1042
expectedActiveTargets .put (targetId , new ArrayList <>());
1028
1043
for (int i = 0 ; i < queryArrayJson .length (); i ++) {
1029
1044
Query query = parseQuery (queryArrayJson .getJSONObject (i ));
1030
- // TODO: populate the purpose of the target once it's possible to encode that in the
1031
- // spec tests. For now, hard-code that it's a listen despite the fact that it's not
1045
+ // TODO: populate the purpose of the target once it's possible to encode that in
1046
+ // the
1047
+ // spec tests. For now, hard-code that it's a listen despite the fact that it's
1048
+ // not
1032
1049
// always the right value.
1033
1050
TargetData targetData =
1034
1051
new TargetData (
@@ -1058,7 +1075,8 @@ private void validateExpectedState(@Nullable JSONObject expectedState) throws JS
1058
1075
// Always validate that the expected limbo docs match the actual limbo docs.
1059
1076
validateActiveLimboDocs ();
1060
1077
validateEnqueuedLimboDocs ();
1061
- // Always validate that the expected active targets match the actual active targets.
1078
+ // Always validate that the expected active targets match the actual active
1079
+ // targets.
1062
1080
validateActiveTargets ();
1063
1081
}
1064
1082
@@ -1097,7 +1115,8 @@ private void validateUserCallbacks(@Nullable JSONObject expected) throws JSONExc
1097
1115
}
1098
1116
1099
1117
private void validateActiveLimboDocs () {
1100
- // Make a copy so it can modified while checking against the expected limbo docs.
1118
+ // Make a copy so it can modified while checking against the expected limbo
1119
+ // docs.
1101
1120
@ SuppressWarnings ("VisibleForTests" )
1102
1121
Map <DocumentKey , Integer > actualLimboDocs =
1103
1122
new HashMap <>(syncEngine .getActiveLimboDocumentResolutions ());
@@ -1174,7 +1193,8 @@ private void validateActiveTargets() {
1174
1193
TargetData expectedTarget = expectedQueries .get (0 );
1175
1194
TargetData actualTarget = actualTargets .get (expected .getKey ());
1176
1195
1177
- // TODO: validate the purpose of the target once it's possible to encode that in the
1196
+ // TODO: validate the purpose of the target once it's possible to encode that in
1197
+ // the
1178
1198
// spec tests. For now, only validate properties that can be validated.
1179
1199
// assertEquals(expectedTarget, actualTarget);
1180
1200
assertEquals (expectedTarget .getTarget (), actualTarget .getTarget ());
@@ -1233,10 +1253,14 @@ private void runSteps(JSONArray steps, JSONObject config) throws Exception {
1233
1253
} catch (Exception e ) {
1234
1254
throw Assert .fail ("Spec test failed with %s" , e );
1235
1255
} finally {
1236
- // Ensure that Persistence is torn down even if the test is failing due to a thrown exception
1237
- // so that any open databases are closed. This is important when the LocalStore is backed by
1238
- // SQLite because SQLite opens databases in exclusive mode. If tearDownForSpec were not called
1239
- // after an exception then subsequent attempts to open the SQLite database will fail, making
1256
+ // Ensure that Persistence is torn down even if the test is failing due to a
1257
+ // thrown exception
1258
+ // so that any open databases are closed. This is important when the LocalStore
1259
+ // is backed by
1260
+ // SQLite because SQLite opens databases in exclusive mode. If tearDownForSpec
1261
+ // were not called
1262
+ // after an exception then subsequent attempts to open the SQLite database will
1263
+ // fail, making
1240
1264
// it harder to zero in on the spec tests as a culprit.
1241
1265
specTearDown ();
1242
1266
}
@@ -1286,7 +1310,8 @@ public void testSpecTests() throws Exception {
1286
1310
String fileName = parsedSpecFile .first ;
1287
1311
JSONObject fileJSON = parsedSpecFile .second ;
1288
1312
1289
- // Print the names of the files and tests regardless of whether verbose logging is enabled.
1313
+ // Print the names of the files and tests regardless of whether verbose logging
1314
+ // is enabled.
1290
1315
info ("Spec test file: " + fileName );
1291
1316
1292
1317
// Iterate over the tests in the file and run them.
0 commit comments