geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [37/37] incubator-geode git commit: Merge remote-tracking branch 'origin/develop' into feature/GEODE-1276
Date Fri, 06 May 2016 21:41:08 GMT
Merge remote-tracking branch 'origin/develop' into feature/GEODE-1276


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

Branch: refs/heads/feature/GEODE-1276
Commit: 7ce7ddc0401a4c53eefde7cc3236dd4a248ad1f2
Parents: d0f925c 4ad4d63
Author: Kirk Lund <klund@pivotal.io>
Authored: Fri May 6 11:30:09 2016 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Fri May 6 11:30:09 2016 -0700

----------------------------------------------------------------------
 .../LocatorLauncherAssemblyIntegrationTest.java |  155 ++
 .../LocatorLauncherAssemblyJUnitTest.java       |  156 --
 .../SharedConfigurationEndToEndDUnitTest.java   |  311 ++--
 .../gemfire/cache/execute/Function.java         |   17 +-
 .../gemfire/cache/execute/FunctionAdapter.java  |   87 +-
 .../cache/operations/OperationContext.java      |    4 -
 .../internal/SharedConfiguration.java           |  532 +++----
 .../cache/execute/FunctionAdapterJUnitTest.java |   65 +
 .../AbstractLauncherIntegrationJUnitTest.java   |   71 -
 .../AbstractLauncherIntegrationTest.java        |   71 +
 .../AbstractLauncherIntegrationTestCase.java    |  254 ++++
 .../distributed/AbstractLauncherJUnitTest.java  |  298 ----
 .../AbstractLauncherJUnitTestCase.java          |  254 ----
 .../AbstractLauncherServiceStatusJUnitTest.java |  259 ----
 .../AbstractLauncherServiceStatusTest.java      |  259 ++++
 .../distributed/AbstractLauncherTest.java       |  298 ++++
 ...tractLocatorLauncherIntegrationTestCase.java |  117 ++
 .../AbstractLocatorLauncherJUnitTestCase.java   |  105 --
 ...ocatorLauncherRemoteIntegrationTestCase.java |   67 +
 ...stractServerLauncherIntegrationTestCase.java |   95 ++
 .../AbstractServerLauncherJUnitTestCase.java    |   93 --
 ...ServerLauncherRemoteIntegrationTestCase.java |   95 ++
 .../distributed/DistributedTestSuite.java       |   35 -
 .../distributed/HostedLocatorsDUnitTest.java    |   30 +-
 .../LauncherMemberMXBeanIntegrationTest.java    |  151 ++
 .../LauncherMemberMXBeanJUnitTest.java          |  152 --
 .../gemfire/distributed/LauncherTestSuite.java  |   47 -
 .../gemfire/distributed/LocatorJUnitTest.java   |   67 +-
 .../LocatorLauncherIntegrationJUnitTest.java    |  248 ---
 .../LocatorLauncherIntegrationTest.java         |  248 +++
 .../distributed/LocatorLauncherJUnitTest.java   |  340 -----
 ...LocatorLauncherLocalFileIntegrationTest.java |   54 +
 .../LocatorLauncherLocalFileJUnitTest.java      |   51 -
 .../LocatorLauncherLocalIntegrationTest.java    |  827 ++++++++++
 .../LocatorLauncherLocalJUnitTest.java          |  842 -----------
 ...ocatorLauncherRemoteFileIntegrationTest.java |  218 +++
 .../LocatorLauncherRemoteFileJUnitTest.java     |  218 ---
 .../LocatorLauncherRemoteIntegrationTest.java   |  977 ++++++++++++
 .../LocatorLauncherRemoteJUnitTest.java         | 1011 -------------
 ...rRemoteWithCustomLoggingIntegrationTest.java |  124 ++
 .../distributed/LocatorLauncherTest.java        |  340 +++++
 .../distributed/LocatorStateJUnitTest.java      |  222 ---
 .../gemfire/distributed/LocatorStateTest.java   |  222 +++
 .../MockServerLauncherCacheProvider.java        |    8 +-
 .../ServerLauncherIntegrationJUnitTest.java     |  312 ----
 .../ServerLauncherIntegrationTest.java          |  311 ++++
 .../distributed/ServerLauncherJUnitTest.java    |  894 -----------
 .../ServerLauncherLocalFileIntegrationTest.java |   54 +
 .../ServerLauncherLocalFileJUnitTest.java       |   54 -
 .../ServerLauncherLocalIntegrationTest.java     | 1073 +++++++++++++
 .../ServerLauncherLocalJUnitTest.java           | 1073 -------------
 ...ServerLauncherRemoteFileIntegrationTest.java |  222 +++
 .../ServerLauncherRemoteFileJUnitTest.java      |  222 ---
 .../ServerLauncherRemoteIntegrationTest.java    | 1380 +++++++++++++++++
 .../ServerLauncherRemoteJUnitTest.java          | 1430 ------------------
 ...rRemoteWithCustomLoggingIntegrationTest.java |  122 ++
 .../gemfire/distributed/ServerLauncherTest.java |  894 +++++++++++
 ...rverLauncherWithProviderIntegrationTest.java |   89 ++
 .../ServerLauncherWithProviderJUnitTest.java    |   90 --
 .../gemstone/gemfire/internal/ClassBuilder.java |    2 +-
 .../cache/execute/FunctionServiceBase.java      |  287 ++++
 .../FunctionServiceLocalPRDUnitTest.java        |   54 +
 .../FunctionServiceLocalRRDUnitTest.java        |   52 +
 ...unctionServiceMultipleOnMemberDUnitTest.java |   57 +
 .../FunctionServicePeerAccessorPRDUnitTest.java |   73 +
 .../FunctionServicePeerAccessorRRDUnitTest.java |   63 +
 .../FunctionServiceSingleOnMemberDUnitTest.java |   49 +
 .../logging/log4j/custom/BasicAppender.java     |   76 +
 .../CustomConfigWithCacheIntegrationTest.java   |  148 ++
 ...stomConfigWithLogServiceIntegrationTest.java |  119 ++
 .../log4j/custom/CustomConfiguration.java       |   64 +
 ...leProcessControllerIntegrationJUnitTest.java |   13 +-
 .../management/internal/cli/HeadlessGfsh.java   |   23 +-
 .../cli/HeadlessGfshIntegrationTest.java        |   90 ++
 .../internal/cli/HeadlessGfshJUnitTest.java     |   85 --
 .../cli/commands/CliCommandTestBase.java        |   36 +-
 .../cli/commands/ConfigCommandsDUnitTest.java   |    8 +-
 .../ConnectCommandWithHttpAndSSLDUnitTest.java  |  305 ++++
 ...eateAlterDestroyRegionCommandsDUnitTest.java |    6 -
 .../cli/commands/DeployCommandsDUnitTest.java   |   59 +-
 .../commands/DiskStoreCommandsDUnitTest.java    |    5 -
 .../cli/commands/FunctionCommandsDUnitTest.java |    8 +-
 .../commands/GemfireDataCommandsDUnitTest.java  |    5 -
 ...WithCacheLoaderDuringCacheMissDUnitTest.java |  162 +-
 .../cli/commands/IndexCommandsDUnitTest.java    |    8 +-
 ...stAndDescribeDiskStoreCommandsDUnitTest.java |  121 +-
 .../ListAndDescribeRegionDUnitTest.java         |    5 -
 .../cli/commands/ListIndexCommandDUnitTest.java |  123 +-
 .../MiscellaneousCommandsDUnitTest.java         |    8 +-
 ...laneousCommandsExportLogsPart1DUnitTest.java |    8 +-
 ...laneousCommandsExportLogsPart2DUnitTest.java |    9 +-
 ...laneousCommandsExportLogsPart3DUnitTest.java |   10 +-
 ...laneousCommandsExportLogsPart4DUnitTest.java |    8 +-
 .../cli/commands/QueueCommandsDUnitTest.java    |    8 +-
 .../SharedConfigurationCommandsDUnitTest.java   |  288 ++--
 .../cli/commands/ShellCommandsDUnitTest.java    |   10 +-
 .../cli/commands/ShowMetricsDUnitTest.java      |    8 +-
 .../cli/commands/ShowStackTraceDUnitTest.java   |    8 +-
 .../cli/commands/UserCommandsDUnitTest.java     |   10 +-
 .../SharedConfigurationDUnitTest.java           |  227 ++-
 .../SharedConfigurationTestUtils.java           |   40 +
 .../SharedConfigurationUsingDirDUnitTest.java   |  128 +-
 .../security/GfshCommandsSecurityTest.java      |   17 +-
 .../security/GfshShellConnectionRule.java       |    8 +-
 .../logging/log4j/custom/log4j2-custom.xml      |   27 +
 .../pulse/internal/data/JMXDataUpdater.java     |    3 -
 .../cache/wan/Simple2CacheServerDUnitTest.java  |   24 +-
 .../wan/wancommand/WANCommandTestBase.java      |    2 +-
 .../ClusterConfigurationDUnitTest.java          | 1236 ++++++++-------
 gradle/dependency-versions.properties           |    8 +-
 110 files changed, 11939 insertions(+), 10577 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7ce7ddc0/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
