Skip to content

Commit

Permalink
Move the assertOnIOContext to VertxTestBase
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Mar 2, 2019
1 parent 699545d commit 5e57b77
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/test/java/io/vertx/core/http/Http2TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 73,4 @@ protected HttpServerOptions createBaseServerOptions() {
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");
}
}
6 changes: 6 additions & 0 deletions src/test/java/io/vertx/test/core/AsyncTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -655,4 657,8 @@ protected void close(Vertx vertx) throws Exception {
});
awaitLatch(latch);
}

protected void assertSameEventLoop(Context expected, Context actual) {
assertSame(((ContextInternal)expected).nettyEventLoop(), ((ContextInternal)actual).nettyEventLoop());
}
}
14 changes: 14 additions & 0 deletions src/test/java/io/vertx/test/core/VertxTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 235,18 @@ protected List<Context> createWorkers(int num) throws Exception {
}
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");
}
}

0 comments on commit 5e57b77

Please sign in to comment.