You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/11/12 02:54:49 UTC
tomee git commit: TOMEE-1655 patch from Daniel Cunha,
ApplicationComposers not isolating @Configuration for each test class.
Repository: tomee
Updated Branches:
refs/heads/master a81347e4f -> 5f26017a9
TOMEE-1655 patch from Daniel Cunha, ApplicationComposers not isolating @Configuration for each test class.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5f26017a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5f26017a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5f26017a
Branch: refs/heads/master
Commit: 5f26017a95c2388a1ebf62500590af72e1aca21d
Parents: a81347e
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Wed Nov 11 17:54:31 2015 -0800
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Wed Nov 11 17:54:31 2015 -0800
----------------------------------------------------------------------
.../openejb/testing/ApplicationComposers.java | 3 ++
.../classic/CleanSystemPropertiesTest.java | 42 ++++++++++++++++++++
2 files changed, 45 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f26017a/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 ff50dfc..bf65928 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
@@ -169,6 +169,7 @@ public class ApplicationComposers {
private final Collection<String> globalJndiEntries = new ArrayList<>();
private final Collection<Runnable> beforeDestroyAfterRunnables = new ArrayList<>();
private final Collection<Runnable> afterRunnables = new ArrayList<>();
+ private Properties originalProperties;
public ApplicationComposers(final Object... modules) {
this(modules[0].getClass(), modules);
@@ -1058,6 +1059,7 @@ public class ApplicationComposers {
if (originalLoader != null) {
Thread.currentThread().setContextClassLoader(originalLoader);
}
+ System.setProperties(originalProperties);
}
}
@@ -1237,6 +1239,7 @@ public class ApplicationComposers {
}
public void startContainer(final Object instance) throws Exception {
+ originalProperties = (Properties) System.getProperties().clone();
originalLoader = Thread.currentThread().getContextClassLoader();
testClassFinders.remove(this); // see constructor
http://git-wip-us.apache.org/repos/asf/tomee/blob/5f26017a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/CleanSystemPropertiesTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/CleanSystemPropertiesTest.java b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/CleanSystemPropertiesTest.java
new file mode 100644
index 0000000..e8c7d3e
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/CleanSystemPropertiesTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.assembler.classic;
+
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.ContainerProperties;
+import org.junit.AfterClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(ApplicationComposer.class)
+@Classes
+@ContainerProperties(@ContainerProperties.Property(name = "test-property", value = "true"))
+public class CleanSystemPropertiesTest {
+ @Test
+ public void test() {
+ assertTrue(Boolean.getBoolean("test-property"));
+ }
+
+ @AfterClass
+ public static void shouldClearSystemProperties() {
+ assertNull("ApplicationComposers not clear the System properties", System.getProperty("test-property"));
+ }
+}
\ No newline at end of file