You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/10/11 22:12:06 UTC

[1/2] incubator-geode git commit: Added some tests and TODOs for PropertiesResolver

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1466 b2d85b4b0 -> d26b03cf8


Added some tests and TODOs for PropertiesResolver


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

Branch: refs/heads/feature/GEODE-1466
Commit: 47bef6a85282fb346b86c71e692d7bbab7385665
Parents: b2d85b4
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Oct 11 13:27:05 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Oct 11 13:27:05 2016 -0700

----------------------------------------------------------------------
 .../geode/distributed/DistributedSystem.java    |   4 +-
 .../geode/distributed/LocatorLauncher.java      |   2 +-
 .../geode/internal/PropertiesResolver.java      |  81 ++++++++
 .../PropertiesResolverIntegrationTest.java      | 187 +++++++++++++++++++
 4 files changed, 271 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47bef6a8/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 d0c7366..e5c420d 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
@@ -569,7 +569,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
    * @see #getPropertiesFile()
    * @since Geode 1.0
    */
-  public static final String PROPERTIES_FILE_DEFAULT = DistributionConfig.GEMFIRE_PREFIX + "properties";
+  public static final String PROPERTIES_FILE_DEFAULT = DistributionConfig.GEMFIRE_PREFIX + "properties"; // TODO: GEODE-1466
 
   /**
    * Returns the current value of {@link #PROPERTIES_FILE_PROPERTY} system 
@@ -579,7 +579,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
    * @see #PROPERTIES_FILE_DEFAULT
    * @since Geode 1.0
    */
