mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
Move the assertOnIOContext to VertxTestBase
This commit is contained in:
@@ -73,16 +73,4 @@ public class Http2TestBase extends HttpTestBase {
|
||||
protected HttpClientOptions createBaseClientOptions() {
|
||||
return clientOptions;
|
||||
}
|
||||
|
||||
protected void assertOnIOContext(Context context) {
|
||||
Context current = Vertx.currentContext();
|
||||
assertNotNull(current);
|
||||
assertEquals(context, current);
|
||||
for (StackTraceElement elt : Thread.currentThread().getStackTrace()) {
|
||||
if (elt.getMethodName().equals("executeFromIO")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("Not from IO");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
package io.vertx.test.core;
|
||||
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Context;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.impl.ContextInternal;
|
||||
import io.vertx.core.logging.Logger;
|
||||
import io.vertx.core.logging.LoggerFactory;
|
||||
import org.hamcrest.Matcher;
|
||||
@@ -655,4 +657,8 @@ public class AsyncTestBase {
|
||||
});
|
||||
awaitLatch(latch);
|
||||
}
|
||||
|
||||
protected void assertSameEventLoop(Context expected, Context actual) {
|
||||
assertSame(((ContextInternal)expected).nettyEventLoop(), ((ContextInternal)actual).nettyEventLoop());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,4 +235,18 @@ public class VertxTestBase extends AsyncTestBase {
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
|
||||
protected void assertOnIOContext(Context context) {
|
||||
Context current = Vertx.currentContext();
|
||||
assertNotNull(current);
|
||||
assertSameEventLoop(context, current);
|
||||
for (StackTraceElement elt : Thread.currentThread().getStackTrace()) {
|
||||
String className = elt.getClassName();
|
||||
String methodName = elt.getMethodName();
|
||||
if (className.equals("io.vertx.core.impl.ContextImpl") && methodName.equals("dispatch")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("Not dispatching");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user