geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: Initial work to move log4j2.xml into root of gemfire-core jar.
Date Mon, 05 Oct 2015 21:59:01 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-189-new [created] e4d2b09df


Initial work to move log4j2.xml into root of gemfire-core jar.


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

Branch: refs/heads/feature/GEODE-189-new
Commit: e4d2b09df91719ff10f1e77648a6583cdd3f2e01
Parents: 35d3f06
Author: Kirk Lund <klund@pivotal.io>
Authored: Thu Aug 13 11:36:43 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Mon Oct 5 14:06:55 2015 -0700

----------------------------------------------------------------------
 .../gemfire/internal/logging/LogService.java    | 129 ++++++++-----------
 .../internal/logging/log4j/Configurator.java    |   5 +
 .../internal/logging/log4j/log4j2-default.xml   |  21 ---
 gemfire-core/src/main/resources/log4j2.xml      |  22 ++++
 .../logging/LogServiceIntegrationJUnitTest.java |  48 +++----
 .../internal/logging/LogServiceJUnitTest.java   |  28 ----
 .../LogServiceUserDirIntegrationJUnitTest.java  |  70 ----------
 .../logging/LoggingIntegrationTestSuite.java    |   1 -
 .../logging/MergeLogFilesJUnitTest.java         |   4 +-
 .../log4j/FastLoggerIntegrationJUnitTest.java   |   4 +-
 10 files changed, 108 insertions(+), 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/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 637f8ca..51dfe1c 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
@@ -9,13 +9,28 @@ package com.gemstone.gemfire.internal.logging;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -25,12 +40,27 @@ import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AppenderRef;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.config.FileConfigurationMonitor;
 import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.status.StatusConfiguration;
+import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
 import org.apache.logging.log4j.core.filter.AbstractFilterable;
 import org.apache.logging.log4j.core.lookup.Interpolator;
+import org.apache.logging.log4j.core.lookup.StrLookup;
 import org.apache.logging.log4j.core.lookup.StrSubstitutor;
