geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [1/2] incubator-geode git commit: Upgrade system rules to 1.12.1 for logging integration tests. Move log4j2-cli.xml to root of gemfire-core jar. Change gfsh scripts to specify log4j2-cli.xml with classpath: protocol. Move some unit tests and add some new
Date Thu, 08 Oct 2015 21:54:31 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-189-new 42b3e8399 -> 326a82abe


Upgrade system rules to 1.12.1 for logging integration tests. Move log4j2-cli.xml to root
of gemfire-core jar. Change gfsh scripts to specify log4j2-cli.xml with classpath: protocol.
Move some unit tests and add some new tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/0e87990a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/0e87990a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/0e87990a

Branch: refs/heads/feature/GEODE-189-new
Commit: 0e87990a86b46d77da0c3e76bc4095aeb07f96fa
Parents: 42b3e83
Author: Kirk Lund <klund@pivotal.io>
Authored: Thu Oct 8 14:52:00 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Thu Oct 8 14:52:00 2015 -0700

----------------------------------------------------------------------
 build.gradle                                    |  2 +-
 gemfire-assembly/src/main/dist/bin/gfsh         |  2 +-
 gemfire-assembly/src/main/dist/bin/gfsh.bat     |  2 +-
 .../gemfire/internal/logging/LogService.java    |  2 +-
 .../internal/logging/log4j/log4j2-cli.xml       | 17 -----
 gemfire-core/src/main/resources/log4j2-cli.xml  | 17 +++++
 .../logging/LogServiceIntegrationJUnitTest.java | 80 +++++++++++---------
 .../internal/logging/LogServiceJUnitTest.java   | 39 ++++++++++
 8 files changed, 103 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index eda7642..774f62a 100755