-  public static String getPropertiesFile() {
+  public static String getPropertiesFile() { // TODO: GEODE-1466
 	return System.getProperty(PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_DEFAULT);
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47bef6a8/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 5db332e..b18ce81 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
@@ -1732,7 +1732,7 @@ public final class LocatorLauncher extends AbstractLauncher<String> {
         if (StringUtils.isBlank(getMemberName())
             && !isSet(System.getProperties(), DistributionConfig.GEMFIRE_PREFIX + NAME)
             && !isSet(getDistributedSystemProperties(), NAME)
-            && !isSet(loadGemFireProperties(DistributedSystem.getPropertyFileURL()), NAME))
+            && !isSet(loadGemFireProperties(DistributedSystem.getPropertyFileURL()), NAME)) // TODO: GEODE-1466
         {
           throw new IllegalStateException(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE
             .toLocalizedString("Locator"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47bef6a8/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
new file mode 100644
index 0000000..ce5c3e5
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/PropertiesResolver.java
@@ -0,0 +1,81 @@
+/*
+ * 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.internal;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.util.IOUtils;
+
+public class PropertiesResolver {
+
+  static final String GEODE_PROPERTIES_FILE_PROPERTY = "geodePropertyFile";
+  static final String GEMFIRE_PROPERTIES_FILE_PROPERTY = DistributedSystem.PROPERTIES_FILE_PROPERTY;
+  static final String DEFAULT_GEODE_PROPERTIES_FILE_NAME = "geode.properties";
+  static final String DEFAULT_GEMFIRE_PROPERTIES_FILE_NAME = "gemfire.properties";
+
+  private static URI propertiesFileURL = findPropertiesFileLocation();
+
+  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));
+
+    return possibleUrls.stream().filter(s -> s != null).findFirst().orElse(null);
+  }
+
+  static boolean hasProperty(final String key) {
+    return System.getProperties().containsKey(DistributedSystem.PROPERTIES_FILE_PROPERTY);
+  }
+
+  private static URI getFileURI(String fileName) {
+    if (fileName == null) {
+      return null;
+    }
+
+    File file = new File(fileName); // absolute path or current dir
+
+    if (file.exists()) {
+        return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI();
+    }
+
+    file = new File(System.getProperty("user.home"), fileName); // user home
+
+    if (file.exists()) {
+        return IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(file).toURI();
+    }
+
+    return getResourceOrNull(fileName); // resource
+  }
+
+  private static URI getResourceOrNull(final String name) {
+    try {
+      URL url = ClassPathLoader.getLatest().getResource(DistributedSystem.class, name); // resource
+      return (url == null) ? null : url.toURI();
+    } catch (URISyntaxException ignore) {
+      return null;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/47bef6a8/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
new file mode 100644
index 0000000..c866e10
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/PropertiesResolverIntegrationTest.java
@@ -0,0 +1,187 @@
+/*
+ * 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.internal;
+
+import static org.apache.geode.internal.PropertiesResolver.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+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.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+public class PropertiesResolverIntegrationTest {
+
+  private File geodeCustomProperties;
+  private File gemfireCustomProperties;
+
+  List<File> files = new ArrayList<>();
+
+
+  @Rule
+  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public void createFiles() throws Exception {
+    this.geodeCustomProperties = this.temporaryFolder.newFile("geodeCustom.properties");
+    this.gemfireCustomProperties = this.temporaryFolder.newFile("gemfireCustom.properties");
+  }
+
+  @After
+  public void cleanup() throws Exception {
+    for (File file: files) {
+      FileUtils.forceDelete(file);
+    }
+  }
+
+  @Test
+  public void canSpecifyGeodePropertiesFileAbsolutePath() throws Exception {
+    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, this.geodeCustomProperties.getCanonicalPath());
+    assertThat(findPropertiesFileLocation()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void canSpecifyGeodePropertiesFileInCurrentDir() throws Exception {
+    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, geodeCustomFileInCurrentDir().getName());
+    assertThat(findPropertiesFileLocation()).isEqualTo(geodeCustomFileInCurrentDir().getCanonicalFile().toURI());
+  }
+
+ @Test
+  public void canSpecifyGeodePropertiesFileInUserHomeDir() throws Exception {
+    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, geodeCustomFileInHomeDir().getName());
+    assertThat(findPropertiesFileLocation()).isEqualTo(geodeCustomFileInHomeDir().getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void canSpecifyGemFirePropertiesFileAbsolutePath() throws Exception {
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, this.gemfireCustomProperties.getCanonicalPath());
+    assertThat(findPropertiesFileLocation()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void canSpecifyGemFirePropertiesFileInCurrentDir() throws Exception {
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, gemfireCustomFileInCurrentDir().getName());
+    assertThat(findPropertiesFileLocation()).isEqualTo(gemfireCustomFileInCurrentDir().getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void canSpecifyGemFirePropertiesFileInUserHomeDir() throws Exception {
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, gemfireCustomFileInHomeDir().getName());
+    assertThat(findPropertiesFileLocation()).isEqualTo(gemfireCustomFileInHomeDir().getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void findPrefersGeodePropertiesFileFirst() throws Exception {
+    System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, this.geodeCustomProperties.getCanonicalPath());
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, this.gemfireCustomProperties.getCanonicalPath());
+    geodeDefaultFileInCurrentDir();
+    gemfireDefaultFileInCurrentDir();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(this.geodeCustomProperties.getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void findPrefersGemFirePropertiesFileSecond() throws Exception {
+    System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, this.gemfireCustomProperties.getCanonicalPath());
+    geodeDefaultFileInCurrentDir();
+    gemfireDefaultFileInCurrentDir();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(this.gemfireCustomProperties.getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void findPrefersGeodeDefaultThird() throws Exception {
+    geodeDefaultFileInCurrentDir();
+    gemfireDefaultFileInCurrentDir();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInCurrentDir().getCanonicalFile().toURI());
+  }
+
+  @Test
+  public void findPrefersGemFireDefaultFourth() throws Exception {
+    gemfireDefaultFileInCurrentDir();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(gemfireDefaultFileInCurrentDir().getCanonicalFile().toURI());
+  }
+
+  private File geodeDefaultFileInHomeDir() {
+    return createFileInHomeDir("geode.properties");
+  }
+
+  private File geodeDefaultFileInCurrentDir() {
+    return createFileInCurrentDir("geode.properties");
+  }
+  private File gemfireDefaultFileInHomeDir() {
+    return createFileInHomeDir("gemfire.properties");
+  }
+
+  private File gemfireDefaultFileInCurrentDir() {
+    return createFileInCurrentDir("gemfire.properties");
+  }
+  private File gemfireCustomFileInHomeDir() {
+    return createFileInHomeDir("gemfireCustomFileInHomeDir.properties");
+  }
+
+  private File gemfireCustomFileInCurrentDir() {
+    return createFileInCurrentDir("gemfireCustomFileInCurrentDir.properties");
+  }
+
+  private File geodeCustomFileInHomeDir() {
+    return createFileInHomeDir("geodeCustomFileInHomeDir.properties");
+  }
+  private File geodeCustomFileInCurrentDir()  {
+    return createFileInCurrentDir("geodeCustomFileInCurrentDir.properties");
+  }
+  
+  private File createFileInCurrentDir(String name) {
+    return createFile(System.getProperty("user.dir"), name);
+  }
+  private File createFileInHomeDir(String name){
+    return createFile(System.getProperty("user.home"), name);
+  }
+
+  private File createFile(String parent, String child) {
+    File file = new File(parent, child);
+
+    if (file.exists()) {
+      return file;
+    }
+    try {
+      assertThat(file.createNewFile()).isTrue();
+      files.add(file);
+      file.deleteOnExit();
+    } catch(IOException e) {
+      throw new AssertionError(e);
+    }
+    return file;
+  }
+}
\ No newline at end of file


[2/2] incubator-geode git commit: Added more tests for PropertiesResolver

Posted by kl...@apache.org.
Added more tests for PropertiesResolver


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

Branch: refs/heads/feature/GEODE-1466
Commit: d26b03cf848afe5030584e50a060f2dded6c6f54
Parents: 47bef6a
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Oct 11 15:12:32 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Oct 11 15:12:32 2016 -0700

----------------------------------------------------------------------
 .../geode/internal/PropertiesResolver.java      |   2 +-
 .../PropertiesResolverIntegrationTest.java      | 148 ++++++++++++++++++-
 2 files changed, 148 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d26b03cf/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 ce5c3e5..f105bcd 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
@@ -71,7 +71,7 @@ public class PropertiesResolver {
 
   private static URI getResourceOrNull(final String name) {
     try {
-      URL url = ClassPathLoader.getLatest().getResource(DistributedSystem.class, name); // resource
+      URL url = ClassPathLoader.getLatest().getResource(name); // resource
       return (url == null) ? null : url.toURI();
     } catch (URISyntaxException ignore) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d26b03cf/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 c866e10..c317ded 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
@@ -19,10 +19,20 @@ package org.apache.geode.internal;
 import static org.apache.geode.internal.PropertiesResolver.*;
 import static org.assertj.core.api.Assertions.*;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
@@ -59,7 +69,9 @@ public class PropertiesResolverIntegrationTest {
   @After
   public void cleanup() throws Exception {
     for (File file: files) {
-      FileUtils.forceDelete(file);
+      try {
+        FileUtils.forceDelete(file);
+      } catch (Exception ignored) {}
     }
   }
 
@@ -100,6 +112,89 @@ public class PropertiesResolverIntegrationTest {
   }
 
   @Test
+  public void searchesCurrentDirFirst() throws Exception {
+    geodeDefaultFileInCurrentDir();
+    geodeDefaultFileInHomeDir();
+    geodeInJarAsClasspathResource();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInCurrentDir().toURI());
+  }
+
+  @Test
+  public void searchesHomeDirSecond() throws Exception {
+    geodeDefaultFileInHomeDir();
+    geodeInJarAsClasspathResource();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(geodeDefaultFileInHomeDir().toURI());
+  }
+
+  @Test
+  public void searchesJarOnClasspathThird() throws Exception {
+    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_PROPERTY, "geodeInJar.properties");
+
+    URL url = propsFileInJarOnClasspath();
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(url.toURI());
+  }
+
+  @Test
+  public void searchesDirOnClasspathThird() throws Exception {
+    System.setProperty(PropertiesResolver.GEODE_PROPERTIES_FILE_PROPERTY, "geodeInDir.properties");
+
+    URL url = propsFileInDirOnClasspath(); // TODO
+
+    assertThat(findPropertiesFileLocation()).isEqualTo(url.toURI());
+  }
+
+  @Test
+  public void searchReturnsNullLast() throws Exception {
+    assertThat(findPropertiesFileLocation()).isNull();
+  }
+
+  private URL propsFileInJarOnClasspath() throws IOException, URISyntaxException {
+    //Create jar containing our properties file
+    File jar = geodeInJarAsClasspathResource();
+    
+    //Create classloader pointing to our jar
+    URLClassLoader ourClassLoader = new URLClassLoader(new URL[]{new URL("file://" + jar.getCanonicalPath())});
+    assertThat(ourClassLoader.getURLs()).hasSize(1);
+
+    //Make sure we can load the properties file from our jar
+    URL stream = ourClassLoader.getResource("geodeInJar.properties");
+    assertThat(stream).isNotNull();
+
+    //Add our classloader to Geode
+    ClassPathLoader.getLatest().addOrReplaceAndSetLatest(ourClassLoader);
+    assertThat(ClassPathLoader.getLatest().getClassLoaders()).contains(ourClassLoader);
+
+    //Get URL for properties file inside jar
+    URL url = ClassPathLoader.getLatest().getResource("geodeInJar.properties");
+    assertThat(url).isNotNull();
+    return url;
+  }
+
+  private URL propsFileInDirOnClasspath() throws IOException, URISyntaxException {
+    File propsFile = temporaryFolder.newFile("geodeInDir.properties");
+
+    //Create classloader pointing to our dir
+    URLClassLoader ourClassLoader = new URLClassLoader(new URL[]{temporaryFolder.getRoot().toURL()});
+    assertThat(ourClassLoader.getURLs()).hasSize(1);
+
+    //Make sure we can load the properties file from our jar
+    URL stream = ourClassLoader.getResource("geodeInDir.properties");
+    assertThat(stream).isNotNull();
+
+    //Add our classloader to Geode
+    ClassPathLoader.getLatest().addOrReplaceAndSetLatest(ourClassLoader);
+    assertThat(ClassPathLoader.getLatest().getClassLoaders()).contains(ourClassLoader);
+
+    //Get URL for properties file inside jar
+    URL url = ClassPathLoader.getLatest().getResource("geodeInDir.properties");
+    assertThat(url).isNotNull();
+    return url;
+  }
+
+  @Test
   public void findPrefersGeodePropertiesFileFirst() throws Exception {
     System.setProperty(GEODE_PROPERTIES_FILE_PROPERTY, this.geodeCustomProperties.getCanonicalPath());
     System.setProperty(GEMFIRE_PROPERTIES_FILE_PROPERTY, this.gemfireCustomProperties.getCanonicalPath());
@@ -133,6 +228,19 @@ public class PropertiesResolverIntegrationTest {
     assertThat(findPropertiesFileLocation()).isEqualTo(gemfireDefaultFileInCurrentDir().getCanonicalFile().toURI());
   }
 
+  private File geodeInJarAsClasspathResource() throws IOException {
+    File existingJar = new File(this.temporaryFolder.getRoot().getCanonicalPath(), "ourJar.jar");
+    if (existingJar.exists()){
+      return existingJar;
+    }
+
+    File tempFile = createFile(this.temporaryFolder.getRoot().getCanonicalPath(), "geodeInJar.properties");
+    File jar = createJar("ourJar.jar", tempFile);
+    FileUtils.forceDelete(tempFile);
+
+    return jar;
+  }
+
   private File geodeDefaultFileInHomeDir() {
     return createFileInHomeDir("geode.properties");
   }
@@ -184,4 +292,42 @@ public class PropertiesResolverIntegrationTest {
     }
     return file;
   }
+
+  public File createJar(String jarName, File inputFile) throws IOException
+  {
+    Manifest manifest = new Manifest();
+    manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+    File jarFile = createFile(this.temporaryFolder.getRoot().getCanonicalPath(), jarName);
+    JarOutputStream target = new JarOutputStream(new FileOutputStream(jarFile), manifest);
+    add(inputFile, target);
+    target.close();
+    return jarFile;
+  }
+
+  private void add(File source, JarOutputStream target) throws IOException
+  {
+    BufferedInputStream in = null;
+    try
+    {
+      JarEntry entry = new JarEntry(source.getName().replace("\\", "/"));
+      entry.setTime(source.lastModified());
+      target.putNextEntry(entry);
+      in = new BufferedInputStream(new FileInputStream(source));
+
+      byte[] buffer = new byte[1024];
+      while (true)
+      {
+        int count = in.read(buffer);
+        if (count == -1)
+          break;
+        target.write(buffer, 0, count);
+      }
+      target.closeEntry();
+    }
+    finally
+    {
+      if (in != null)
+        in.close();
+    }
+  }
 }
\ No newline at end of file