index 0000000,c741def..940802f
mode 000000,100755..100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
@@@ -1,0 -1,264 +1,259 @@@
+ /*
+  * 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.junit.Assert.*;
+ 
+ import java.io.File;
+ import java.io.IOException;
+ import java.lang.management.ManagementFactory;
+ import java.net.InetAddress;
 -import java.net.UnknownHostException;
+ import java.util.Arrays;
+ import java.util.List;
+ 
++import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ 
 -import com.gemstone.gemfire.distributed.AbstractLauncherServiceStatusTest.TestLauncher.TestState;
+ import com.gemstone.gemfire.internal.GemFireVersion;
 -import com.gemstone.gemfire.internal.process.PidUnavailableException;
+ import com.gemstone.gemfire.internal.process.ProcessUtils;
+ import com.gemstone.gemfire.management.internal.cli.json.GfJsonArray;
+ import com.gemstone.gemfire.management.internal.cli.json.GfJsonException;
+ import com.gemstone.gemfire.management.internal.cli.json.GfJsonObject;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ /**
+  * Tests marshaling of ServiceStatus to and from JSON.
+  * 
+  * @since 7.0
+  */
+ @Category(UnitTest.class)
+ public class AbstractLauncherServiceStatusTest {
+ 
 -  private static final String SERVICE_NAME = "Test";
 -  private static final InetAddress HOST = getLocalHost();
 -  private static final int PORT = 12345;
 -  private static final String NAME = AbstractLauncherServiceStatusTest.class.getSimpleName();
 -  private static final int PID = identifyPid();
 -  private static final long UPTIME = 123456789;
 -  private static final String WORKING_DIRECTORY = identifyWorkingDirectory();
 -  private static final List<String> JVM_ARGUMENTS = ManagementFactory.getRuntimeMXBean().getInputArguments();
 -  private static final String CLASSPATH = ManagementFactory.getRuntimeMXBean().getClassPath();
 -  private static final String GEMFIRE_VERSION = GemFireVersion.getGemFireVersion();
 -  private static final String JAVA_VERSION = System.getProperty("java.version");
++  private static String serviceName;
++  private static InetAddress host;
++  private static int port;
++  private static String name;
++  private static int pid;
++  private static long uptime;
++  private static String workingDirectory;
++  private static List<String> jvmArguments;
++  private static String classpath;
++  private static String gemfireVersion;
++  private static String javaVersion;
+ 
+   private TestLauncher launcher;
+ 
+   @Before
 -  public void setUp() {
 -    this.launcher = new TestLauncher(HOST, PORT, NAME);
++  public void setUp() throws Exception {
++    serviceName = "Test";
++    port = 12345;
++    host = InetAddress.getLocalHost();
++    pid = ProcessUtils.identifyPid();
++    uptime = 123456789;
++    name = AbstractLauncherServiceStatusTest.class.getSimpleName();
++    workingDirectory = new File(System.getProperty("user.dir")).getAbsolutePath();
++    jvmArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
++    classpath = ManagementFactory.getRuntimeMXBean().getClassPath();
++    gemfireVersion = GemFireVersion.getGemFireVersion();
++    javaVersion = System.getProperty("java.version");
++
++    this.launcher = new TestLauncher(host, port, name);
++  }
++
++  @After
++  public void tearDown() throws Exception {
++    serviceName = null;
++    host = null;
++    name = null;
++    workingDirectory = null;
++    jvmArguments = null;
++    classpath = null;
++    gemfireVersion = null;
++    javaVersion = null;
+   }
+ 
+   @Test
+   public void testMarshallingTestStatusToAndFromJson() {
 -    final TestState status = this.launcher.status();
++    final TestLauncher.TestState status = this.launcher.status();
+     final String json = status.toJson();
+     validateJson(status, json);
 -    validateStatus(status, TestState.fromJson(json));
++    validateStatus(status, TestLauncher.TestState.fromJson(json));
+   }
+ 
 -  private void validateStatus(final TestState expected, final TestState actual) {
++  private void validateStatus(final TestLauncher.TestState expected, final TestLauncher.TestState actual) {
+     assertEquals(expected.getClasspath(), actual.getClasspath());
+     assertEquals(expected.getGemFireVersion(), actual.getGemFireVersion());
+     assertEquals(expected.getJavaVersion(), actual.getJavaVersion());
+     assertEquals(expected.getJvmArguments(), actual.getJvmArguments());
+     assertEquals(expected.getPid(), actual.getPid());
+     assertEquals(expected.getStatus(), actual.getStatus());
+     assertEquals(expected.getTimestamp(), actual.getTimestamp());
+     assertEquals(expected.getUptime(), actual.getUptime());
+     assertEquals(expected.getWorkingDirectory(), actual.getWorkingDirectory());
+     assertEquals(expected.getHost(), actual.getHost());
+     assertEquals(expected.getPort(), actual.getPort());
+     assertEquals(expected.getMemberName(), actual.getMemberName());
+   }
+ 
 -  private void validateJson(final TestState expected, final String json) {
 -    final TestState actual = TestState.fromJson(json);
++  private void validateJson(final TestLauncher.TestState expected, final String json) {
++    final TestLauncher.TestState actual = TestLauncher.TestState.fromJson(json);
+     validateStatus(expected, actual);
+   }
+ 
 -  private static int identifyPid() {
 -    try {
 -      return ProcessUtils.identifyPid();
 -    }
 -    catch (PidUnavailableException e) {
 -      return 0;
 -    }
 -  }
 -
 -  private static String identifyWorkingDirectory() {
 -    try {
 -      return new File(System.getProperty("user.dir")).getCanonicalPath();
 -    }
 -    catch (IOException e) {
 -      return new File(System.getProperty("user.dir")).getAbsolutePath();
 -    }
 -  }
 -
 -  private static InetAddress getLocalHost() {
 -    try {
 -      return InetAddress.getLocalHost();
 -    }
 -    catch (UnknownHostException e) {
 -      return null;
 -    }
 -  }
 -  
 -  static class TestLauncher extends AbstractLauncher<String> {
++  private static class TestLauncher extends AbstractLauncher<String> {
+ 
+     private final InetAddress bindAddress;
+     private final int port;
+     private final String memberName;
+     private final File logFile;
+ 
+     TestLauncher(InetAddress bindAddress,
+                  int port,
+                  String memberName) {
+       this.bindAddress = bindAddress;
+       this.port = port;
+       this.memberName = memberName;
+       this.logFile = new File(memberName + ".log");
+     }
+ 
+     public TestState status() {
+       return new TestState(Status.ONLINE,
+         null,
+         System.currentTimeMillis(),
+         getId(),
 -        PID,
 -        UPTIME,
 -        WORKING_DIRECTORY,
 -        JVM_ARGUMENTS,
 -        CLASSPATH,
 -        GEMFIRE_VERSION,
 -        JAVA_VERSION,
++              pid,
++              uptime,
++              workingDirectory,
++              jvmArguments,
++              classpath,
++              gemfireVersion,
++              javaVersion,
+         getLogFileName(),
+         getBindAddressAsString(),
+         getPortAsString(),
 -        NAME);
++              name);
+     }
+ 
+     @Override
+     public void run() {
+     }
+ 
+     public String getId() {
+       return getServiceName() + "@" + getBindAddress() + "[" + getPort() + "]";
+     }
+ 
+     @Override
+     public String getLogFileName() {
+       try {
+         return this.logFile.getCanonicalPath();
+       }
+       catch (IOException e) {
+         return this.logFile.getAbsolutePath();
+       }
+     }
+ 
+     @Override
+     public String getMemberName() {
+       return this.memberName;
+     }
+ 
+     @Override
+     public Integer getPid() {
+       return null;
+     }
+ 
+     @Override
+     public String getServiceName() {
 -      return SERVICE_NAME;
++      return serviceName;
+     }
+ 
+     InetAddress getBindAddress() {
+       return this.bindAddress;
+     }
+ 
+     String getBindAddressAsString() {
+       return this.bindAddress.getCanonicalHostName();
+     }
+ 
+     int getPort() {
+       return this.port;
+     }
+ 
+     String getPortAsString() {
+       return String.valueOf(getPort());
+     }
+ 
 -    public static class TestState extends ServiceState<String> {
++    private static class TestState extends ServiceState<String> {
+ 
+       protected static TestState fromJson(final String json) {
+         try {
+           final GfJsonObject gfJsonObject = new GfJsonObject(json);
+ 
+           final Status status = Status.valueOfDescription(gfJsonObject.getString(JSON_STATUS));
+           final List<String> jvmArguments =
+             Arrays.asList(GfJsonArray.toStringArray(gfJsonObject.getJSONArray(JSON_JVMARGUMENTS)));
+ 
+           return new TestState(status,
+             gfJsonObject.getString(JSON_STATUSMESSAGE),
+             gfJsonObject.getLong(JSON_TIMESTAMP),
+             gfJsonObject.getString(JSON_LOCATION),
+             gfJsonObject.getInt(JSON_PID),
+             gfJsonObject.getLong(JSON_UPTIME),
+             gfJsonObject.getString(JSON_WORKINGDIRECTORY),
+             jvmArguments,
+             gfJsonObject.getString(JSON_CLASSPATH),
+             gfJsonObject.getString(JSON_GEMFIREVERSION),
+             gfJsonObject.getString(JSON_JAVAVERSION),
+             gfJsonObject.getString(JSON_LOGFILE),
+             gfJsonObject.getString(JSON_HOST),
+             gfJsonObject.getString(JSON_PORT),
+             gfJsonObject.getString(JSON_MEMBERNAME));
+         }
+         catch (GfJsonException e) {
+           throw new IllegalArgumentException("Unable to create TestState from JSON: " + json);
+         }
+       }
+ 
+       protected TestState(final Status status,
+                           final String statusMessage,
+                           final long timestamp,
+                           final String location,
+                           final Integer pid,
+                           final Long uptime,
+                           final String workingDirectory,
+                           final List<String> jvmArguments,
+                           final String classpath,
+                           final String gemfireVersion,
+                           final String javaVersion,
+                           final String logFile,
+                           final String host,
+                           final String port,
+                           final String name) {
+         super(status, statusMessage, timestamp, location, pid, uptime, workingDirectory, jvmArguments, classpath,
+           gemfireVersion, javaVersion, logFile, host, port, name);
+       }
+ 
+       @Override
+       protected String getServiceName() {
 -        return SERVICE_NAME;
++        return serviceName;
+       }
+     }
+   }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7ce7ddc0/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
index 0000000,cabb5ff..0ebd4b6
mode 000000,100644..100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
@@@ -1,0 -1,298 +1,298 @@@
+ /*
+  * 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.junit.Assert.*;
+ 
+ import java.net.MalformedURLException;
+ import java.net.URL;
+ import java.util.Properties;
+ import java.util.concurrent.TimeUnit;
+ 
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ 
+ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+ import com.gemstone.gemfire.internal.lang.StringUtils;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ 
+ /**
+  * The AbstractLauncherTest class is a test suite of unit tests testing the contract and functionality
+  * of the AbstractLauncher class.
+  * <p/>
+  * @see com.gemstone.gemfire.distributed.AbstractLauncher
+  * @see org.junit.Assert
+  * @see org.junit.Test
+  * @since 7.0
+  */
+ @Category(UnitTest.class)
+ public class AbstractLauncherTest {
+ 
 -  protected AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
++  private AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
+     return new FakeServiceLauncher(memberName, memberId);
+   }
+ 
+   @Test
+   public void testIsAttachAPINotFound() {
+     final AbstractLauncher<?> launcher = createAbstractLauncher("012", "TestMember");
+ 
+     assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+       "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException")));
+     assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
+       "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
+     assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+       "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/ibm/tools/attach/AgentNotSupportedException")));
+     assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
+       "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
+     assertFalse(launcher.isAttachAPINotFound(new IllegalArgumentException(
+       "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
+     assertFalse(launcher.isAttachAPINotFound(new IllegalStateException(
+       "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
+     assertFalse(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+       "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/companyx/app/service/MyServiceClass")));
+     assertFalse(launcher.isAttachAPINotFound(new ClassNotFoundException(
+       "Caused by: java.lang.ClassNotFoundException: com.companyx.app.attach.NutsNotAttachedException")));
+   }
+ 
+   @Test
+   public void testIsSet() {
+     final Properties properties = new Properties();
+ 
+     assertFalse(properties.containsKey(DistributionConfig.NAME_NAME));
+     assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+ 
+     properties.setProperty(DistributionConfig.NAME_NAME, "");
+ 
+     assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
+     assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+ 
+     properties.setProperty(DistributionConfig.NAME_NAME, "  ");
+ 
+     assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
+     assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+ 
+     properties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
+ 
+     assertTrue(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+     assertFalse(AbstractLauncher.isSet(properties, "NaMe"));
+   }
+ 
+   @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");
+ 
+     assertNotNull(launcher);
+     assertEquals("1", launcher.getMemberId());
+     assertEquals("memberOne", launcher.getMemberName());
+ 
+     Properties distributedSystemProperties = launcher.getDistributedSystemProperties();
+ 
+     assertNotNull(distributedSystemProperties);
+     assertTrue(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+     assertEquals("memberOne", distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
+ 
+     launcher = createAbstractLauncher(null, "22");
+ 
+     assertNotNull(launcher);
+     assertEquals("22", launcher.getMemberId());
+     assertNull(launcher.getMemberName());
+ 
+     distributedSystemProperties = launcher.getDistributedSystemProperties();
+ 
+     assertNotNull(distributedSystemProperties);
+     assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+ 
+     launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "333");
+ 
+     assertNotNull(launcher);
+     assertEquals("333", launcher.getMemberId());
+     assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+ 
+     distributedSystemProperties = launcher.getDistributedSystemProperties();
+ 
+     assertNotNull(distributedSystemProperties);
+     assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+ 
+     launcher = createAbstractLauncher("  ", "4444");
+ 
+     assertNotNull(launcher);
+     assertEquals("4444", launcher.getMemberId());
+     assertEquals("  ", launcher.getMemberName());
+ 
+     distributedSystemProperties = launcher.getDistributedSystemProperties();
+ 
+     assertNotNull(distributedSystemProperties);
+     assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+   }
+ 
+   @Test
+   public void testGetDistributedSystemPropertiesWithDefaults() {
+     AbstractLauncher<?> launcher = createAbstractLauncher("TestMember", "123");
+ 
+     assertNotNull(launcher);
+     assertEquals("123", launcher.getMemberId());
+     assertEquals("TestMember", launcher.getMemberName());
+ 
+     Properties defaults = new Properties();
+ 
+     defaults.setProperty("testKey", "testValue");
+ 
+     Properties distributedSystemProperties = launcher.getDistributedSystemProperties(defaults);
+ 
+     assertNotNull(distributedSystemProperties);
+     assertEquals(launcher.getMemberName(), distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
+     assertEquals("testValue", distributedSystemProperties.getProperty("testKey"));
+   }
+ 
+   @Test
+   public void testGetMember() {
+     AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "123");
+ 
+     assertNotNull(launcher);
+     assertEquals("123", launcher.getMemberId());
+     assertEquals("memberOne", launcher.getMemberName());
+     assertEquals("memberOne", launcher.getMember());
+ 
+     launcher = createAbstractLauncher(null, "123");
+ 
+     assertNotNull(launcher);
+     assertEquals("123", launcher.getMemberId());
+     assertNull(launcher.getMemberName());
+     assertEquals("123", launcher.getMember());
+ 
+     launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "123");
+ 
+     assertNotNull(launcher);
+     assertEquals("123", launcher.getMemberId());
+     assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+     assertEquals("123", launcher.getMember());
+ 
+     launcher = createAbstractLauncher(" ", "123");
+ 
+     assertNotNull(launcher);
+     assertEquals("123", launcher.getMemberId());
+     assertEquals(" ", launcher.getMemberName());
+     assertEquals("123", launcher.getMember());
+ 
+     launcher = createAbstractLauncher(null, StringUtils.EMPTY_STRING);
+ 
+     assertNotNull(launcher);
+     assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberId());
+     assertNull(launcher.getMemberName());
+     assertNull(launcher.getMember());
+ 
+     launcher = createAbstractLauncher(null, " ");
+ 
+     assertNotNull(launcher);
+     assertEquals(" ", launcher.getMemberId());
+     assertNull(launcher.getMemberName());
+     assertNull(launcher.getMember());
+   }
+ 
+   @Test
+   public void testAbstractLauncherServiceStateToDaysHoursMinutesSeconds() {
+     assertEquals("", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(null));
+     assertEquals("0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(0l));
+     assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1000l));
+     assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1999l));
+     assertEquals("2 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(2001l));
+     assertEquals("45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(45000l));
+     assertEquals("1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 1000l));
+     assertEquals("1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(61 * 1000l));
+     assertEquals("1 minute 30 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(90 * 1000l));
+     assertEquals("2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(120 * 1000l));
+     assertEquals("2 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(121 * 1000l));
+     assertEquals("2 minutes 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(135 * 1000l));
+     assertEquals("1 hour 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l));
+     assertEquals("1 hour 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 1000l));
+     assertEquals("1 hour 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 15000l));
+     assertEquals("1 hour 1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l));
+     assertEquals("1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 1000l));
+     assertEquals("1 hour 1 minute 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 45000l));
+     assertEquals("1 hour 2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 62 * 1000l));
+     assertEquals("1 hour 5 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 1000l));
+     assertEquals("1 hour 5 minutes 10 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 10000l));
+     assertEquals("1 hour 59 minutes 11 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 119 * 1000l + 11000l));
+     assertEquals("1 day 1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+       TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(1) + TimeUnit.SECONDS.toMillis(1)));
+     assertEquals("1 day 5 hours 15 minutes 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+       TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(5) + TimeUnit.MINUTES.toMillis(15) + TimeUnit.SECONDS.toMillis(45)));
+     assertEquals("2 days 1 hour 30 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+       TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
+   }
+ 
 -  protected static final class FakeServiceLauncher extends AbstractLauncher<String> {
++  private static final class FakeServiceLauncher extends AbstractLauncher<String> {
+ 
+     private final String memberId;
+     private final String memberName;
+ 
+     public FakeServiceLauncher(final String memberName, final String memberId) {
+       this.memberId = memberId;
+       this.memberName = memberName;
+     }
+ 
+     @Override
+     boolean isAttachAPIOnClasspath() {
+       return false;
+     }
+ 
+     @Override
+     public String getLogFileName() {
+       throw new UnsupportedOperationException("Not Implemented!");
+     }
+ 
+     @Override
+     public String getMemberId() {
+       return memberId;
+     }
+ 
+     @Override
+     public String getMemberName() {
+       return memberName;
+     }
+ 
+     @Override
+     public Integer getPid() {
+       throw new UnsupportedOperationException("Not Implemented!");
+     }
+ 
+     @Override
+     public String getServiceName() {
+       return "TestService";
+     }
+ 
+     @Override
+     public void run() {
+       throw new UnsupportedOperationException("Not Implemented!");
+     }
+   }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7ce7ddc0/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
index 0000000,252b5aa..897d0fa
mode 000000,100755..100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
@@@ -1,0 -1,827 +1,827 @@@
+ /*
+  * 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.junit.Assert.*;
+ 
+ import java.io.File;
+ import java.lang.management.ManagementFactory;
+ import java.net.BindException;
+ import java.net.InetAddress;
+ 
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Ignore;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ 
+ import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+ import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+ import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+ import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+ import com.gemstone.gemfire.distributed.internal.InternalLocator;
+ import com.gemstone.gemfire.internal.AvailablePort;
+ import com.gemstone.gemfire.internal.AvailablePortHelper;
+ import com.gemstone.gemfire.internal.DistributionLocator;
+ import com.gemstone.gemfire.internal.GemFireVersion;
+ import com.gemstone.gemfire.internal.SocketCreator;
+ import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+ import com.gemstone.gemfire.internal.process.ProcessType;
+ import com.gemstone.gemfire.internal.process.ProcessUtils;
+ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+ 
+ /**
+  * Tests usage of LocatorLauncher as a local API in existing JVM.
+  *
+  * @since 8.0
+  */
+ @Category(IntegrationTest.class)
+ public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncherIntegrationTestCase {
+   
+   @Before
+   public final void setUpLocatorLauncherLocalIntegrationTest() throws Exception {
+     disconnectFromDS();
+     System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
+   }
+ 
+   @After
+   public final void tearDownLocatorLauncherLocalIntegrationTest() throws Exception {
+     disconnectFromDS();
+   }
+ 
+   @Test
+   public void testBuilderSetProperties() throws Throwable {
+     this.launcher = new Builder()
+         .setForce(true)
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+         .set(DistributionConfig.MCAST_PORT_NAME, "0")
+         .build();
+ 
+     try {
+       assertEquals(Status.ONLINE, this.launcher.start().getStatus());
+       waitForLocatorToStart(this.launcher, true);
+   
+       final InternalLocator locator = this.launcher.getLocator();
+       assertNotNull(locator);
+   
+       final DistributedSystem distributedSystem = locator.getDistributedSystem();
+   
+       assertNotNull(distributedSystem);
+       assertEquals("true", distributedSystem.getProperties().getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME));
+       assertEquals("0", distributedSystem.getProperties().getProperty(DistributionConfig.MCAST_PORT_NAME));
+       assertEquals("config", distributedSystem.getProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME));
+       assertEquals(getUniqueName(), distributedSystem.getProperties().getProperty(DistributionConfig.NAME_NAME));
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       assertNull(this.launcher.getLocator());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+ 
+   @Test
+   public void testIsAttachAPIFound() throws Exception {
+     final ProcessControllerFactory factory = new ProcessControllerFactory();
+     assertTrue(factory.isAttachAPIFound());
+   }
+   
+   @Test
+   public void testStartCreatesPidFile() throws Throwable {
+     this.launcher = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+         .build();
+ 
+     try {
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+       assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+ 
+       // validate the pid file and its contents
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue(this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertTrue(ProcessUtils.isProcessAlive(pid));
+       assertEquals(getPid(), pid);
+ 
+       assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+       
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+       
+     try {
+       assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+ 
+   @Test
+   public void testStartDeletesStaleControlFiles() throws Throwable {
+     // create existing control files
+     this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
+     this.stopRequestFile.createNewFile();
+     assertTrue(this.stopRequestFile.exists());
+ 
+     this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
+     this.statusRequestFile.createNewFile();
+     assertTrue(this.statusRequestFile.exists());
+ 
+     this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
+     this.statusFile.createNewFile();
+     assertTrue(this.statusFile.exists());
+     
+     // build and start the locator
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+     this.launcher.start();
+     
+     try {
+       waitForLocatorToStart(this.launcher);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     try {
+       // validate the pid file and its contents
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue(this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertTrue(ProcessUtils.isProcessAlive(pid));
+       assertEquals(getPid(), pid);
+       
+       // validate stale control files were deleted
+       assertFalse(stopRequestFile.exists());
+       assertFalse(statusRequestFile.exists());
+       assertFalse(statusFile.exists());
+       
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+   
+   @Test
+   public void testStartOverwritesStalePidFile() throws Throwable {
+     // create existing pid file
+     this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+     assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE, Integer.MAX_VALUE == ProcessUtils.identifyPid());
+     writePid(this.pidFile, Integer.MAX_VALUE);
+ 
+     // build and start the locator
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+     this.launcher.start();
+     
+     try {
+       waitForLocatorToStart(this.launcher);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     try {
+       // validate the pid file and its contents
+       assertTrue(this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertTrue(ProcessUtils.isProcessAlive(pid));
+       assertEquals(getPid(), pid);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+ 
+   @Test
+   @Ignore("Need to rewrite this without using dunit.Host")
+   public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
+   }/*
+     assertTrue(getUniqueName() + " is broken if PID == Integer.MAX_VALUE", ProcessUtils.identifyPid() != Integer.MAX_VALUE);
+     
+     // create existing pid file
+     this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
+     final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+     assertFalse(realPid == ProcessUtils.identifyPid());
+     writePid(this.pidFile, realPid);
+ 
+     // build and start the locator
+     final Builder builder = new Builder()
+         .setForce(true)
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertTrue(builder.getForce());
+     this.launcher = builder.build();
+     assertTrue(this.launcher.isForcing());
+     this.launcher.start();
+ 
+     // collect and throw the FIRST failure
+     Throwable failure = null;
+ 
+     try {
+       waitForLocatorToStart(this.launcher);
+ 
+       // validate the pid file and its contents
+       assertTrue(this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertTrue(ProcessUtils.isProcessAlive(pid));
 -      assertEquals(getPid(), pid);
++      assertIndexDetailsEquals(getPid(), pid);
+       
+       // validate log file was created
+       final String logFileName = getUniqueName()+".log";
+       assertTrue("Log file should exist: " + logFileName, new File(logFileName).exists());
+       
+     } catch (Throwable e) {
+       logger.error(e);
+       if (failure == null) {
+         failure = e;
+       }
+     }
+ 
+     try {
 -      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
++      assertIndexDetailsEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       logger.error(e);
+       if (failure == null) {
+         failure = e;
+       }
+     }
+     
+     if (failure != null) {
+       throw failure;
+     }
+   } // testStartUsingForceOverwritesExistingPidFile
+   */
+   
+   @Test
+   public void testStartWithDefaultPortInUseFails() throws Throwable {
+     this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+     assertTrue(this.socket.isBound());
+     assertFalse(this.socket.isClosed());
+     assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+ 
+     assertNotNull(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY));
+     assertEquals(this.locatorPort, Integer.valueOf(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY)).intValue());
+     assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+     
+     this.launcher = new Builder()
+         .setMemberName(getUniqueName())
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+         .build();
+     
+     assertEquals(this.locatorPort, this.launcher.getPort().intValue());
+     
+     RuntimeException expected = null;
+     try {
+       this.launcher.start();
+      
+       // why did it not fail like it's supposed to?
+       final String property = System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY);
+       assertNotNull(property);
+       assertEquals(this.locatorPort, Integer.valueOf(property).intValue());
+       assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+       assertEquals(this.locatorPort, this.launcher.getPort().intValue());
+       assertEquals(this.locatorPort, this.socket.getLocalPort());
+       assertTrue(this.socket.isBound());
+       assertFalse(this.socket.isClosed());
+       
+       fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
+     } catch (RuntimeException e) {
+       expected = e;
+       assertNotNull(expected.getMessage());
+       // BindException text varies by platform
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     try {
+       assertNotNull(expected);
+       final Throwable cause = expected.getCause();
+       assertNotNull(cause);
+       assertTrue(cause instanceof BindException);
+       // BindException string varies by platform
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+       
+       // creation of log file seems to be random -- look into why sometime
+       final String logFileName = getUniqueName()+".log";
+       assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+       
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     // just in case the launcher started...
+     LocatorState status = null;
+     try {
+       status = this.launcher.stop();
+     } catch (Throwable t) { 
+       // ignore
+     }
+     
+     try {
+       waitForFileToDelete(this.pidFile);
+       assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+   
+   @Test
+   @Ignore("Need to rewrite this without using dunit.Host")
+   public void testStartWithExistingPidFileFails() throws Throwable {
+   }/*
+     // create existing pid file
+     final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+     assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
+ 
+     this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
+     writePid(this.pidFile, realPid);
+     
+     // build and start the locator
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+ 
+     // collect and throw the FIRST failure
+     Throwable failure = null;
+     RuntimeException expected = null;
+     
+     try {
+       this.launcher.start();
+       fail("LocatorLauncher start should have thrown RuntimeException caused by FileAlreadyExistsException");
+     } catch (RuntimeException e) {
+       expected = e;
+       assertNotNull(expected.getMessage());
+       assertTrue(expected.getMessage(), expected.getMessage().contains("A PID file already exists and a Locator may be running in"));
 -      assertEquals(RuntimeException.class, expected.getClass());
++      assertIndexDetailsEquals(RuntimeException.class, expected.getClass());
+     } catch (Throwable e) {
+       logger.error(e);
+       if (failure == null) {
+         failure = e;
+       }
+     }
+ 
+     // just in case the launcher started...
+     LocatorState status = null;
+     try {
+       status = this.launcher.stop();
+     } catch (Throwable t) { 
+       // ignore
+     }
+     
+     try {
+       assertNotNull(expected);
+       final Throwable cause = expected.getCause();
+       assertNotNull(cause);
+       assertTrue(cause instanceof FileAlreadyExistsException);
+       assertTrue(cause.getMessage().contains("Pid file already exists: "));
+       assertTrue(cause.getMessage().contains("vf.gf.locator.pid for process " + realPid));
+     } catch (Throwable e) {
+       logger.error(e);
+       if (failure == null) {
+         failure = e;
+       }
+     }
+     
+     try {
+       delete(this.pidFile);
+       final Status theStatus = status.getStatus();
+       assertFalse(theStatus == Status.STARTING);
+       assertFalse(theStatus == Status.ONLINE);
+     } catch (Throwable e) {
+       logger.error(e);
+       if (failure == null) {
+         failure = e;
+       }
+     }
+     
+     if (failure != null) {
+       throw failure;
+     }
+   } // testStartWithExistingPidFileFails
+   */
+   
+   @Test
+   public void testStartUsingPort() throws Throwable {
+     // generate one free port and then use it instead of default
+     final int freeTCPPort = AvailablePortHelper.getRandomAvailableTCPPort();
+     assertTrue(AvailablePort.isPortAvailable(freeTCPPort, AvailablePort.SOCKET));
+     
+     this.launcher = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(freeTCPPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+         .build();
+ 
+     int pid = 0;
+     try {
+       // if start succeeds without throwing exception then #47778 is fixed
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+ 
+       // validate the pid file and its contents
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue(pidFile.exists());
+       pid = readPid(pidFile);
+       assertTrue(pid > 0);
+       assertTrue(ProcessUtils.isProcessAlive(pid));
+       assertEquals(getPid(), pid);
+ 
+       // verify locator did not use default port
+       assertTrue(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+       
+       final LocatorState status = this.launcher.status();
+       final String portString = status.getPort();
+       assertEquals("Port should be \"" + freeTCPPort + "\" instead of " + portString, String.valueOf(freeTCPPort), portString);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     // stop the locator
+     try {
+       assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+   
+   @Test
+   public void testStartUsingPortInUseFails() throws Throwable {
+     // generate one free port and then use it instead of default
+     final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+     this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
+     
+     this.launcher = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(freeTCPPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+         .build();
+     
+     RuntimeException expected = null;
+     try {
+       this.launcher.start();
+       fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
+     } catch (RuntimeException e) {
+       expected = e;
+       assertNotNull(expected.getMessage());
+       // BindException string varies by platform
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     try {
+       assertNotNull(expected);
+       final Throwable cause = expected.getCause();
+       assertNotNull(cause);
+       assertTrue(cause instanceof BindException);
+       // BindException string varies by platform
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+       
+       // creation of log file seems to be random -- look into why sometime
+       final String logFileName = getUniqueName()+".log";
+       assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+       
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+     
+     // just in case the launcher started...
+     LocatorState status = null;
+     try {
+       status = this.launcher.stop();
+     } catch (Throwable t) { 
+       // ignore
+     }
+     
+     try {
+       waitForFileToDelete(this.pidFile);
+       assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+   
+   @Test
+   public void testStatusUsingPid() throws Throwable {
+     // build and start the locator
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+     
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+     
+     LocatorLauncher pidLauncher = null;
+     try {
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+       
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertEquals(ProcessUtils.identifyPid(), pid);
+   
+       pidLauncher = new Builder().setPid(pid).build();
+       assertNotNull(pidLauncher);
+       assertFalse(pidLauncher.isRunning());
+ 
+       final LocatorState actualStatus = pidLauncher.status();
+       assertNotNull(actualStatus);
+       assertEquals(Status.ONLINE, actualStatus.getStatus());
+       assertEquals(pid, actualStatus.getPid().intValue());
+       assertTrue(actualStatus.getUptime() > 0);
+       // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
+       assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+       assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+       assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+       assertEquals(this.workingDirectory + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+       assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+       assertEquals(getUniqueName(), actualStatus.getMemberName());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     if (pidLauncher == null) {
+       try {
+         assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+         waitForFileToDelete(this.pidFile);
+       } catch (Throwable e) {
+         this.errorCollector.addError(e);
+       }
+       
+     } else {
+       try {
+         assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+         waitForFileToDelete(this.pidFile);
+       } catch (Throwable e) {
+         this.errorCollector.addError(e);
+       }
+     }
+   }
+   
+   @Test
+   public void testStatusUsingWorkingDirectory() throws Throwable {
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+     
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+     
+     LocatorLauncher dirLauncher = null;
+     try {
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+       
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertEquals(ProcessUtils.identifyPid(), pid);
+   
+       dirLauncher = new Builder().setWorkingDirectory(this.workingDirectory).build();
+       assertNotNull(dirLauncher);
+       assertFalse(dirLauncher.isRunning());
+ 
+       final LocatorState actualStatus = dirLauncher.status();
+       assertNotNull(actualStatus);
+       assertEquals(Status.ONLINE, actualStatus.getStatus());
+       assertEquals(pid, actualStatus.getPid().intValue());
+       assertTrue(actualStatus.getUptime() > 0);
+       // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
+       assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+       assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+       assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+       assertEquals(this.workingDirectory + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+       assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+       assertEquals(getUniqueName(), actualStatus.getMemberName());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     if (dirLauncher == null) {
+       try {
+         assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+         waitForFileToDelete(this.pidFile);
+       } catch (Throwable e) {
+         this.errorCollector.addError(e);
+       }
+       
+     } else {
+       try {
+         assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+         waitForFileToDelete(this.pidFile);
+       } catch (Throwable e) {
+         this.errorCollector.addError(e);
+       }
+     }
+   }
+   
+   @Test
+   public void testStopUsingPid() throws Throwable {
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+ 
+     LocatorLauncher pidLauncher = null;
+     try {
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+   
+       // validate the pid file and its contents
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue(this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertEquals(ProcessUtils.identifyPid(), pid);
+ 
+       pidLauncher = new Builder().setPid(pid).build();
+       assertNotNull(pidLauncher);
+       assertFalse(pidLauncher.isRunning());
+       
+       // stop the locator
+       final LocatorState locatorState = pidLauncher.stop();
+       assertNotNull(locatorState);
+       assertEquals(Status.STOPPED, locatorState.getStatus());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       this.launcher.stop();
+     } catch (Throwable e) {
+       // ignore
+     }
+ 
+     try {
+       // verify the PID file was deleted
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+   
+   @Test
+   public void testStopUsingWorkingDirectory() throws Throwable {
+     final Builder builder = new Builder()
+         .setMemberName(getUniqueName())
+         .setPort(this.locatorPort)
+         .setRedirectOutput(true)
+         .setWorkingDirectory(this.workingDirectory)
+         .set(DistributionConfig.CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory)
+         .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+ 
+     assertFalse(builder.getForce());
+     this.launcher = builder.build();
+     assertFalse(this.launcher.isForcing());
+ 
+     LocatorLauncher dirLauncher = null;
+     try {
+       this.launcher.start();
+       waitForLocatorToStart(this.launcher);
+     
+       // validate the pid file and its contents
+       this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+       assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+       final int pid = readPid(this.pidFile);
+       assertTrue(pid > 0);
+       assertEquals(ProcessUtils.identifyPid(), pid);
+ 
+       dirLauncher = new Builder().setWorkingDirectory(this.workingDirectory).build();
+       assertNotNull(dirLauncher);
+       assertFalse(dirLauncher.isRunning());
+       
+       // stop the locator
+       final LocatorState locatorState = dirLauncher.stop();
+       assertNotNull(locatorState);
+       assertEquals(Status.STOPPED, locatorState.getStatus());
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+ 
+     try {
+       this.launcher.stop();
+     } catch (Throwable e) {
+       // ignore
+     }
+ 
+     try {
+       // verify the PID file was deleted
+       waitForFileToDelete(this.pidFile);
+     } catch (Throwable e) {
+       this.errorCollector.addError(e);
+     }
+   }
+ }


Mime
View raw message