You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/10/14 22:11:19 UTC
incubator-geode git commit: Rework test with junit rule
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-2001 375c6c5bc -> 3bead85c2
Rework test with junit rule
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3bead85c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3bead85c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3bead85c
Branch: refs/heads/feature/GEODE-2001
Commit: 3bead85c25e3721cdf1917a9fd4dc247999ddf7e
Parents: 375c6c5
Author: Kirk Lund <kl...@apache.org>
Authored: Fri Oct 14 15:11:51 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Fri Oct 14 15:11:51 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/LoggingConfigurationRule.java | 50 ++++++++++++++++++++
.../CustomConfigWithCacheIntegrationTest.java | 3 --
2 files changed, 50 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3bead85c/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LoggingConfigurationRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LoggingConfigurationRule.java b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LoggingConfigurationRule.java
new file mode 100644
index 0000000..1c5dc86
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LoggingConfigurationRule.java
@@ -0,0 +1,50 @@
+package org.apache.geode.internal.logging.log4j;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import org.apache.geode.internal.logging.LogService;
+import org.apache.geode.internal.logging.log4j.custom.BasicAppender;
+import org.apache.geode.test.junit.rules.serializable.SerializableExternalResource;
+
+public class LoggingConfigurationRule extends SerializableExternalResource {
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ /**
+ * @param name name of the resource to use as logging config
+ */
+ public LoggingConfigurationRule(final String name) {
+ assertThat(getClass().getResource(name)).isNotNull();
+ return new Configuration(getClass().getResource(name), name).createConfigFileIn(this.temporaryFolder.getRoot());
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ Configurator.shutdown();
+ BasicAppender.clearInstance();
+
+ this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ this.beforeLevel = StatusLogger.getLogger().getLevel();
+ }
+
+ @Override
+ protected void after() {
+ Configurator.shutdown();
+
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ if (this.beforeConfigFileProp != null) {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
+ }
+ StatusLogger.getLogger().setLevel(this.beforeLevel);
+
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
+
+ BasicAppender.clearInstance();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3bead85c/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
index 2b10062..0850f42 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/custom/CustomConfigWithCacheIntegrationTest.java
@@ -49,9 +49,6 @@ import static org.assertj.core.api.Assertions.assertThat;
@Category(IntegrationTest.class)
public class CustomConfigWithCacheIntegrationTest {
- private String beforeConfigFileProp;
- private Level beforeLevel;
-
private File customConfigFile;
private Cache cache;