Skip to content

Commit 44b0e5c

Browse files
committed
Merge branch 'main' into JAVA-4586_bulk-write
2 parents c05816b + dc9c8a6 commit 44b0e5c

File tree

3 files changed

+41
-49
lines changed

3 files changed

+41
-49
lines changed

driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import static org.junit.jupiter.api.Assertions.assertNull;
9292
import static org.junit.jupiter.api.Assertions.assertTrue;
9393
import static org.junit.jupiter.api.Assertions.fail;
94+
import static org.junit.jupiter.api.Assumptions.assumeFalse;
9495
import static org.junit.jupiter.api.Assumptions.assumeTrue;
9596
import static util.JsonPoweredTestHelper.getTestDocument;
9697
import static util.JsonPoweredTestHelper.getTestFiles;
@@ -216,7 +217,11 @@ public void setUp(
216217
ignoreExtraEvents = false;
217218
testDef = testDef(directoryName, fileDescription, testDescription, isReactive());
218219
UnifiedTestModifications.doSkips(testDef);
220+
221+
boolean skip = testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.SKIP);
222+
assumeFalse(skip, "Skipping test");
219223
skips(fileDescription, testDescription);
224+
220225
assertTrue(
221226
schemaVersion.equals("1.0")
222227
|| schemaVersion.equals("1.1")

driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestFailureValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ final class UnifiedTestFailureValidator extends UnifiedSyncTest {
3636
@Override
3737
@BeforeEach
3838
public void setUp(
39-
final String directoryName,
4039
@Nullable final String fileDescription,
4140
@Nullable final String testDescription,
41+
final String directoryName,
4242
final String schemaVersion,
4343
@Nullable final BsonArray runOnRequirements,
4444
final BsonArray entitiesArray,
4545
final BsonArray initialData,
4646
final BsonDocument definition) {
4747
try {
4848
super.setUp(
49-
directoryName,
5049
fileDescription,
5150
testDescription,
51+
directoryName,
5252
schemaVersion,
5353
runOnRequirements,
5454
entitiesArray,

driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.mongodb.client.unified;
1818

1919
import com.mongodb.assertions.Assertions;
20-
import com.mongodb.lang.NonNull;
21-
import com.mongodb.lang.Nullable;
2220

2321
import java.util.ArrayList;
2422
import java.util.Arrays;
@@ -30,11 +28,12 @@
3028
import static com.mongodb.ClusterFixture.isServerlessTest;
3129
import static com.mongodb.ClusterFixture.isSharded;
3230
import static com.mongodb.ClusterFixture.serverVersionLessThan;
31+
import static com.mongodb.assertions.Assertions.assertNotNull;
3332
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier.IGNORE_EXTRA_EVENTS;
33+
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier.SKIP;
3434
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier.SLEEP_AFTER_CURSOR_CLOSE;
3535
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier.SLEEP_AFTER_CURSOR_OPEN;
3636
import static com.mongodb.client.unified.UnifiedTestModifications.Modifier.WAIT_FOR_BATCH_CURSOR_CREATION;
37-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
3837

3938
public final class UnifiedTestModifications {
4039
public static void doSkips(final TestDef def) {
@@ -90,7 +89,7 @@ public static void doSkips(final TestDef def) {
9089
// added as part of https://jira.mongodb.org/browse/JAVA-4976 , but unknown Jira to complete
9190
// The implementation of the functionality related to clearing the connection pool before closing the connection
9291
// will be carried out once the specification is finalized and ready.
93-
def.skipTodo("")
92+
def.skipUnknownReason("")
9493
.test("connection-monitoring-and-pooling/logging", "connection-logging", "Connection checkout fails due to error establishing connection");
9594

9695
// load-balancers
@@ -129,7 +128,7 @@ public static void doSkips(final TestDef def) {
129128
.test("crud", "count", "Deprecated count without a filter")
130129
.test("crud", "count", "Deprecated count with a filter")
131130
.test("crud", "count", "Deprecated count with skip and limit");
132-
def.skipTodo("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275")
131+
def.skipUnknownReason("See downstream changes comment on https://jira.mongodb.org/browse/JAVA-4275")
133132
.test("crud", "findOneAndReplace-hint-unacknowledged", "Unacknowledged findOneAndReplace with hint string on 4.4+ server")
134133
.test("crud", "findOneAndReplace-hint-unacknowledged", "Unacknowledged findOneAndReplace with hint document on 4.4+ server")
135134
.test("crud", "findOneAndUpdate-hint-unacknowledged", "Unacknowledged findOneAndUpdate with hint string on 4.4+ server")
@@ -295,58 +294,58 @@ private TestDef(final String dir, final String file, final String test, final bo
295294
* Test is skipped because it is pending implementation, and there is
296295
* a Jira ticket tracking this which has more information.
297296
*
298-
* @param skip reason for skipping the test; must start with a Jira URL
297+
* @param ticket reason for skipping the test; must start with a Jira URL
299298
*/
300-
public TestApplicator skipJira(final String skip) {
301-
Assertions.assertTrue(skip.startsWith("https://jira.mongodb.org/browse/JAVA-"));
302-
return new TestApplicator(this, skip);
299+
public TestApplicator skipJira(final String ticket) {
300+
Assertions.assertTrue(ticket.startsWith("https://jira.mongodb.org/browse/JAVA-"));
301+
return new TestApplicator(this, ticket, SKIP);
303302
}
304303

305304
/**
306305
* Test is skipped because the feature under test was deprecated, and
307306
* was removed in the Java driver.
308307
*
309-
* @param skip reason for skipping the test
308+
* @param reason reason for skipping the test
310309
*/
311-
public TestApplicator skipDeprecated(final String skip) {
312-
return new TestApplicator(this, skip);
310+
public TestApplicator skipDeprecated(final String reason) {
311+
return new TestApplicator(this, reason, SKIP);
313312
}
314313

315314
/**
316315
* Test is skipped because the Java driver cannot comply with the spec.
317316
*
318-
* @param skip reason for skipping the test
317+
* @param reason reason for skipping the test
319318
*/
320-
public TestApplicator skipNoncompliant(final String skip) {
321-
return new TestApplicator(this, skip);
319+
public TestApplicator skipNoncompliant(final String reason) {
320+
return new TestApplicator(this, reason, SKIP);
322321
}
323322

324323
/**
325324
* Test is skipped because the Java Reactive driver cannot comply with the spec.
326325
*
327-
* @param skip reason for skipping the test
326+
* @param reason reason for skipping the test
328327
*/
329-
public TestApplicator skipNoncompliantReactive(final String skip) {
330-
return new TestApplicator(this, skip);
328+
public TestApplicator skipNoncompliantReactive(final String reason) {
329+
return new TestApplicator(this, reason, SKIP);
331330
}
332331

333332
/**
334333
* The test is skipped, as specified. This should be paired with a
335334
* "when" clause.
336335
*/
337-
public TestApplicator skipAccordingToSpec(final String skip) {
338-
return new TestApplicator(this, skip);
336+
public TestApplicator skipAccordingToSpec(final String reason) {
337+
return new TestApplicator(this, reason, SKIP);
339338
}
340339

341340
/**
342341
* The test is skipped for an unknown reason.
343342
*/
344-
public TestApplicator skipTodo(final String skip) {
345-
return new TestApplicator(this, skip);
343+
public TestApplicator skipUnknownReason(final String reason) {
344+
return new TestApplicator(this, reason, SKIP);
346345
}
347346

348347
public TestApplicator modify(final Modifier... modifiers) {
349-
return new TestApplicator(this, Arrays.asList(modifiers));
348+
return new TestApplicator(this, null, modifiers);
350349
}
351350

352351
public boolean isReactive() {
@@ -363,44 +362,28 @@ public boolean wasAssignedModifier(final Modifier modifier) {
363362
*/
364363
public static final class TestApplicator {
365364
private final TestDef testDef;
366-
367-
private final boolean shouldSkip;
368-
@Nullable
369-
private final String reasonToApply;
370365
private final List<Modifier> modifiersToApply;
371366
private Supplier<Boolean> precondition;
372367
private boolean matchWasPerformed = false;
373368

374369
private TestApplicator(
375370
final TestDef testDef,
376-
final List<Modifier> modifiersToApply) {
377-
this.testDef = testDef;
378-
this.shouldSkip = false;
379-
this.reasonToApply = null;
380-
this.modifiersToApply = modifiersToApply;
381-
}
382-
383-
private TestApplicator(
384-
final TestDef testDef,
385-
@NonNull
386-
final String reason) {
371+
final String reason,
372+
final Modifier... modifiersToApply) {
387373
this.testDef = testDef;
388-
this.shouldSkip = true;
389-
this.reasonToApply = reason;
390-
this.modifiersToApply = new ArrayList<>();
374+
this.modifiersToApply = Arrays.asList(modifiersToApply);
375+
if (this.modifiersToApply.contains(SKIP)) {
376+
assertNotNull(reason);
377+
}
391378
}
392379

393380
private TestApplicator onMatch(final boolean match) {
394381
matchWasPerformed = true;
395382
if (precondition != null && !precondition.get()) {
396383
return this;
397384
}
398-
if (shouldSkip) {
399-
assumeFalse(match, reasonToApply);
400-
} else {
401-
if (match) {
402-
this.testDef.modifiers.addAll(this.modifiersToApply);
403-
}
385+
if (match) {
386+
this.testDef.modifiers.addAll(this.modifiersToApply);
404387
}
405388
return this;
406389
}
@@ -513,5 +496,9 @@ public enum Modifier {
513496
* Reactive only.
514497
*/
515498
WAIT_FOR_BATCH_CURSOR_CREATION,
499+
/**
500+
* Skip the test.
501+
*/
502+
SKIP,
516503
}
517504
}

0 commit comments

Comments
 (0)