Skip to content

Commit

Permalink
Explicitly trigger static init of SharedContainerConfig early in exte…
Browse files Browse the repository at this point in the history
…nsion lifecycle
  • Loading branch information
aguibert committed Feb 6, 2020
1 parent 34c8681 commit fe3e428
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.commons.support.AnnotationSupport;
import org.microshed.testing.ApplicationEnvironment;
import org.microshed.testing.SharedContainerConfig;
import org.microshed.testing.jaxrs.RESTClient;
import org.microshed.testing.jaxrs.RestClientBuilder;
import org.microshed.testing.jwt.JwtBuilder;
Expand All @@ -50,6 +51,12 @@ class MicroShedTestExtension implements BeforeAllCallback {
@Override
public void beforeAll(ExtensionContext context) throws Exception {
Class<?> testClass = context.getRequiredTestClass();

// Explicitly trigger static initialization of any SharedContainerConfig before we do further processing
if (testClass.isAnnotationPresent(SharedContainerConfig.class)) {
Class.forName(testClass.getAnnotation(SharedContainerConfig.class).value().getName());
}

ApplicationEnvironment config = ApplicationEnvironment.Resolver.load();
LOG.info("Using ApplicationEnvironment class: " + config.getClass().getCanonicalName());
config.applyConfiguration(testClass);
Expand Down

0 comments on commit fe3e428

Please sign in to comment.