@@ -143,27 +143,18 @@ 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
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",
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",
160
153
// separated by a space character.
161
154
private static final String TEST_FILTER_PROPERTY = "specTestFilter" ;
162
155
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
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
167
158
// 'multi-client').
168
159
private static final Set <String > DISABLED_TAGS =
169
160
RUN_BENCHMARK_TESTS
@@ -242,8 +233,7 @@ public abstract class SpecTestCase implements RemoteStoreCallback {
242
233
243
234
public static void info (String line ) {
244
235
if (DEBUG ) {
245
- // Print log information out directly to cut down on logger-related cruft like
246
- // the extra
236
+ // Print log information out directly to cut down on logger-related cruft like the extra
247
237
// line for the date and class method which are always SpecTestCase+info
248
238
System .err .println (line );
249
239
} else {
@@ -502,6 +492,7 @@ private BloomFilter parseBloomFilter(JSONObject obj) throws JSONException {
502
492
//
503
493
// Methods for doing the steps of the spec test.
504
494
//
495
+
505
496
private void doListen (JSONObject listenSpec ) throws Exception {
506
497
int expectedId = listenSpec .getInt ("targetId" );
507
498
Query query = parseQuery (listenSpec .getJSONObject ("query" ));
@@ -642,8 +633,7 @@ private void doWatchRemove(JSONObject watchRemoveSpec) throws Exception {
642
633
new WatchTargetChange (
643
634
WatchTargetChangeType .Removed , targetIds , WatchStream .EMPTY_RESUME_TOKEN , error );
644
635
writeWatchChange (change , SnapshotVersion .NONE );
645
- // Unlike web, the MockDatastore detects a watch removal with cause and will
646
- // remove active
636
+ // Unlike web, the MockDatastore detects a watch removal with cause and will remove active
647
637
// targets
648
638
}
649
639
@@ -697,7 +687,6 @@ private void doWatchFilter(JSONObject watchFilter) throws Exception {
697
687
? parseBloomFilter (watchFilter .getJSONObject ("bloomFilter" ))
698
688
: null ;
699
689
700
- // TODO: extend this with different existence filters over time.
701
690
ExistenceFilter filter = new ExistenceFilter (keyCount , bloomFilterProto );
702
691
ExistenceFilterWatchChange change = new ExistenceFilterWatchChange (targets .get (0 ), filter );
703
692
writeWatchChange (change , SnapshotVersion .NONE );
@@ -710,8 +699,7 @@ private void doWatchReset(JSONArray targetIds) throws Exception {
710
699
}
711
700
712
701
private void doWatchSnapshot (JSONObject watchSnapshot ) throws Exception {
713
- // The client will only respond to watchSnapshots if they are on a target change
714
- // with an empty
702
+ // The client will only respond to watchSnapshots if they are on a target change with an empty
715
703
// set of target IDs.
716
704
List <Integer > targets =
717
705
watchSnapshot .has ("targetIds" )
@@ -734,8 +722,7 @@ private void doWatchStreamClose(JSONObject spec) throws Exception {
734
722
Status status =
735
723
Status .fromCodeValue (error .getInt ("code" )).withDescription (error .getString ("message" ));
736
724
queue .runSync (() -> datastore .failWatchStream (status ));
737
- // Unlike web, stream should re-open synchronously (if we have active
738
- // listeners).
725
+ // Unlike web, stream should re-open synchronously (if we have active listeners).
739
726
if (!this .queryListeners .isEmpty ()) {
740
727
assertTrue ("Watch stream is open" , datastore .isWatchStreamOpen ());
741
728
}
@@ -876,8 +863,7 @@ private void doStep(JSONObject step) throws Exception {
876
863
} else if (step .has ("watchStreamClose" )) {
877
864
doWatchStreamClose (step .getJSONObject ("watchStreamClose" ));
878
865
} else if (step .has ("watchProto" )) {
879
- // watchProto isn't yet used, and it's unclear how to create arbitrary protos
880
- // from JSON.
866
+ // watchProto isn't yet used, and it's unclear how to create arbitrary protos from JSON.
881
867
throw Assert .fail ("watchProto is not yet supported." );
882
868
} else if (step .has ("writeAck" )) {
883
869
doWriteAck (step .getJSONObject ("writeAck" ));
@@ -894,12 +880,9 @@ private void doStep(JSONObject step) throws Exception {
894
880
doDisableNetwork ();
895
881
}
896
882
} else if (step .has ("changeUser" )) {
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
883
+ // NOTE: JSONObject.getString("foo") where "foo" is mapped to null will return "null".
884
+ // Explicitly testing for isNull here allows the null value to be preserved. This is important
885
+ // because the unauthenticated user is represented as having a null uid as a value for
903
886
// "changeUser".
904
887
String uid = step .isNull ("changeUser" ) ? null : step .getString ("changeUser" );
905
888
doChangeUser (uid );
@@ -1042,10 +1025,8 @@ private void validateExpectedState(@Nullable JSONObject expectedState) throws JS
1042
1025
expectedActiveTargets .put (targetId , new ArrayList <>());
1043
1026
for (int i = 0 ; i < queryArrayJson .length (); i ++) {
1044
1027
Query query = parseQuery (queryArrayJson .getJSONObject (i ));
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
1028
+ // TODO: populate the purpose of the target once it's possible to encode that in the
1029
+ // spec tests. For now, hard-code that it's a listen despite the fact that it's not
1049
1030
// always the right value.
1050
1031
TargetData targetData =
1051
1032
new TargetData (
@@ -1075,8 +1056,7 @@ private void validateExpectedState(@Nullable JSONObject expectedState) throws JS
1075
1056
// Always validate that the expected limbo docs match the actual limbo docs.
1076
1057
validateActiveLimboDocs ();
1077
1058
validateEnqueuedLimboDocs ();
1078
- // Always validate that the expected active targets match the actual active
1079
- // targets.
1059
+ // Always validate that the expected active targets match the actual active targets.
1080
1060
validateActiveTargets ();
1081
1061
}
1082
1062
@@ -1115,8 +1095,7 @@ private void validateUserCallbacks(@Nullable JSONObject expected) throws JSONExc
1115
1095
}
1116
1096
1117
1097
private void validateActiveLimboDocs () {
1118
- // Make a copy so it can modified while checking against the expected limbo
1119
- // docs.
1098
+ // Make a copy so it can modified while checking against the expected limbo docs.
1120
1099
@ SuppressWarnings ("VisibleForTests" )
1121
1100
Map <DocumentKey , Integer > actualLimboDocs =
1122
1101
new HashMap <>(syncEngine .getActiveLimboDocumentResolutions ());
@@ -1193,8 +1172,7 @@ private void validateActiveTargets() {
1193
1172
TargetData expectedTarget = expectedQueries .get (0 );
1194
1173
TargetData actualTarget = actualTargets .get (expected .getKey ());
1195
1174
1196
- // TODO: validate the purpose of the target once it's possible to encode that in
1197
- // the
1175
+ // TODO: validate the purpose of the target once it's possible to encode that in the
1198
1176
// spec tests. For now, only validate properties that can be validated.
1199
1177
// assertEquals(expectedTarget, actualTarget);
1200
1178
assertEquals (expectedTarget .getTarget (), actualTarget .getTarget ());
@@ -1217,7 +1195,6 @@ private void validateActiveTargets() {
1217
1195
private void runSteps (JSONArray steps , JSONObject config ) throws Exception {
1218
1196
try {
1219
1197
specSetUp (config );
1220
-
1221
1198
for (int i = 0 ; i < steps .length (); ++i ) {
1222
1199
JSONObject step = steps .getJSONObject (i );
1223
1200
@ Nullable JSONArray expectedSnapshotEvents = step .optJSONArray ("expectedSnapshotEvents" );
@@ -1253,14 +1230,10 @@ private void runSteps(JSONArray steps, JSONObject config) throws Exception {
1253
1230
} catch (Exception e ) {
1254
1231
throw Assert .fail ("Spec test failed with %s" , e );
1255
1232
} finally {
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
1233
+ // Ensure that Persistence is torn down even if the test is failing due to a thrown exception
1234
+ // so that any open databases are closed. This is important when the LocalStore is backed by
1235
+ // SQLite because SQLite opens databases in exclusive mode. If tearDownForSpec were not called
1236
+ // after an exception then subsequent attempts to open the SQLite database will fail, making
1264
1237
// it harder to zero in on the spec tests as a culprit.
1265
1238
specTearDown ();
1266
1239
}
@@ -1310,8 +1283,7 @@ public void testSpecTests() throws Exception {
1310
1283
String fileName = parsedSpecFile .first ;
1311
1284
JSONObject fileJSON = parsedSpecFile .second ;
1312
1285
1313
- // Print the names of the files and tests regardless of whether verbose logging
1314
- // is enabled.
1286
+ // Print the names of the files and tests regardless of whether verbose logging is enabled.
1315
1287
info ("Spec test file: " + fileName );
1316
1288
1317
1289
// Iterate over the tests in the file and run them.
0 commit comments