Still WIP

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

Branch: refs/heads/feature/GEODE-1466
Commit: 7eb83021f611237e73a46fb00dcfb409c6e949ca
Parents: 24a6096
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Oct 12 11:50:27 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Oct 13 10:15:05 2016 -0700

----------------------------------------------------------------------
 .../geode/distributed/AbstractLauncher.java     |  56 ++++----
 .../geode/distributed/DistributedSystem.java    |  15 +--
 .../geode/distributed/LocatorLauncher.java      |   4 +-
 .../geode/distributed/ServerLauncher.java       |   4 +-
 .../org/apache/geode/internal/ConfigSource.java |  14 +-
 .../geode/internal/PropertiesResolver.java      | 118 +++++++++++++---
 .../internal/cache/CacheServerLauncher.java     |  21 +--
 .../cache/persistence/BackupManager.java        |   3 +-
 .../AbstractLauncherIntegrationTest.java        |  71 ----------
 .../geode/distributed/AbstractLauncherTest.java |  14 --
 .../LocatorLauncherIntegrationTest.java         |   2 +-
 ...ocatorLauncherPropertiesIntegrationTest.java |  93 ++++++++++++-
 .../PropertiesResolverIntegrationTest.java      | 134 +++++++++++++++----
 13 files changed, 343 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java 
b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
index e301078..43982f4 100644
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/AbstractLauncher.java
@@ -23,6 +23,7 @@ import 
org.apache.geode.distributed.internal.unsafe.RegisterSignalHandlerSupport
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.OSProcess;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.lang.ClassUtils;
 import org.apache.geode.internal.lang.ObjectUtils;
@@ -144,33 +145,34 @@ public abstract class AbstractLauncher<T extends 
Comparable<T>> implements Runna
     return !StringUtils.isBlank(properties.getProperty(propertyName));
   }
 
