Skip to content

Commit a05882d

Browse files
committed
Disable Kotlin tests.
JAVA-5530
1 parent e352b31 commit a05882d

File tree

10 files changed

+118
-64
lines changed

10 files changed

+118
-64
lines changed

driver-core/src/main/com/mongodb/internal/async/AsyncRunnable.java

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,6 @@ default AsyncRunnable thenRun(final AsyncRunnable runnable) {
183183
};
184184
}
185185

186-
// /**
187-
// * @param runnable The async runnable to run after this runnable
188-
// * @return the composition of this runnable and the runnable, a runnable
189-
// */
190-
// default AsyncSupplier<T> thenSupplyUntil(
191-
// final AsyncSupplier supplier,
192-
// final Predicate<Boolean> condition,
193-
// final Consumer<T> runnable) {
194-
// return (c) -> {
195-
// this.unsafeFinish((r, e) -> {
196-
// if (e == null) {
197-
// /* If 'runnable' is executed on a different thread from the one that executed the initial 'finish()',
198-
// then invoking 'finish()' within 'runnable' will catch and propagate any exceptions to 'c' (the callback). */
199-
// supplier.finish(c);
200-
// } else {
201-
// c.completeExceptionally(e);
202-
// }
203-
// });
204-
// };
205-
// }
206-
207186
/**
208187
* The error check checks if the exception is an instance of the provided class.
209188
* @see #thenRunTryCatchAsyncBlocks(AsyncRunnable, java.util.function.Predicate, AsyncFunction)
@@ -318,23 +297,6 @@ default AsyncRunnable thenRunRetryingWhile(
318297
});
319298
}
320299

321-
/**
322-
* In order to break the loop and complete the ongoing iteration, use
323-
* {@link LoopState#breakAndCompleteIf(Supplier, SingleResultCallback)} in the loopBodyRunnable.
324-
*
325-
* <p>
326-
* This is equivalent to while(true) with break.
327-
*
328-
* @param loopBodyRunnable the loopBodyRunnable to loop
329-
* @return the composition of this, and the looping branch
330-
* @see AsyncCallbackLoop
331-
*/
332-
default AsyncRunnable thenRunWhileLoop(final AsyncRunnable loopBodyRunnable, final LoopState loopState) {
333-
return thenRun(callback -> {
334-
new AsyncCallbackLoop(loopState, loopBodyRunnable::finish).run(callback);
335-
});
336-
}
337-
338300
/**
339301
* This method is equivalent to a do-while loop, where the loop body is executed first and
340302
* then the condition is checked to determine whether the loop should continue.

driver-core/src/main/com/mongodb/internal/time/TimePoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import static com.mongodb.assertions.Assertions.assertNotNull;
3030
import static com.mongodb.internal.VisibleForTesting.AccessModifier.PRIVATE;
31+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
3132
import static java.util.concurrent.TimeUnit.NANOSECONDS;
3233

3334
/**
@@ -234,7 +235,7 @@ public int hashCode() {
234235
public String toString() {
235236
String remainingMs = isInfinite()
236237
? "infinite"
237-
: "" + TimeUnit.MILLISECONDS.convert(currentNanos() - assertNotNull(nanos), NANOSECONDS);
238+
: "" + remaining(MILLISECONDS);
238239
return "TimePoint{"
239240
+ "nanos=" + nanos
240241
+ ", remainingMs=" + remainingMs

driver-core/src/test/unit/com/mongodb/internal/async/AsyncFunctionsAbstractTest.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,26 @@ void testRetryLoop() {
748748
});
749749
}
750750

751+
@Test
752+
void testDoWhileLoop() {
753+
assertBehavesSameVariations(67,
754+
() -> {
755+
do {
756+
plain(0);
757+
sync(1);
758+
} while (plainTest(2));
759+
},
760+
(finalCallback) -> {
761+
beginAsync().thenRunDoWhileLoop(
762+
callback -> {
763+
plain(0);
764+
async(1, callback);
765+
},
766+
() -> plainTest(2)
767+
).finish(finalCallback);
768+
});
769+
}
770+
751771
@Test
752772
void testFinallyWithPlainInsideTry() {
753773
// (in try: normal flow + exception + exception) * (in finally: normal + exception) = 6
@@ -770,6 +790,50 @@ void testFinallyWithPlainInsideTry() {
770790
});
771791
}
772792

793+
@Test
794+
void testSupplyFinallyWithPlainInsideTry() {
795+
assertBehavesSameVariations(6,
796+
() -> {
797+
try {
798+
plain(1);
799+
return syncReturns(2);
800+
} finally {
801+
plain(3);
802+
}
803+
},
804+
(callback) -> {
805+
beginAsync().<Integer>thenSupply(c -> {
806+
plain(1);
807+
asyncReturns(2, c);
808+
}).thenAlwaysRunAndFinish(() -> {
809+
plain(3);
810+
}, callback);
811+
});
812+
}
813+
814+
@Test
815+
void testSupplyFinallyWithPlainOutsideTry() {
816+
assertBehavesSameVariations(5,
817+
() -> {
818+
plain(1);
819+
try {
820+
return syncReturns(2);
821+
} finally {
822+
plain(3);
823+
}
824+
},
825+
(callback) -> {
826+
beginAsync().<Integer>thenSupply(c -> {
827+
plain(1);
828+
beginAsync().<Integer>thenSupply(c2 -> {
829+
asyncReturns(2, c2);
830+
}).thenAlwaysRunAndFinish(() -> {
831+
plain(3);
832+
}, c);
833+
}).finish(callback);
834+
});
835+
}
836+
773837
@Test
774838
void testFinallyWithPlainOutsideTry() {
775839
assertBehavesSameVariations(5,

driver-core/src/test/unit/com/mongodb/internal/async/AsyncFunctionsTestBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ private <T> void assertBehavesSame(final Supplier<T> sync, final Runnable betwee
256256
await(wasCalledFuture, "Callback should have been called");
257257

258258
// The following code can be used to debug variations:
259-
// System.out.println("===VARIATION START");
259+
// System.out.println("===VARIATION START: " + invocationTracker.getVariationCount());
260260
// System.out.println("sync: " + expectedEvents);
261+
// System.out.println("sync size: " + expectedEvents.size());
261262
// System.out.println("callback called?: " + wasCalledFuture.isDone());
262263
// System.out.println("value -- sync: " + expectedValue + " -- async: " + actualValue.get());
263264
// System.out.println("excep -- sync: " + expectedException + " -- async: " + actualException.get());

driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncMongoCluster.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,37 @@ internal open class SyncMongoCluster(open val wrapped: MongoCluster) : JMongoClu
115115
SyncChangeStreamIterable(wrapped.watch(clientSession.unwrapped(), pipeline, resultClass))
116116

117117
override fun bulkWrite(models: MutableList<out ClientNamespacedWriteModel>): ClientBulkWriteResult {
118-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
119-
TODO("BULK-TODO implement")
118+
org.junit.jupiter.api.Assumptions.assumeTrue(
119+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
120+
TODO("BULK-TODO Kotlin implement")
120121
}
121122

122123
override fun bulkWrite(
123124
models: MutableList<out ClientNamespacedWriteModel>,
124125
options: ClientBulkWriteOptions
125126
): ClientBulkWriteResult {
126-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
127-
TODO("BULK-TODO implement")
127+
org.junit.jupiter.api.Assumptions.assumeTrue(
128+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
129+
TODO("BULK-TODO Kotlin implement")
128130
}
129131

130132
override fun bulkWrite(
131133
clientSession: ClientSession,
132134
models: MutableList<out ClientNamespacedWriteModel>
133135
): ClientBulkWriteResult {
134-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
135-
TODO("BULK-TODO implement")
136+
org.junit.jupiter.api.Assumptions.assumeTrue(
137+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
138+
TODO("BULK-TODO Kotlin implement")
136139
}
137140

138141
override fun bulkWrite(
139142
clientSession: ClientSession,
140143
models: MutableList<out ClientNamespacedWriteModel>,
141144
options: ClientBulkWriteOptions
142145
): ClientBulkWriteResult {
143-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
144-
TODO("BULK-TODO implement")
146+
org.junit.jupiter.api.Assumptions.assumeTrue(
147+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
148+
TODO("BULK-TODO Kotlin implement")
145149
}
146150

147151
private fun ClientSession.unwrapped() = (this as SyncClientSession).wrapped

driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncMongoCluster.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,37 @@ internal open class SyncMongoCluster(open val wrapped: MongoCluster) : JMongoClu
114114
SyncChangeStreamIterable(wrapped.watch(clientSession.unwrapped(), pipeline, resultClass))
115115

116116
override fun bulkWrite(models: MutableList<out ClientNamespacedWriteModel>): ClientBulkWriteResult {
117-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
118-
TODO("BULK-TODO implement")
117+
org.junit.jupiter.api.Assumptions.assumeTrue(
118+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
119+
TODO("BULK-TODO Kotlin implement")
119120
}
120121

121122
override fun bulkWrite(
122123
models: MutableList<out ClientNamespacedWriteModel>,
123124
options: ClientBulkWriteOptions
124125
): ClientBulkWriteResult {
125-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
126-
TODO("BULK-TODO implement")
126+
org.junit.jupiter.api.Assumptions.assumeTrue(
127+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
128+
TODO("BULK-TODO Kotlin implement")
127129
}
128130

129131
override fun bulkWrite(
130132
clientSession: ClientSession,
131133
models: MutableList<out ClientNamespacedWriteModel>
132134
): ClientBulkWriteResult {
133-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
134-
TODO("BULK-TODO implement")
135+
org.junit.jupiter.api.Assumptions.assumeTrue(
136+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
137+
TODO("BULK-TODO Kotlin implement")
135138
}
136139

137140
override fun bulkWrite(
138141
clientSession: ClientSession,
139142
models: MutableList<out ClientNamespacedWriteModel>,
140143
options: ClientBulkWriteOptions
141144
): ClientBulkWriteResult {
142-
org.junit.jupiter.api.Assumptions.assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement")
143-
TODO("BULK-TODO implement")
145+
org.junit.jupiter.api.Assumptions.assumeTrue(
146+
java.lang.Boolean.parseBoolean(toString()), "BULK-TODO Kotlin implement")
147+
TODO("BULK-TODO Kotlin implement")
144148
}
145149

146150
private fun ClientSession.unwrapped() = (this as SyncClientSession).wrapped

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ public void testTimeoutMsISHonoredForNnextOperationWhenSeveralGetMoreExecutedInt
489489
}
490490
}
491491

492-
@DisplayName("11. Multi-batch bulkWrites")
493-
@Test
494-
@Override
495-
protected void test11MultiBatchBulkWrites() {
496-
assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement");
497-
}
492+
// @DisplayName("11. Multi-batch bulkWrites")
493+
// @Test
494+
// @Override
495+
// protected void test11MultiBatchBulkWrites() {
496+
// assumeTrue(java.lang.Boolean.parseBoolean(toString()), "BULK-TODO implement");
497+
// }
498498

499499
private static void assertCommandStartedEventsInOder(final List<String> expectedCommandNames,
500500
final List<CommandStartedEvent> commandStartedEvents) {

driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/MongoOperationPublisherTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import java.util.concurrent.TimeUnit;
3333

34+
import static com.mongodb.ClusterFixture.TIMEOUT;
3435
import static com.mongodb.ClusterFixture.TIMEOUT_SETTINGS_WITH_TIMEOUT;
3536
import static org.junit.jupiter.api.Assertions.assertEquals;
3637
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -113,7 +114,7 @@ public void withReadPreference() {
113114

114115
@Test
115116
public void withTimeout() {
116-
assertEquals(DEFAULT_MOP, DEFAULT_MOP.withTimeout(60_000, TimeUnit.MILLISECONDS));
117+
assertEquals(DEFAULT_MOP, DEFAULT_MOP.withTimeout(TIMEOUT, TimeUnit.SECONDS));
117118
assertEquals(1000, DEFAULT_MOP.withTimeout(1000, TimeUnit.MILLISECONDS).getTimeoutMS());
118119
assertThrows(IllegalArgumentException.class, () -> DEFAULT_MOP.withTimeout(500, TimeUnit.NANOSECONDS));
119120
}

driver-scala/src/test/scala/org/mongodb/scala/MongoClientSpec.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ class MongoClientSpec extends BaseSpec with MockitoSugar {
3535

3636
wrapped.foreach((name: String) => {
3737
val cleanedName = name.stripPrefix("get")
38-
assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name")
38+
39+
// TODO("BULK-TODO remove this if when bulkWrite is implemented and uncomment line 43")
40+
if (!cleanedName.contains("bulkWrite")) {
41+
assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name")
42+
}
43+
// assert(local.contains(name) | local.contains(cleanedName.head.toLower + cleanedName.tail), s"Missing: $name")
3944
})
4045
}
4146

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,18 @@ private void assertOperation(final UnifiedTestContext context, final BsonDocumen
403403

404404
private static void assertOperationResult(final UnifiedTestContext context, final BsonDocument operation, final int operationIndex,
405405
final OperationResult result) {
406+
if (result.getException() instanceof org.opentest4j.TestAbortedException) {
407+
// BULK-TODO remove
408+
if (result.getException().getMessage().contains("BULK-TODO Kotlin implement")) {
409+
throw (org.opentest4j.TestAbortedException) result.getException();
410+
}
411+
}
412+
if (result.getException() instanceof org.junit.AssumptionViolatedException) {
413+
// BULK-TODO remove
414+
if (result.getException().getMessage().contains("BULK-TODO Kotlin implement")) {
415+
throw (org.junit.AssumptionViolatedException) result.getException();
416+
}
417+
}
406418
context.getAssertionContext().push(ContextElement.ofCompletedOperation(operation, result, operationIndex));
407419

408420
if (!operation.getBoolean("ignoreResultAndError", BsonBoolean.FALSE).getValue()) {

0 commit comments

Comments
 (0)