You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/06/13 17:22:40 UTC
[geode] branch develop updated (a930ee4 -> 87c83ee)
This is an automated email from the ASF dual-hosted git repository.
klund pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git.
from a930ee4 GEODE-6856: Remove old CacheServerLauncher
new f074ca7 GEODE-6183: Make isAttachAPIFound load providers
new 03f8395 GEODE-6183: Use SocketCreator.getLocalHost in LocatorLauncherRemoteIntegrationTest
new de19a41 GEODE-6183: Cleanup Launcher integration tests
new c6f0b1a GEODE-6183: Cleanup and rename DistributedSystemIntegrationTest
new 87c83ee GEODE-6183: Cleanup and rename LocatorIntegrationTest
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../AbstractLauncherIntegrationTest.java | 5 +-
.../DistributedSystemIntegrationJUnitTest.java | 94 ----------
.../DistributedSystemIntegrationTest.java | 95 ++++++++++
.../distributed/LauncherIntegrationTestCase.java | 12 +-
.../apache/geode/distributed/LocatorCommand.java | 15 +-
...rJUnitTest.java => LocatorIntegrationTest.java} | 193 +++++++++++----------
.../LocatorLauncherIntegrationTest.java | 35 ++--
.../LocatorLauncherIntegrationTestCase.java | 11 +-
...catorLauncherJmxManagerLocalRegressionTest.java | 55 +++---
...atorLauncherJmxManagerRemoteRegressionTest.java | 37 ++--
.../LocatorLauncherLocalFileIntegrationTest.java | 2 +-
.../LocatorLauncherLocalIntegrationTest.java | 91 ++++++----
.../LocatorLauncherRemoteFileIntegrationTest.java | 40 +++--
.../LocatorLauncherRemoteIntegrationTest.java | 107 +++++++-----
.../LocatorLauncherRemoteIntegrationTestCase.java | 30 +++-
...cherRemoteWithCustomLoggingIntegrationTest.java | 15 +-
.../apache/geode/distributed/ServerCommand.java | 18 +-
.../ServerLauncherBuilderIntegrationTest.java | 71 ++++----
.../distributed/ServerLauncherIntegrationTest.java | 56 +++---
.../ServerLauncherIntegrationTestCase.java | 24 +--
.../ServerLauncherLocalIntegrationTest.java | 142 +++++++++------
.../ServerLauncherRemoteFileIntegrationTest.java | 30 +++-
.../ServerLauncherRemoteIntegrationTest.java | 79 ++++++---
.../ServerLauncherRemoteIntegrationTestCase.java | 39 +++--
...cherRemoteWithCustomLoggingIntegrationTest.java | 20 ++-
.../ServerLauncherWithProviderRegressionTest.java | 8 +-
.../internal/process/ProcessControllerFactory.java | 14 +-
27 files changed, 808 insertions(+), 530 deletions(-)
delete mode 100755 geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationJUnitTest.java
create mode 100755 geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationTest.java
rename geode-core/src/integrationTest/java/org/apache/geode/distributed/{LocatorJUnitTest.java => LocatorIntegrationTest.java} (53%)
[geode] 03/05: GEODE-6183: Cleanup Launcher integration tests
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit de19a41571476ecb179c2e561d1f5d6bc8b1c1b5
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 13:03:09 2019 -0700
GEODE-6183: Cleanup Launcher integration tests
* Fixup IDE warnings
* Reformat test code
* Use SocketCreator.getLocalHost
---
.../AbstractLauncherIntegrationTest.java | 5 +-
.../distributed/LauncherIntegrationTestCase.java | 12 +-
.../apache/geode/distributed/LocatorCommand.java | 15 +--
.../LocatorLauncherIntegrationTest.java | 35 +++--
.../LocatorLauncherIntegrationTestCase.java | 11 +-
...catorLauncherJmxManagerLocalRegressionTest.java | 55 ++++----
...atorLauncherJmxManagerRemoteRegressionTest.java | 37 +++---
.../LocatorLauncherLocalFileIntegrationTest.java | 2 +-
.../LocatorLauncherLocalIntegrationTest.java | 91 ++++++++-----
.../LocatorLauncherRemoteFileIntegrationTest.java | 40 ++++--
.../LocatorLauncherRemoteIntegrationTest.java | 110 ++++++++++------
.../LocatorLauncherRemoteIntegrationTestCase.java | 30 +++--
...cherRemoteWithCustomLoggingIntegrationTest.java | 15 ++-
.../apache/geode/distributed/ServerCommand.java | 18 +--
.../ServerLauncherBuilderIntegrationTest.java | 71 ++++++-----
.../distributed/ServerLauncherIntegrationTest.java | 56 ++++----
.../ServerLauncherIntegrationTestCase.java | 24 ++--
.../ServerLauncherLocalIntegrationTest.java | 142 ++++++++++++++-------
.../ServerLauncherRemoteFileIntegrationTest.java | 30 ++++-
.../ServerLauncherRemoteIntegrationTest.java | 79 ++++++++----
.../ServerLauncherRemoteIntegrationTestCase.java | 39 ++++--
...cherRemoteWithCustomLoggingIntegrationTest.java | 20 ++-
.../ServerLauncherWithProviderRegressionTest.java | 8 +-
23 files changed, 602 insertions(+), 343 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
index 47661cc..c93d547 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
@@ -30,7 +30,6 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestName;
-
/**
* Integration tests for {@link AbstractLauncher} that require file system I/O.
*/
@@ -40,10 +39,10 @@ public class AbstractLauncherIntegrationTest {
private Properties expectedProperties;
@Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
- public final TestName testName = new TestName();
+ public TestName testName = new TestName();
@Before
public void setUp() throws Exception {
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
index 073dcfa..e7e9fc0 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
@@ -14,11 +14,13 @@
*/
package org.apache.geode.distributed;
+import static java.lang.System.lineSeparator;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.internal.AvailablePort.SOCKET;
import static org.apache.geode.internal.AvailablePort.isPortAvailable;
import static org.apache.geode.internal.process.ProcessUtils.identifyPid;
import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
@@ -50,7 +52,6 @@ import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
import org.apache.geode.internal.process.ProcessType;
import org.apache.geode.internal.process.lang.AvailablePid;
import org.apache.geode.test.awaitility.GeodeAwaitility;
-import org.apache.geode.test.dunit.IgnoredException;
/**
* Abstract base class for integration tests of both {@link LocatorLauncher} and
@@ -67,8 +68,8 @@ public abstract class LauncherIntegrationTestCase {
protected volatile int localPid;
protected volatile int fakePid;
+
private volatile ServerSocket socket;
- private IgnoredException ignoredException;
@Rule
public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
@@ -82,15 +83,13 @@ public abstract class LauncherIntegrationTestCase {
@Before
public void setUpAbstractLauncherIntegrationTestCase() throws Exception {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, Integer.toString(0));
- ignoredException =
- IgnoredException.addIgnoredException(EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
+ addIgnoredException(EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
localPid = identifyPid();
fakePid = new AvailablePid().findAvailablePid(PREFERRED_FAKE_PID);
}
@After
public void tearDownAbstractLauncherIntegrationTestCase() throws Exception {
- ignoredException.remove();
if (socket != null) {
socket.close();
}
@@ -142,7 +141,7 @@ public abstract class LauncherIntegrationTestCase {
File file = new File(getWorkingDirectory(), getProcessType().getPidFileName());
FileWriter writer = new FileWriter(file);
writer.write(String.valueOf(content));
- writer.write("\n");
+ writer.write(lineSeparator());
writer.flush();
writer.close();
assertTrue(file.exists());
@@ -314,5 +313,4 @@ public abstract class LauncherIntegrationTestCase {
assertThat(isProcessAlive(pid)).isTrue();
return pid;
}
-
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorCommand.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorCommand.java
index ef809af..01f22cf 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorCommand.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorCommand.java
@@ -34,11 +34,11 @@ public class LocatorCommand {
}
public LocatorCommand(final UsesLocatorCommand user) {
- this.javaPath = user.getJavaPath();
- this.jvmArguments = user.getJvmArguments();
- this.classPath = user.getClassPath();
- this.name = user.getName();
- this.command = Command.START;
+ javaPath = user.getJavaPath();
+ jvmArguments = user.getJvmArguments();
+ classPath = user.getClassPath();
+ name = user.getName();
+ command = Command.START;
}
public LocatorCommand withJavaPath(final String javaPath) {
@@ -52,7 +52,7 @@ public class LocatorCommand {
}
public LocatorCommand addJvmArgument(final String arg) {
- this.jvmArguments.add(arg);
+ jvmArguments.add(arg);
return this;
}
@@ -76,7 +76,7 @@ public class LocatorCommand {
}
public LocatorCommand force(final boolean value) {
- this.force = value;
+ force = value;
return this;
}
@@ -103,5 +103,4 @@ public class LocatorCommand {
}
return cmd;
}
-
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
index 8469408..da1c7fa 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
@@ -62,7 +62,9 @@ public class LocatorLauncherIntegrationTest {
givenGemFirePropertiesFile(withMemberName());
// when: starting with null MemberName
- LocatorLauncher launcher = new Builder().setCommand(Command.START).build();
+ LocatorLauncher launcher = new Builder()
+ .setCommand(Command.START)
+ .build();
// then: name in gemfire.properties file should be used for MemberName
assertThat(launcher.getMemberName()).isNull(); // name will be read during start()
@@ -74,10 +76,13 @@ public class LocatorLauncherIntegrationTest {
givenGemFirePropertiesFile(withoutMemberName());
// when: no MemberName is specified
- Throwable thrown = catchThrowable(() -> new Builder().setCommand(Command.START).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .build());
// then: throw IllegalStateException
- then(thrown).isExactlyInstanceOf(IllegalStateException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalStateException.class)
.hasMessage(memberNameValidationErrorMessage());
}
@@ -86,9 +91,11 @@ public class LocatorLauncherIntegrationTest {
// given: using LocatorLauncher in-process
// when: setting WorkingDirectory to non-current directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setCommand(Command.START).setMemberName("memberOne")
- .setWorkingDirectory(getWorkingDirectoryPath()).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .setMemberName("memberOne")
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build());
// then: throw IllegalStateException
then(thrown).isExactlyInstanceOf(IllegalStateException.class)
@@ -204,11 +211,12 @@ public class LocatorLauncherIntegrationTest {
File nonDirectory = temporaryFolder.newFile();
// when: setting WorkingDirectory to that file
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory(nonDirectory.getCanonicalPath()));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory(nonDirectory.getCanonicalPath()));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException(nonDirectory.getCanonicalPath()));
}
@@ -218,11 +226,12 @@ public class LocatorLauncherIntegrationTest {
// given:
// when: setting WorkingDirectory to non-existing directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory("/path/to/non_existing/directory"));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory("/path/to/non_existing/directory"));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
}
@@ -282,7 +291,7 @@ public class LocatorLauncherIntegrationTest {
/**
* Creates a gemfire properties file in temporaryFolder:
* <ol>
- * <li>creates gemfire.properties in <code>temporaryFolder</code></li>
+ * <li>creates gemfire.properties in {@code temporaryFolder}</li>
* <li>writes config to the file</li>
* <li>sets "gemfirePropertyFile" system property</li>
* </ol>
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTestCase.java
index 1e484dc..713917a 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherIntegrationTestCase.java
@@ -17,14 +17,12 @@ package org.apache.geode.distributed;
import static org.apache.geode.distributed.AbstractLauncher.Status.STOPPED;
import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_CONFIGURATION_DIR;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
import static org.apache.geode.distributed.internal.InternalConfigurationPersistenceService.CLUSTER_CONFIG_DISK_DIR_PREFIX;
import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
import static org.apache.geode.internal.DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.IOException;
@@ -71,7 +69,7 @@ public abstract class LocatorLauncherIntegrationTestCase extends LauncherIntegra
}
@After
- public void tearDownAbstractLocatorLauncherIntegrationTestCase() throws Exception {
+ public void tearDownAbstractLocatorLauncherIntegrationTestCase() {
if (launcher != null) {
launcher.stop();
}
@@ -119,10 +117,11 @@ public abstract class LocatorLauncherIntegrationTestCase extends LauncherIntegra
* without any of these defaults then simply use {@code new Builder()} instead.
*/
protected Builder newBuilder() {
- return new Builder().setMemberName(getUniqueName()).setRedirectOutput(true)
+ return new Builder()
+ .setMemberName(getUniqueName())
.setWorkingDirectory(getWorkingDirectoryPath())
.set(CLUSTER_CONFIGURATION_DIR, getClusterConfigDirectoryPath())
- .set(DISABLE_AUTO_RECONNECT, "true").set(LOG_LEVEL, "config").set(MCAST_PORT, "0");
+ .set(DISABLE_AUTO_RECONNECT, "true");
}
protected LocatorLauncher startLocator() {
@@ -157,7 +156,7 @@ public abstract class LocatorLauncherIntegrationTestCase extends LauncherIntegra
private boolean isLauncherOnline() {
LocatorState locatorState = launcher.status();
- assertNotNull(locatorState);
+ assertThat(locatorState).isNotNull();
return Status.ONLINE.equals(locatorState.getStatus());
}
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerLocalRegressionTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerLocalRegressionTest.java
index 5059f7e..8705417 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerLocalRegressionTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerLocalRegressionTest.java
@@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_P
import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_START;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Set;
@@ -28,13 +29,12 @@ import org.junit.Before;
import org.junit.Test;
import org.apache.geode.internal.process.ProcessType;
-import org.apache.geode.test.awaitility.GeodeAwaitility;
/**
* Regression tests for stopping a JMX Manager process launched with {@link LocatorLauncher}.
*
* <p>
- * Confirms fix for <bold>GEODE-528: Locator not stopping correctly if jmx-manager-port=0</bold>
+ * Confirms fix for <bold>Locator not stopping correctly if jmx-manager-port=0</bold>
*
* <p>
* Refactored from LocatorLauncherAssemblyIntegrationTest which used to be in geode-assembly.
@@ -51,25 +51,31 @@ public class LocatorLauncherJmxManagerLocalRegressionTest
private int jmxManagerPort;
@Before
- public void setUpLocatorLauncherJmxManagerLocalIntegrationTest() throws Exception {
+ public void setUpLocatorLauncherJmxManagerLocalIntegrationTest() {
disconnectFromDS();
System.setProperty(ProcessType.PROPERTY_TEST_PREFIX, getUniqueName() + "-");
int[] ports = getRandomAvailableTCPPorts(3);
- this.defaultLocatorPort = ports[0];
- this.nonDefaultLocatorPort = ports[1];
- this.jmxManagerPort = ports[2];
+ defaultLocatorPort = ports[0];
+ nonDefaultLocatorPort = ports[1];
+ jmxManagerPort = ports[2];
- this.initialThreads = Thread.getAllStackTraces().keySet();
+ initialThreads = Thread.getAllStackTraces().keySet();
}
@Test
- public void locatorWithZeroJmxPortCleansUpWhenStopped() throws Exception {
- startLocator(newBuilder().setDeletePidFileOnStop(true).setMemberName(getUniqueName())
- .setPort(this.defaultLocatorPort).setRedirectOutput(false)
- .setWorkingDirectory(getWorkingDirectoryPath()).set(LOG_LEVEL, "config")
- .set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true")
- .set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, "0"));
+ public void locatorWithZeroJmxPortCleansUpWhenStopped() {
+ startLocator(newBuilder()
+ .setDeletePidFileOnStop(true)
+ .setMemberName(getUniqueName())
+ .setPort(defaultLocatorPort)
+ .setRedirectOutput(false)
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .set(ENABLE_CLUSTER_CONFIGURATION, "false")
+ .set(JMX_MANAGER, "true")
+ .set(JMX_MANAGER_START, "true")
+ .set(JMX_MANAGER_PORT, "0")
+ .set(LOG_LEVEL, "config"));
stopLocator();
@@ -78,12 +84,18 @@ public class LocatorLauncherJmxManagerLocalRegressionTest
}
@Test
- public void locatorWithNonZeroJmxPortCleansUpWhenStopped() throws Exception {
- startLocator(newBuilder().setDeletePidFileOnStop(true).setMemberName(getUniqueName())
- .setPort(this.defaultLocatorPort).setRedirectOutput(false)
- .setWorkingDirectory(getWorkingDirectoryPath()).set(LOG_LEVEL, "config")
- .set(ENABLE_CLUSTER_CONFIGURATION, "false").set(JMX_MANAGER, "true")
- .set(JMX_MANAGER_START, "true").set(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort)));
+ public void locatorWithNonZeroJmxPortCleansUpWhenStopped() {
+ startLocator(newBuilder()
+ .setDeletePidFileOnStop(true)
+ .setMemberName(getUniqueName())
+ .setPort(defaultLocatorPort)
+ .setRedirectOutput(false)
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .set(ENABLE_CLUSTER_CONFIGURATION, "false")
+ .set(JMX_MANAGER, "true")
+ .set(JMX_MANAGER_START, "true")
+ .set(JMX_MANAGER_PORT, String.valueOf(jmxManagerPort))
+ .set(LOG_LEVEL, "config"));
stopLocator();
@@ -92,9 +104,8 @@ public class LocatorLauncherJmxManagerLocalRegressionTest
}
private void assertThatThreadsStopped() {
- GeodeAwaitility.await().untilAsserted(
- () -> assertThat(currentThreadCount())
- .isLessThanOrEqualTo(initialThreadCountPlusAwaitility()));
+ await().untilAsserted(() -> assertThat(currentThreadCount())
+ .isLessThanOrEqualTo(initialThreadCountPlusAwaitility()));
}
private int currentThreadCount() {
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerRemoteRegressionTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerRemoteRegressionTest.java
index 4367a40..c59ddda 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerRemoteRegressionTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherJmxManagerRemoteRegressionTest.java
@@ -22,12 +22,11 @@ import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTC
import org.junit.Before;
import org.junit.Test;
-
/**
* Regression tests for stopping a JMX Manager process launched with {@link LocatorLauncher}.
*
* <p>
- * Confirms fix for <bold>GEODE-528: Locator not stopping correctly if jmx-manager-port=0</bold>
+ * Confirms fix for <bold>Locator not stopping correctly if jmx-manager-port=0</bold>
*
* <p>
* Refactored from LocatorLauncherAssemblyIntegrationTest which used to be in geode-assembly.
@@ -40,29 +39,37 @@ public class LocatorLauncherJmxManagerRemoteRegressionTest
@Before
public void before() throws Exception {
int[] ports = getRandomAvailableTCPPorts(3);
- this.defaultLocatorPort = ports[0];
- this.nonDefaultLocatorPort = ports[1];
- this.jmxManagerPort = ports[2];
+ defaultLocatorPort = ports[0];
+ nonDefaultLocatorPort = ports[1];
+ jmxManagerPort = ports[2];
}
@Test
- public void locatorProcessWithZeroJmxPortExitsWhenStopped() throws Exception {
- givenRunningLocator(addJvmArgument("-D" + JMX_MANAGER + "=true")
- .addJvmArgument("-D" + JMX_MANAGER_START + "=true")
- .addJvmArgument("-D" + JMX_MANAGER_PORT + "=0"));
+ public void locatorProcessWithZeroJmxPortExitsWhenStopped() {
+ givenRunningLocator(
+ addJvmArgument("-D" + JMX_MANAGER + "=true")
+ .addJvmArgument("-D" + JMX_MANAGER_START + "=true")
+ .addJvmArgument("-D" + JMX_MANAGER_PORT + "=0"));
- new LocatorLauncher.Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new LocatorLauncher.Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertStopOf(getLocatorProcess());
}
@Test
- public void locatorProcessWithNonZeroJmxPortExitsWhenStopped() throws Exception {
- givenRunningLocator(addJvmArgument("-D" + JMX_MANAGER + "=true")
- .addJvmArgument("-D" + JMX_MANAGER_START + "=true")
- .addJvmArgument("-D" + JMX_MANAGER_PORT + "=" + jmxManagerPort));
+ public void locatorProcessWithNonZeroJmxPortExitsWhenStopped() {
+ givenRunningLocator(
+ addJvmArgument("-D" + JMX_MANAGER + "=true")
+ .addJvmArgument("-D" + JMX_MANAGER_START + "=true")
+ .addJvmArgument("-D" + JMX_MANAGER_PORT + "=" + jmxManagerPort));
- new LocatorLauncher.Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new LocatorLauncher.Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertStopOf(getLocatorProcess());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java
index d009e2a..68bc8c5 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java
@@ -32,7 +32,7 @@ import org.apache.geode.internal.process.ProcessControllerFactory;
public class LocatorLauncherLocalFileIntegrationTest extends LocatorLauncherLocalIntegrationTest {
@Before
- public void setUpLocatorLauncherLocalFileIntegrationTest() throws Exception {
+ public void setUpLocatorLauncherLocalFileIntegrationTest() {
System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
assertThat(new ProcessControllerFactory().isAttachAPIFound()).isFalse();
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java
index 9a227f0..3fddd44 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java
@@ -14,6 +14,7 @@
*/
package org.apache.geode.distributed;
+import static java.lang.management.ManagementFactory.getRuntimeMXBean;
import static org.apache.geode.distributed.AbstractLauncher.Status.NOT_RESPONDING;
import static org.apache.geode.distributed.AbstractLauncher.Status.ONLINE;
import static org.apache.geode.distributed.AbstractLauncher.Status.STOPPED;
@@ -21,13 +22,12 @@ import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
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;
@@ -76,14 +76,16 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
@Test
public void startWithPortUsesPort() {
- LocatorLauncher launcher = startLocator(newBuilder().setPort(defaultLocatorPort));
+ LocatorLauncher launcher = startLocator(newBuilder()
+ .setPort(defaultLocatorPort));
assertThat(launcher.getInternalLocator().getPort()).isEqualTo(defaultLocatorPort);
}
@Test
public void startWithPortZeroUsesAnEphemeralPort() {
- LocatorLauncher launcher = startLocator(newBuilder().setPort(0));
+ LocatorLauncher launcher = startLocator(newBuilder()
+ .setPort(0));
assertThat(launcher.getInternalLocator().getPort()).isGreaterThan(0);
assertThat(launcher.getInternalLocator().isPeerLocator()).isTrue();
@@ -91,7 +93,8 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
@Test
public void startUsesBuilderValues() {
- LocatorLauncher launcher = startLocator(newBuilder().setPort(nonDefaultLocatorPort));
+ LocatorLauncher launcher = startLocator(newBuilder()
+ .setPort(nonDefaultLocatorPort));
InternalLocator locator = launcher.getInternalLocator();
assertThat(locator.getPort()).isEqualTo(nonDefaultLocatorPort);
@@ -142,20 +145,27 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
@Test
public void startWithDefaultPortInUseFailsWithBindException() {
givenLocatorPortInUse(defaultLocatorPort);
+ launcher = newBuilder()
+ .build();
- launcher = new Builder().build();
+ Throwable thrown = catchThrowable(() -> launcher.start());
- assertThatThrownBy(() -> launcher.start()).isInstanceOf(RuntimeException.class)
+ assertThat(thrown)
+ .isInstanceOf(RuntimeException.class)
.hasCauseInstanceOf(BindException.class);
}
@Test
public void startWithLocatorPortInUseFailsWithBindException() {
givenServerPortInUse(nonDefaultLocatorPort);
+ launcher = newBuilder()
+ .setPort(nonDefaultLocatorPort)
+ .build();
- launcher = new Builder().setPort(nonDefaultLocatorPort).build();
+ Throwable thrown = catchThrowable(() -> launcher.start());
- assertThatThrownBy(() -> launcher.start()).isInstanceOf(RuntimeException.class)
+ assertThat(thrown)
+ .isInstanceOf(RuntimeException.class)
.hasCauseInstanceOf(BindException.class);
}
@@ -163,12 +173,15 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void statusWithPidReturnsOnlineWithDetails() throws Exception {
givenRunningLocator();
- LocatorState locatorState = new Builder().setPid(localPid).build().status();
+ LocatorState locatorState = new Builder()
+ .setPid(localPid)
+ .build()
+ .status();
assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFilePath());
@@ -182,13 +195,15 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void statusWithWorkingDirectoryReturnsOnlineWithDetails() throws Exception {
givenRunningLocator();
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFilePath());
@@ -201,10 +216,14 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
@Test
public void statusWithEmptyPidFileThrowsIllegalArgumentException() {
givenEmptyPidFile();
+ LocatorLauncher launcher = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build();
- LocatorLauncher launcher = new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build();
+ Throwable thrown = catchThrowable(() -> launcher.status());
- assertThatThrownBy(launcher::status).isInstanceOf(IllegalArgumentException.class)
+ assertThat(thrown)
+ .isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid pid 'null' found in");
}
@@ -212,16 +231,17 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void statusWithEmptyWorkingDirectoryReturnsNotRespondingWithDetails() throws Exception {
givenEmptyWorkingDirectory();
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(locatorState.getClasspath()).isNull();
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
- assertThat(locatorState.getJvmArguments())
- .isEqualTo(ManagementFactory.getRuntimeMXBean().getInputArguments());
+ assertThat(locatorState.getJvmArguments()).isEqualTo(getRuntimeMXBean().getInputArguments());
assertThat(locatorState.getLogFile()).isNull();
assertThat(locatorState.getMemberName()).isNull();
assertThat(locatorState.getPid()).isNull();
@@ -236,8 +256,10 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void statusWithStalePidFileReturnsNotResponding() {
givenPidFile(fakePid);
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
}
@@ -246,7 +268,10 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void stopWithPidReturnsStopped() {
givenRunningLocator();
- LocatorState locatorState = new Builder().setPid(localPid).build().stop();
+ LocatorState locatorState = new Builder()
+ .setPid(localPid)
+ .build()
+ .stop();
assertThat(locatorState.getStatus()).isEqualTo(STOPPED);
}
@@ -255,7 +280,10 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void stopWithPidDeletesPidFile() {
givenRunningLocator(newBuilder().setDeletePidFileOnStop(true));
- new Builder().setPid(localPid).build().stop();
+ new Builder()
+ .setPid(localPid)
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
@@ -264,8 +292,10 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void stopWithWorkingDirectoryReturnsStopped() {
givenRunningLocator();
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertThat(locatorState.getStatus()).isEqualTo(STOPPED);
}
@@ -274,7 +304,10 @@ public class LocatorLauncherLocalIntegrationTest extends LocatorLauncherIntegrat
public void stopWithWorkingDirectoryDeletesPidFile() {
givenRunningLocator(newBuilder().setDeletePidFileOnStop(true));
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java
index cee83d1..1ce34d7 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java
@@ -15,7 +15,7 @@
package org.apache.geode.distributed;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
import org.junit.Before;
import org.junit.Test;
@@ -36,44 +36,64 @@ import org.apache.geode.lang.AttachAPINotFoundException;
public class LocatorLauncherRemoteFileIntegrationTest extends LocatorLauncherRemoteIntegrationTest {
@Before
- public void setUpLocatorLauncherRemoteFileIntegrationTest() throws Exception {
+ public void setUpLocatorLauncherRemoteFileIntegrationTest() {
System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
assertThat(new ProcessControllerFactory().isAttachAPIFound()).isFalse();
}
@Test
@Override
- public void statusWithPidReturnsOnlineWithDetails() throws Exception {
+ public void statusWithPidReturnsOnlineWithDetails() {
givenRunningLocator();
- assertThatThrownBy(() -> new Builder().setPid(getLocatorPid()).build().status())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .status());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@Test
@Override
- public void stopWithPidDeletesPidFile() throws Exception {
+ public void stopWithPidDeletesPidFile() {
givenRunningLocator();
- assertThatThrownBy(() -> new Builder().setPid(getLocatorPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@Test
@Override
- public void stopWithPidReturnsStopped() throws Exception {
+ public void stopWithPidReturnsStopped() {
givenRunningLocator();
- assertThatThrownBy(() -> new Builder().setPid(getLocatorPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@Test
@Override
- public void stopWithPidStopsLocatorProcess() throws Exception {
+ public void stopWithPidStopsLocatorProcess() {
givenRunningLocator();
- assertThatThrownBy(() -> new Builder().setPid(getLocatorPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
index 4b1ad85..7097f40 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -17,8 +17,9 @@ package org.apache.geode.distributed;
import static org.apache.geode.distributed.AbstractLauncher.Status.NOT_RESPONDING;
import static org.apache.geode.distributed.AbstractLauncher.Status.ONLINE;
import static org.apache.geode.distributed.AbstractLauncher.Status.STOPPED;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
import java.io.File;
import java.net.BindException;
@@ -29,7 +30,6 @@ import org.junit.Test;
import org.apache.geode.distributed.LocatorLauncher.Builder;
import org.apache.geode.distributed.LocatorLauncher.LocatorState;
import org.apache.geode.internal.GemFireVersion;
-import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.process.ProcessControllerFactory;
/**
@@ -40,33 +40,33 @@ import org.apache.geode.internal.process.ProcessControllerFactory;
public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteIntegrationTestCase {
@Before
- public void setUpLocatorLauncherRemoteIntegrationTest() throws Exception {
+ public void setUpLocatorLauncherRemoteIntegrationTest() {
assertThat(new ProcessControllerFactory().isAttachAPIFound()).isTrue();
}
@Test
- public void startCreatesPidFile() throws Exception {
+ public void startCreatesPidFile() {
startLocator();
assertThat(getPidFile()).exists();
}
@Test
- public void pidFileContainsServerPid() throws Exception {
+ public void pidFileContainsServerPid() {
startLocator();
assertThatPidIsAlive(getLocatorPid());
}
@Test
- public void startCreatesLogFile() throws Exception {
+ public void startCreatesLogFile() {
startLocator();
assertThat(getLogFile()).exists();
}
@Test
- public void startDeletesStaleControlFiles() throws Exception {
+ public void startDeletesStaleControlFiles() {
File stopRequestFile = givenControlFile(getStopRequestFileName());
File statusRequestFile = givenControlFile(getStatusRequestFileName());
File statusFile = givenControlFile(getStatusFileName());
@@ -82,7 +82,7 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
* This test takes > 1 minute to run in {@link LocatorLauncherRemoteFileIntegrationTest}.
*/
@Test
- public void startOverwritesStalePidFile() throws Exception {
+ public void startOverwritesStalePidFile() {
givenPidFile(fakePid);
startLocator();
@@ -94,7 +94,7 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
* This test takes > 1 minute to run in {@link LocatorLauncherRemoteFileIntegrationTest}.
*/
@Test
- public void startWithForceOverwritesExistingPidFile() throws Exception {
+ public void startWithForceOverwritesExistingPidFile() {
givenPidFile(localPid);
startLocator(withForce());
@@ -127,18 +127,20 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
public void statusWithPidReturnsOnlineWithDetails() throws Exception {
givenRunningLocator();
- LocatorState locatorState = new Builder().setPid(getLocatorPid()).build().status();
+ LocatorState locatorState = new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .status();
- assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost())
- .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
assertThat(locatorState.getMemberName()).isEqualTo(getUniqueName());
assertThat(locatorState.getPid().intValue()).isEqualTo(getLocatorPid());
+ assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getUptime()).isGreaterThan(0);
assertThat(locatorState.getWorkingDirectory()).isEqualToIgnoringCase(getWorkingDirectoryPath());
}
@@ -147,30 +149,35 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
public void statusWithWorkingDirectoryReturnsOnlineWithDetails() throws Exception {
givenRunningLocator();
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
- assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost())
- .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
assertThat(locatorState.getMemberName()).isEqualTo(getUniqueName());
assertThat(locatorState.getPid().intValue()).isEqualTo(readPidFile());
+ assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getUptime()).isGreaterThan(0);
assertThat(locatorState.getWorkingDirectory()).isEqualToIgnoringCase(getWorkingDirectoryPath());
}
@Test
- public void statusWithEmptyPidFileThrowsIllegalArgumentException() throws Exception {
+ public void statusWithEmptyPidFileThrowsIllegalArgumentException() {
givenEmptyPidFile();
+ LocatorLauncher launcher = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build();
- LocatorLauncher launcher = new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build();
+ Throwable thrown = catchThrowable(() -> launcher.status());
- assertThatThrownBy(() -> launcher.status()).isInstanceOf(IllegalArgumentException.class)
+ assertThat(thrown)
+ .isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid pid 'null' found in");
}
@@ -178,18 +185,19 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
public void statusWithEmptyWorkingDirectoryReturnsNotRespondingWithDetails() throws Exception {
givenEmptyWorkingDirectory();
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
- assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(locatorState.getClasspath()).isNull();
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost())
- .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getLogFile()).isNull();
assertThat(locatorState.getMemberName()).isNull();
assertThat(locatorState.getPid()).isNull();
+ assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(locatorState.getUptime().intValue()).isEqualTo(0);
assertThat(locatorState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@@ -198,66 +206,84 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
* This test takes > 1 minute to run in {@link LocatorLauncherRemoteFileIntegrationTest}.
*/
@Test
- public void statusWithStalePidFileReturnsNotResponding() throws Exception {
+ public void statusWithStalePidFileReturnsNotResponding() {
givenPidFile(fakePid);
- LocatorState locatorState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ LocatorState locatorState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
}
@Test
- public void stopWithPidReturnsStopped() throws Exception {
+ public void stopWithPidReturnsStopped() {
givenRunningLocator();
- LocatorState serverState = new Builder().setPid(getLocatorPid()).build().stop();
+ LocatorState serverState = new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@Test
- public void stopWithPidStopsLocatorProcess() throws Exception {
+ public void stopWithPidStopsLocatorProcess() {
givenRunningLocator();
- new Builder().setPid(getLocatorPid()).build().stop();
+ new Builder().setPid(getLocatorPid())
+ .build()
+ .stop();
assertStopOf(getLocatorProcess());
}
@Test
- public void stopWithPidDeletesPidFile() throws Exception {
+ public void stopWithPidDeletesPidFile() {
givenRunningLocator();
- new Builder().setPid(getLocatorPid()).build().stop();
+ new Builder()
+ .setPid(getLocatorPid())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
@Test
- public void stopWithWorkingDirectoryReturnsStopped() throws Exception {
+ public void stopWithWorkingDirectoryReturnsStopped() {
givenRunningLocator();
- LocatorState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ LocatorState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@Test
- public void stopWithWorkingDirectoryStopsLocatorProcess() throws Exception {
+ public void stopWithWorkingDirectoryStopsLocatorProcess() {
givenRunningLocator();
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertStopOf(getLocatorProcess());
}
@Test
- public void stopWithWorkingDirectoryDeletesPidFile() throws Exception {
+ public void stopWithWorkingDirectoryDeletesPidFile() {
givenRunningLocator();
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
index 34f8f31..f623cd6 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTestCase.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.distributed;
-import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.geode.internal.DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
@@ -37,6 +37,7 @@ import org.apache.geode.distributed.LocatorLauncher.Command;
import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.internal.process.ProcessStreamReader;
import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
/**
* Abstract base class for integration tests of {@link LocatorLauncher} as an application main in a
@@ -47,6 +48,8 @@ import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
public abstract class LocatorLauncherRemoteIntegrationTestCase
extends LocatorLauncherIntegrationTestCase implements UsesLocatorCommand {
+ private static final long TIMEOUT_MILLIS = GeodeAwaitility.getTimeout().getValueInMS();
+
private final AtomicBoolean threwBindException = new AtomicBoolean();
private volatile Process process;
@@ -61,7 +64,7 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
}
@After
- public void tearDownAbstractLocatorLauncherRemoteIntegrationTestCase() throws Exception {
+ public void tearDownAbstractLocatorLauncherRemoteIntegrationTestCase() {
if (process != null) {
process.destroy();
}
@@ -77,8 +80,7 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
public List<String> getJvmArguments() {
List<String> jvmArguments = new ArrayList<>();
jvmArguments.add("-D" + DistributionConfig.GEMFIRE_PREFIX + "log-level=config");
- jvmArguments
- .add("-D" + TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + String.valueOf(defaultLocatorPort));
+ jvmArguments.add("-D" + TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + defaultLocatorPort);
return jvmArguments;
}
@@ -170,7 +172,7 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
private void awaitStartFail(final LocatorCommand command, final InputListener outListener,
final InputListener errListener) throws InterruptedException {
executeCommandWithReaders(command.create(), outListener, errListener);
- process.waitFor(2, MINUTES);
+ process.waitFor(TIMEOUT_MILLIS, MILLISECONDS);
assertThatProcessIsNotAlive();
assertThat(process.exitValue()).isEqualTo(1);
}
@@ -225,9 +227,13 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
try {
process = new ProcessBuilder(command).directory(getWorkingDirectory()).start();
processOutReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getInputStream()).build().start();
+ .inputStream(process.getInputStream())
+ .build()
+ .start();
processErrReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getErrorStream()).build().start();
+ .inputStream(process.getErrorStream())
+ .build()
+ .start();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -238,9 +244,15 @@ public abstract class LocatorLauncherRemoteIntegrationTestCase
try {
process = new ProcessBuilder(command).directory(getWorkingDirectory()).start();
processOutReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getInputStream()).inputListener(outListener).build().start();
+ .inputStream(process.getInputStream())
+ .inputListener(outListener)
+ .build()
+ .start();
processErrReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getErrorStream()).inputListener(errListener).build().start();
+ .inputStream(process.getErrorStream())
+ .inputListener(errListener)
+ .build()
+ .start();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
index 3299bbb..611c9f3 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -50,19 +50,24 @@ public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest
public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
@Before
- public void setUpLocatorLauncherRemoteWithCustomLoggingIntegrationTest() throws Exception {
+ public void setUpLocatorLauncherRemoteWithCustomLoggingIntegrationTest() {
String configFileName = getClass().getSimpleName() + "_log4j2.xml";
- customLoggingConfigFile = createFileFromResource(getResource(configFileName),
- getWorkingDirectory(), configFileName);
+ customLoggingConfigFile = createFileFromResource(
+ getResource(configFileName),
+ getWorkingDirectory(),
+ configFileName);
}
@Test
public void startWithCustomLoggingConfiguration() {
startLocator(new LocatorCommand(this)
.addJvmArgument("-D" + CONFIGURATION_FILE_PROPERTY + "=" + getCustomLoggingConfigFilePath())
- .withCommand(Command.START), new ToSystemOut(), new ToSystemOut());
+ .withCommand(Command.START),
+ new ToSystemOut(),
+ new ToSystemOut());
- assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX)
+ assertThat(systemOutRule.getLog())
+ .contains(CONFIG_LAYOUT_PREFIX)
.contains(CONFIGURATION_FILE_PROPERTY + " = " + getCustomLoggingConfigFilePath());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerCommand.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerCommand.java
index ca1bfd9..8b7d0c5 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerCommand.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerCommand.java
@@ -35,12 +35,12 @@ public class ServerCommand {
}
public ServerCommand(final UsesServerCommand user) {
- this.javaPath = user.getJavaPath();
- this.jvmArguments = user.getJvmArguments();
- this.classPath = user.getClassPath();
- this.name = user.getName();
- this.disableDefaultServer = user.getDisableDefaultServer();
- this.command = Command.START;
+ javaPath = user.getJavaPath();
+ jvmArguments = user.getJvmArguments();
+ classPath = user.getClassPath();
+ name = user.getName();
+ disableDefaultServer = user.getDisableDefaultServer();
+ command = Command.START;
}
public ServerCommand withJavaPath(final String javaPath) {
@@ -54,7 +54,7 @@ public class ServerCommand {
}
public ServerCommand addJvmArgument(final String arg) {
- this.jvmArguments.add(arg);
+ jvmArguments.add(arg);
return this;
}
@@ -78,7 +78,7 @@ public class ServerCommand {
}
public ServerCommand disableDefaultServer(final boolean value) {
- this.disableDefaultServer = value;
+ disableDefaultServer = value;
return this;
}
@@ -87,7 +87,7 @@ public class ServerCommand {
}
public ServerCommand force(final boolean value) {
- this.force = value;
+ force = value;
return this;
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherBuilderIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherBuilderIntegrationTest.java
index 3b6f53f..91366df 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherBuilderIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherBuilderIntegrationTest.java
@@ -14,9 +14,11 @@
*/
package org.apache.geode.distributed;
+import static java.net.InetAddress.getLocalHost;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.distributed.DistributedSystem.PROPERTIES_FILE_PROPERTY;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort;
import static org.apache.geode.internal.cache.AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
@@ -27,7 +29,6 @@ import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
@@ -39,7 +40,6 @@ import org.junit.rules.TestName;
import org.apache.geode.distributed.ServerLauncher.Builder;
import org.apache.geode.distributed.ServerLauncher.Command;
-import org.apache.geode.internal.AvailablePortHelper;
/**
* Integration tests for using {@link ServerLauncher} as an in-process API within an existing JVM.
@@ -63,7 +63,9 @@ public class ServerLauncherBuilderIntegrationTest {
givenGemFirePropertiesFile(withMemberName());
// when: starting with null MemberName
- ServerLauncher launcher = new Builder().setCommand(Command.START).build();
+ ServerLauncher launcher = new Builder()
+ .setCommand(Command.START)
+ .build();
// then: name in gemfire.properties file should be used for MemberName
assertThat(launcher.getMemberName()).isNull(); // name will be read during start()
@@ -75,10 +77,13 @@ public class ServerLauncherBuilderIntegrationTest {
givenGemFirePropertiesFile(withoutMemberName());
// when: no MemberName is specified
- Throwable thrown = catchThrowable(() -> new Builder().setCommand(Command.START).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .build());
// then: throw IllegalStateException
- then(thrown).isExactlyInstanceOf(IllegalStateException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalStateException.class)
.hasMessage(memberNameValidationErrorMessage());
}
@@ -87,12 +92,15 @@ public class ServerLauncherBuilderIntegrationTest {
// given: using LocatorLauncher in-process
// when: setting WorkingDirectory to non-current directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setCommand(Command.START).setMemberName("memberOne")
- .setWorkingDirectory(getWorkingDirectoryPath()).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .setMemberName("memberOne")
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build());
// then: throw IllegalStateException
- then(thrown).isExactlyInstanceOf(IllegalStateException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalStateException.class)
.hasMessage(workingDirectoryOptionNotValidErrorMessage());
}
@@ -103,7 +111,7 @@ public class ServerLauncherBuilderIntegrationTest {
// when: parsing many arguments
builder.parseArguments("start", "memberOne", "--server-bind-address",
- InetAddress.getLocalHost().getHostAddress(), "--dir", getWorkingDirectoryPath(),
+ getLocalHost().getHostAddress(), "--dir", getWorkingDirectoryPath(),
"--hostname-for-clients", "Tucows", "--pid", "1234", "--server-port", "11235",
"--redirect-output", "--force", "--debug", "--max-connections", "300",
"--max-message-count", "1000", "--message-time-to-live", "10000", "--socket-buffer-size",
@@ -114,16 +122,16 @@ public class ServerLauncherBuilderIntegrationTest {
assertThat(builder.getDebug()).isTrue();
assertThat(builder.getForce()).isTrue();
assertThat(builder.getHostNameForClients()).isEqualTo("Tucows");
- assertThat(builder.getPid().intValue()).isEqualTo(1234);
- assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
- assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
- assertThat(builder.getRedirectOutput()).isTrue();
- assertThat(builder.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
assertThat(builder.getMaxConnections()).isEqualTo(300);
assertThat(builder.getMaxMessageCount()).isEqualTo(1000);
+ assertThat(builder.getMaxThreads()).isEqualTo(900);
assertThat(builder.getMessageTimeToLive()).isEqualTo(10000);
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getServerBindAddress()).isEqualTo(getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
assertThat(builder.getSocketBufferSize()).isEqualTo(1024);
- assertThat(builder.getMaxThreads()).isEqualTo(900);
+ assertThat(builder.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@Test
@@ -143,16 +151,16 @@ public class ServerLauncherBuilderIntegrationTest {
assertThat(builder.getForce()).isFalse();
assertThat(builder.getHelp()).isFalse();
assertThat(builder.getHostNameForClients()).isNull();
+ assertThat(builder.getMaxConnections()).isEqualTo(300);
+ assertThat(builder.getMaxMessageCount()).isEqualTo(1000);
+ assertThat(builder.getMaxThreads()).isEqualTo(900);
assertThat(builder.getMemberName()).isEqualTo("memberOne");
+ assertThat(builder.getMessageTimeToLive()).isEqualTo(10000);
assertThat(builder.getPid()).isNull();
assertThat(builder.getServerBindAddress()).isNull();
assertThat(builder.getServerPort().intValue()).isEqualTo(12345);
- assertThat(builder.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
- assertThat(builder.getMaxConnections()).isEqualTo(300);
- assertThat(builder.getMaxMessageCount()).isEqualTo(1000);
- assertThat(builder.getMessageTimeToLive()).isEqualTo(10000);
assertThat(builder.getSocketBufferSize()).isEqualTo(1024);
- assertThat(builder.getMaxThreads()).isEqualTo(900);
+ assertThat(builder.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@Test
@@ -219,11 +227,12 @@ public class ServerLauncherBuilderIntegrationTest {
File nonDirectory = temporaryFolder.newFile();
// when: setting WorkingDirectory to that file
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory(nonDirectory.getCanonicalPath()));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory(nonDirectory.getCanonicalPath()));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException(nonDirectory.getCanonicalPath()));
}
@@ -233,11 +242,12 @@ public class ServerLauncherBuilderIntegrationTest {
// given:
// when: setting WorkingDirectory to non-existing directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory("/path/to/non_existing/directory"));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory("/path/to/non_existing/directory"));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
}
@@ -245,7 +255,7 @@ public class ServerLauncherBuilderIntegrationTest {
@Test
public void serverPortCanBeOverriddenBySystemProperty() {
// given: overridden default port
- int overriddenPort = AvailablePortHelper.getRandomAvailableTCPPort();
+ int overriddenPort = getRandomAvailableTCPPort();
System.setProperty(TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(overriddenPort));
// when: creating new ServerLauncher
@@ -268,7 +278,8 @@ public class ServerLauncherBuilderIntegrationTest {
}
private String workingDirectoryNotFoundErrorMessage() {
- return String.format(AbstractLauncher.WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE,
+ return String.format(
+ AbstractLauncher.WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE,
"Server");
}
@@ -297,7 +308,7 @@ public class ServerLauncherBuilderIntegrationTest {
/**
* Creates a gemfire properties file in temporaryFolder:
* <ol>
- * <li>creates gemfire.properties in <code>temporaryFolder</code></li>
+ * <li>creates gemfire.properties in {@code temporaryFolder}</li>
* <li>writes config to the file</li>
* <li>sets "gemfirePropertyFile" system property</li>
* </ol>
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
index c104c26..f4a9ddb 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
@@ -14,9 +14,11 @@
*/
package org.apache.geode.distributed;
+import static java.net.InetAddress.getLocalHost;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.distributed.DistributedSystem.PROPERTIES_FILE_PROPERTY;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPort;
import static org.apache.geode.internal.cache.AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
@@ -27,7 +29,6 @@ import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UncheckedIOException;
-import java.net.InetAddress;
import java.util.Properties;
import org.junit.Rule;
@@ -38,7 +39,6 @@ import org.junit.rules.TestName;
import org.apache.geode.distributed.ServerLauncher.Builder;
import org.apache.geode.distributed.ServerLauncher.Command;
-import org.apache.geode.internal.AvailablePortHelper;
/**
* Integration tests for using {@link ServerLauncher} as an in-process API within an existing JVM.
@@ -62,7 +62,9 @@ public class ServerLauncherIntegrationTest {
givenGemFirePropertiesFile(withMemberName());
// when: starting with null MemberName
- ServerLauncher launcher = new Builder().setCommand(Command.START).build();
+ ServerLauncher launcher = new Builder()
+ .setCommand(Command.START)
+ .build();
// then: name in gemfire.properties file should be used for MemberName
assertThat(launcher.getMemberName()).isNull(); // name will be read during start()
@@ -74,10 +76,13 @@ public class ServerLauncherIntegrationTest {
givenGemFirePropertiesFile(withoutMemberName());
// when: no MemberName is specified
- Throwable thrown = catchThrowable(() -> new Builder().setCommand(Command.START).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .build());
// then: throw IllegalStateException
- then(thrown).isExactlyInstanceOf(IllegalStateException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalStateException.class)
.hasMessage(memberNameValidationErrorMessage());
}
@@ -86,12 +91,15 @@ public class ServerLauncherIntegrationTest {
// given: using LocatorLauncher in-process
// when: setting WorkingDirectory to non-current directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setCommand(Command.START).setMemberName("memberOne")
- .setWorkingDirectory(getWorkingDirectoryPath()).build());
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setCommand(Command.START)
+ .setMemberName("memberOne")
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build());
// then: throw IllegalStateException
- then(thrown).isExactlyInstanceOf(IllegalStateException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalStateException.class)
.hasMessage(workingDirectoryOptionNotValidErrorMessage());
}
@@ -102,7 +110,7 @@ public class ServerLauncherIntegrationTest {
// when: parsing many arguments
builder.parseArguments("start", "memberOne", "--server-bind-address",
- InetAddress.getLocalHost().getHostAddress(), "--dir", getWorkingDirectoryPath(),
+ getLocalHost().getHostAddress(), "--dir", getWorkingDirectoryPath(),
"--hostname-for-clients", "Tucows", "--pid", "1234", "--server-port", "11235",
"--redirect-output", "--force", "--debug");
@@ -112,9 +120,9 @@ public class ServerLauncherIntegrationTest {
assertThat(builder.getForce()).isTrue();
assertThat(builder.getHostNameForClients()).isEqualTo("Tucows");
assertThat(builder.getPid().intValue()).isEqualTo(1234);
- assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
- assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getServerBindAddress()).isEqualTo(getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
assertThat(builder.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@@ -204,11 +212,12 @@ public class ServerLauncherIntegrationTest {
File nonDirectory = temporaryFolder.newFile();
// when: setting WorkingDirectory to that file
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory(nonDirectory.getCanonicalPath()));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory(nonDirectory.getCanonicalPath()));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException(nonDirectory.getCanonicalPath()));
}
@@ -218,11 +227,12 @@ public class ServerLauncherIntegrationTest {
// given:
// when: setting WorkingDirectory to non-existing directory
- Throwable thrown =
- catchThrowable(() -> new Builder().setWorkingDirectory("/path/to/non_existing/directory"));
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setWorkingDirectory("/path/to/non_existing/directory"));
// then: throw IllegalArgumentException
- then(thrown).isExactlyInstanceOf(IllegalArgumentException.class)
+ then(thrown)
+ .isExactlyInstanceOf(IllegalArgumentException.class)
.hasMessage(workingDirectoryNotFoundErrorMessage())
.hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
}
@@ -230,11 +240,12 @@ public class ServerLauncherIntegrationTest {
@Test
public void serverPortCanBeOverriddenBySystemProperty() {
// given: overridden default port
- int overriddenPort = AvailablePortHelper.getRandomAvailableTCPPort();
+ int overriddenPort = getRandomAvailableTCPPort();
System.setProperty(TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(overriddenPort));
// when: creating new ServerLauncher
- ServerLauncher launcher = new Builder().build();
+ ServerLauncher launcher = new Builder()
+ .build();
// then: server port should be the overridden default port
assertThat(launcher.getServerPort()).isEqualTo(overriddenPort);
@@ -253,7 +264,8 @@ public class ServerLauncherIntegrationTest {
}
private String workingDirectoryNotFoundErrorMessage() {
- return String.format(AbstractLauncher.WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE,
+ return String.format(
+ AbstractLauncher.WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE,
"Server");
}
@@ -282,7 +294,7 @@ public class ServerLauncherIntegrationTest {
/**
* Creates a gemfire properties file in temporaryFolder:
* <ol>
- * <li>creates gemfire.properties in <code>temporaryFolder</code></li>
+ * <li>creates gemfire.properties in {@code temporaryFolder}</li>
* <li>writes config to the file</li>
* <li>sets "gemfirePropertyFile" system property</li>
* </ol>
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTestCase.java
index 4636560..b5b011f 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherIntegrationTestCase.java
@@ -15,13 +15,13 @@
package org.apache.geode.distributed;
import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
-import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
import static org.apache.geode.internal.cache.AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.FileWriter;
@@ -44,7 +44,6 @@ import org.apache.geode.internal.cache.xmlcache.CacheCreation;
import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
import org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation;
import org.apache.geode.internal.process.ProcessType;
-import org.apache.geode.test.awaitility.GeodeAwaitility;
/**
* Abstract base class for integration tests of {@link ServerLauncher}.
@@ -89,7 +88,7 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
}
protected ServerLauncher awaitStart(final ServerLauncher launcher) {
- GeodeAwaitility.await().untilAsserted(() -> assertThat(isLauncherOnline()).isTrue());
+ await().untilAsserted(() -> assertThat(isLauncherOnline()).isTrue());
return launcher;
}
@@ -104,9 +103,10 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
* without any of these defaults then simply use {@code new Builder()} instead.
*/
protected Builder newBuilder() {
- return new Builder().setMemberName(getUniqueName()).setRedirectOutput(true)
- .setWorkingDirectory(getWorkingDirectoryPath()).set(LOG_LEVEL, "config")
- .set(MCAST_PORT, "0");
+ return new Builder()
+ .setMemberName(getUniqueName())
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .set(DISABLE_AUTO_RECONNECT, "true");
}
protected ServerLauncher givenServerLauncher() {
@@ -182,8 +182,8 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
private File writeCacheXml(final int serverPort) throws IOException {
CacheCreation creation = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
- attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.REPLICATE);
+ attrs.setScope(Scope.DISTRIBUTED_ACK);
creation.createRegion(getUniqueName(), attrs);
creation.addCacheServer().setPort(serverPort);
@@ -201,17 +201,17 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
throws IOException {
CacheCreation creation = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
- attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.REPLICATE);
+ attrs.setScope(Scope.DISTRIBUTED_ACK);
creation.createRegion(getUniqueName(), attrs);
CacheServer server = creation.addCacheServer();
- server.setPort(serverPort);
server.setBindAddress(bindAddress);
server.setHostnameForClients(hostnameForClients);
server.setMaxConnections(maxConnections);
server.setMaxThreads(maxThreads);
server.setMaximumMessageCount(maximumMessageCount);
server.setMessageTimeToLive(messageTimeToLive);
+ server.setPort(serverPort);
server.setSocketBufferSize(socketBufferSize);
File cacheXmlFile = new File(getWorkingDirectory(), getUniqueName() + ".xml");
@@ -225,8 +225,8 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
private File writeCacheXml() throws IOException {
CacheCreation creation = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
- attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.REPLICATE);
+ attrs.setScope(Scope.DISTRIBUTED_ACK);
creation.createRegion(getUniqueName(), attrs);
creation.addCacheServer();
@@ -240,7 +240,7 @@ public abstract class ServerLauncherIntegrationTestCase extends LauncherIntegrat
private boolean isLauncherOnline() {
ServerState serverState = launcher.status();
- assertNotNull(serverState);
+ assertThat(serverState).isNotNull();
return Status.ONLINE.equals(serverState.getStatus());
}
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java
index 6d4ca21..0c28ebf 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java
@@ -22,12 +22,12 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
import java.io.File;
import java.net.BindException;
-import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
@@ -78,23 +78,26 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
@Test
public void startWithPortUsesPort() {
- ServerLauncher launcher =
- startServer(newBuilder().setDisableDefaultServer(false).setServerPort(defaultServerPort));
+ ServerLauncher launcher = startServer(newBuilder()
+ .setDisableDefaultServer(false)
+ .setServerPort(defaultServerPort));
assertThat(launcher.getCache().getCacheServers().get(0).getPort()).isEqualTo(defaultServerPort);
}
@Test
public void startWithPortZeroUsesAnEphemeralPort() {
- ServerLauncher launcher =
- startServer(newBuilder().setDisableDefaultServer(false).setServerPort(0));
+ ServerLauncher launcher = startServer(newBuilder()
+ .setDisableDefaultServer(false)
+ .setServerPort(0));
assertThat(launcher.getCache().getCacheServers().get(0).getPort()).isGreaterThan(0);
}
@Test
public void startUsesBuilderValues() {
- ServerLauncher launcher = startServer(newBuilder().set(DISABLE_AUTO_RECONNECT, "true"));
+ ServerLauncher launcher = startServer(newBuilder()
+ .set(DISABLE_AUTO_RECONNECT, "true"));
Cache cache = launcher.getCache();
assertThat(cache).isNotNull();
@@ -168,7 +171,8 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
int startPort = freePorts[1];
givenCacheXmlFileWithServerPort(cacheXmlPort);
- launcher = startServer(new Builder().setServerPort(startPort));
+ launcher = startServer(newBuilder()
+ .setServerPort(startPort));
// server should use --server-port instead of port in cache.xml
assertThatServerPortIsInUse(startPort);
@@ -180,9 +184,8 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void startWithServerPortOverridesDefaultWithCacheXml() {
givenCacheXmlFile();
- launcher = awaitStart(new Builder().setMemberName(getUniqueName()).setRedirectOutput(true)
- .setServerPort(defaultServerPort).setWorkingDirectory(getWorkingDirectoryPath())
- .set(LOG_LEVEL, "config").set(MCAST_PORT, "0"));
+ launcher = awaitStart(newBuilder()
+ .setServerPort(defaultServerPort));
// verify server used --server-port instead of default
assertThatServerPortIsInUse(defaultServerPort);
@@ -192,20 +195,27 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
@Test
public void startWithDefaultPortInUseFailsWithBindException() {
givenServerPortInUse(defaultServerPort);
+ launcher = newBuilder()
+ .build();
- launcher = new Builder().build();
+ Throwable thrown = catchThrowable(() -> launcher.start());
- assertThatThrownBy(() -> launcher.start()).isInstanceOf(RuntimeException.class)
+ assertThat(thrown)
+ .isInstanceOf(RuntimeException.class)
.hasCauseInstanceOf(BindException.class);
}
@Test
public void startWithServerPortInUseFailsWithBindException() {
givenServerPortInUse(nonDefaultServerPort);
+ launcher = newBuilder()
+ .setServerPort(nonDefaultServerPort)
+ .build();
- launcher = new Builder().setServerPort(nonDefaultServerPort).build();
+ Throwable thrown = catchThrowable(() -> launcher.start());
- assertThatThrownBy(() -> launcher.start()).isInstanceOf(RuntimeException.class)
+ assertThat(thrown)
+ .isInstanceOf(RuntimeException.class)
.hasCauseInstanceOf(BindException.class);
}
@@ -214,18 +224,24 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
int[] freePorts = getRandomAvailableTCPPorts(2);
int xmlPort = freePorts[0];
int serverPort = freePorts[1];
- Integer maxThreads = 100;
- Integer maxConnections = 1200;
- Integer maxMessageCount = 500000;
- Integer socketBufferSize = 342768;
- Integer messageTimeToLive = 120;
+ int maxThreads = 100;
+ int maxConnections = 1200;
+ int maxMessageCount = 500000;
+ int socketBufferSize = 342768;
+ int messageTimeToLive = 120;
String hostnameForClients = "hostName4Clients";
String serverBindAddress = "127.0.0.1";
- ServerLauncher.Builder launcherBuilder = new Builder().setServerBindAddress(serverBindAddress)
- .setServerPort(serverPort).setMaxThreads(maxThreads).setMaxConnections(maxConnections)
- .setMaxMessageCount(maxMessageCount).setMessageTimeToLive(messageTimeToLive)
- .setSocketBufferSize(socketBufferSize).setHostNameForClients(hostnameForClients);
+ ServerLauncher.Builder launcherBuilder = newBuilder()
+ .setHostNameForClients(hostnameForClients)
+ .setMaxConnections(maxConnections)
+ .setMaxMessageCount(maxMessageCount)
+ .setMaxThreads(maxThreads)
+ .setMessageTimeToLive(messageTimeToLive)
+ .setServerBindAddress(serverBindAddress)
+ .setServerPort(serverPort)
+ .setSocketBufferSize(socketBufferSize);
+
givenCacheXmlFileWithServerProperties(xmlPort, CacheServer.DEFAULT_BIND_ADDRESS,
CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS, CacheServer.DEFAULT_MAX_CONNECTIONS,
CacheServer.DEFAULT_MAX_THREADS, CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT,
@@ -236,23 +252,27 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
assertThatServerPortIsInUse(serverPort);
assertThatServerPortIsFree(xmlPort);
assertThat(Integer.valueOf(launcher.status().getPort())).isEqualTo(serverPort);
+
List<CacheServer> servers = launcher.getCache().getCacheServers();
assertThat(servers.size()).isEqualTo(1);
+
CacheServer server = servers.get(0);
- assertThat(server.getMaxThreads()).isEqualTo(maxThreads);
+ assertThat(server.getBindAddress()).isEqualTo(serverBindAddress);
+ assertThat(server.getHostnameForClients()).isEqualTo(hostnameForClients);
assertThat(server.getMaxConnections()).isEqualTo(maxConnections);
+ assertThat(server.getMaxThreads()).isEqualTo(maxThreads);
assertThat(server.getMaximumMessageCount()).isEqualTo(maxMessageCount);
- assertThat(server.getSocketBufferSize()).isEqualTo(socketBufferSize);
assertThat(server.getMessageTimeToLive()).isEqualTo(messageTimeToLive);
- assertThat(server.getHostnameForClients()).isEqualTo(hostnameForClients);
- assertThat(server.getBindAddress()).isEqualTo(serverBindAddress);
+ assertThat(server.getSocketBufferSize()).isEqualTo(socketBufferSize);
}
@Test
public void statusForDisableDefaultServerHasEmptyPort() {
givenServerPortIsFree(defaultServerPort);
- ServerState serverState = startServer(newBuilder().setDisableDefaultServer(true)).status();
+ ServerState serverState = startServer(newBuilder()
+ .setDisableDefaultServer(true))
+ .status();
assertThat(serverState.getPort()).isEqualTo("");
}
@@ -261,17 +281,20 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void statusWithPidReturnsOnlineWithDetails() throws UnknownHostException {
givenRunningServer();
- ServerState serverState = new Builder().setPid(localPid).build().status();
+ ServerState serverState = new Builder()
+ .setPid(localPid)
+ .build()
+ .status();
- assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getClasspath()).isEqualTo(getClassPath());
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(serverState.getLogFile()).isEqualTo(getLogFilePath());
assertThat(serverState.getMemberName()).isEqualTo(getUniqueName());
assertThat(serverState.getPid().intValue()).isEqualTo(localPid);
+ assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getUptime()).isGreaterThan(0);
assertThat(serverState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@@ -280,18 +303,20 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void statusWithWorkingDirectoryReturnsOnlineWithDetails() throws UnknownHostException {
givenRunningServer();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
- assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getClasspath()).isEqualTo(getClassPath());
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(serverState.getLogFile()).isEqualTo(getLogFilePath());
assertThat(serverState.getMemberName()).isEqualTo(getUniqueName());
assertThat(serverState.getPid().intValue()).isEqualTo(readPidFile());
+ assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getUptime()).isGreaterThan(0);
assertThat(serverState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@@ -299,10 +324,14 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
@Test
public void statusWithEmptyPidFileThrowsIllegalArgumentException() {
givenEmptyPidFile();
+ ServerLauncher launcher = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build();
- ServerLauncher launcher = new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build();
+ Throwable thrown = catchThrowable(() -> launcher.status());
- assertThatThrownBy(() -> launcher.status()).isInstanceOf(IllegalArgumentException.class)
+ assertThat(thrown)
+ .isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid pid 'null' found in");
}
@@ -311,18 +340,20 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
throws UnknownHostException {
givenEmptyWorkingDirectory();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
- assertThat(serverState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(serverState.getClasspath()).isNull();
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(serverState.getLogFile()).isNull();
assertThat(serverState.getMemberName()).isNull();
assertThat(serverState.getPid()).isNull();
+ assertThat(serverState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(serverState.getUptime().intValue()).isEqualTo(0);
assertThat(serverState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
}
@@ -334,8 +365,10 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void statusWithStalePidFileReturnsNotResponding() {
givenPidFile(fakePid);
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(serverState.getStatus()).isEqualTo(NOT_RESPONDING);
}
@@ -344,7 +377,10 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void stopWithPidReturnsStopped() {
givenRunningServer();
- ServerState serverState = new Builder().setPid(localPid).build().stop();
+ ServerState serverState = new Builder()
+ .setPid(localPid)
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@@ -353,7 +389,10 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void stopWithPidDeletesPidFile() {
givenRunningServer(newBuilder().setDeletePidFileOnStop(true));
- new Builder().setPid(localPid).build().stop();
+ new Builder()
+ .setPid(localPid)
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
@@ -362,8 +401,10 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void stopWithWorkingDirectoryReturnsStopped() {
givenRunningServer();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@@ -372,7 +413,10 @@ public class ServerLauncherLocalIntegrationTest extends ServerLauncherLocalInteg
public void stopWithWorkingDirectoryDeletesPidFile() {
givenRunningServer(newBuilder().setDeletePidFileOnStop(true));
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java
index 01f5c6c..4709997 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java
@@ -15,7 +15,7 @@
package org.apache.geode.distributed;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,12 @@ public class ServerLauncherRemoteFileIntegrationTest extends ServerLauncherRemot
public void statusWithPidReturnsOnlineWithDetails() {
givenRunningServer();
- assertThatThrownBy(() -> new Builder().setPid(getServerPid()).build().status())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getServerPid())
+ .build()
+ .status());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@@ -59,7 +64,12 @@ public class ServerLauncherRemoteFileIntegrationTest extends ServerLauncherRemot
public void stopWithPidDeletesPidFile() {
givenRunningServer();
- assertThatThrownBy(() -> new Builder().setPid(getServerPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@@ -71,7 +81,12 @@ public class ServerLauncherRemoteFileIntegrationTest extends ServerLauncherRemot
public void stopWithPidReturnsStopped() {
givenRunningServer();
- assertThatThrownBy(() -> new Builder().setPid(getServerPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
@@ -83,7 +98,12 @@ public class ServerLauncherRemoteFileIntegrationTest extends ServerLauncherRemot
public void stopWithPidStopsServerProcess() {
givenRunningServer();
- assertThatThrownBy(() -> new Builder().setPid(getServerPid()).build().stop())
+ Throwable thrown = catchThrowable(() -> new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop());
+
+ assertThat(thrown)
.isInstanceOf(AttachAPINotFoundException.class);
}
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
index aaea0f5..8ef565a 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -19,13 +19,13 @@ import static org.apache.geode.distributed.AbstractLauncher.Status.ONLINE;
import static org.apache.geode.distributed.AbstractLauncher.Status.STOPPED;
import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
+import static org.apache.geode.internal.net.SocketCreator.getLocalHost;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.catchThrowable;
import java.io.File;
import java.io.IOException;
import java.net.BindException;
-import java.net.InetAddress;
import org.junit.Before;
import org.junit.Test;
@@ -176,8 +176,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusForDisableDefaultServerHasEmptyPort() {
givenRunningServer(withDisableDefaultServer());
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(serverState.getPort()).isEmpty();
}
@@ -186,7 +188,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusWithPidReturnsOnlineWithDetails() throws IOException {
givenRunningServer();
- ServerState serverState = new Builder().setPid(getServerPid()).build().status();
+ ServerState serverState = new Builder()
+ .setPid(getServerPid())
+ .build()
+ .status();
assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getPid().intValue()).isEqualTo(getServerPid());
@@ -197,7 +202,7 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getMemberName()).isEqualTo(getUniqueName());
}
@@ -205,8 +210,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusWithWorkingDirectoryReturnsOnlineWithDetails() throws IOException {
givenRunningServer();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(serverState.getStatus()).isEqualTo(ONLINE);
assertThat(serverState.getPid().intValue()).isEqualTo(readPidFile());
@@ -217,7 +224,7 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getMemberName()).isEqualTo(getUniqueName());
}
@@ -225,9 +232,14 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusWithEmptyPidFileThrowsIllegalArgumentException() {
givenEmptyPidFile();
- ServerLauncher launcher = new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build();
+ ServerLauncher launcher = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build();
- assertThatThrownBy(() -> launcher.status()).isInstanceOf(IllegalArgumentException.class)
+ Throwable thrown = catchThrowable(() -> launcher.status());
+
+ assertThat(thrown)
+ .isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid pid 'null' found in");
}
@@ -235,8 +247,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusWithEmptyWorkingDirectoryReturnsNotRespondingWithDetails() throws IOException {
givenEmptyWorkingDirectory();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(serverState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(serverState.getPid()).isNull();
@@ -246,7 +260,7 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(serverState.getLogFile()).isNull();
- assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(serverState.getHost()).isEqualTo(getLocalHost().getCanonicalHostName());
assertThat(serverState.getMemberName()).isNull();
}
@@ -254,8 +268,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void statusWithStalePidFileReturnsNotResponding() {
givenPidFile(fakePid);
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().status();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .status();
assertThat(serverState.getStatus()).isEqualTo(NOT_RESPONDING);
}
@@ -264,7 +280,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithPidReturnsStopped() {
givenRunningServer();
- ServerState serverState = new Builder().setPid(getServerPid()).build().stop();
+ ServerState serverState = new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@@ -273,7 +292,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithPidStopsServerProcess() {
givenRunningServer();
- new Builder().setPid(getServerPid()).build().stop();
+ new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop();
assertStopOf(getServerProcess());
}
@@ -282,7 +304,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithPidDeletesPidFile() {
givenRunningServer();
- new Builder().setPid(getServerPid()).build().stop();
+ new Builder()
+ .setPid(getServerPid())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
@@ -291,8 +316,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithWorkingDirectoryReturnsStopped() {
givenRunningServer();
- ServerState serverState =
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ ServerState serverState = new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertThat(serverState.getStatus()).isEqualTo(STOPPED);
}
@@ -301,7 +328,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithWorkingDirectoryStopsServerProcess() {
givenRunningServer();
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertStopOf(getServerProcess());
}
@@ -310,7 +340,10 @@ public class ServerLauncherRemoteIntegrationTest extends ServerLauncherRemoteInt
public void stopWithWorkingDirectoryDeletesPidFile() {
givenRunningServer();
- new Builder().setWorkingDirectory(getWorkingDirectoryPath()).build().stop();
+ new Builder()
+ .setWorkingDirectory(getWorkingDirectoryPath())
+ .build()
+ .stop();
assertDeletionOf(getPidFile());
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
index 4cb241d..b507895 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
@@ -14,7 +14,7 @@
*/
package org.apache.geode.distributed;
-import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
@@ -37,6 +37,7 @@ import org.junit.Before;
import org.apache.geode.distributed.AbstractLauncher.Status;
import org.apache.geode.internal.process.ProcessStreamReader;
import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
+import org.apache.geode.test.awaitility.GeodeAwaitility;
/**
* Abstract base class for integration tests of {@link ServerLauncher} as an application main in a
@@ -47,6 +48,8 @@ import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
public abstract class ServerLauncherRemoteIntegrationTestCase
extends ServerLauncherIntegrationTestCase implements UsesServerCommand {
+ private static final long TIMEOUT_MILLIS = GeodeAwaitility.getTimeout().getValueInMS();
+
private final AtomicBoolean threwBindException = new AtomicBoolean();
private volatile Process process;
@@ -84,8 +87,7 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
List<String> jvmArguments = new ArrayList<>();
jvmArguments.add("-D" + GEMFIRE_PREFIX + LOG_LEVEL + "=config");
jvmArguments.add("-D" + GEMFIRE_PREFIX + MCAST_PORT + "=0");
- jvmArguments
- .add("-D" + TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + String.valueOf(defaultServerPort));
+ jvmArguments.add("-D" + TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + defaultServerPort);
return jvmArguments;
}
@@ -129,9 +131,8 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
return awaitStart(command);
}
- protected ServerLauncher startServer(final ServerCommand command,
- final ProcessStreamReader.InputListener outListener,
- final ProcessStreamReader.InputListener errListener) throws IOException {
+ protected ServerLauncher startServer(final ServerCommand command, final InputListener outListener,
+ final InputListener errListener) throws IOException {
executeCommandWithReaders(command.create(), outListener, errListener);
ServerLauncher launcher = awaitStart(getWorkingDirectory());
assertThat(process.isAlive()).isTrue();
@@ -144,7 +145,8 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
protected void startServerShouldFail(final ServerCommand command)
throws IOException, InterruptedException {
- startServerShouldFail(command, createBindExceptionListener("sysout", threwBindException),
+ startServerShouldFail(command,
+ createBindExceptionListener("sysout", threwBindException),
createBindExceptionListener("syserr", threwBindException));
}
@@ -175,7 +177,8 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
private ServerLauncher awaitStart(final File workingDirectory) {
try {
launcher = new ServerLauncher.Builder()
- .setWorkingDirectory(workingDirectory.getCanonicalPath()).build();
+ .setWorkingDirectory(workingDirectory.getCanonicalPath())
+ .build();
awaitStart(launcher);
assertThat(process.isAlive()).isTrue();
return launcher;
@@ -226,18 +229,28 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
private void executeCommandWithReaders(final List<String> command) throws IOException {
process = new ProcessBuilder(command).directory(getWorkingDirectory()).start();
processOutReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getInputStream()).build().start();
+ .inputStream(process.getInputStream())
+ .build()
+ .start();
processErrReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getErrorStream()).build().start();
+ .inputStream(process.getErrorStream())
+ .build()
+ .start();
}
private void executeCommandWithReaders(final List<String> command,
final InputListener outListener, final InputListener errListener) throws IOException {
process = new ProcessBuilder(command).directory(getWorkingDirectory()).start();
processOutReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getInputStream()).inputListener(outListener).build().start();
+ .inputStream(process.getInputStream())
+ .inputListener(outListener)
+ .build()
+ .start();
processErrReader = new ProcessStreamReader.Builder(process)
- .inputStream(process.getErrorStream()).inputListener(errListener).build().start();
+ .inputStream(process.getErrorStream())
+ .inputListener(errListener)
+ .build()
+ .start();
}
private void executeCommandWithReaders(final ServerCommand command) throws IOException {
@@ -247,7 +260,7 @@ public abstract class ServerLauncherRemoteIntegrationTestCase
private void startServerShouldFail(final ServerCommand command, final InputListener outListener,
final InputListener errListener) throws IOException, InterruptedException {
executeCommandWithReaders(command.create(), outListener, errListener);
- process.waitFor(2, MINUTES);
+ process.waitFor(TIMEOUT_MILLIS, MILLISECONDS);
assertThat(process.isAlive()).isFalse();
assertThat(process.exitValue()).isEqualTo(1);
}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
index 760f700..e8491e0 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -49,22 +49,28 @@ public class ServerLauncherRemoteWithCustomLoggingIntegrationTest
public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
@Before
- public void setUpServerLauncherRemoteWithCustomLoggingIntegrationTest() throws Exception {
+ public void setUpServerLauncherRemoteWithCustomLoggingIntegrationTest() {
String configFileName = getClass().getSimpleName() + "_log4j2.xml";
- customLoggingConfigFile = createFileFromResource(getResource(configFileName),
- getWorkingDirectory(), configFileName);
+ customLoggingConfigFile = createFileFromResource(
+ getResource(configFileName),
+ getWorkingDirectory(),
+ configFileName);
}
@Test
public void startWithCustomLoggingConfiguration() throws Exception {
startServer(
- new ServerCommand(this).addJvmArgument(customLoggingConfigArgument())
- .disableDefaultServer(true).withCommand(Command.START),
- new ToSystemOut(), new ToSystemOut());
+ new ServerCommand(this)
+ .addJvmArgument(customLoggingConfigArgument())
+ .disableDefaultServer(true)
+ .withCommand(Command.START),
+ new ToSystemOut(),
+ new ToSystemOut());
assertThat(systemOutRule.getLog())
.contains(CONFIGURATION_FILE_PROPERTY + " = " + getCustomLoggingConfigFilePath());
- assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+ assertThat(systemOutRule.getLog())
+ .contains(CONFIG_LAYOUT_PREFIX);
}
private String customLoggingConfigArgument() {
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherWithProviderRegressionTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherWithProviderRegressionTest.java
index f8daffb..21c77db 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherWithProviderRegressionTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/ServerLauncherWithProviderRegressionTest.java
@@ -26,10 +26,10 @@ import org.apache.geode.cache.Cache;
/**
* Extracted from {@link ServerLauncherLocalIntegrationTest}. This tests the same mechanism used by
- * Spring Data GemFire/Geode. This test confirms the fix for TRAC #51201 (see below).
+ * Spring Data GemFire/Geode.
*
* <p>
- * TRAC #51201: ServerLauncher.start fails to configure server with Spring
+ * ServerLauncher.start fails to configure server with Spring
*/
public class ServerLauncherWithProviderRegressionTest extends ServerLauncherIntegrationTestCase {
@@ -52,7 +52,9 @@ public class ServerLauncherWithProviderRegressionTest extends ServerLauncherInte
@Test
public void startGetsCacheFromServerLauncherCacheProvider() {
- startServer(newBuilder().setDisableDefaultServer(true).setSpringXmlLocation(springXml()));
+ startServer(newBuilder()
+ .setDisableDefaultServer(true)
+ .setSpringXmlLocation(springXml()));
Cache cache = launcher.getCache();
[geode] 02/05: GEODE-6183: Use SocketCreator.getLocalHost in
LocatorLauncherRemoteIntegrationTest
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 03f8395e17dd24606c79a88ede2b5ff430be0f1e
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 11:19:28 2019 -0700
GEODE-6183: Use SocketCreator.getLocalHost in LocatorLauncherRemoteIntegrationTest
The tests that were using InetAddress.getLostHost for assertions may
fail depending on /etc/hosts configuration. This change should prevent
these failures.
Co-authored-by: Michael Oleske <mo...@pivotal.io>
Co-authored-by: Mark Hanson <mh...@pivotal.io>
---
.../distributed/LocatorLauncherRemoteIntegrationTest.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
index 34aa1d5..4b1ad85 100755
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -22,7 +22,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.File;
import java.net.BindException;
-import java.net.InetAddress;
import org.junit.Before;
import org.junit.Test;
@@ -30,6 +29,7 @@ import org.junit.Test;
import org.apache.geode.distributed.LocatorLauncher.Builder;
import org.apache.geode.distributed.LocatorLauncher.LocatorState;
import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.internal.net.SocketCreator;
import org.apache.geode.internal.process.ProcessControllerFactory;
/**
@@ -132,7 +132,8 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost())
+ .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
@@ -152,7 +153,8 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
assertThat(locatorState.getStatus()).isEqualTo(ONLINE);
assertThat(locatorState.getClasspath()).isEqualTo(getClassPath());
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost())
+ .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getJvmArguments()).isEqualTo(getJvmArguments());
assertThat(locatorState.getLogFile()).isEqualTo(getLogFile().getCanonicalPath());
@@ -182,7 +184,8 @@ public class LocatorLauncherRemoteIntegrationTest extends LocatorLauncherRemoteI
assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
assertThat(locatorState.getClasspath()).isNull();
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
- assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+ assertThat(locatorState.getHost())
+ .isEqualTo(SocketCreator.getLocalHost().getCanonicalHostName());
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
assertThat(locatorState.getLogFile()).isNull();
assertThat(locatorState.getMemberName()).isNull();
[geode] 05/05: GEODE-6183: Cleanup and rename LocatorIntegrationTest
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 87c83ee4e2e6214bf2dd65d279520c8d437c56ee
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 13:46:46 2019 -0700
GEODE-6183: Cleanup and rename LocatorIntegrationTest
* Fixup IDE warnings
* Reformat test code
* Update to use AssertJ
---
...rJUnitTest.java => LocatorIntegrationTest.java} | 193 +++++++++++----------
1 file changed, 100 insertions(+), 93 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java
similarity index 53%
rename from geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorJUnitTest.java
rename to geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java
index 9f0c4ce..3ce6811 100644
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorJUnitTest.java
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/LocatorIntegrationTest.java
@@ -21,13 +21,11 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_S
import static org.apache.geode.distributed.ConfigurationProperties.LOCATOR_WAIT_TIME;
import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
import static org.apache.geode.internal.AvailablePort.SOCKET;
import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowable;
import java.io.File;
import java.io.IOException;
@@ -42,13 +40,16 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
import org.apache.geode.SystemConnectException;
-import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.distributed.internal.ServerLocation;
import org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessenger;
@@ -63,162 +64,168 @@ import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactor
@Category({MembershipTest.class})
@RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
-public class LocatorJUnitTest {
-
- private static final int REQUEST_TIMEOUT = 5 * 1000;
+@UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class LocatorIntegrationTest {
private Locator locator;
private File tmpFile;
private int port;
- @Parameterized.Parameters
+ @Parameters
public static Collection<Object> data() {
- return Arrays.asList(new Object[] {(IntSupplier) () -> 0,
- (IntSupplier) () -> AvailablePortHelper.getRandomAvailableTCPPort()});
+ return Arrays.asList(new Object[] {
+ (IntSupplier) () -> 0,
+ (IntSupplier) AvailablePortHelper::getRandomAvailableTCPPort});
}
- @Parameterized.Parameter
+ @Parameter
public IntSupplier portSupplier;
@Rule
+ public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Before
public void setUp() throws IOException {
tmpFile = File.createTempFile("locator", ".log");
- this.port = portSupplier.getAsInt();
+ port = portSupplier.getAsInt();
deleteLocatorViewFile(port);
}
- private void deleteLocatorViewFile(int portNumber) {
- File locatorFile = new File("locator" + portNumber + "view.dat");
- if (locatorFile.exists()) {
- locatorFile.delete();
- }
- }
-
@After
public void tearDown() {
+ JGroupsMessenger.THROW_EXCEPTION_ON_START_HOOK = false;
if (locator != null) {
locator.stop();
}
- assertEquals(false, Locator.hasLocator());
+ assertThat(Locator.hasLocator()).isFalse();
}
/**
- * GEODE-4176: locator creates "locator0view.dat" file when started with port 0
- *
+ * Fix: locator creates "locator0view.dat" file when started with port 0
*/
@Test
public void testThatLocatorDoesNotCreateFileWithZeroPort() throws Exception {
deleteLocatorViewFile(0);
- Properties dsprops = new Properties();
- dsprops.setProperty(MCAST_PORT, "0");
- dsprops.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
- dsprops.setProperty(LOCATOR_WAIT_TIME, "1"); // seconds
- dsprops.setProperty(LOG_FILE, "");
- locator = Locator.startLocatorAndDS(port, null, dsprops);
+
+ Properties configProperties = new Properties();
+ configProperties.setProperty(MCAST_PORT, "0");
+ configProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+ configProperties.setProperty(LOCATOR_WAIT_TIME, "1"); // seconds
+ configProperties.setProperty(LOG_FILE, "");
+
+ locator = Locator.startLocatorAndDS(port, null, configProperties);
+
File viewFile = new File("locator0view.dat");
- assertFalse("file should not exist: " + viewFile.getAbsolutePath(), viewFile.exists());
+
+ assertThat(viewFile).doesNotExist();
}
/**
- * TRAC #45804: if jmx-manager-start is true in a locator then gfsh connect will fail
+ * Fix: if jmx-manager-start is true in a locator then gfsh connect will fail
*/
@Test
public void testGfshConnectShouldSucceedIfJmxManagerStartIsTrueInLocator() throws Exception {
- Properties dsprops = new Properties();
int jmxPort = getRandomAvailablePort(SOCKET);
- dsprops.setProperty(MCAST_PORT, "0");
- dsprops.setProperty(JMX_MANAGER_PORT, "" + jmxPort);
- dsprops.setProperty(JMX_MANAGER_START, "true");
- dsprops.setProperty(JMX_MANAGER_HTTP_PORT, "0");
- dsprops.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
- dsprops.setProperty(LOG_FILE, "");
- System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "disableManagement", "false"); // not
- // needed
- try {
- locator = Locator.startLocatorAndDS(port, null, dsprops);
- List<JmxManagerProfile> alreadyManaging =
- GemFireCacheImpl.getInstance().getJmxManagerAdvisor().adviseAlreadyManaging();
- assertEquals(1, alreadyManaging.size());
- assertEquals(GemFireCacheImpl.getInstance().getMyId(),
- alreadyManaging.get(0).getDistributedMember());
- } finally {
- System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + "enabledManagement");
- }
- }
+ Properties configProperties = new Properties();
+ configProperties.setProperty(MCAST_PORT, "0");
+ configProperties.setProperty(JMX_MANAGER_PORT, "" + jmxPort);
+ configProperties.setProperty(JMX_MANAGER_START, "true");
+ configProperties.setProperty(JMX_MANAGER_HTTP_PORT, "0");
+ configProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+ configProperties.setProperty(LOG_FILE, "");
+
+ // not needed
+ System.setProperty(GEMFIRE_PREFIX + "disableManagement", "false");
+
+ locator = Locator.startLocatorAndDS(port, null, configProperties);
+ List<JmxManagerProfile> alreadyManaging =
+ GemFireCacheImpl.getInstance().getJmxManagerAdvisor().adviseAlreadyManaging();
+
+ assertThat(alreadyManaging).hasSize(1);
+ assertThat(alreadyManaging.get(0).getDistributedMember())
+ .isEqualTo(GemFireCacheImpl.getInstance().getMyId());
+ }
@Test
public void testHandlersAreWaitedOn() throws Exception {
- Properties dsprops = new Properties();
- int jmxPort = getRandomAvailablePort(SOCKET);
- dsprops.setProperty(MCAST_PORT, "0");
- dsprops.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
- dsprops.setProperty(LOCATOR_WAIT_TIME, "1"); // seconds
- dsprops.setProperty(LOG_FILE, "");
- locator = Locator.startLocatorAndDS(port, null, dsprops);
+ Properties configProperties = new Properties();
+ configProperties.setProperty(MCAST_PORT, "0");
+ configProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+ configProperties.setProperty(LOCATOR_WAIT_TIME, "1"); // seconds
+ configProperties.setProperty(LOG_FILE, "");
+
+ locator = Locator.startLocatorAndDS(port, null, configProperties);
+
InternalLocator internalLocator = (InternalLocator) locator;
+
// the locator should always install a SharedConfigurationStatusRequest handler
- assertTrue(internalLocator.hasHandlerForClass(SharedConfigurationStatusRequest.class));
+ assertThat(internalLocator.hasHandlerForClass(SharedConfigurationStatusRequest.class)).isTrue();
}
-
@Test
public void testBasicInfo() throws Exception {
locator = Locator.startLocator(port, tmpFile);
- int boundPort = (port == 0) ? locator.getPort() : port;
+ int boundPort = port == 0 ? locator.getPort() : port;
TcpClient client = new TcpClient();
String[] info = client.getInfo(InetAddress.getLocalHost(), boundPort);
- assertNotNull(info);
- assertTrue(info.length > 1);
+
+ assertThat(info).isNotNull();
+ assertThat(info.length).isGreaterThanOrEqualTo(1);
}
@Test
public void testNoThreadLeftBehind() throws Exception {
- Properties dsprops = new Properties();
- dsprops.setProperty(MCAST_PORT, "0");
- dsprops.setProperty(JMX_MANAGER_START, "false");
- dsprops.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
-
JGroupsMessenger.THROW_EXCEPTION_ON_START_HOOK = true;
+
+ Properties configProperties = new Properties();
+ configProperties.setProperty(MCAST_PORT, "0");
+ configProperties.setProperty(JMX_MANAGER_START, "false");
+ configProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
+
int threadCount = Thread.activeCount();
- try {
- locator = Locator.startLocatorAndDS(port, new File(""), dsprops);
- locator.stop();
- fail("expected an exception");
- } catch (SystemConnectException expected) {
- for (int i = 0; i < 10; i++) {
- if (threadCount < Thread.activeCount()) {
- Thread.sleep(1000);
- }
- }
+ Throwable thrown = catchThrowable(
+ () -> locator = Locator.startLocatorAndDS(port, new File(""), configProperties));
+
+ assertThat(thrown).isInstanceOf(SystemConnectException.class);
+
+ for (int i = 0; i < 10; i++) {
if (threadCount < Thread.activeCount()) {
- OSProcess.printStacks(0);
- fail("expected " + threadCount + " threads or fewer but found " + Thread.activeCount()
- + ". Check log file for a thread dump.");
+ Thread.sleep(1000);
}
- } finally {
- JGroupsMessenger.THROW_EXCEPTION_ON_START_HOOK = false;
}
+
+ OSProcess.printStacks(0);
+
+ assertThat(threadCount)
+ .as("Expected " + threadCount + " threads or fewer but found " + Thread.activeCount()
+ + ". Check log file for a thread dump.")
+ .isGreaterThanOrEqualTo(Thread.activeCount());
}
/**
* Make sure two ServerLocation objects on different hosts but with the same port are not equal
- * <p/>
- * TRAC #42040: LoadBalancing directs all traffic to a single cache server if all servers are
- * started on the same port
+ *
+ * <p>
+ * Fix: LoadBalancing directs all traffic to a single cache server if all servers are started on
+ * the same port
*/
@Test
public void testServerLocationOnDifferentHostsShouldNotTestEqual() {
- ServerLocation sl1 = new ServerLocation("host1", 777);
- ServerLocation sl2 = new ServerLocation("host2", 777);
- if (sl1.equals(sl2)) {
- fail("ServerLocation instances on different hosts should not test equal");
- }
+ ServerLocation serverLocation1 = new ServerLocation("host1", 777);
+ ServerLocation serverLocation2 = new ServerLocation("host2", 777);
+
+ assertThat(serverLocation1).isNotEqualTo(serverLocation2);
}
+ private void deleteLocatorViewFile(int portNumber) {
+ File locatorFile = new File("locator" + portNumber + "view.dat");
+ if (locatorFile.exists()) {
+ assertThat(locatorFile.delete()).isTrue();
+ }
+ }
}
[geode] 01/05: GEODE-6183: Make isAttachAPIFound load providers
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit f074ca72ae9a8e76066c3ccd7ba74499ceec1743
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 11:17:49 2019 -0700
GEODE-6183: Make isAttachAPIFound load providers
VirtualMachine class can be loaded even if AttachProvider service
providers are not found. This change forces loading of providers
for isAttachAPIFound.
Co-authored-by: Michael Oleske <mo...@pivotal.io>
---
.../geode/internal/process/ProcessControllerFactory.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
index 3911a08..93a8238 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
@@ -20,6 +20,9 @@ import static org.apache.commons.lang3.Validate.notNull;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ServiceConfigurationError;
import java.util.concurrent.TimeoutException;
import org.apache.geode.distributed.internal.DistributionConfig;
@@ -72,9 +75,14 @@ public class ProcessControllerFactory {
}
boolean found = false;
try {
- final Class<?> virtualMachineClass = Class.forName("com.sun.tools.attach.VirtualMachine");
- found = virtualMachineClass != null;
- } catch (ClassNotFoundException ignore) {
+ final Class<?> virtualMachineClass = Class.forName("com.sun.tools.attach.spi.AttachProvider");
+ if (virtualMachineClass != null) {
+ Method providersMethod = virtualMachineClass.getMethod("providers");
+ providersMethod.invoke(virtualMachineClass);
+ found = true;
+ }
+ } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException | ServiceConfigurationError ignore) {
}
return found;
}
[geode] 04/05: GEODE-6183: Cleanup and rename
DistributedSystemIntegrationTest
Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit c6f0b1a5b563d54f3bfd5d9c6f2588be8409ceec
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu May 30 13:27:54 2019 -0700
GEODE-6183: Cleanup and rename DistributedSystemIntegrationTest
* Fixup IDE warnings
* Reformat test code
---
.../DistributedSystemIntegrationJUnitTest.java | 94 ---------------------
.../DistributedSystemIntegrationTest.java | 95 ++++++++++++++++++++++
2 files changed, 95 insertions(+), 94 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationJUnitTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationJUnitTest.java
deleted file mode 100755
index 5c27045..0000000
--- a/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationJUnitTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.distributed;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.net.URL;
-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 org.apache.geode.test.junit.categories.MembershipTest;
-
-/**
- * Integration tests for DistributedSystem class. These tests require file system I/O.
- */
-@Category({MembershipTest.class})
-public class DistributedSystemIntegrationJUnitTest {
-
- @Rule
- public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- @Rule
- public final TestName testName = new TestName();
-
- @Test
- public void getPropertiesFileShouldUsePathInSystemProperty() throws Exception {
- File propertiesFile = this.temporaryFolder.newFile("test.properties");
- System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY,
- propertiesFile.getCanonicalPath());
- Properties properties = new Properties();
- properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-
- assertThat(DistributedSystem.getPropertiesFile()).isEqualTo(propertiesFile.getCanonicalPath());
- }
-
- @Test
- public void getPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
- File propertiesFile = this.temporaryFolder.newFile("test.properties");
- System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY,
- propertiesFile.getCanonicalPath());
- Properties properties = new Properties();
- properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-
- URL propertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
- assertThat(DistributedSystem.getPropertiesFileURL()).isEqualTo(propertiesURL);
- }
-
- @Test
- public void getSecurityPropertiesFileShouldUsePathInSystemProperty() throws Exception {
- File propertiesFile = this.temporaryFolder.newFile("testsecurity.properties");
- System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY,
- propertiesFile.getCanonicalPath());
- Properties properties = new Properties();
- properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-
- assertThat(DistributedSystem.getSecurityPropertiesFile())
- .isEqualTo(propertiesFile.getCanonicalPath());
- }
-
- @Test
- public void getSecurityPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
- File propertiesFile = this.temporaryFolder.newFile("testsecurity.properties");
- System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY,
- propertiesFile.getCanonicalPath());
- Properties properties = new Properties();
- properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-
- URL propertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
- assertThat(DistributedSystem.getSecurityPropertiesFileURL()).isEqualTo(propertiesURL);
- }
-}
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationTest.java
new file mode 100755
index 0000000..8075cb5
--- /dev/null
+++ b/geode-core/src/integrationTest/java/org/apache/geode/distributed/DistributedSystemIntegrationTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.distributed;
+
+import static org.apache.geode.distributed.DistributedSystem.PROPERTIES_FILE_PROPERTY;
+import static org.apache.geode.distributed.DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URL;
+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 org.apache.geode.test.junit.categories.MembershipTest;
+
+/**
+ * Integration tests for DistributedSystem class. These tests require file system I/O.
+ */
+@Category(MembershipTest.class)
+public class DistributedSystemIntegrationTest {
+
+ @Rule
+ public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @Test
+ public void getPropertiesFileShouldUsePathInSystemProperty() throws Exception {
+ File propertiesFile = temporaryFolder.newFile("test.properties");
+ System.setProperty(PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+ new Properties().store(new FileWriter(propertiesFile, false), testName.getMethodName());
+
+ String value = DistributedSystem.getPropertiesFile();
+
+ assertThat(value).isEqualTo(propertiesFile.getCanonicalPath());
+ }
+
+ @Test
+ public void getPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
+ File propertiesFile = temporaryFolder.newFile("test.properties");
+ System.setProperty(PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+ new Properties().store(new FileWriter(propertiesFile, false), testName.getMethodName());
+ URL expectedPropertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
+
+ URL value = DistributedSystem.getPropertiesFileURL();
+
+ assertThat(value).isEqualTo(expectedPropertiesURL);
+ }
+
+ @Test
+ public void getSecurityPropertiesFileShouldUsePathInSystemProperty() throws Exception {
+ File propertiesFile = temporaryFolder.newFile("testsecurity.properties");
+ System.setProperty(SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+ new Properties().store(new FileWriter(propertiesFile, false), testName.getMethodName());
+
+ String value = DistributedSystem.getSecurityPropertiesFile();
+
+ assertThat(value).isEqualTo(propertiesFile.getCanonicalPath());
+ }
+
+ @Test
+ public void getSecurityPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
+ File propertiesFile = temporaryFolder.newFile("testsecurity.properties");
+ System.setProperty(SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+ new Properties().store(new FileWriter(propertiesFile, false), testName.getMethodName());
+ URL expectedPropertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
+
+ URL value = DistributedSystem.getSecurityPropertiesFileURL();
+
+ assertThat(value).isEqualTo(expectedPropertiesURL);
+ }
+}