[1/4] tomee git commit: fixing app composer container handling
Repository: tomee Updated Branches: refs/heads/tomee-7.0.0-M1 ffa109cc3 -> c90d7ee75 fixing app composer container handling Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c63f2ec3 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c63f2ec3 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c63f2ec3 Branch: refs/heads/tomee-7.0.0-M1 Commit: c63f2ec304a174ccefd88dda48bbe440c2036a5f Parents: 06f4b74 Author: Romain Manni-Bucau Authored: Wed Dec 2 18:37:28 2015 +0100 Committer: Romain Manni-Bucau Committed: Wed Dec 2 18:37:28 2015 +0100 -- .../openejb/testing/ApplicationComposers.java | 14 +++--- .../junit/ContainerAndApplicationRulesTest.java | 46 2 files changed, 53 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/c63f2ec3/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java -- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java index d7c42f2..bc5fefd 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java @@ -385,6 +385,13 @@ public class ApplicationComposers { } public void deployApp(final Object inputTestInstance) throws Exception { +// test injections +ClassFinder testClassFinder = testClassFinders.remove(inputTestInstance); +if (testClassFinder == null) { +testClassFinders.put(inputTestInstance, testClassFinders.remove(this)); +testClassFinder = testClassFinders.remove(inputTestInstance); +} + final ClassLoader loader = testClass.getClassLoader(); AppModule appModule = new AppModule(loader, testClass.getSimpleName()); @@ -731,13 +738,6 @@ public class ApplicationComposers { System.getProperties().put(OPENEJB_APPLICATION_COMPOSER_CONTEXT, appContext.getGlobalJndiContext()); -// test injections -ClassFinder testClassFinder = testClassFinders.remove(inputTestInstance); -if (testClassFinder == null) { -testClassFinders.put(inputTestInstance, testClassFinders.remove(this)); -testClassFinder = testClassFinders.remove(inputTestInstance); -} - final List fields = new ArrayList<>(testClassFinder.findAnnotatedFields(AppResource.class)); fields.addAll(testClassFinder.findAnnotatedFields(org.apache.openejb.junit.AppResource.class)); for (final Field field : fields) { http://git-wip-us.apache.org/repos/asf/tomee/blob/c63f2ec3/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java -- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java b/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java new file mode 100644 index 000..1f0ce56 --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java @@ -0,0 +1,46 @@ +package org.apache.openejb.junit; + +import org.apache.openejb.api.configuration.PersistenceUnitDefinition; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.RuleChain; +import org.junit.rules.TestRule; + +import javax.inject.Inject; +import javax.inject.Provider; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class ContainerAndApplicationRulesTest { +private final ContainerRule instanceContainer = new ContainerRule(new Container()); +private final ApplicationRule instanceServer = new ApplicationRule(new App()); + +@Rule +public final TestRule rule = RuleChain.outerRule(instanceContainer).around(instanceServer); + +@Test +public void test() { +assertNotNull(instanceServer.getInstance(App.class).v); +assertNull(instanceContainer.getInstance(Container.class).ignored); +} + +@org.apache.openejb.testing.Classes(cdi = true, value = Ignored.class) // @Classes invalid for a container +public static class Container { +@Inject +private Provider ignored; +} + +@PersistenceUnitDefinition +@org.apache.openejb.testing.Classes(context = "App1", cdi = true, value = Valuable.class) +public static class App { +@Inject +private Valuable v; +} + +public static class Ignored { +} + +public static c
tomee git commit: fixing app composer container handling
Repository: tomee Updated Branches: refs/heads/master 06f4b74a9 -> c63f2ec30 fixing app composer container handling Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c63f2ec3 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c63f2ec3 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c63f2ec3 Branch: refs/heads/master Commit: c63f2ec304a174ccefd88dda48bbe440c2036a5f Parents: 06f4b74 Author: Romain Manni-Bucau Authored: Wed Dec 2 18:37:28 2015 +0100 Committer: Romain Manni-Bucau Committed: Wed Dec 2 18:37:28 2015 +0100 -- .../openejb/testing/ApplicationComposers.java | 14 +++--- .../junit/ContainerAndApplicationRulesTest.java | 46 2 files changed, 53 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/tomee/blob/c63f2ec3/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java -- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java index d7c42f2..bc5fefd 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java @@ -385,6 +385,13 @@ public class ApplicationComposers { } public void deployApp(final Object inputTestInstance) throws Exception { +// test injections +ClassFinder testClassFinder = testClassFinders.remove(inputTestInstance); +if (testClassFinder == null) { +testClassFinders.put(inputTestInstance, testClassFinders.remove(this)); +testClassFinder = testClassFinders.remove(inputTestInstance); +} + final ClassLoader loader = testClass.getClassLoader(); AppModule appModule = new AppModule(loader, testClass.getSimpleName()); @@ -731,13 +738,6 @@ public class ApplicationComposers { System.getProperties().put(OPENEJB_APPLICATION_COMPOSER_CONTEXT, appContext.getGlobalJndiContext()); -// test injections -ClassFinder testClassFinder = testClassFinders.remove(inputTestInstance); -if (testClassFinder == null) { -testClassFinders.put(inputTestInstance, testClassFinders.remove(this)); -testClassFinder = testClassFinders.remove(inputTestInstance); -} - final List fields = new ArrayList<>(testClassFinder.findAnnotatedFields(AppResource.class)); fields.addAll(testClassFinder.findAnnotatedFields(org.apache.openejb.junit.AppResource.class)); for (final Field field : fields) { http://git-wip-us.apache.org/repos/asf/tomee/blob/c63f2ec3/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java -- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java b/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java new file mode 100644 index 000..1f0ce56 --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/junit/ContainerAndApplicationRulesTest.java @@ -0,0 +1,46 @@ +package org.apache.openejb.junit; + +import org.apache.openejb.api.configuration.PersistenceUnitDefinition; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.RuleChain; +import org.junit.rules.TestRule; + +import javax.inject.Inject; +import javax.inject.Provider; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class ContainerAndApplicationRulesTest { +private final ContainerRule instanceContainer = new ContainerRule(new Container()); +private final ApplicationRule instanceServer = new ApplicationRule(new App()); + +@Rule +public final TestRule rule = RuleChain.outerRule(instanceContainer).around(instanceServer); + +@Test +public void test() { +assertNotNull(instanceServer.getInstance(App.class).v); +assertNull(instanceContainer.getInstance(Container.class).ignored); +} + +@org.apache.openejb.testing.Classes(cdi = true, value = Ignored.class) // @Classes invalid for a container +public static class Container { +@Inject +private Provider ignored; +} + +@PersistenceUnitDefinition +@org.apache.openejb.testing.Classes(context = "App1", cdi = true, value = Valuable.class) +public static class App { +@Inject +private Valuable v; +} + +public static class Ignored { +} + +public static class Valuable {