Repository: tomee Updated Branches: refs/heads/develop c5ccadf94 -> c02589847
light support of placeholder in container properties for appcomposer Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c0258984 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c0258984 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c0258984 Branch: refs/heads/develop Commit: c02589847ec1350411244abd17873abae1334d01 Parents: c5ccadf Author: Romain Manni-Bucau <[email protected]> Authored: Sat Feb 21 20:11:21 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Sat Feb 21 20:11:21 2015 +0100 ---------------------------------------------------------------------- .../openejb/testing/ApplicationComposers.java | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/c0258984/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 91ca837..d0f13fc 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 @@ -72,6 +72,7 @@ import org.apache.openejb.spi.ContainerSystem; import org.apache.openejb.testing.rest.ContextProvider; import org.apache.openejb.util.Join; import org.apache.openejb.util.NetworkUtil; +import org.apache.openejb.util.PropertyPlaceHolderHelper; import org.apache.openejb.util.ServiceManagerProxy; import org.apache.openejb.util.URLs; import org.apache.openejb.web.LightweightWebAppBuilder; @@ -436,11 +437,19 @@ public final class ApplicationComposers { SystemInstance.reset(); } + Collection<String> propertiesToSetAgain = null; final ContainerProperties configAnnot = testClass.getAnnotation(ContainerProperties.class); if (configAnnot != null) { for (final ContainerProperties.Property p : configAnnot.value()) { final String value = p.value(); - configuration.put(p.name(), value.equals(ContainerProperties.Property.IGNORED) ? null : value); + final String name = p.name(); + configuration.put(name, value.equals(ContainerProperties.Property.IGNORED) ? null : value); + if (value.contains("${")) { + if (propertiesToSetAgain == null) { + propertiesToSetAgain = new LinkedList<>(); + } + propertiesToSetAgain.add(name); + } } } @@ -468,6 +477,7 @@ public final class ApplicationComposers { } } } + for (final Map.Entry<Object, ClassFinder> finder : testClassFinders.entrySet()) { if (!finder.getValue().findAnnotatedClasses(SimpleLog.class).isEmpty()) { SystemInstance.get().setProperty("openejb.jul.forceReload", "true"); @@ -826,6 +836,15 @@ public final class ApplicationComposers { } } + if (propertiesToSetAgain != null) { + for (final String name : propertiesToSetAgain) { + final String value = PropertyPlaceHolderHelper.simpleValue(SystemInstance.get().getProperty(name)); + configuration.put(name, value); + System.setProperty(name, value); // done lazily to support placeholders so container will not do it here + } + propertiesToSetAgain.clear(); + } + servletContext = new MockServletContext(); session = new MockHttpSession();