+import org.apache.logging.log4j.core.util.Closer;
+import org.apache.logging.log4j.core.util.Loader;
+import org.apache.logging.log4j.core.util.Patterns;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.util.PropertiesUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 import com.gemstone.gemfire.InternalGemFireError;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
@@ -66,20 +96,21 @@ public class LogService extends LogManager {
 
   private static final PropertyChangeListener propertyChangeListener = new PropertyChangeListenerImpl();
   
-  public static final String DEFAULT_CONFIG = "/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml";
+  public static final String DEFAULT_CONFIG = "/log4j2.xml";
   public static final String CLI_CONFIG = "/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml";
 
+  /**
+   * Name of variable that is set to "true" in log4j2.xml to indicate that it is the default
gemfire config xml.
+   */
+  private static final String GEMFIRE_DEFAULT_PROPERTY = "gemfire-default";
+  
   /** Protected by static synchronization. Used for removal and adding stdout back in. */
   private static Appender stdoutAppender;
   
-  /** Set with info for Banner to log anytime LogService is reinitialized */
-  private static String configFileInformation;
-  
   static {
     init();
   }
   private static void init() {
-    setLog4jConfigFileProperty();
     LoggerContext context = ((org.apache.logging.log4j.core.Logger) LogManager.getLogger(BASE_LOGGER_NAME,
GemFireParameterizedMessageFactory.INSTANCE)).getContext();
     context.removePropertyChangeListener(propertyChangeListener);
     context.addPropertyChangeListener(propertyChangeListener);
@@ -110,84 +141,23 @@ public class LogService extends LogManager {
     return new AppenderContext(name);
   }
   
-  public static boolean isUsingGemFireDefaultConfig() {
-    final String configFileName = new StrSubstitutor(new Interpolator()).replace(
-        PropertiesUtil.getProperties().getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
-    return configFileName == null ? false : configFileName.contains(DEFAULT_CONFIG);
-  }
+  private static final String GEMFIRE_CONFIG_LOCATION_BUILD = "gemfire-core" + File.separator
+ "build" + File.separator + "resources" + File.separator + "main" + File.separator + "log4j2.xml";
+  private static final String GEMFIRE_CONFIG_LOCATION_JAR = "gemfire-core" + File.separator
+ "build" + File.separator + "resources" + File.separator + "main" + File.separator + "log4j2.xml";
   
-  /**
-   * Check to see if the user has specified a Log4j configuration file.  If not, attempt
-   * to find a GemFire Log4j configuration file in various locations.
-   * 
-   * @return true if log4j.configurationFile property was set; false if it was unchanged
-   */
-  private static final boolean setLog4jConfigFileProperty() {
-    // fix bug #52175
-    final URL configInClasspath = ConfigLocator.findConfigInClasspath();
-    if (configInClasspath != null ) {
-      // Log4J 2 will find the configuration file in classpath so do nothing
-      configFileInformation = "Using log4j configuration found in classpath: '" + configInClasspath.toString()
+ "'";
-      StatusLogger.getLogger().info(configFileInformation);
-      return false;
-    }
+  public static boolean isUsingGemFireDefaultConfig() {
+    final Configuration config = ((org.apache.logging.log4j.core.Logger)
+        LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
     
-    // If the user set the log4j system property then there's nothing else to do.
-    final String configFileName = new StrSubstitutor(new Interpolator()).replace(
-        PropertiesUtil.getProperties().getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
-    if (configFileName != null) {
-      final URL configUrl = LogService.class.getResource(configFileName);// log4j2-cli.xml
is non-null, external is null
-      if (configUrl == null) {
-        //We will let log4j2 handle the null case and just log what file we are attempting
to use
-        configFileInformation = "Using log4j configuration file specified by " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY
+ ": '" + configFileName + "'";
-        StatusLogger.getLogger().info(configFileInformation);
-        return false;
-      }
-      else {
-        //If the resource can be found and in cases where the resource is in gemfire jar,
-        //we set the log location to the file that was found
-
-        // must change from Java resource syntax to Java URL syntax (GEODE-232)
-        // jar:file:/export/latvia1/users/klund/dev/asf-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-1.0.0-incubating-SNAPSHOT.jar!/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
-        
-        String configFilePropertyValue = configUrl.toString();
-        // configFileName is Java resource syntax, configFilePropertyValue is URL syntax
as required by log4j2
-        
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
-        configFileInformation = "Using log4j configuration file specified by " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY
+ ": '" + configFilePropertyValue + "'";
-        StatusLogger.getLogger().info(configFileInformation);
-        return true;
-      }
-    }
+    final StrSubstitutor sub = config.getStrSubstitutor();
+    final StrLookup resolver = sub.getVariableResolver();
     
-//    // set log4j.configurationFactory to be our optimized version
-//    final String factory = GemFireXmlConfigurationFactory.class.getName();
-//    System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY, factory);
-//    StatusLogger.getLogger().debug("Using log4j configuration factory '{}'", factory);
+    final String value = resolver.lookup(GEMFIRE_DEFAULT_PROPERTY);
     
-    // If one of the default log4j config files exists in the current directory then use
it.
-    File log4jConfigFile = findLog4jConfigInCurrentDir();
-    if (log4jConfigFile != null) {
-      String filePath = IOUtils.tryGetCanonicalPathElseGetAbsolutePath(log4jConfigFile);
-      String value = new File(filePath).toURI().toString();
-      String configFilePropertyValue = new File(filePath).toURI().toString();
-      System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
-      configFileInformation = "Setting " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY
+ " to specify log4j configuration file in current directory: '" + configFilePropertyValue
+ "'";
-      StatusLogger.getLogger().debug(configFileInformation);
-      return true;
-    }
-
-    // Use the log4j config file found on the classpath in the gemfire jar file.
-    final URL configUrl = LogService.class.getResource(DEFAULT_CONFIG);
-    String configFilePropertyValue = configUrl.toString();
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
-    configFileInformation = "Setting " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY
+ " to specify log4j configuration file: '" + configFilePropertyValue + "'";
-    StatusLogger.getLogger().info(configFileInformation);
-    return true;
+    return "true".equals(value);
   }
   
   public static String getConfigInformation() {
-    return configFileInformation;
+    return getConfiguration().getConfigurationSource().toString();
   }
 
   /**
@@ -255,6 +225,12 @@ public class LogService extends LogManager {
     return new Throwable().getStackTrace()[depth].getClassName();
   }
 
+  public static Configuration getConfiguration() {
+    final Configuration config = ((org.apache.logging.log4j.core.Logger)
+        LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
+    return config;
+  }
+  
   public static void configureFastLoggerDelegating() {
     final Configuration config = ((org.apache.logging.log4j.core.Logger)
         LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
@@ -300,7 +276,6 @@ public class LogService extends LogManager {
   }
   
   public static LoggerConfig getRootLoggerConfig() {
-    //return ((org.apache.logging.log4j.core.Logger)LogService.getLogger()).getContext().getConfiguration().getLoggerConfig(LogManager.getRootLogger().getName());
     return Configurator.getLoggerConfig(LogManager.getRootLogger().getName());
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
index e07f214..f1509df 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
@@ -10,6 +10,7 @@ import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.AppenderRef;
 import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
 import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.config.Property;
 import org.apache.logging.log4j.core.filter.AbstractFilterable;
@@ -125,6 +126,10 @@ public class Configurator {
     return config.hasFilter();
   }
   
+  public static String getConfigurationSourceLocation(final Configuration config) {
+    return config.getConfigurationSource().getLocation();
+  }
+  
   public static boolean hasAppenderFilter(final Configuration config) {
     for (Appender appender : config.getAppenders().values()) {
       if (appender instanceof AbstractFilterable) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
b/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
deleted file mode 100644
index a6e8cd8..0000000
--- a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
+++ /dev/null
@@ -1,21 +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="INFO" additivity="true">
-    <filters>
-      <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
-    </filters>
-    </Logger>
-    <Root level="INFO">
-      <AppenderRef ref="STDOUT"/>
-    </Root>
-  </Loggers>
-</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/log4j2.xml b/gemfire-core/src/main/resources/log4j2.xml
new file mode 100755
index 0000000..a21a333
--- /dev/null
+++ b/gemfire-core/src/main/resources/log4j2.xml
@@ -0,0 +1,22 @@
+<?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>
+    <Property name="gemfire-default">true</Property>
+  </Properties>
+  <Appenders>
+    <Console name="STDOUT" target="SYSTEM_OUT">
+      <PatternLayout pattern="${gemfire-pattern}"/>
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Logger name="com.gemstone" level="INFO" additivity="true">
+    <filters>
+      <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
+    </filters>
+    </Logger>
+    <Root level="INFO">
+      <AppenderRef ref="STDOUT"/>
+    </Root>
+  </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/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 6425c1f..7625481 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
@@ -7,7 +7,6 @@ import java.io.File;
 import java.net.URL;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -53,6 +52,7 @@ public class LogServiceIntegrationJUnitTest {
     protected void after() {
       Configurator.shutdown();
       
+      System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
       if (beforeConfigFileProp != null) {
         System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, beforeConfigFileProp);
       }
@@ -91,7 +91,7 @@ public class LogServiceIntegrationJUnitTest {
     LogService.reconfigure();
     
     assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
-    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.defaultConfigUrl.toString());
+    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
   }
   
   @Test
@@ -167,23 +167,6 @@ public class LogServiceIntegrationJUnitTest {
   }
   
   @Test
-  public void intializeAfterUsingLoggerShouldReconfigure() {
-    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
-    
-    Configurator.shutdown();
-    
-    LogManager.getRootLogger();
-
-    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
-    
-    LogService.reconfigure();
-    LogService.initialize();
-    
-    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).contains(LogService.DEFAULT_CONFIG);
-    assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
-  }
-  
-  @Test
   public void cliConfigLoadsAsResource() {
     assertThat(this.cliConfigUrl).isNotNull();
     assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
@@ -194,16 +177,33 @@ public class LogServiceIntegrationJUnitTest {
     assertThat(this.defaultConfigUrl).isNotNull();
     assertThat(this.defaultConfigUrl.toString()).contains(LogService.DEFAULT_CONFIG);
   }
-  
+
   @Test
-  public void shouldConvertConfigurationFilePropertyValueToURL() throws Exception {
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.CLI_CONFIG);
+  public void shouldNotUseDefaultConfigIfCliConfigSpecified() throws Exception {
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.cliConfigUrl.toString());
     
     LogService.reconfigure();
-    
+  
     assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-    assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
     assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.cliConfigUrl.toString());
     assertThat(LogService.getLogger().getName()).isEqualTo(getClass().getName());
   }
+
+  @Test
+  public void isUsingGemFireDefaultConfigShouldBeTrueIfDefaultConfig() throws Exception {
+    final String config = LogService.class.getResource(LogService.DEFAULT_CONFIG).toURI().toString();
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, config);
+    
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains("log4j2.xml");
+    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);
+    
+    assertThat(LogService.getConfiguration().getConfigurationSource().toString()).isNotEqualTo("/log4j2.xml");
+    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/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 8d6278a..2d6ed4d 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
@@ -45,34 +45,6 @@ public class LogServiceJUnitTest {
   }
   
   @Test
-  public void isUsingGemFireDefaultConfigShouldBeTrueIfDefaultConfig() {
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.DEFAULT_CONFIG);
-    
-    assertThat(LogService.isUsingGemFireDefaultConfig()).isTrue();
-  }
-
-  @Test
-  public void isUsingGemFireDefaultConfigShouldBeFalseIfEmpty() {
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "");
-    
-    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
-  }
-
-  @Test
-  public void isUsingGemFireDefaultConfigShouldBeFalseIfNull() {
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "");
-    
-    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
-  }
-
-  @Test
-  public void isUsingGemFireDefaultConfigShouldBeFalseIfCliConfig() {
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.CLI_CONFIG);
-    
-    assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
-  }
-  
-  @Test
   @Parameters(method = "getToLevelParameters")
   public void toLevelShouldReturnMatchingLog4jLevel(final int intLevel, final Level level)
{
     assertThat(LogService.toLevel(intLevel)).isSameAs(level);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
deleted file mode 100755
index 4d83c22..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.gemstone.gemfire.internal.logging;
-
-import static com.gemstone.gemfire.internal.logging.LogServiceIntegrationTestSupport.*;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assume.assumeFalse;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.ClearSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-
-import com.gemstone.gemfire.internal.lang.SystemUtils;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Tests LogService when a log4j2 config file is in the user.dir
- * 
- * @author Kirk Lund
- */
-@Category(IntegrationTest.class)
-public class LogServiceUserDirIntegrationJUnitTest {
-
-  @Rule
-  public final ClearSystemProperties clearConfigFileProperty = new ClearSystemProperties(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-  
-  @Rule
-  public final ExternalResource externalResource = new ExternalResource() {
-    @Override
-    protected void after() {
-      LogService.reconfigure();
-      assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
-    }
-  };
-  
-  private File configFile;
-  
-  @Before
-  public void setUp() throws Exception {
-    this.configFile = new File(System.getProperty("user.dir"), "log4j2-test.xml");
-    writeConfigFile(this.configFile, Level.DEBUG);
-    LogService.reconfigure();
-  }
-  
-  @After
-  public void tearDown() {
-    this.configFile.delete();
-  }
-  
-  @Test
-  public void shouldPreferConfigInCurrentDirectoryIfFound() throws Exception {
-    // if working directory is in classpath this test will fail
-    assumeFalse(isUserDirInClassPath());
-    
-    assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
-    //ConfigurationFactory.getInstance().getConfiguration(null, null); TODO: delete
-    assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.configFile.toURI().toString());
-  }
-  
-  private static boolean isUserDirInClassPath() throws MalformedURLException {
-    return SystemUtils.isInClassPath(System.getProperty("user.dir"));
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
index dd9504b..316788a 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
@@ -8,7 +8,6 @@ import org.junit.runners.Suite;
   DistributedSystemLogFileJUnitTest.class,
   LocatorLogFileJUnitTest.class,
   LogServiceIntegrationJUnitTest.class,
-  LogServiceUserDirIntegrationJUnitTest.class,
   MergeLogFilesJUnitTest.class,
 })
 public class LoggingIntegrationTestSuite {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
index d8d774c..37ba6c2 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
@@ -90,7 +90,7 @@ public class MergeLogFilesJUnitTest {
     PrintWriter pw = new PrintWriter(sw, true);
     MergeLogFiles.mergeLogFiles(streams, names, pw);
 
-    System.out.println(sw.toString());
+    //System.out.println(sw.toString());
 
     // Verfiy that the entries are sorted
     BufferedReader br =
@@ -222,7 +222,7 @@ public class MergeLogFilesJUnitTest {
         }
       }
 
-      System.out.println(baos.toString());
+      //System.out.println(baos.toString());
       in = new ByteArrayInputStream(baos.toByteArray());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e4d2b09d/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
index f1c7ab9..c20b6a7 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
@@ -47,6 +47,7 @@ public class FastLoggerIntegrationJUnitTest {
   public final TemporaryFolder temporaryFolder = new TemporaryFolder();
   
   private File configFile;
+  private String configFileLocation;
   private Logger logger;
   private LoggerContext appenderContext;
   private Marker enabledMarker;
@@ -56,6 +57,7 @@ public class FastLoggerIntegrationJUnitTest {
   public void setUp() throws Exception {
     System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
     this.configFile = new File(this.temporaryFolder.getRoot(), "log4j2-test.xml");
+    this.configFileLocation = this.configFile.toURI().toURL().toString();
     this.enabledMarker = MarkerManager.getMarker(ENABLED_MARKER_NAME);
     this.unusedMarker = MarkerManager.getMarker(UNUSED_MARKER_NAME);
     setUpLogService();
@@ -70,7 +72,7 @@ public class FastLoggerIntegrationJUnitTest {
   private void setUpLogService() throws Exception {
     // Load a base config and do some sanity checks
     writeSimpleConfigFile(this.configFile, Level.WARN);
-    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.configFile.toURI().toURL().toString());
+    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.configFileLocation);
 
     LogService.reconfigure();
     LogService.getLogger().getName(); // This causes the config file to be loaded


Mime
View raw message