Repository: tomee Updated Branches: refs/heads/master 9c6a31497 -> 849292df6
TOMEE-1530 try to guess app ctx if not found from class Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/f24db560 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/f24db560 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/f24db560 Branch: refs/heads/master Commit: f24db560b815ccd3f8c1964fb04934ec754481b7 Parents: 9c6a314 Author: Romain Manni-Bucau <[email protected]> Authored: Wed Mar 25 11:35:27 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Wed Mar 25 11:35:27 2015 +0100 ---------------------------------------------------------------------- .../arquillian/common/enrichment/OpenEJBEnricher.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/f24db560/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/enrichment/OpenEJBEnricher.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/enrichment/OpenEJBEnricher.java b/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/enrichment/OpenEJBEnricher.java index 6cea677..aa7eb7e 100644 --- a/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/enrichment/OpenEJBEnricher.java +++ b/arquillian/arquillian-common/src/main/java/org/apache/openejb/arquillian/common/enrichment/OpenEJBEnricher.java @@ -27,6 +27,7 @@ import org.apache.openejb.core.ThreadContext; import org.apache.openejb.core.WebContext; import org.apache.openejb.loader.SystemInstance; import org.apache.openejb.spi.ContainerSystem; +import org.apache.openejb.util.AppFinder; import org.apache.webbeans.annotation.AnyLiteral; import org.apache.webbeans.annotation.DefaultLiteral; import org.apache.webbeans.config.WebBeansContext; @@ -61,11 +62,15 @@ public final class OpenEJBEnricher { // no-op } - public static void enrich(final Object testInstance, final AppContext ctx) { + public static void enrich(final Object testInstance, final AppContext appCtx) { // don't rely on arquillian since this enrichment should absolutely be done before the following ones new MockitoEnricher().enrich(testInstance); + AppContext ctx = appCtx; if (ctx == null) { - return; + ctx = AppFinder.findAppContextOrWeb(Thread.currentThread().getContextClassLoader(), AppFinder.AppContextTransformer.INSTANCE); + if (ctx == null) { + return; + } } final BeanContext context = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext(ctx.getId() + "_" + testInstance.getClass().getName());