--- a/build.gradle
+++ b/build.gradle
@@ -275,7 +275,7 @@ subprojects {
     compile 'org.springframework:spring-web:3.2.12.RELEASE'
     compile 'org.springframework:spring-webmvc:3.2.12.RELEASE'
 
-    testCompile 'com.github.stefanbirkner:system-rules:1.9.0'
+    testCompile 'com.github.stefanbirkner:system-rules:1.12.1'
     testCompile 'edu.umd.cs.mtc:multithreadedtc:1.01'
     testCompile 'junit:junit:4.12'
     testCompile 'org.assertj:assertj-core:2.1.0'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-assembly/src/main/dist/bin/gfsh
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh b/gemfire-assembly/src/main/dist/bin/gfsh
index e700aae..bcb5a3d 100755
--- a/gemfire-assembly/src/main/dist/bin/gfsh
+++ b/gemfire-assembly/src/main/dist/bin/gfsh
@@ -134,5 +134,5 @@ fi
 # This enables job control and monitoring, effectively switching on the trap
 # handler to run when the java exe exits, regardless of how (even if killed).
 set -bm
-"$GF_JAVA" -Dgfsh=true -Dlog4j.configurationFile=/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
${JLINE_TERMINAL} -classpath "${CLASSPATH}" $JAVA_ARGS $LAUNCHER  "$@"
+"$GF_JAVA" -Dgfsh=true -Dlog4j.configurationFile=classpath:log4j2-cli.xml ${JLINE_TERMINAL}
-classpath "${CLASSPATH}" $JAVA_ARGS $LAUNCHER  "$@"
 exit $?

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-assembly/src/main/dist/bin/gfsh.bat
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh.bat b/gemfire-assembly/src/main/dist/bin/gfsh.bat
index c4a9480..10c2726 100755
--- a/gemfire-assembly/src/main/dist/bin/gfsh.bat
+++ b/gemfire-assembly/src/main/dist/bin/gfsh.bat
@@ -69,5 +69,5 @@ REM  Consider java is from JDK
 @if defined JAVA_ARGS (
 @set JAVA_ARGS="%JAVA_ARGS%"
 )
-@"%GF_JAVA%" -Dgfsh=true -Dlog4j.configurationFile=/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
%JAVA_ARGS% %LAUNCHER% %*
+@"%GF_JAVA%" -Dgfsh=true -Dlog4j.configurationFile=classpath:log4j2-cli.xml %JAVA_ARGS% %LAUNCHER%
%*
 :done

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
index 51dfe1c..9722588 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
@@ -97,7 +97,7 @@ public class LogService extends LogManager {
   private static final PropertyChangeListener propertyChangeListener = new PropertyChangeListenerImpl();
   
   public static final String DEFAULT_CONFIG = "/log4j2.xml";
-  public static final String CLI_CONFIG = "/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml";
+  public static final String CLI_CONFIG = "/log4j2-cli.xml";
 
   /**
    * Name of variable that is set to "true" in log4j2.xml to indicate that it is the default
gemfire config xml.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
b/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
deleted file mode 100644
index 14b7075..0000000
--- a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
-  <Properties>
-    <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS
z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
-  </Properties>
-  <Appenders>
-    <Console name="STDOUT" target="SYSTEM_OUT">
-      <PatternLayout pattern="${gemfire-pattern}"/>
-    </Console>
-  </Appenders>
-  <Loggers>
-    <Logger name="com.gemstone" level="WARN" additivity="true"/>
-    <Root level="WARN">
-      <AppenderRef ref="STDOUT"/>
-    </Root>
-  </Loggers>
-</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-core/src/main/resources/log4j2-cli.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/log4j2-cli.xml b/gemfire-core/src/main/resources/log4j2-cli.xml
new file mode 100644
index 0000000..14b7075
--- /dev/null
+++ b/gemfire-core/src/main/resources/log4j2-cli.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
+  <Properties>
+    <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS
z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
+  </Properties>
+  <Appenders>
+    <Console name="STDOUT" target="SYSTEM_OUT">
+      <PatternLayout pattern="${gemfire-pattern}"/>
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="com.gemstone" level="WARN" additivity="true"/>
+    <Root level="WARN">
+      <AppenderRef ref="STDOUT"/>
+    </Root>
+  </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
index 7625481..c9d8064 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
@@ -11,14 +11,16 @@ import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.contrib.java.lang.system.SystemOutRule;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExternalResource;
 import org.junit.rules.TemporaryFolder;
 
-import com.gemstone.gemfire.internal.ClassPathLoader;
 import com.gemstone.gemfire.internal.logging.log4j.Configurator;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 
@@ -30,8 +32,14 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
 @Category(IntegrationTest.class)
 public class LogServiceIntegrationJUnitTest {
   
-  private String beforeConfigFileProp;
-  private Level beforeLevel;
+  private static final String DEFAULT_CONFIG_FILE_NAME = "log4j2.xml";
+  private static final String CLI_CONFIG_FILE_NAME = "log4j2-cli.xml";
+  
+  @Rule
+  public final SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+  
+  @Rule
+  public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
   
   @Rule
   public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -63,6 +71,9 @@ public class LogServiceIntegrationJUnitTest {
     }
   };
   
+  private String beforeConfigFileProp;
+  private Level beforeLevel;
+  
   private URL defaultConfigUrl;
   private URL cliConfigUrl;
   
@@ -72,9 +83,16 @@ public class LogServiceIntegrationJUnitTest {
     this.cliConfigUrl = LogService.class.getResource(LogService.CLI_CONFIG);
   }
   
+  @After
+  public void after() {
+    // if either of these fail then log4j2 probably logged a failure to stdout
+    assertThat(this.systemErrRule.getLog()).isEmpty();
+    assertThat(this.systemOutRule.getLog()).isEmpty();
+  }
+  
   @Test
-  public void shouldPreferConfigInConfigurationFilePropertyIfSet() throws Exception {
-    final File configFile = this.temporaryFolder.newFile("log4j2.xml");
+  public void shouldPreferConfigurationFilePropertyIfSet() throws Exception {
+    final File configFile = this.temporaryFolder.newFile(DEFAULT_CONFIG_FILE_NAME);
     final String configFileName = configFile.toURI().toString();
     System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFileName);
     writeConfigFile(configFile, Level.DEBUG);
@@ -95,20 +113,6 @@ public class LogServiceIntegrationJUnitTest {
   }
   
   @Test
-  public void defaultConfigShouldBeLoadableAsResource() {
-    final URL configUrlFromLogService = LogService.class.getResource(LogService.DEFAULT_CONFIG);
-    final URL configUrlFromClassLoader = getClass().getClassLoader().getResource(LogService.DEFAULT_CONFIG.substring(1));
-    final URL configUrlFromClassPathLoader = ClassPathLoader.getLatest().getResource(LogService.DEFAULT_CONFIG.substring(1));
-    
-    assertThat(configUrlFromLogService).isNotNull();
-    assertThat(configUrlFromClassLoader).isNotNull();
-    assertThat(configUrlFromClassPathLoader).isNotNull();
-    assertThat(configUrlFromLogService)
-        .isEqualTo(configUrlFromClassLoader)
-        .isEqualTo(configUrlFromClassPathLoader);
-  }
-  
-  @Test
   public void defaultConfigShouldIncludeStdout() {
     LogService.reconfigure();
     final Logger rootLogger = (Logger) LogService.getRootLogger();
@@ -167,18 +171,6 @@ public class LogServiceIntegrationJUnitTest {
   }
   
   @Test
-  public void cliConfigLoadsAsResource() {
-    assertThat(this.cliConfigUrl).isNotNull();
-    assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
-  }
-  
-  @Test
-  public void defaultConfigLoadsAsResource() {
-    assertThat(this.defaultConfigUrl).isNotNull();
-    assertThat(this.defaultConfigUrl.toString()).contains(LogService.DEFAULT_CONFIG);
-  }
-
-  @Test
   public void shouldNotUseDefaultConfigIfCliConfigSpecified() throws Exception {
     System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.cliConfigUrl.toString());
     
@@ -191,19 +183,33 @@ public class LogServiceIntegrationJUnitTest {
 
   @Test
   public void isUsingGemFireDefaultConfigShouldBeTrueIfDefaultConfig() throws Exception {
-    final String config = LogService.class.getResource(LogService.DEFAULT_CONFIG).toURI().toString();
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, config);
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.defaultConfigUrl.toString());
     
-    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains("log4j2.xml");
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains(DEFAULT_CONFIG_FILE_NAME);
     assertThat(LogService.isUsingGemFireDefaultConfig()).isTrue();
   }
 
   @Test
   public void isUsingGemFireDefaultConfigShouldBeFalseIfCliConfig() throws Exception {
-    final String config = LogService.class.getResource(LogService.CLI_CONFIG).toURI().toString();
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, config);
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.cliConfigUrl.toString());
+    
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).doesNotContain(DEFAULT_CONFIG_FILE_NAME);
+    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+  }
+
+  @Test
+  public void shouldUsCliConfigIfCliConfigIsSpecifiedViaClasspath() throws Exception {
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "classpath:"+CLI_CONFIG_FILE_NAME);
+    
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains(CLI_CONFIG_FILE_NAME);
+    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+  }
+
+  @Test
+  public void shouldUsCliConfigIfCliConfigIsSpecifiedViaClasspathWithQuotes() throws Exception
{
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "\"classpath:"+CLI_CONFIG_FILE_NAME+"\"");
     
-    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).isNotEqualTo("/log4j2.xml");
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains(CLI_CONFIG_FILE_NAME);
     assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0e87990a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
index 2d6ed4d..5c224a9 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
@@ -3,14 +3,18 @@ package com.gemstone.gemfire.internal.logging;
 import static junitparams.JUnitParamsRunner.$;
 import static org.assertj.core.api.Assertions.*;
 
+import java.net.URL;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
+import com.gemstone.gemfire.internal.ClassPathLoader;
 import com.gemstone.gemfire.internal.logging.log4j.AppenderContext;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
@@ -29,6 +33,15 @@ public class LogServiceJUnitTest {
   @Rule
   public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
   
+  private URL defaultConfigUrl;
+  private URL cliConfigUrl;
+  
+  @Before
+  public void setUp() {
+    this.defaultConfigUrl = LogService.class.getResource(LogService.DEFAULT_CONFIG);
+    this.cliConfigUrl = LogService.class.getResource(LogService.CLI_CONFIG);
+  }
+  
   @Test
   public void getAppenderContextShouldHaveEmptyName() throws Exception {
     final AppenderContext appenderContext = LogService.getAppenderContext();
@@ -50,6 +63,32 @@ public class LogServiceJUnitTest {
     assertThat(LogService.toLevel(intLevel)).isSameAs(level);
   }
 
+  @Test
+  public void cliConfigLoadsAsResource() {
+    assertThat(this.cliConfigUrl).isNotNull();
+    assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
+  }
+  
+  @Test
+  public void defaultConfigLoadsAsResource() {
+    assertThat(this.defaultConfigUrl).isNotNull();
+    assertThat(this.defaultConfigUrl.toString()).contains(LogService.DEFAULT_CONFIG);
+  }
+  
+  @Test
+  public void defaultConfigShouldBeLoadableAsResource() {
+    final URL configUrlFromLogService = LogService.class.getResource(LogService.DEFAULT_CONFIG);
+    final URL configUrlFromClassLoader = getClass().getClassLoader().getResource(LogService.DEFAULT_CONFIG.substring(1));
+    final URL configUrlFromClassPathLoader = ClassPathLoader.getLatest().getResource(LogService.DEFAULT_CONFIG.substring(1));
+    
+    assertThat(configUrlFromLogService).isNotNull();
+    assertThat(configUrlFromClassLoader).isNotNull();
+    assertThat(configUrlFromClassPathLoader).isNotNull();
+    assertThat(configUrlFromLogService)
+        .isEqualTo(configUrlFromClassLoader)
+        .isEqualTo(configUrlFromClassPathLoader);
+  }
+  
   @SuppressWarnings("unused")
   private static final Object[] getToLevelParameters() {
     return $(


Mime
View raw message