Return-Path:
+ * The default value is {@link #PROPERTIES_FILE_DEFAULT}. However
+ * if the
+ * The default value is {@link #SECURITY_PROPERTIES_FILE_DEFAULT}. However
+ * if the
- * The default value of SECURITY_PROPERTY_FILE is
- *
+ * The default value of SECURITY_PROPERTY_FILE is
+ *
+ * See {@link #PROPERTIES_FILE_PROPERTY} for information on the name of
+ * the properties file and what locations it will be looked for in.
+ *
+ * @return a
- * See {@link #PROPERTY_FILE} for information on the name of
+ * See {@link #PROPERTIES_FILE_PROPERTY} for information on the name of
* the property file and what locations it will be looked for in.
+ *
* @return a
- * See {@link #SECURITY_PROPERTY_FILE} for information on the name of
- * the property file and what locations it will be looked for in.
- * @return a SystemMembershipEvent
that
-// * is delivered to all {@link
-// * com.gemstone.gemfire.admin.SystemMembershipListener}s.
-// *
-// * @param callback
-// * A user-specified object that is delivered with the {@link
-// * com.gemstone.gemfire.admin.SystemMembershipEvent}
-// * triggered by invoking this method.
-// *
-// * @see com.gemstone.gemfire.admin.SystemMembershipListener#memberInfo
-// *
-// * @since 4.0
-// */
-// public abstract void fireInfoEvent(Object callback);
+ /**
+ * The PROPERTIES_FILE_PROPERTY
is the system property
+ * that can be used to specify the name of the properties file that the
+ * connect method will check for when it looks for a properties file. Unless
+ * the value specifies the fully qualified path to the file, the file will
+ * be searched for, in order, in the following directories:
+ *
+ *
+ * Only the first file found will be used.
+ * PROPERTIES_FILE_PROPERTY
is set then its value
+ * will be used instead of the default. If this value is a relative file
+ * system path then the above search is done. If it is an absolute
+ * file system path then that file must exist; no search for it is
+ * done.
+ *
+ * @see #PROPERTIES_FILE_DEFAULT
+ * @see #getPropertiesFile()
+ * @since 9.0
+ */
+ public static final String PROPERTIES_FILE_PROPERTY = "gemfirePropertyFile";
+
+ /**
+ * The default value of PROPERTIES_FILE_PROPERTY
is
+ * "gemfire.properties"
. The location of the file will be
+ * resolved during connect as described for {@link #PROPERTIES_FILE_PROPERTY}.
+ *
+ * @see #PROPERTIES_FILE_PROPERTY
+ * @see #getPropertiesFile()
+ * @since 9.0
+ */
+ public static final String PROPERTIES_FILE_DEFAULT = "gemfire.properties";
/**
+ * Returns the current value of {@link #PROPERTIES_FILE_PROPERTY} system
+ * property if set or the default value {@link #PROPERTIES_FILE_DEFAULT}.
+ *
+ * @see #PROPERTIES_FILE_PROPERTY
+ * @see #PROPERTIES_FILE_DEFAULT
+ * @since 9.0
+ */
+ public static String getPropertiesFile() {
+ return System.getProperty(PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_DEFAULT);
+ }
+
+ /**
* The PROPERTY_FILE
is the name of the
- * property file that the connect method will check for when
- * it looks for a property file.
+ * properties file that the connect method will check for when
+ * it looks for a properties file.
* The file will be searched for, in order, in the following directories:
*
*
SECURITY_PROPERTIES_FILE_PROPERTY
is the system property
+ * that can be used to specify the name of the property file that the
+ * connect method will check for when it looks for a property file. Unless
+ * the value specifies the fully qualified path to the file, the file will
+ * be searched for, in order, in the following directories:
+ *
+ *
+ * Only the first file found will be used.
+ * SECURITY_PROPERTIES_FILE_PROPERTY
is set then its value
+ * will be used instead of the default. If this value is a relative file
+ * system path then the above search is done. If it is an absolute
+ * file system path then that file must exist; no search for it is
+ * done.
+ *
+ * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+ * @see #getSecurityPropertiesFile()
+ * @since 9.0
+ */
+ public static final String SECURITY_PROPERTIES_FILE_PROPERTY = "gemfireSecurityPropertyFile";
+
+ /**
+ * The default value of SECURITY_PROPERTIES_FILE_PROPERTY
is
+ * "gfsecurity.properties"
. The location of the file will be
+ * resolved during connect as described for {@link #SECURITY_PROPERTIES_FILE_PROPERTY}.
+ *
+ * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+ * @see #getSecurityPropertiesFile()
+ * @since 9.0
+ */
+ public static final String SECURITY_PROPERTIES_FILE_DEFAULT = "gfsecurity.properties";
/**
+ * Returns the current value of {@link #SECURITY_PROPERTIES_FILE_PROPERTY} system
+ * property if set or the default value {@link #SECURITY_PROPERTIES_FILE_DEFAULT}.
+ *
+ * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+ * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+ * @since 9.0
+ */
+ public static String getSecurityPropertiesFile() {
+ return System.getProperty(SECURITY_PROPERTIES_FILE_PROPERTY, SECURITY_PROPERTIES_FILE_DEFAULT);
+ }
+
+ /**
* The SECURITY_PROPERTY_FILE
is the name of the
- * property file that the connect method will check for when
- * it looks for a security property file.
- * The file will be searched for, in order, in the following directories:
- *
- *
- * Only the first file found will be used.
- * "gfsecurity.properties"
. However if the
- * "gemfireSecurityPropertyFile" system property is set then its value is
- * the value of SECURITY_PROPERTY_FILE. If this value is a relative file
- * system path then the above search is done. If it is an absolute
- * file system path then that file must exist; no search for it is
- * done.
- * @since 6.6.2
+ * property file that the connect method will check for when
+ * it looks for a security property file.
+ * The file will be searched for, in order, in the following directories:
+ *
+ *
+ * Only the first file found will be used.
+ * "gfsecurity.properties"
. However if the
+ * "gemfireSecurityPropertyFile" system property is set then its value is
+ * the value of SECURITY_PROPERTY_FILE. If this value is a relative file
+ * system path then the above search is done. If it is an absolute
+ * file system path then that file must exist; no search for it is
+ * done.
+ *
+ * @see #getSecurityPropertiesFile()
+ * @since 6.6.2
+ * @deprecated As of 9.0, please use {@link #getSecurityPropertiesFile()} instead.
*/
- public static final String SECURITY_PROPERTY_FILE = System.getProperty("gemfireSecurityPropertyFile",
- "gfsecurity.properties");
+ public static String SECURITY_PROPERTY_FILE = getSecurityPropertiesFile();
+
+ /**
+ * Gets an URL
for the properties file, if one can be found,
+ * that the connect method will use as its properties file.
+ * URL
that names the GemFire property file.
+ * Null is returned if no property file was found.
+ * @see #PROPERTIES_FILE_PROPERTY
+ * @see #PROPERTIES_FILE_DEFAULT
+ * @see #getPropertiesFile()
+ * @since 9.0
+ */
+ public static URL getPropertiesFileURL() {
+ return getFileURL(getPropertiesFile());
+ }
/**
* Gets an URL
for the property file, if one can be found,
* that the connect method will use as its property file.
* URL
that names the GemFire property file.
* Null is returned if no property file was found.
+ * @see #getPropertiesFileURL()
* @since 5.0
+ * @deprecated As of 9.0, please use {@link #getPropertiesFileURL()}
*/
public static URL getPropertyFileURL() {
- return getFileURL(PROPERTY_FILE);
+ return getPropertiesFileURL();
}
/**
- * Gets an URL
for the security property file, if one can be found,
- * that the connect method will use as its property file.
+ * Gets an URL
for the security properties file, if one can be found,
+ * that the connect method will use as its properties file.
* URL
that names the GemFire security property file.
- * Null is returned if no property file was found.
+ * See {@link #SECURITY_PROPERTIES_FILE_PROPERTY} for information on the name of
+ * the properties file and what locations it will be looked for in.
+ *
+ * @return a URL
that names the GemFire security properties file.
+ * Null is returned if no properties file was found.
+ * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+ * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+ * @see #getSecurityPropertiesFile()
* @since 6.6.2
*/
public static URL getSecurityPropertiesFileURL() {
- return getFileURL(SECURITY_PROPERTY_FILE);
+ return getFileURL(getSecurityPropertiesFile());
}
private static URL getFileURL(String fileName) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..745090d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 com.gemstone.gemfire.distributed;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.util.Properties;
+
+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 com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for AbstractLauncher class. These tests require file system I/O.
+ */
+@Category(IntegrationTest.class)
+public class AbstractLauncherIntegrationJUnitTest {
+
+ @Rule
+ public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public final TestName testName = new TestName();
+
+ private File gemfirePropertiesFile;
+ private Properties expectedGemfireProperties;
+
+ @Before
+ public void setUp() throws Exception {
+ this.gemfirePropertiesFile = this.temporaryFolder.newFile("gemfire.properties");
+
+ this.expectedGemfireProperties = new Properties();
+ this.expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
+ this.expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "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/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
index 399c78f..7b8a6bb 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
@@ -18,8 +18,6 @@ package com.gemstone.gemfire.distributed;
import static org.junit.Assert.*;
-import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
@@ -45,10 +43,10 @@ import org.junit.experimental.categories.Category;
* @since 7.0
*/
@Category(UnitTest.class)
-public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
+public class AbstractLauncherJUnitTest {
protected AbstractLauncher> createAbstractLauncher(final String memberName, final String memberId) {
- return new TestServiceLauncher(memberName, memberId);
+ return new FakeServiceLauncher(memberName, memberId);
}
@Test
@@ -111,26 +109,6 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testLoadGemFirePropertiesFromFile() throws IOException {
- final Properties expectedGemfireProperties = new Properties();
-
- expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
- expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
-
- final File gemfirePropertiesFile = writeGemFirePropertiesToFile(expectedGemfireProperties, "gemfire.properties",
- "Test gemfire.properties file for AbstractLauncherJUnitTest.testLoadGemFirePropertiesFromFile");
-
- assertNotNull(gemfirePropertiesFile);
- assertTrue(gemfirePropertiesFile.isFile());
-
- final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(
- gemfirePropertiesFile.toURI().toURL());
-
- assertNotNull(actualGemFireProperties);
- assertEquals(expectedGemfireProperties, actualGemFireProperties);
- }
-
- @Test
public void testGetDistributedSystemProperties() {
AbstractLauncher> launcher = createAbstractLauncher("memberOne", "1");
@@ -274,12 +252,12 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
}
- protected static final class TestServiceLauncher extends AbstractLauncher
+ *
+ */
+ private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+ File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+ System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+
+ gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+ assertThat(propertiesFile.isFile()).isTrue();
+ assertThat(propertiesFile.exists()).isTrue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
index 003a098..c1b6ed0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
@@ -17,14 +17,9 @@
package com.gemstone.gemfire.distributed;
import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.util.Properties;
import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
@@ -34,8 +29,11 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
import joptsimple.OptionException;
+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.TestName;
/**
* The LocatorLauncherJUnitTest class is a test suite of test cases for testing the contract and functionality of
@@ -52,46 +50,13 @@ import org.junit.experimental.categories.Category;
* @since 7.0
*/
@Category(UnitTest.class)
-public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
+public class LocatorLauncherJUnitTest {
- @Test
- public void testBuilderParseArguments() throws Exception {
- String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath().toString();
- Builder builder = new Builder();
-
- builder.parseArguments("start", "memberOne", "--bind-address", InetAddress.getLocalHost().getHostAddress(),
- "--dir", expectedWorkingDirectory, "--hostname-for-clients", "Tucows", "--pid", "1234", "--port", "11235",
- "--redirect-output", "--force", "--debug");
-
- assertEquals(Command.START, builder.getCommand());
- assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
- assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
- assertEquals("Tucows", builder.getHostnameForClients());
- assertEquals(1234, builder.getPid().intValue());
- assertEquals(11235, builder.getPort().intValue());
- assertTrue(builder.getRedirectOutput());
- assertTrue(builder.getForce());
- assertTrue(builder.getDebug());
- }
-
- @Test
- public void testBuilderParseArgumentsWithCommandInArguments() throws Exception {
- String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath().toString();
- Builder builder = new Builder();
-
- builder.parseArguments("start", "--dir=" + expectedWorkingDirectory, "--port", "12345", "memberOne");
-
- assertEquals(Command.START, builder.getCommand());
- assertFalse(Boolean.TRUE.equals(builder.getDebug()));
- assertFalse(Boolean.TRUE.equals(builder.getForce()));
- assertFalse(Boolean.TRUE.equals(builder.getHelp()));
- assertNull(builder.getBindAddress());
- assertNull(builder.getHostnameForClients());
- assertEquals("12345", builder.getMemberName());
- assertNull(builder.getPid());
- assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
- assertEquals(12345, builder.getPort().intValue());
- }
+ @Rule
+ public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
+ public final TestName testName = new TestName();
@Test(expected = IllegalArgumentException.class)
public void testBuilderParseArgumentsWithNonNumericPort() {
@@ -307,59 +272,6 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testSetAndGetWorkingDirectory() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
- Builder builder = new Builder();
-
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(""));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(" "));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(rootFolder));
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToFile() throws IOException {
- File tmpFile = File.createTempFile("tmp", "file");
-
- assertNotNull(tmpFile);
- assertTrue(tmpFile.isFile());
-
- tmpFile.deleteOnExit();
-
- try {
- new Builder().setWorkingDirectory(tmpFile.getCanonicalPath());
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals(tmpFile.getCanonicalPath(), expected.getCause().getMessage());
- throw expected;
- }
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToNonExistingDirectory() {
- try {
- new Builder().setWorkingDirectory("/path/to/non_existing/directory");
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
- throw expected;
- }
- }
-
- @Test
public void testBuild() throws Exception {
Builder builder = new Builder();
@@ -396,26 +308,6 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testBuildWithMemberNameSetInGemfirePropertiesOnStart() throws Exception {
- System.setProperty("user.dir", this.temporaryFolder.getRoot().getCanonicalPath());
-
- Properties gemfireProperties = new Properties();
- gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "locator123");
- File gemfirePropertiesFile = writeGemFirePropertiesToFile(gemfireProperties, "gemfire.properties",
- String.format("Test gemfire.properties file for %1$s.%2$s.", getClass().getSimpleName(),
- "testBuildWithMemberNameSetInGemfirePropertiesOnStart"));
-
- assertNotNull(gemfirePropertiesFile);
- assertTrue(gemfirePropertiesFile.isFile());
-
- LocatorLauncher launcher = new Builder().setCommand(Command.START).setMemberName(null).build();
-
- assertNotNull(launcher);
- assertEquals(Command.START, launcher.getCommand());
- assertNull(launcher.getMemberName());
- }
-
- @Test
public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "locatorXYZ");
@@ -428,32 +320,4 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
assertNull(launcher.getMemberName());
}
-
- @Test(expected = IllegalStateException.class)
- public void testBuildWithNoMemberNameOnStart() throws Exception {
- System.setProperty("user.dir", this.temporaryFolder.getRoot().getCanonicalPath());
- try {
- new Builder().setCommand(Command.START).build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"),
- expected.getMessage());
- throw expected;
- }
- }
-
- @Test(expected = IllegalStateException.class)
- public void testBuildWithMismatchingCurrentAndWorkingDirectoryOnStart() throws Exception {
- try {
- new Builder().setCommand(Command.START)
- .setMemberName("memberOne")
- .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath().toString())
- .build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- throw expected;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..b61f89d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
@@ -0,0 +1,312 @@
+/*
+ * 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 com.gemstone.gemfire.distributed;
+
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.net.InetAddress;
+import java.util.Properties;
+
+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 com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.ServerLauncher.Command;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for ServerLauncher class. These tests may require file system and/or network I/O.
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherIntegrationJUnitTest {
+
+ @Rule
+ public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
+ public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public final TestName testName = new TestName();
+
+ @Test
+ public void testBuildWithManyArguments() throws Exception {
+ // given
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+ // when
+ ServerLauncher launcher = new Builder()
+ .setCommand(Command.STOP)
+ .setAssignBuckets(true)
+ .setForce(true)
+ .setMemberName("serverOne")
+ .setRebalance(true)
+ .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
+ .setServerPort(11235)
+ .setWorkingDirectory(rootFolder)
+ .setCriticalHeapPercentage(90.0f)
+ .setEvictionHeapPercentage(75.0f)
+ .setMaxConnections(100)
+ .setMaxMessageCount(512)
+ .setMaxThreads(8)
+ .setMessageTimeToLive(120000)
+ .setSocketBufferSize(32768)
+ .build();
+
+ // then
+ assertThat(launcher).isNotNull();
+ assertThat(launcher.isAssignBuckets()).isTrue();
+ assertThat(launcher.isDebugging()).isFalse();
+ assertThat(launcher.isDisableDefaultServer()).isFalse();
+ assertThat(launcher.isForcing()).isTrue();
+ assertThat(launcher.isHelping()).isFalse();
+ assertThat(launcher.isRebalancing()).isTrue();
+ assertThat(launcher.isRunning()).isFalse();
+ assertThat(launcher.getCommand()).isEqualTo(Command.STOP);
+ assertThat(launcher.getMemberName()).isEqualTo("serverOne");
+ assertThat(launcher.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(launcher.getServerPort().intValue()).isEqualTo(11235);
+ assertThat(launcher.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(launcher.getCriticalHeapPercentage().floatValue()).isEqualTo(90.0f);
+ assertThat(launcher.getEvictionHeapPercentage().floatValue()).isEqualTo(75.0f);
+ assertThat(launcher.getMaxConnections().intValue()).isEqualTo(100);
+ assertThat(launcher.getMaxMessageCount().intValue()).isEqualTo(512);
+ assertThat(launcher.getMaxThreads().intValue()).isEqualTo(8);
+ assertThat(launcher.getMessageTimeToLive().intValue()).isEqualTo(120000);
+ assertThat(launcher.getSocketBufferSize().intValue()).isEqualTo(32768);
+ }
+
+ @Test
+ public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
+ // given a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+ Builder builder = new Builder();
+
+ // when: parsing many arguments
+ builder.parseArguments(
+ "start",
+ "serverOne",
+ "--assign-buckets",
+ "--disable-default-server",
+ "--debug",
+ "--force",
+ "--rebalance",
+ "--redirect-output",
+ "--dir", rootFolder,
+ "--pid", "1234",
+ "--server-bind-address", InetAddress.getLocalHost().getHostAddress(),
+ "--server-port", "11235",
+ "--hostname-for-clients", "192.168.99.100");
+
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getMemberName()).isEqualTo("serverOne");
+ assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+ assertThat(builder.getAssignBuckets()).isTrue();
+ assertThat(builder.getDisableDefaultServer()).isTrue();
+ assertThat(builder.getDebug()).isTrue();
+ assertThat(builder.getForce()).isTrue();
+ assertThat(builder.getHelp()).isFalse();
+ assertThat(builder.getRebalance()).isTrue();
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
+ }
+
+ @Test
+ public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
+ // given a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+ Builder builder = new Builder();
+
+ // when: parsing many arguments
+ builder.parseArguments(
+ "start",
+ "serverOne",
+ "--assign-buckets",
+ "--disable-default-server",
+ "--debug",
+ "--force",
+ "--rebalance",
+ "--redirect-output",
+ "--dir=" + rootFolder,
+ "--pid=1234",
+ "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(),
+ "--server-port=11235",
+ "--hostname-for-clients=192.168.99.100");
+
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getMemberName()).isEqualTo("serverOne");
+ assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+ assertThat(builder.getAssignBuckets()).isTrue();
+ assertThat(builder.getDisableDefaultServer()).isTrue();
+ assertThat(builder.getDebug()).isTrue();
+ assertThat(builder.getForce()).isTrue();
+ assertThat(builder.getHelp()).isFalse();
+ assertThat(builder.getRebalance()).isTrue();
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
+ }
+
+ @Test
+ public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
+ // given: gemfire.properties with a name
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
+
+ // when: starting with null MemberName
+ ServerLauncher launcher = new Builder()
+ .setCommand(Command.START)
+ .setMemberName(null)
+ .build();
+
+ // then: name in gemfire.properties file should be used for MemberName
+ assertThat(launcher).isNotNull();
+ assertThat(launcher.getCommand()).isEqualTo(Command.START);
+ assertThat(launcher.getMemberName()).isNull();
+ }
+
+ @Test
+ public void testBuildWithNoMemberNameOnStart() throws Exception {
+ // given: gemfire.properties with no name
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
+
+ // when: no MemberName is specified
+ when(new Builder()
+ .setCommand(Command.START))
+ .build();
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"));
+ }
+
+ @Test
+ public void testBuilderSetAndGetWorkingDirectory() throws Exception {
+ // given: a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+ Builder builder = new Builder();
+
+ // when: not setting WorkingDirectory
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(ServerLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to null
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to empty string
+ assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to white space
+ assertThat(builder.setWorkingDirectory(" ")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to a directory
+ assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
+ // then: getWorkingDirectory returns that directory
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+
+ // when: setting WorkingDirectory to null (again)
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+ }
+
+ @Test
+ public void testBuilderSetWorkingDirectoryToFile() throws Exception {
+ // given: a file instead of a directory
+ File tmpFile = this.temporaryFolder.newFile();
+
+ // when: setting WorkingDirectory to that file
+ when(new Builder())
+ .setWorkingDirectory(tmpFile.getAbsolutePath());
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+ .hasCause(new FileNotFoundException(tmpFile.getAbsolutePath()));
+ }
+
+ @Test
+ public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
+ // given: using ServerLauncher in-process
+
+ // when: setting WorkingDirectory to non-current directory
+ when(new Builder()
+ .setCommand(Command.START)
+ .setMemberName("serverOne")
+ .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
+ .build();
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Server"));
+ }
+
+ @Test
+ public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
+ // when: setting WorkingDirectory to non-existing directory
+ when(new Builder())
+ .setWorkingDirectory("/path/to/non_existing/directory");
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+ .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
+ }
+
+ /**
+ * Creates a gemfire properties file in temporaryFolder:
+ * fileName
in temporaryFolder
gemfireProperties
to the filefileName
in temporaryFolder
+ * gemfireProperties
to the file
+ */
+ private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+ File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+ System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+
+ gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+ assertThat(propertiesFile.isFile()).isTrue();
+ assertThat(propertiesFile.exists()).isTrue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
index 6884e58..802df9f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
@@ -46,8 +46,11 @@ import org.jmock.lib.legacy.ClassImposteriser;
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.TestName;
/**
* The ServerLauncherJUnitTest class is a test suite of unit tests testing the contract, functionality and invariants
@@ -65,10 +68,16 @@ import org.junit.experimental.categories.Category;
*/
@SuppressWarnings({"deprecation", "unused"})
@Category(UnitTest.class)
-public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
+public class ServerLauncherJUnitTest {
private Mockery mockContext;
+ @Rule
+ public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
+ public final TestName testName = new TestName();
+
@Before
public void setup() {
mockContext = new Mockery() {{
@@ -84,31 +93,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testParseArguments() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
- Builder builder = new Builder();
-
- builder.parseArguments("start", "serverOne", "--assign-buckets", "--disable-default-server", "--debug", "--force",
- "--rebalance", "--redirect-output", "--dir=" + rootFolder, "--pid=1234",
- "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(), "--server-port=11235", "--hostname-for-clients=192.168.99.100");
-
- assertEquals(Command.START, builder.getCommand());
- assertEquals("serverOne", builder.getMemberName());
- assertEquals("192.168.99.100", builder.getHostNameForClients());
- assertTrue(builder.getAssignBuckets());
- assertTrue(builder.getDisableDefaultServer());
- assertTrue(builder.getDebug());
- assertTrue(builder.getForce());
- assertFalse(Boolean.TRUE.equals(builder.getHelp()));
- assertTrue(builder.getRebalance());
- assertTrue(builder.getRedirectOutput());
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertEquals(1234, builder.getPid().intValue());
- assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
- assertEquals(11235, builder.getServerPort().intValue());
- }
-
- @Test
public void testParseCommand() {
Builder builder = new Builder();
@@ -323,57 +307,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testSetAndGetWorkingDirectory() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
- Builder builder = new Builder();
-
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(rootFolder));
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(" "));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(""));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToNonExistingDirectory() {
- try {
- new Builder().setWorkingDirectory("/path/to/non_existing/directory");
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
- throw expected;
- }
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToFile() throws IOException {
- File tmpFile = File.createTempFile("tmp", "file");
-
- assertNotNull(tmpFile);
- assertTrue(tmpFile.isFile());
-
- tmpFile.deleteOnExit();
-
- try {
- new Builder().setWorkingDirectory(tmpFile.getAbsolutePath());
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals(tmpFile.getAbsolutePath(), expected.getCause().getMessage());
- throw expected;
- }
- }
-
- @Test
public void testSetAndGetCriticalHeapPercentage() {
Builder builder = new Builder();
@@ -550,50 +483,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testBuild() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-
- ServerLauncher launcher = new Builder()
- .setCommand(Command.STOP)
- .setAssignBuckets(true)
- .setForce(true)
- .setMemberName("serverOne")
- .setRebalance(true)
- .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
- .setServerPort(11235)
- .setWorkingDirectory(rootFolder)
- .setCriticalHeapPercentage(90.0f)
- .setEvictionHeapPercentage(75.0f)
- .setMaxConnections(100)
- .setMaxMessageCount(512)
- .setMaxThreads(8)
- .setMessageTimeToLive(120000)
- .setSocketBufferSize(32768)
- .build();
-
- assertNotNull(launcher);
- assertTrue(launcher.isAssignBuckets());
- assertFalse(launcher.isDebugging());
- assertFalse(launcher.isDisableDefaultServer());
- assertTrue(launcher.isForcing());
- assertFalse(launcher.isHelping());
- assertTrue(launcher.isRebalancing());
- assertFalse(launcher.isRunning());
- assertEquals(Command.STOP, launcher.getCommand());
- assertEquals("serverOne", launcher.getMemberName());
- assertEquals(InetAddress.getLocalHost(), launcher.getServerBindAddress());
- assertEquals(11235, launcher.getServerPort().intValue());
- assertEquals(rootFolder, launcher.getWorkingDirectory());
- assertEquals(90.0f, launcher.getCriticalHeapPercentage().floatValue(), 0.0f);
- assertEquals(75.0f, launcher.getEvictionHeapPercentage().floatValue(), 0.0f);
- assertEquals(100, launcher.getMaxConnections().intValue());
- assertEquals(512, launcher.getMaxMessageCount().intValue());
- assertEquals(8, launcher.getMaxThreads().intValue());
- assertEquals(120000, launcher.getMessageTimeToLive().intValue());
- assertEquals(32768, launcher.getSocketBufferSize().intValue());
- }
-
- @Test
public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
ServerLauncher launcher = new Builder()
.setCommand(ServerLauncher.Command.START)
@@ -607,24 +496,10 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
assertEquals("serverABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
}
- @Ignore("GEODE-69: We need to change DistributedSystem to not use static final for gemfirePropertyFile")
@Test
- public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() {
- Properties gemfireProperties = new Properties();
-
- gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
-
- File gemfirePropertiesFile = writeGemFirePropertiesToFile(
- gemfireProperties,
- "gemfire.properties",
- String.format("Test gemfire.properties file for %1$s.%2$s.", getClass().getSimpleName(), this.testName.getMethodName()));
-
- assertNotNull(gemfirePropertiesFile);
- assertTrue(gemfirePropertiesFile.isFile());
+ public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
+ System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "serverXYZ");
- System.setProperty("gemfirePropertyFile", gemfirePropertiesFile.getAbsolutePath());
- System.out.println("gemfirePropertiesFile.getAbsolutePath()=" + gemfirePropertiesFile.getAbsolutePath());
-
ServerLauncher launcher = new Builder()
.setCommand(ServerLauncher.Command.START)
.setMemberName(null)
@@ -635,25 +510,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
assertNull(launcher.getMemberName());
}
- @Test
- public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
- try {
- System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "serverXYZ");
-
- ServerLauncher launcher = new Builder()
- .setCommand(ServerLauncher.Command.START)
- .setMemberName(null)
- .build();
-
- assertNotNull(launcher);
- assertEquals(ServerLauncher.Command.START, launcher.getCommand());
- assertNull(launcher.getMemberName());
- }
- finally {
- System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME);
- }
- }
-
@Test(expected = IllegalStateException.class)
public void testBuildNoMemberNameOnStart() {
try {
@@ -666,21 +522,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
}
}
- @Test(expected = IllegalStateException.class)
- public void testBuildWithInvalidWorkingDirectoryOnStart() throws Exception {
- try {
- new Builder().setCommand(Command.START)
- .setMemberName("serverOne")
- .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath().toString())
- .build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- throw expected;
- }
- }
-
@Test
public void testIsServing() {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
index e99dceb..a2f02c4 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
@@ -16,83 +16,74 @@
*/
package com.gemstone.gemfire.test.process;
-import java.util.List;
+import java.util.concurrent.TimeUnit;
/**
- * Reads the stdout and stderr from a running process and stores then for test
- * validation. Also provides a mechanism to waitFor the process to terminate.
+ * Starts the stdout and stderr reader threads for a running process. Provides
+ * a mechanism to waitFor the process to terminate.
+ *