mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Fix ordering of Arquillian events to make sure req. context activation comes first.
This commit is contained in:
committed by
Ken Finnigan
parent
4e611df6ac
commit
7d019af517
@@ -38,9 +38,6 @@
|
||||
<!-- Hystrix is unable to interrupt the calling thread, as it didn't create it. -->
|
||||
<!-- We have a custom version of this TCK class that excludes TimeoutUninterruptableTest.testTimeout() as all the other methods pass -->
|
||||
<exclude>org.eclipse.microprofile.fault.tolerance.tck.TimeoutUninterruptableTest</exclude>
|
||||
|
||||
<!-- Weird error only in CI that RequestContext is not active during call to @BeforeTest method. Unable to reproduce failure locally -->
|
||||
<exclude>org.eclipse.microprofile.fault.tolerance.tck.metrics.CircuitBreakerMetricTest</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@@ -16,7 +16,10 @@ public class QuarkusBeforeAfterLifecycle {
|
||||
private static final String TESTNG_INVOKE_BEFORE_METHOD = "invokeTestNgBeforeMethods";
|
||||
private static final String TESTNG_INVOKE_AFTER_METHOD = "invokeTestNgAfterMethods";
|
||||
|
||||
public void on(@Observes(precedence = -100) org.jboss.arquillian.test.spi.event.suite.Before event) throws Throwable {
|
||||
private static final int DEFAULT_PRECEDENCE = -100;
|
||||
|
||||
public void on(@Observes(precedence = DEFAULT_PRECEDENCE) org.jboss.arquillian.test.spi.event.suite.Before event)
|
||||
throws Throwable {
|
||||
if (isJunitAvailable()) {
|
||||
invokeCallbacks(JUNIT_INVOKE_BEFORES, JUNIT_CALLBACKS);
|
||||
}
|
||||
@@ -25,7 +28,8 @@ public class QuarkusBeforeAfterLifecycle {
|
||||
}
|
||||
}
|
||||
|
||||
public void on(@Observes(precedence = 100) org.jboss.arquillian.test.spi.event.suite.After event) throws Throwable {
|
||||
public void on(@Observes(precedence = DEFAULT_PRECEDENCE) org.jboss.arquillian.test.spi.event.suite.After event)
|
||||
throws Throwable {
|
||||
if (isJunitAvailable()) {
|
||||
invokeCallbacks(JUNIT_INVOKE_AFTERS, JUNIT_CALLBACKS);
|
||||
}
|
||||
@@ -34,14 +38,16 @@ public class QuarkusBeforeAfterLifecycle {
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeClass(@Observes(precedence = -100) org.jboss.arquillian.test.spi.event.suite.BeforeClass event)
|
||||
public void beforeClass(
|
||||
@Observes(precedence = DEFAULT_PRECEDENCE) org.jboss.arquillian.test.spi.event.suite.BeforeClass event)
|
||||
throws Throwable {
|
||||
if (isTestNGAvailable()) {
|
||||
invokeCallbacks(TESTNG_INVOKE_BEFORE_CLASS, TESTNG_CALLBACKS);
|
||||
}
|
||||
}
|
||||
|
||||
public void afterClass(@Observes(precedence = 100) org.jboss.arquillian.test.spi.event.suite.AfterClass event)
|
||||
public void afterClass(
|
||||
@Observes(precedence = DEFAULT_PRECEDENCE) org.jboss.arquillian.test.spi.event.suite.AfterClass event)
|
||||
throws Throwable {
|
||||
if (isTestNGAvailable()) {
|
||||
invokeCallbacks(TESTNG_INVOKE_AFTER_CLASS, TESTNG_CALLBACKS);
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.quarkus.arquillian;
|
||||
import org.jboss.arquillian.core.api.annotation.Observes;
|
||||
import org.jboss.arquillian.test.spi.event.suite.After;
|
||||
import org.jboss.arquillian.test.spi.event.suite.Before;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import io.quarkus.arc.Arc;
|
||||
import io.quarkus.arc.ArcContainer;
|
||||
@@ -11,17 +12,24 @@ import io.quarkus.arc.ArcContainer;
|
||||
* Activates request context before test runs and shuts it down afterwards
|
||||
*/
|
||||
public class RequestContextLifecycle {
|
||||
public void on(@Observes(precedence = -100) Before event) throws Throwable {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(RequestContextLifecycle.class);
|
||||
|
||||
private static final int DEFAULT_PRECEDENCE = 100;
|
||||
|
||||
public void on(@Observes(precedence = DEFAULT_PRECEDENCE) Before event) throws Throwable {
|
||||
ArcContainer container = Arc.container();
|
||||
if (container != null && container.isRunning()) {
|
||||
container.requestContext().activate();
|
||||
LOGGER.debug("RequestContextLifecycle activating CDI Request context.");
|
||||
}
|
||||
}
|
||||
|
||||
public void on(@Observes(precedence = 100) After event) throws Throwable {
|
||||
public void on(@Observes(precedence = DEFAULT_PRECEDENCE) After event) throws Throwable {
|
||||
ArcContainer container = Arc.container();
|
||||
if (container != null && container.isRunning()) {
|
||||
container.requestContext().terminate();
|
||||
LOGGER.debug("RequestContextLifecycle shutting down CDI Request context.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user