-  /**
-   * Loads the GemFire properties at the specified URL.
-   * 
-   * @param url the URL to the gemfire.properties to load.
-   * @return a Properties instance populated with the gemfire.properties.
-   * @see java.net.URL
-   */
-  protected static Properties loadGemFireProperties(final URL url) { // TODO: 
GEODE-1466
-    final Properties properties = new Properties();
-
-    if (url != null) {
-      try {
-        properties.load(new FileReader(new File(url.toURI())));
-      }
-      catch (Exception e) {
-        try {
-          // not in the file system, try the classpath
-          
properties.load(AbstractLauncher.class.getResourceAsStream(DistributedSystem.getPropertiesFile()));
-        }
-        catch (Exception ignore) {
-          // not in the file system or the classpath; gemfire.properties does 
not exist
-        }
-      }
-    }
-
-    return properties;
-  }
+//  /**
+//   * Loads the GemFire properties at the specified URL.
+//   *
+//   * @param url the URL to the gemfire.properties to load.
+//   * @return a Properties instance populated with the gemfire.properties.
+//   * @see java.net.URL
+//   */
+//  protected static Properties loadGemFireProperties(final URL url) { // 
TODO: GEODE-1466
+////    return new PropertiesResolver().loadProperties();
+//    final Properties properties = new Properties();
+//
+//    if (url != null) {
+//      try {
+//        properties.load(new FileReader(new File(url.toURI())));
+//      }
+//      catch (Exception e) {
+//        try {
+//          // not in the file system, try the classpath
+//          
properties.load(AbstractLauncher.class.getResourceAsStream(DistributedSystem.getPropertiesFile()));
+//        }
+//        catch (Exception ignore) {
+//          // not in the file system or the classpath; gemfire.properties 
does not exist
+//        }
+//      }
+//    }
+//
+//    return properties;
+//  }
 
   void initLogger() {
     try {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java 
b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
index e5c420d..c40aaea 100644
--- 
a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
+++ 
b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
@@ -24,15 +24,14 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.client.ClientCache;
 import org.apache.geode.cache.client.ClientCacheFactory;
-import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.DistributionManager;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.Assert;
 import org.apache.geode.internal.ClassPathLoader;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.tcp.ConnectionTable;
 import org.apache.geode.internal.util.IOUtils;
-import org.apache.geode.security.GemFireSecurityException;
 
 import java.io.File;
 import java.net.InetAddress;
@@ -558,7 +557,7 @@ public abstract class DistributedSystem implements 
StatisticsFactory {
    * @see #getPropertiesFile()
    * @since Geode 1.0
    */
-  public static final String PROPERTIES_FILE_PROPERTY = "gemfirePropertyFile";
+  public static final String PROPERTIES_FILE_PROPERTY = 
PropertiesResolver.GEODE_PROPERTIES_FILE_KEY;
   
   /** 
    * The default value of <code>PROPERTIES_FILE_PROPERTY</code> is
@@ -569,7 +568,7 @@ public abstract class DistributedSystem implements 
StatisticsFactory {
    * @see #getPropertiesFile()
    * @since Geode 1.0
    */
-  public static final String PROPERTIES_FILE_DEFAULT = 
DistributionConfig.GEMFIRE_PREFIX + "properties"; // TODO: GEODE-1466
+  public static final String PROPERTIES_FILE_DEFAULT = 
PropertiesResolver.DEFAULT_PROPERTIES_FILE_VALUE;
 
   /**
    * Returns the current value of {@link #PROPERTIES_FILE_PROPERTY} system 
@@ -579,8 +578,8 @@ public abstract class DistributedSystem implements 
StatisticsFactory {
    * @see #PROPERTIES_FILE_DEFAULT
    * @since Geode 1.0
    */
-  public static String getPropertiesFile() { // TODO: GEODE-1466
-       return System.getProperty(PROPERTIES_FILE_PROPERTY, 
PROPERTIES_FILE_DEFAULT);
+  public static String getPropertiesFile() {
+         return new PropertiesResolver().getSpecifiedPropertiesFileName();
   }
   
   /**
@@ -633,7 +632,7 @@ public abstract class DistributedSystem implements 
StatisticsFactory {
    * @see #getSecurityPropertiesFile()
    * @since Geode 1.0
    */
-  public static final String SECURITY_PROPERTIES_FILE_PROPERTY = 
"gemfireSecurityPropertyFile";
+  public static final String SECURITY_PROPERTIES_FILE_PROPERTY = 
"gemfireSecurityPropertyFile"; // TODO: GEODE-1466
   
   /** 
    * The default value of <code>SECURITY_PROPERTIES_FILE_PROPERTY</code> is
@@ -699,7 +698,7 @@ public abstract class DistributedSystem implements 
StatisticsFactory {
    * @since Geode 1.0
    */
   public static URL getPropertiesFileURL() {
-    return getFileURL(getPropertiesFile());
+    return PropertiesResolver.findPropertiesFile();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java 
b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
index b18ce81..470ef16 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/LocatorLauncher.java
@@ -26,6 +26,7 @@ import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.distributed.internal.tcpserver.*;
 import org.apache.geode.internal.DistributionLocator;
 import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.lang.ObjectUtils;
@@ -1730,9 +1731,8 @@ public final class LocatorLauncher extends 
AbstractLauncher<String> {
     protected void validateOnStart() {
       if (Command.START.equals(getCommand())) {
         if (StringUtils.isBlank(getMemberName())
-            && !isSet(System.getProperties(), 
DistributionConfig.GEMFIRE_PREFIX + NAME)
             && !isSet(getDistributedSystemProperties(), NAME)
-            && 
!isSet(loadGemFireProperties(DistributedSystem.getPropertyFileURL()), NAME)) // 
TODO: GEODE-1466
+            && !new PropertiesResolver().hasNonBlankPropertyValue(NAME))
         {
           throw new 
IllegalStateException(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE
             .toLocalizedString("Locator"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java 
b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
index a3d3845..1ceafcb 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ServerLauncher.java
@@ -27,6 +27,7 @@ import 
org.apache.geode.distributed.internal.DefaultServerLauncherCacheProvider;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.cache.*;
 import org.apache.geode.internal.cache.tier.sockets.CacheServerHelper;
@@ -2264,9 +2265,8 @@ public class ServerLauncher extends 
AbstractLauncher<String> {
     protected void validateOnStart() {
       if (Command.START.equals(getCommand())) {
         if (StringUtils.isBlank(getMemberName())
-            && !isSet(System.getProperties(), 
DistributionConfig.GEMFIRE_PREFIX + NAME)
             && !isSet(getDistributedSystemProperties(), NAME)
-            && 
!isSet(loadGemFireProperties(DistributedSystem.getPropertyFileURL()), NAME))
+            && !new PropertiesResolver().hasNonBlankPropertyValue(NAME))
         {
           throw new 
IllegalStateException(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE
             .toLocalizedString("Server"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/internal/ConfigSource.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/ConfigSource.java 
b/geode-core/src/main/java/org/apache/geode/internal/ConfigSource.java
index fbe467b..87309f6 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/ConfigSource.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/ConfigSource.java
@@ -32,13 +32,13 @@ public class ConfigSource implements Serializable {
   private ConfigSource(Type t) {
     this.type = t;
     switch (t) {
-      case API: this.description = "api"; break;
-      case SYSTEM_PROPERTY: this.description = "system property"; break;
-      case FILE: this.description = "file"; break;
-      case SECURE_FILE: this.description = "secure file"; break;
-      case XML: this.description = "cache.xml"; break;
-      case RUNTIME: this.description = "runtime modification"; break;
-      case LAUNCHER: this.description = "launcher"; break;
+      case API: this.description = "api"; break; // Properties instance passed 
in to DistributedSystem.connect
+      case SYSTEM_PROPERTY: this.description = "system property"; break; // 
System.getProperties
+      case FILE: this.description = "file"; break; // gemfire.properties file
+      case SECURE_FILE: this.description = "secure file"; break; // 
gfsecurity.properties file
+      case XML: this.description = "cache.xml"; break; // cache.xml file
+      case RUNTIME: this.description = "runtime modification"; break; // 
RuntimeDistributionConfigImpl setter
+      case LAUNCHER: this.description = "launcher"; break; // Launcher setter
       default:
         this.description = "";
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java 
b/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java
index 9bd0325..a07e3b7 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java
@@ -17,39 +17,107 @@
 package org.apache.geode.internal;
 
 import java.io.File;
-import java.net.URI;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
+import org.apache.geode.GemFireIOException;
 import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.util.IOUtils;
 
 public class PropertiesResolver {
 
-  public static final String GEODE_PROPERTIES_FILE_PROPERTY = 
"geodePropertyFile";
-  public static final String GEMFIRE_PROPERTIES_FILE_PROPERTY = 
DistributedSystem.PROPERTIES_FILE_PROPERTY;
-  public static final String DEFAULT_GEODE_PROPERTIES_FILE_NAME = 
"geode.properties";
-  public static final String DEFAULT_GEMFIRE_PROPERTIES_FILE_NAME = 
"gemfire.properties";
+  public static final String GEODE_PREFIX = "geode.";
+  public static final String GEMFIRE_PREFIX = "gemfire.";
+  public static final String GEODE_PROPERTIES_FILE_KEY = "geodePropertyFile";
+  public static final String GEMFIRE_PROPERTIES_FILE_KEY = 
"gemfirePropertyFile";
+  public static final String DEFAULT_GEODE_PROPERTIES_FILE_VALUE = 
"geode.properties";
+  public static final String DEFAULT_GEMFIRE_PROPERTIES_FILE_VALUE = 
"gemfire.properties";
+  public static final String DEFAULT_PROPERTIES_FILE_VALUE = 
DEFAULT_GEODE_PROPERTIES_FILE_VALUE;
 
-  private static URI propertiesFileURL = findPropertiesFileLocation();
+  private Properties properties;
 
-  static URI findPropertiesFileLocation() {
-    List<URI> possibleUrls = new ArrayList<>();
-    
possibleUrls.add(getFileURI(System.getProperty(GEODE_PROPERTIES_FILE_PROPERTY)));
-    
possibleUrls.add(getFileURI(System.getProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY)));
-    possibleUrls.add(getFileURI(DEFAULT_GEODE_PROPERTIES_FILE_NAME));
-    possibleUrls.add(getFileURI(DEFAULT_GEMFIRE_PROPERTIES_FILE_NAME));
+  public PropertiesResolver() {
+    this(findPropertiesFile());
+  }
+
+  protected PropertiesResolver(URL url) {
+    properties = loadPropertiesFromURL(url);
+  }
+
+  private Properties loadPropertiesFromURL(URL url) {
+    Properties properties = new Properties();
+    try {
+      properties.load(new FileReader(new File(url.toURI())));
+    } catch (URISyntaxException | IOException e) {
+      throw new 
GemFireIOException(LocalizedStrings.DistributionConfigImpl_FAILED_READING_0.toLocalizedString(url),
 e);
+    }
+    return properties;
+  }
+
+  public String getSpecifiedPropertiesFileName() {
+    if (hasSystemProperty(GEODE_PROPERTIES_FILE_KEY)) {
+      return System.getProperty(GEODE_PROPERTIES_FILE_KEY);
+    } else if (hasSystemProperty(GEMFIRE_PROPERTIES_FILE_KEY)) {
+      return System.getProperty(GEMFIRE_PROPERTIES_FILE_KEY);
+    } else {
+      return DEFAULT_PROPERTIES_FILE_VALUE;
+    }
+  }
+
+  public Map<String, ConfigSource> propertiesWithSource() {
+    // add props from gemfire system props
+    // add props from geode system props
+    //add props from file
+    // add props from security file
+
+    return null;
+  }
+
+  public static URL findPropertiesFile() {
+    List<URL> possibleUrls = new ArrayList<>();
+    
possibleUrls.add(getFileURI(System.getProperty(GEODE_PROPERTIES_FILE_KEY)));
+    
possibleUrls.add(getFileURI(System.getProperty(GEMFIRE_PROPERTIES_FILE_KEY)));
+    possibleUrls.add(getFileURI(DEFAULT_GEODE_PROPERTIES_FILE_VALUE));
+    possibleUrls.add(getFileURI(DEFAULT_GEMFIRE_PROPERTIES_FILE_VALUE));
 
+    //TODO: Should we make a list of Strings instead of URLs and turn it into 
a URL after picking one?
     return possibleUrls.stream().filter(s -> s != 
null).findFirst().orElse(null);
   }
 
-  static boolean hasProperty(final String key) {
+  static boolean hasSystemProperty(final String key) {
     return 
System.getProperties().containsKey(DistributedSystem.PROPERTIES_FILE_PROPERTY);
   }
 
-  private static URI getFileURI(String fileName) {
+  public boolean hasProperty(String key) {
+    return getProperty(key) != null;
+  }
+
+  public boolean hasNonBlankPropertyValue(String key) {
+    return !StringUtils.isBlank(getProperty(key));
+  }
+
+  //TODO: Should we fall back to default instead of null?
+  // What should this do for blank properties?
+  public String getProperty(final String key) {
+    List<String> possibleValues = new ArrayList<>();
+    possibleValues.add(System.getProperty(GEODE_PREFIX + key));
+    possibleValues.add(System.getProperty(GEMFIRE_PREFIX + key));
+    possibleValues.add(properties.getProperty(key));
+
+    return possibleValues.stream().filter( s -> 
s!=null).findFirst().orElse(null);
+  }
+
+  private static URL getFileURI(String fileName) {
     if (fileName == null) {
       return null;
     }
@@ -57,25 +125,35 @@ public class PropertiesResolver {
     File file = new File(fileName); // absolute path or current dir
 
     if (file.exists()) {
-        return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI();
+      URL url = getFileURL(file);
+      if (url != null) {
+        return url;
+      }
     }
 
     file = new File(System.getProperty("user.home"), fileName); // user home
 
     if (file.exists()) {
-        return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI();
+      URL url = getFileURL(file);
+      if (url != null) {
+        return url;
+      }
     }
 
     return getResourceOrNull(fileName); // resource
   }
 
-  private static URI getResourceOrNull(final String name) {
+  private static URL getFileURL(File file) {
     try {
-      URL url = ClassPathLoader.getLatest().getResource(name); // resource
-      return (url == null) ? null : url.toURI();
-    } catch (URISyntaxException ignore) {
+      return 
IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI().toURL();
+    } catch (MalformedURLException e) {
       return null;
     }
   }
 
+
+  private static URL getResourceOrNull(final String name) {
+    return ClassPathLoader.getLatest().getResource(name); // resource
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerLauncher.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerLauncher.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerLauncher.java
index 20cc5a7..1233b15 100755
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerLauncher.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerLauncher.java
@@ -29,6 +29,7 @@ import 
org.apache.geode.distributed.internal.DistributionConfigImpl;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.i18n.LogWriterI18n;
 import org.apache.geode.internal.OSProcess;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.PureJavaMode;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.cache.tier.sockets.CacheServerHelper;
@@ -1208,25 +1209,7 @@ public class CacheServerLauncher  {
    * @return true if the logging would go to stdout
    */
   private static boolean isLoggingToStdOut() {
-    Properties gfprops = new Properties();
-    URL url = DistributedSystem.getPropertyFileURL();
-    if (url != null) {
-      try {
-        gfprops.load(url.openStream());
-      } catch (IOException io) {
-        //throw new GemFireIOException("Failed reading " + url, io);
-        System.out.println("Failed reading " + url);
-        System.exit( 1 );
-      }
-      final String logFile = gfprops.getProperty(LOG_FILE);
-      if ( logFile == null || logFile.length() == 0 ) {
-        return true;
-      }
-    } else {
-      //Didnt find a property file, assuming the default is to log to stdout
-      return true;
-    }
-    return false;
+      return !(new PropertiesResolver().hasNonBlankPropertyValue(LOG_FILE));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/BackupManager.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/BackupManager.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/BackupManager.java
index 8a44275..deec9d1 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/BackupManager.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/BackupManager.java
@@ -26,6 +26,7 @@ import 
org.apache.geode.distributed.internal.membership.InternalDistributedMembe
 import org.apache.geode.internal.FileUtil;
 import org.apache.geode.internal.JarClassLoader;
 import org.apache.geode.internal.JarDeployer;
+import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.cache.DiskStoreImpl;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -236,7 +237,7 @@ public class BackupManager implements MembershipListener {
       FileUtil.copy(url, cacheXMLBackup);
     }
     
-    URL propertyURL = DistributedSystem.getPropertyFileURL();
+    URL propertyURL = PropertiesResolver.findPropertiesFile();
     if(propertyURL != null) {
       File propertyBackup = new File(configBackupDir, 
DistributionConfig.GEMFIRE_PREFIX + "properties");
       FileUtil.copy(propertyURL, propertyBackup);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
deleted file mode 100755
index 4ae78fc..0000000
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.geode.distributed;
-
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.util.Properties;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-
-/**
- * Integration tests for AbstractLauncher class. These tests require file 
system I/O.
- */
-@Category(IntegrationTest.class)
-public class AbstractLauncherIntegrationTest {
-
-  private File gemfirePropertiesFile;
-  private Properties expectedGemfireProperties;
-
-  @Rule
-  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  @Before
-  public void setUp() throws Exception {
-    this.gemfirePropertiesFile = 
this.temporaryFolder.newFile(DistributionConfig.GEMFIRE_PREFIX + "properties");
-    
-    this.expectedGemfireProperties = new Properties();
-    this.expectedGemfireProperties.setProperty(NAME, "memberOne");
-    this.expectedGemfireProperties.setProperty(GROUPS, "groupOne, groupTwo");
-    this.expectedGemfireProperties.store(new 
FileWriter(this.gemfirePropertiesFile, false), this.testName.getMethodName());
-
-    assertThat(this.gemfirePropertiesFile).isNotNull();
-    assertThat(this.gemfirePropertiesFile.exists()).isTrue();
-    assertThat(this.gemfirePropertiesFile.isFile()).isTrue();
-  }
-  
-  @Test
-  public void testLoadGemFirePropertiesFromFile() throws Exception {
-    final Properties actualGemFireProperties = 
AbstractLauncher.loadGemFireProperties(this.gemfirePropertiesFile.toURI().toURL());
-
-    assertThat(actualGemFireProperties).isNotNull();
-    
assertThat(actualGemFireProperties).isEqualTo(this.expectedGemfireProperties);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
index b9a589a..68b82ab 100644
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
@@ -91,20 +91,6 @@ public class AbstractLauncherTest {
   }
 
   @Test
-  public void testLoadGemFirePropertiesWithNullURL() {
-    final Properties properties = AbstractLauncher.loadGemFireProperties(null);
-    assertNotNull(properties);
-    assertTrue(properties.isEmpty());
-  }
-
-  @Test
-  public void testLoadGemFirePropertiesWithNonExistingURL() throws 
MalformedURLException {
-    final Properties properties = AbstractLauncher.loadGemFireProperties(new 
URL("file:///path/to/non_existing/gemfire.properties"));
-    assertNotNull(properties);
-    assertTrue(properties.isEmpty());
-  }
-
-  @Test
   public void testGetDistributedSystemProperties() {
     AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "1");
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
index 169015a..ae5c0e3 100755
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
@@ -138,7 +138,7 @@ public class LocatorLauncherIntegrationTest {
     // given: gemfire.properties with a name
     Properties gemfireProperties = new Properties();
     gemfireProperties.setProperty(NAME, "locator123");
-    
useGemFirePropertiesFileInTemporaryFolder(PropertiesResolver.DEFAULT_GEODE_PROPERTIES_FILE_NAME,
 gemfireProperties); // TODO: GEODE-1466
+    
useGemFirePropertiesFileInTemporaryFolder(PropertiesResolver.DEFAULT_GEODE_PROPERTIES_FILE_VALUE,
 gemfireProperties); // TODO: GEODE-1466
 
     // when: starting with null MemberName
     LocatorLauncher launcher = new Builder()

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherPropertiesIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherPropertiesIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherPropertiesIntegrationTest.java
index eb310aa..df644ff 100644
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherPropertiesIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherPropertiesIntegrationTest.java
@@ -18,6 +18,7 @@ package org.apache.geode.distributed;
 
 import static java.util.concurrent.TimeUnit.*;
 import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.internal.PropertiesResolver.*;
 import static org.assertj.core.api.Assertions.*;
 
 import java.io.BufferedReader;
@@ -35,15 +36,22 @@ 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.rules.TemporaryFolder;
 
 import org.apache.geode.distributed.AbstractLauncher.Status;
 import org.apache.geode.distributed.LocatorLauncher.Builder;
 import org.apache.geode.distributed.internal.SharedConfiguration;
-import org.apache.geode.internal.PropertiesResolver;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.test.junit.categories.IntegrationTest;
 
+/**
+ * TODO: create LocatorLauncherPropertiesRemoteIntegrationTest
+ *
+ * This test is all in-process
+ */
+@Category(IntegrationTest.class)
 public class LocatorLauncherPropertiesIntegrationTest {
 
   private File propsFile;
@@ -73,13 +81,84 @@ public class LocatorLauncherPropertiesIntegrationTest {
     try {
       FileUtils.forceDelete(propsFile);
     } catch (Exception ignored) {
+      ignored.printStackTrace();
     }
   }
 
   @Test
-  public void usesNameInGemFireProperties() throws Throwable {
-    String memberName = "myLocatorName";
-    createPropertiesFile("myGemfire.properties", memberName);
+  public void prefersNameInBuilderFirst() throws Exception {
+    String nameInBuilder = "nameInBuilder";
+    String nameInSystemProperty = "nameInSystemProperty";
+    String nameInProperties = "nameInProperties";
+    System.setProperty(GEODE_PREFIX + NAME, nameInSystemProperty);
+
+    createPropertiesFile(GEODE_PROPERTIES_FILE_KEY, "myGeode.properties", 
nameInProperties);
+
+    this.launcher = new 
Builder().setMemberName(nameInBuilder).setPort(0).set(CLUSTER_CONFIGURATION_DIR,
 this.clusterConfigDirectory).build();
+    this.launcher.start();
+    awaitLocator(this.launcher);
+
+    System.out.println(this.launcher.status());
+    
assertThat(this.launcher.status().getMemberName()).isEqualTo(nameInBuilder);
+
+    assertThat(this.launcher.stop().getStatus()).isEqualTo(Status.STOPPED);
+  }
+
+  @Test
+  public void prefersNameInGeodeSystemPropertySecond() throws Exception {
+    String nameInSystemProperty = "nameInSystemProperty";
+    String nameInProperties = "nameInProperties";
+    System.setProperty(GEODE_PREFIX + NAME, nameInSystemProperty);
+
+    createPropertiesFile(GEODE_PROPERTIES_FILE_KEY, "myGeode.properties", 
nameInProperties);
+
+    this.launcher = new Builder().setPort(0).set(CLUSTER_CONFIGURATION_DIR, 
this.clusterConfigDirectory).build();
+    this.launcher.start();
+    awaitLocator(this.launcher);
+
+    System.out.println(this.launcher.status());
+    
assertThat(this.launcher.status().getMemberName()).isEqualTo(nameInSystemProperty);
+
+    assertThat(this.launcher.stop().getStatus()).isEqualTo(Status.STOPPED);
+  }
+
+  @Test
+  public void prefersNameInGemFireSystemPropertySecond() throws Exception {
+    String nameInSystemProperty = "nameInSystemProperty";
+    String nameInProperties = "nameInProperties";
+    System.setProperty(GEMFIRE_PREFIX + NAME, nameInSystemProperty);
+
+    createPropertiesFile(GEODE_PROPERTIES_FILE_KEY, "myGeode.properties", 
nameInProperties);
+
+    this.launcher = new Builder().setPort(0).set(CLUSTER_CONFIGURATION_DIR, 
this.clusterConfigDirectory).build();
+    this.launcher.start();
+    awaitLocator(this.launcher);
+
+    System.out.println(this.launcher.status());
+    
assertThat(this.launcher.status().getMemberName()).isEqualTo(nameInSystemProperty);
+
+    assertThat(this.launcher.stop().getStatus()).isEqualTo(Status.STOPPED);
+  }
+
+  @Test
+  public void usesNameInGeodeProperties() throws Exception {
+    String memberName = "myLocatorNameGeode";
+    createPropertiesFile(GEODE_PROPERTIES_FILE_KEY, "myGeode.properties", 
memberName);
+
+    this.launcher = new Builder().setPort(0).set(CLUSTER_CONFIGURATION_DIR, 
this.clusterConfigDirectory).build();
+    this.launcher.start();
+    awaitLocator(this.launcher);
+
+    System.out.println(this.launcher.status());
+    assertThat(this.launcher.status().getMemberName()).isEqualTo(memberName);
+
+    assertThat(this.launcher.stop().getStatus()).isEqualTo(Status.STOPPED);
+  }
+
+  @Test
+  public void usesNameInGemFireProperties() throws Exception {
+    String memberName = "myLocatorNameGemfire";
+    createPropertiesFile(GEMFIRE_PROPERTIES_FILE_KEY, "myGemfire.properties", 
memberName);
 
     this.launcher = new Builder().setPort(0).set(CLUSTER_CONFIGURATION_DIR, 
this.clusterConfigDirectory).build();
     this.launcher.start();
@@ -91,10 +170,10 @@ public class LocatorLauncherPropertiesIntegrationTest {
     assertThat(this.launcher.stop().getStatus()).isEqualTo(Status.STOPPED);
   }
 
-  private void createPropertiesFile(String filename, String memberName) throws 
IOException {
-    System.setProperty(PropertiesResolver.GEMFIRE_PROPERTIES_FILE_PROPERTY, 
filename);
+  private void createPropertiesFile(String propertyName, String filename, 
String memberName) throws IOException {
+    System.setProperty(propertyName, filename);
 
-    propsFile = new File(System.getProperty("user.home"), filename);
+    propsFile = new File(System.getProperty("user.dir"), filename);
     propsFile.deleteOnExit();
 
     Properties properties = new Properties();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7eb83021/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
index c317ded..c2cfa23 100644
--- 
a/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
@@ -16,19 +16,24 @@
  */
 package org.apache.geode.internal;
 
+import static org.apache.geode.distributed.ConfigurationProperties.*;
 import static org.apache.geode.internal.PropertiesResolver.*;
 import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
 
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
@@ -37,12 +42,16 @@ import java.util.jar.Manifest;
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 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.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
+import org.apache.geode.distributed.AbstractLauncher;
+import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
@@ -60,6 +69,9 @@ public class PropertiesResolverIntegrationTest {
   @Rule
   public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
+  @Rule
+  public TestName testName = new TestName();
+
   @Before
   public void createFiles() throws Exception {
     this.geodeCustomProperties = 
this.temporaryFolder.newFile("geodeCustom.properties");
@@ -77,38 +89,38 @@ public class PropertiesResolverIntegrationTest {
 
   @Test
   public void canSpecifyGeodePropertiesFileAbsolutePath() throws Exception {
-    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, 
this.geodeCustomProperties.getCanonicalPath());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURI());
+    System.setProperty(GEODE_PROPERTIES_FILE_KEY, 
this.geodeCustomProperties.getCanonicalPath());
+    
assertThat(findPropertiesFile()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURL());
   }
 
   @Test
   public void canSpecifyGeodePropertiesFileInCurrentDir() throws Exception {
-    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, 
geodeCustomFileInCurrentDir().getName());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(geodeCustomFileInCurrentDir().getCanonicalFile().toURI());
+    System.setProperty(GEODE_PROPERTIES_FILE_KEY, 
geodeCustomFileInCurrentDir().getName());
+    
assertThat(findPropertiesFile()).isEqualTo(geodeCustomFileInCurrentDir().getCanonicalFile().toURL());
   }
 
  @Test
   public void canSpecifyGeodePropertiesFileInUserHomeDir() throws Exception {
-    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, 
geodeCustomFileInHomeDir().getName());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(geodeCustomFileInHomeDir().getCanonicalFile().toURI());
+    System.setProperty(GEODE_PROPERTIES_FILE_KEY, 
geodeCustomFileInHomeDir().getName());
+    
assertThat(findPropertiesFile()).isEqualTo(geodeCustomFileInHomeDir().getCanonicalFile().toURL());
   }
 
   @Test
   public void canSpecifyGemFirePropertiesFileAbsolutePath() throws Exception {
-    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, 
this.gemfireCustomProperties.getCanonicalPath());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURI());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_KEY, 
this.gemfireCustomProperties.getCanonicalPath());
+    
assertThat(findPropertiesFile()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURL());
   }
 
   @Test
   public void canSpecifyGemFirePropertiesFileInCurrentDir() throws Exception {
-    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, 
gemfireCustomFileInCurrentDir().getName());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(gemfireCustomFileInCurrentDir().getCanonicalFile().toURI());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_KEY, 
gemfireCustomFileInCurrentDir().getName());
+    
assertThat(findPropertiesFile()).isEqualTo(gemfireCustomFileInCurrentDir().getCanonicalFile().toURL());
   }
 
   @Test
   public void canSpecifyGemFirePropertiesFileInUserHomeDir() throws Exception {
-    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, 
gemfireCustomFileInHomeDir().getName());
-    
assertThat(findPropertiesFileLocation()).isEqualTo(gemfireCustomFileInHomeDir().getCanonicalFile().toURI());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_KEY, 
gemfireCustomFileInHomeDir().getName());
+    
assertThat(findPropertiesFile()).isEqualTo(gemfireCustomFileInHomeDir().getCanonicalFile().toURL());
   }
 
   @Test
@@ -117,7 +129,7 @@ public class PropertiesResolverIntegrationTest {
     geodeDefaultFileInHomeDir();
     geodeInJarAsClasspathResource();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInCurrentDir().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(geodeDefaultFileInCurrentDir().toURL());
   }
 
   @Test
@@ -125,30 +137,30 @@ public class PropertiesResolverIntegrationTest {
     geodeDefaultFileInHomeDir();
     geodeInJarAsClasspathResource();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInHomeDir().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(geodeDefaultFileInHomeDir().toURL());
   }
 
   @Test
   public void searchesJarOnClasspathThird() throws Exception {
-    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_PROPERTY, 
"geodeInJar.properties");
+    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_KEY, 
"geodeInJar.properties");
 
     URL url = propsFileInJarOnClasspath();
 
-    assertThat(findPropertiesFileLocation()).isEqualTo(url.toURI());
+    assertThat(findPropertiesFile()).isEqualTo(url);
   }
 
   @Test
   public void searchesDirOnClasspathThird() throws Exception {
-    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_PROPERTY, 
"geodeInDir.properties");
+    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_KEY, 
"geodeInDir.properties");
 
     URL url = propsFileInDirOnClasspath(); // TODO
 
-    assertThat(findPropertiesFileLocation()).isEqualTo(url.toURI());
+    assertThat(findPropertiesFile()).isEqualTo(url);
   }
 
   @Test
   public void searchReturnsNullLast() throws Exception {
-    assertThat(findPropertiesFileLocation()).isNull();
+    assertThat(findPropertiesFile()).isNull();
   }
 
   private URL propsFileInJarOnClasspath() throws IOException, 
URISyntaxException {
@@ -196,21 +208,21 @@ public class PropertiesResolverIntegrationTest {
 
   @Test
   public void findPrefersGeodePropertiesFileFirst() throws Exception {
-    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, 
this.geodeCustomProperties.getCanonicalPath());
-    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, 
this.gemfireCustomProperties.getCanonicalPath());
+    System.setProperty(GEODE_PROPERTIES_FILE_KEY, 
this.geodeCustomProperties.getCanonicalPath());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_KEY, 
this.gemfireCustomProperties.getCanonicalPath());
     geodeDefaultFileInCurrentDir();
     gemfireDefaultFileInCurrentDir();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURL());
   }
 
   @Test
   public void findPrefersGemFirePropertiesFileSecond() throws Exception {
-    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, 
this.gemfireCustomProperties.getCanonicalPath());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_KEY, 
this.gemfireCustomProperties.getCanonicalPath());
     geodeDefaultFileInCurrentDir();
     gemfireDefaultFileInCurrentDir();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURL());
   }
 
   @Test
@@ -218,14 +230,82 @@ public class PropertiesResolverIntegrationTest {
     geodeDefaultFileInCurrentDir();
     gemfireDefaultFileInCurrentDir();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInCurrentDir().getCanonicalFile().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(geodeDefaultFileInCurrentDir().getCanonicalFile().toURL());
   }
 
   @Test
   public void findPrefersGemFireDefaultFourth() throws Exception {
     gemfireDefaultFileInCurrentDir();
 
-    
assertThat(findPropertiesFileLocation()).isEqualTo(gemfireDefaultFileInCurrentDir().getCanonicalFile().toURI());
+    
assertThat(findPropertiesFile()).isEqualTo(gemfireDefaultFileInCurrentDir().getCanonicalFile().toURL());
+  }
+
+  @Test
+  public void getPropertyPrefersGeodeSystemPropertyFirst() throws Exception {
+    System.setProperty(GEODE_PREFIX + NAME, "nameFromGeodeSystemProperty");
+    System.setProperty(GEMFIRE_PREFIX + NAME, "nameFromGemFireSystemProperty");
+
+    File gemfirePropertiesFile = this.temporaryFolder.newFile(GEODE_PREFIX + 
"properties");
+    Properties expectedGemfireProperties = new Properties();
+    expectedGemfireProperties.setProperty(NAME, "nameFromPropertiesFile");
+    expectedGemfireProperties.store(new FileWriter(gemfirePropertiesFile, 
false), this.testName.getMethodName());
+    assertThat(gemfirePropertiesFile).isNotNull().exists().isFile();
+
+    PropertiesResolver propertiesResolver = new 
PropertiesResolver(gemfirePropertiesFile.toURL());
+
+    
assertThat(propertiesResolver.getProperty(NAME)).isEqualTo("nameFromGeodeSystemProperty");
+  }
+
+  @Test
+  public void getPropertyPrefersGemfireSystemPropertySecond() throws Exception 
{
+    System.clearProperty(GEODE_PREFIX + NAME);
+    System.setProperty(GEMFIRE_PREFIX + NAME, "nameFromGemFireSystemProperty");
+
+    File gemfirePropertiesFile = this.temporaryFolder.newFile(GEODE_PREFIX + 
"properties"); // TODO: gemfire.properties and geode.properties
+    Properties expectedGemfireProperties = new Properties();
+    expectedGemfireProperties.setProperty(NAME, "nameFromPropertiesFile");
+    expectedGemfireProperties.store(new FileWriter(gemfirePropertiesFile, 
false), this.testName.getMethodName());
+    assertThat(gemfirePropertiesFile).isNotNull().exists().isFile();
+
+    PropertiesResolver propertiesResolver = new 
PropertiesResolver(gemfirePropertiesFile.toURL());
+
+    
assertThat(propertiesResolver.getProperty(NAME)).isEqualTo("nameFromGemFireSystemProperty");
+  }
+
+  @Test
+  public void getPropertyUsesPropertiesFileLast() throws Exception {
+    System.clearProperty(GEODE_PREFIX + NAME);
+    System.clearProperty(GEMFIRE_PREFIX + NAME);
+
+    File gemfirePropertiesFile = this.temporaryFolder.newFile(GEODE_PREFIX + 
"properties"); // TODO: gemfire.properties and geode.properties
+    Properties expectedGemfireProperties = new Properties();
+    expectedGemfireProperties.setProperty(NAME, "nameFromPropertiesFile");
+    expectedGemfireProperties.store(new FileWriter(gemfirePropertiesFile, 
false), this.testName.getMethodName());
+    assertThat(gemfirePropertiesFile).isNotNull().exists().isFile();
+
+    PropertiesResolver propertiesResolver = new 
PropertiesResolver(gemfirePropertiesFile.toURL());
+
+    
assertThat(propertiesResolver.getProperty(NAME)).isEqualTo("nameFromPropertiesFile");
+  }
+
+  /**
+   * Extracted from AbstractLauncherTest
+   */
+  @Ignore
+  @Test
+  public void testLoadGemFirePropertiesWithNullURL() {
+    PropertiesResolver propertiesResolver = new PropertiesResolver(null);
+    //assertThat(properties).isEmpty(); TODO
+  }
+
+  /**
+   * Extracted from AbstractLauncherTest
+   */
+  @Ignore
+  @Test
+  public void testLoadGemFirePropertiesWithNonExistingURL() throws 
MalformedURLException {
+    PropertiesResolver propertiesResolver = new PropertiesResolver(new 
URL("file:///path/to/non_existing/gemfire.properties"));
+    //assertThat(properties).isEmpty(); TODO
   }
 
   private File geodeInJarAsClasspathResource() throws IOException {
@@ -293,7 +373,7 @@ public class PropertiesResolverIntegrationTest {
     return file;
   }
 
-  public File createJar(String jarName, File inputFile) throws IOException
+  private File createJar(String jarName, File inputFile) throws IOException
   {
     Manifest manifest = new Manifest();
     manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");

Reply via email to