Repository: tomee Updated Branches: refs/heads/master 0040c793b -> 0b0a8983c
TOMEE-1685 ignoring persistence modules when enforcing standalone webapp flag Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0b0a8983 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0b0a8983 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0b0a8983 Branch: refs/heads/master Commit: 0b0a8983c084b78410efb33c12fac574f5ad7403 Parents: 0040c79 Author: Romain Manni-Bucau <rmann...@gmail.com> Authored: Wed Dec 23 22:15:23 2015 +0100 Committer: Romain Manni-Bucau <rmann...@gmail.com> Committed: Wed Dec 23 22:15:23 2015 +0100 ---------------------------------------------------------------------- .../openejb/testing/ApplicationComposers.java | 4 +- .../testing/WebappMultipleModuleTest.java | 67 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/0b0a8983/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 4f54482..f9a1247 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 @@ -561,13 +561,13 @@ public class ApplicationComposers { final Persistence persistence = (Persistence) obj; appModule.addPersistenceModule( new PersistenceModule(appModule, implicitRootUrl(method.getAnnotation(PersistenceRootUrl.class)), persistence)); - + notBusinessModuleNumber++; } else if (obj instanceof PersistenceUnit) { final PersistenceUnit unit = (PersistenceUnit) obj; appModule.addPersistenceModule( new PersistenceModule(appModule, implicitRootUrl(method.getAnnotation(PersistenceRootUrl.class)), new Persistence(unit))); - + notBusinessModuleNumber++; } else if (obj instanceof Beans) { final Beans beans = (Beans) obj; http://git-wip-us.apache.org/repos/asf/tomee/blob/0b0a8983/container/openejb-core/src/test/java/org/apache/openejb/testing/WebappMultipleModuleTest.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/test/java/org/apache/openejb/testing/WebappMultipleModuleTest.java b/container/openejb-core/src/test/java/org/apache/openejb/testing/WebappMultipleModuleTest.java new file mode 100644 index 0000000..7a3bd09 --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/testing/WebappMultipleModuleTest.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.testing; + +import org.apache.openejb.jee.jpa.unit.Persistence; +import org.apache.openejb.jee.jpa.unit.PersistenceUnit; +import org.apache.openejb.junit.ApplicationComposer; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.spi.AfterDeploymentValidation; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.Extension; +import javax.inject.Inject; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +@CdiExtensions(WebappMultipleModuleTest.SuperViciousExtension.class) +@RunWith(ApplicationComposer.class) +@Classes(cdi = true, innerClassesAsBean = true) +public class WebappMultipleModuleTest { + @Module + @PersistenceRootUrl(value = "") + public Persistence jpa() throws Exception { + SuperViciousExtension.CALLED.set(false); // reset before container boot + return new Persistence(new PersistenceUnit("jpa")); + } + + @Inject + private Marker bean; + + @Test + public void run() { + assertNotNull(bean); + assertTrue(SuperViciousExtension.CALLED.get()); + } + + public static class Marker {} + + public static class SuperViciousExtension implements Extension { + public static final AtomicBoolean CALLED = new AtomicBoolean(); + + private void end(@Observes final AfterDeploymentValidation ignored , final BeanManager manager) { + final Bean<?> bean = manager.resolve(manager.getBeans(Marker.class)); + assertNotNull(manager.getReference(bean, Marker.class, manager.createCreationalContext(bean))); + CALLED.set(true); + } + } +}