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 2015/12/05 01:10:49 UTC
[2/2] incubator-geode git commit: Separate integration tests from
UnitTest files to IntegrationTests.
Separate integration tests from UnitTest files to IntegrationTests.
Add and use Catch-Exception for better unit testing.
Remove unused code and class.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9b8a8be9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9b8a8be9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9b8a8be9
Branch: refs/heads/feature/GEODE-291
Commit: 9b8a8be9e05562f98621c057e021ea40f953cdaf
Parents: 6846e4c
Author: Kirk Lund <kl...@pivotal.io>
Authored: Fri Dec 4 16:09:26 2015 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Fri Dec 4 16:09:26 2015 -0800
----------------------------------------------------------------------
build.gradle | 4 +-
.../AbstractLauncherIntegrationJUnitTest.java | 71 ++++
.../distributed/AbstractLauncherJUnitTest.java | 39 +-
.../distributed/CommonLauncherTestSuite.java | 65 ----
.../LocatorLauncherIntegrationJUnitTest.java | 274 ++++++++------
.../ServerLauncherIntegrationJUnitTest.java | 376 ++++++++++++-------
.../gemfire/test/process/Geode291TestSuite.java | 6 +
gradle/dependency-versions.properties | 6 +-
8 files changed, 485 insertions(+), 356 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index b5465b8..eeee24c 100755
--- a/build.gradle
+++ b/build.gradle
@@ -306,9 +306,11 @@ subprojects {
compile 'org.springframework:spring-webmvc:' + project.'springframework.version'
compile 'com.github.stephenc.findbugs:findbugs-annotations:' + project.'stephenc-findbugs.version'
- testCompile 'com.jayway.awaitility:awaitility:' + project.'awaitility.version'
testCompile 'com.github.stefanbirkner:system-rules:' + project.'system-rules.version'
+ testCompile 'com.jayway.awaitility:awaitility:' + project.'awaitility.version'
testCompile 'edu.umd.cs.mtc:multithreadedtc:' + project.'multithreadedtc.version'
+ testCompile 'eu.codearte.catch-exception:catch-exception:' + project.'catch-exception.version'
+ testCompile 'eu.codearte.catch-exception:catch-throwable:' + project.'catch-throwable.version'
testCompile 'junit:junit:' + project.'junit.version'
testCompile 'org.assertj:assertj-core:' + project.'assertj-core.version'
testCompile 'org.mockito:mockito-core:' + project.'mockito-core.version'
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..745090d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for AbstractLauncher class. These tests require file system I/O.
+ */
+@Category(IntegrationTest.class)
+public class AbstractLauncherIntegrationJUnitTest {
+
+ @Rule
+ public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public final TestName testName = new TestName();
+
+ private File gemfirePropertiesFile;
+ private Properties expectedGemfireProperties;
+
+ @Before
+ public void setUp() throws Exception {
+ this.gemfirePropertiesFile = this.temporaryFolder.newFile("gemfire.properties");
+
+ this.expectedGemfireProperties = new Properties();
+ this.expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
+ this.expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
+ this.expectedGemfireProperties.store(new FileWriter(this.gemfirePropertiesFile, false), this.testName.getMethodName());
+
+ assertThat(this.gemfirePropertiesFile).isNotNull();
+ assertThat(this.gemfirePropertiesFile.exists()).isTrue();
+ assertThat(this.gemfirePropertiesFile.isFile()).isTrue();
+ }
+
+ @Test
+ public void testLoadGemFirePropertiesFromFile() throws Exception {
+ final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(this.gemfirePropertiesFile.toURI().toURL());
+
+ assertThat(actualGemFireProperties).isNotNull();
+ assertThat(actualGemFireProperties).isEqualTo(this.expectedGemfireProperties);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
index 399c78f..7b8a6bb 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
@@ -18,8 +18,6 @@ package com.gemstone.gemfire.distributed;
import static org.junit.Assert.*;
-import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
@@ -45,10 +43,10 @@ import org.junit.experimental.categories.Category;
* @since 7.0
*/
@Category(UnitTest.class)
-public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
+public class AbstractLauncherJUnitTest {
protected AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
- return new TestServiceLauncher(memberName, memberId);
+ return new FakeServiceLauncher(memberName, memberId);
}
@Test
@@ -111,26 +109,6 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
}
@Test
- public void testLoadGemFirePropertiesFromFile() throws IOException {
- final Properties expectedGemfireProperties = new Properties();
-
- expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
- expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
-
- final File gemfirePropertiesFile = writeGemFirePropertiesToFile(expectedGemfireProperties, "gemfire.properties",
- "Test gemfire.properties file for AbstractLauncherJUnitTest.testLoadGemFirePropertiesFromFile");
-
- assertNotNull(gemfirePropertiesFile);
- assertTrue(gemfirePropertiesFile.isFile());
-
- final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(
- gemfirePropertiesFile.toURI().toURL());
-
- assertNotNull(actualGemFireProperties);
- assertEquals(expectedGemfireProperties, actualGemFireProperties);
- }
-
- @Test
public void testGetDistributedSystemProperties() {
AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "1");
@@ -274,12 +252,12 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
}
- protected static final class TestServiceLauncher extends AbstractLauncher<String> {
+ protected static final class FakeServiceLauncher extends AbstractLauncher<String> {
private final String memberId;
private final String memberName;
- public TestServiceLauncher(final String memberName, final String memberId) {
+ public FakeServiceLauncher(final String memberName, final String memberId) {
this.memberId = memberId;
this.memberName = memberName;
}
@@ -289,6 +267,7 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
return false;
}
+ @Override
public String getLogFileName() {
throw new UnsupportedOperationException("Not Implemented!");
}
@@ -298,22 +277,22 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
return memberId;
}
+ @Override
public String getMemberName() {
return memberName;
}
+ @Override
public Integer getPid() {
throw new UnsupportedOperationException("Not Implemented!");
}
+ @Override
public String getServiceName() {
return "TestService";
}
- public String getId() {
- throw new UnsupportedOperationException("Not Implemented!");
- }
-
+ @Override
public void run() {
throw new UnsupportedOperationException("Not Implemented!");
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
deleted file mode 100644
index 94ba320..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
+++ /dev/null
@@ -1,65 +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 com.gemstone.gemfire.distributed;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-/**
- * The CommonLauncherTestSuite is a base class for encapsulating reusable functionality across the various, specific
- * launcher test suites.
- * </p>
- * @author John Blum
- * @see com.gemstone.gemfire.distributed.AbstractLauncherJUnitTest
- * @see com.gemstone.gemfire.distributed.LocatorLauncherJUnitTest
- * @see com.gemstone.gemfire.distributed.ServerLauncherJUnitTest
- * @since 7.0
- */
-public abstract class CommonLauncherTestSuite {
-
- @Rule
- public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-
- @Rule
- public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- @Rule
- public final TestName testName = new TestName();
-
- protected File writeGemFirePropertiesToFile(final Properties gemfireProperties,
- final String filename,
- final String comment)
- {
- try {
- final File gemfirePropertiesFile = this.temporaryFolder.newFile(filename);
- gemfireProperties.store(new FileWriter(gemfirePropertiesFile, false), comment);
- return gemfirePropertiesFile;
- }
- catch (IOException e) {
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
index db5b952..3b56554 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
@@ -16,12 +16,9 @@
*/
package com.gemstone.gemfire.distributed;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.assertj.core.api.BDDAssertions.*;
import java.io.File;
import java.io.FileNotFoundException;
@@ -59,140 +56,193 @@ public class LocatorLauncherIntegrationJUnitTest {
public final TestName testName = new TestName();
@Test
- public void testBuilderParseArguments() throws Exception {
+ public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
+ // given: a new builder and working directory
String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
- builder.parseArguments("start", "memberOne", "--bind-address", InetAddress.getLocalHost().getHostAddress(),
- "--dir", expectedWorkingDirectory, "--hostname-for-clients", "Tucows", "--pid", "1234", "--port", "11235",
- "--redirect-output", "--force", "--debug");
-
- assertEquals(Command.START, builder.getCommand());
- assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
- assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
- assertEquals("Tucows", builder.getHostnameForClients());
- assertEquals(1234, builder.getPid().intValue());
- assertEquals(11235, builder.getPort().intValue());
- assertTrue(builder.getRedirectOutput());
- assertTrue(builder.getForce());
- assertTrue(builder.getDebug());
+ // when: parsing many arguments
+ builder.parseArguments(
+ "start",
+ "memberOne",
+ "--bind-address", InetAddress.getLocalHost().getHostAddress(),
+ "--dir", expectedWorkingDirectory,
+ "--hostname-for-clients", "Tucows",
+ "--pid", "1234",
+ "--port", "11235",
+ "--redirect-output",
+ "--force",
+ "--debug");
+
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
+ assertThat(builder.getHostnameForClients()).isEqualTo("Tucows");
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getPort().intValue()).isEqualTo(11235);
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getForce()).isTrue();
+ assertThat(builder.getDebug()).isTrue();
}
@Test
- public void testBuilderParseArgumentsWithCommandInArguments() throws Exception {
+ public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
+ // given: a new builder and a directory
String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
- builder.parseArguments("start", "--dir=" + expectedWorkingDirectory, "--port", "12345", "memberOne");
-
- assertEquals(Command.START, builder.getCommand());
- assertFalse(Boolean.TRUE.equals(builder.getDebug()));
- assertFalse(Boolean.TRUE.equals(builder.getForce()));
- assertFalse(Boolean.TRUE.equals(builder.getHelp()));
- assertNull(builder.getBindAddress());
- assertNull(builder.getHostnameForClients());
- assertEquals("12345", builder.getMemberName());
- assertNull(builder.getPid());
- assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
- assertEquals(12345, builder.getPort().intValue());
+ // when: parsing arguments with values separated by equals
+ builder.parseArguments(
+ "start",
+ "--dir=" + expectedWorkingDirectory,
+ "--port=" + "12345",
+ "memberOne");
+
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getDebug()).isFalse();
+ assertThat(builder.getForce()).isFalse();
+ assertThat(builder.getHelp()).isFalse();
+ assertThat(builder.getBindAddress()).isNull();
+ assertThat(builder.getHostnameForClients()).isNull();
+ assertThat(builder.getMemberName()).isEqualTo("memberOne");
+ assertThat(builder.getPid()).isNull();
+ assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
+ assertThat(builder.getPort().intValue()).isEqualTo(12345);
}
@Test
- public void testBuildWithMemberNameSetInGemfirePropertiesOnStart() throws Exception {
- File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), "gemfire.properties");
- System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
-
+ public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
+ // given: gemfire.properties with a name
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "locator123");
- gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
- assertTrue(propertiesFile.isFile());
- assertTrue(propertiesFile.exists());
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
+
+ // when: starting with null MemberName
+ LocatorLauncher launcher = new Builder()
+ .setCommand(Command.START)
+ .setMemberName(null)
+ .build();
+
+ // then: name in gemfire.properties file should be used for MemberName
+ assertThat(launcher).isNotNull();
+ assertThat(launcher.getCommand()).isEqualTo(Command.START);
+ assertThat(launcher.getMemberName()).isNull();
+ }
- LocatorLauncher launcher = new Builder().setCommand(Command.START).setMemberName(null).build();
+ @Test
+ public void testBuildWithNoMemberNameOnStart() throws Exception {
+ // given: gemfire.properties with no name
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
- assertNotNull(launcher);
- assertEquals(Command.START, launcher.getCommand());
- assertNull(launcher.getMemberName());
+ // when: no MemberName is specified
+ when(new Builder()
+ .setCommand(Command.START))
+ .build();
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"));
}
@Test
- public void testSetAndGetWorkingDirectory() throws Exception {
+ public void testBuilderSetAndGetWorkingDirectory() throws Exception {
+ // given: a new builder and a directory
String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(""));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(" "));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(rootFolder));
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
+ // when: not setting WorkingDirectory
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to null
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to empty string
+ assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to white space
+ assertThat(builder.setWorkingDirectory(" ")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to a directory
+ assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
+ // then: getWorkingDirectory returns that directory
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+
+ // when: setting WorkingDirectory to null (again)
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
}
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToFile() throws IOException {
- File tmpFile = File.createTempFile("tmp", "file");
-
- assertNotNull(tmpFile);
- assertTrue(tmpFile.isFile());
-
- tmpFile.deleteOnExit();
-
- try {
- new Builder().setWorkingDirectory(tmpFile.getCanonicalPath());
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals(tmpFile.getCanonicalPath(), expected.getCause().getMessage());
- throw expected;
- }
+ @Test
+ public void testBuilderSetWorkingDirectoryToFile() throws IOException {
+ // given: a file instead of a directory
+ File tmpFile = this.temporaryFolder.newFile();
+
+ // when: setting WorkingDirectory to that file
+ when(new Builder())
+ .setWorkingDirectory(tmpFile.getCanonicalPath());
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalArgumentException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
+ .hasCause(new FileNotFoundException(tmpFile.getCanonicalPath()));
}
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToNonExistingDirectory() {
- try {
- new Builder().setWorkingDirectory("/path/to/non_existing/directory");
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
- throw expected;
- }
+ @Test
+ public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
+ // given: using LocatorLauncher in-process
+
+ // when: setting WorkingDirectory to non-current directory
+ when(new Builder()
+ .setCommand(Command.START)
+ .setMemberName("memberOne")
+ .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
+ .build();
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Locator"));
}
-
- @Test(expected = IllegalStateException.class)
- public void testBuildWithNoMemberNameOnStart() throws Exception {
- System.setProperty("user.dir", this.temporaryFolder.getRoot().getCanonicalPath());
- try {
- new Builder().setCommand(Command.START).build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"),
- expected.getMessage());
- throw expected;
- }
+
+ @Test
+ public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
+ // when: setting WorkingDirectory to non-existing directory
+ when(new Builder())
+ .setWorkingDirectory("/path/to/non_existing/directory");
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalArgumentException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
+ .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
}
- @Test(expected = IllegalStateException.class)
- public void testBuildWithMismatchingCurrentAndWorkingDirectoryOnStart() throws Exception {
- try {
- new Builder().setCommand(Command.START)
- .setMemberName("memberOne")
- .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
- .build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
- .toLocalizedString("Locator"), expected.getMessage());
- throw expected;
- }
+ /**
+ * Creates a gemfire properties file in temporaryFolder:
+ * <ol>
+ * <li>creates <code>fileName</code> in <code>temporaryFolder</code></li>
+ * <li>sets "gemfirePropertyFile" system property</li>
+ * <li>writes <code>gemfireProperties</code> to the file</li>
+ * </ol>
+ */
+ private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+ File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+ System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+
+ gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+ assertThat(propertiesFile.isFile()).isTrue();
+ assertThat(propertiesFile.exists()).isTrue();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
index c91d80d..b61f89d 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
@@ -16,17 +16,14 @@
*/
package com.gemstone.gemfire.distributed;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
-import java.io.IOException;
import java.net.InetAddress;
import java.util.Properties;
@@ -59,170 +56,257 @@ public class ServerLauncherIntegrationJUnitTest {
public final TestName testName = new TestName();
@Test
- public void testParseArguments() throws Exception {
+ public void testBuildWithManyArguments() throws Exception {
+ // given
String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
- Builder builder = new Builder();
+
+ // when
+ ServerLauncher launcher = new Builder()
+ .setCommand(Command.STOP)
+ .setAssignBuckets(true)
+ .setForce(true)
+ .setMemberName("serverOne")
+ .setRebalance(true)
+ .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
+ .setServerPort(11235)
+ .setWorkingDirectory(rootFolder)
+ .setCriticalHeapPercentage(90.0f)
+ .setEvictionHeapPercentage(75.0f)
+ .setMaxConnections(100)
+ .setMaxMessageCount(512)
+ .setMaxThreads(8)
+ .setMessageTimeToLive(120000)
+ .setSocketBufferSize(32768)
+ .build();
- builder.parseArguments("start", "serverOne", "--assign-buckets", "--disable-default-server", "--debug", "--force",
- "--rebalance", "--redirect-output", "--dir=" + rootFolder, "--pid=1234",
- "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(), "--server-port=11235", "--hostname-for-clients=192.168.99.100");
-
- assertEquals(Command.START, builder.getCommand());
- assertEquals("serverOne", builder.getMemberName());
- assertEquals("192.168.99.100", builder.getHostNameForClients());
- assertTrue(builder.getAssignBuckets());
- assertTrue(builder.getDisableDefaultServer());
- assertTrue(builder.getDebug());
- assertTrue(builder.getForce());
- assertFalse(Boolean.TRUE.equals(builder.getHelp()));
- assertTrue(builder.getRebalance());
- assertTrue(builder.getRedirectOutput());
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertEquals(1234, builder.getPid().intValue());
- assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
- assertEquals(11235, builder.getServerPort().intValue());
+ // then
+ assertThat(launcher).isNotNull();
+ assertThat(launcher.isAssignBuckets()).isTrue();
+ assertThat(launcher.isDebugging()).isFalse();
+ assertThat(launcher.isDisableDefaultServer()).isFalse();
+ assertThat(launcher.isForcing()).isTrue();
+ assertThat(launcher.isHelping()).isFalse();
+ assertThat(launcher.isRebalancing()).isTrue();
+ assertThat(launcher.isRunning()).isFalse();
+ assertThat(launcher.getCommand()).isEqualTo(Command.STOP);
+ assertThat(launcher.getMemberName()).isEqualTo("serverOne");
+ assertThat(launcher.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(launcher.getServerPort().intValue()).isEqualTo(11235);
+ assertThat(launcher.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(launcher.getCriticalHeapPercentage().floatValue()).isEqualTo(90.0f);
+ assertThat(launcher.getEvictionHeapPercentage().floatValue()).isEqualTo(75.0f);
+ assertThat(launcher.getMaxConnections().intValue()).isEqualTo(100);
+ assertThat(launcher.getMaxMessageCount().intValue()).isEqualTo(512);
+ assertThat(launcher.getMaxThreads().intValue()).isEqualTo(8);
+ assertThat(launcher.getMessageTimeToLive().intValue()).isEqualTo(120000);
+ assertThat(launcher.getSocketBufferSize().intValue()).isEqualTo(32768);
}
@Test
- public void testSetAndGetWorkingDirectory() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
+ public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
+ // given a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
Builder builder = new Builder();
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(rootFolder));
- assertEquals(rootFolder, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(" "));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(""));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- assertSame(builder, builder.setWorkingDirectory(null));
- assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
- }
+ // when: parsing many arguments
+ builder.parseArguments(
+ "start",
+ "serverOne",
+ "--assign-buckets",
+ "--disable-default-server",
+ "--debug",
+ "--force",
+ "--rebalance",
+ "--redirect-output",
+ "--dir", rootFolder,
+ "--pid", "1234",
+ "--server-bind-address", InetAddress.getLocalHost().getHostAddress(),
+ "--server-port", "11235",
+ "--hostname-for-clients", "192.168.99.100");
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToNonExistingDirectory() {
- try {
- new Builder().setWorkingDirectory("/path/to/non_existing/directory");
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
- throw expected;
- }
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testSetWorkingDirectoryToFile() throws IOException {
- File tmpFile = File.createTempFile("tmp", "file");
-
- assertNotNull(tmpFile);
- assertTrue(tmpFile.isFile());
-
- tmpFile.deleteOnExit();
-
- try {
- new Builder().setWorkingDirectory(tmpFile.getAbsolutePath());
- }
- catch (IllegalArgumentException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- assertTrue(expected.getCause() instanceof FileNotFoundException);
- assertEquals(tmpFile.getAbsolutePath(), expected.getCause().getMessage());
- throw expected;
- }
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getMemberName()).isEqualTo("serverOne");
+ assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+ assertThat(builder.getAssignBuckets()).isTrue();
+ assertThat(builder.getDisableDefaultServer()).isTrue();
+ assertThat(builder.getDebug()).isTrue();
+ assertThat(builder.getForce()).isTrue();
+ assertThat(builder.getHelp()).isFalse();
+ assertThat(builder.getRebalance()).isTrue();
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
}
@Test
- public void testBuild() throws Exception {
- String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-
- ServerLauncher launcher = new Builder()
- .setCommand(Command.STOP)
- .setAssignBuckets(true)
- .setForce(true)
- .setMemberName("serverOne")
- .setRebalance(true)
- .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
- .setServerPort(11235)
- .setWorkingDirectory(rootFolder)
- .setCriticalHeapPercentage(90.0f)
- .setEvictionHeapPercentage(75.0f)
- .setMaxConnections(100)
- .setMaxMessageCount(512)
- .setMaxThreads(8)
- .setMessageTimeToLive(120000)
- .setSocketBufferSize(32768)
- .build();
-
- assertNotNull(launcher);
- assertTrue(launcher.isAssignBuckets());
- assertFalse(launcher.isDebugging());
- assertFalse(launcher.isDisableDefaultServer());
- assertTrue(launcher.isForcing());
- assertFalse(launcher.isHelping());
- assertTrue(launcher.isRebalancing());
- assertFalse(launcher.isRunning());
- assertEquals(Command.STOP, launcher.getCommand());
- assertEquals("serverOne", launcher.getMemberName());
- assertEquals(InetAddress.getLocalHost(), launcher.getServerBindAddress());
- assertEquals(11235, launcher.getServerPort().intValue());
- assertEquals(rootFolder, launcher.getWorkingDirectory());
- assertEquals(90.0f, launcher.getCriticalHeapPercentage().floatValue(), 0.0f);
- assertEquals(75.0f, launcher.getEvictionHeapPercentage().floatValue(), 0.0f);
- assertEquals(100, launcher.getMaxConnections().intValue());
- assertEquals(512, launcher.getMaxMessageCount().intValue());
- assertEquals(8, launcher.getMaxThreads().intValue());
- assertEquals(120000, launcher.getMessageTimeToLive().intValue());
- assertEquals(32768, launcher.getSocketBufferSize().intValue());
+ public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
+ // given a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+ Builder builder = new Builder();
+
+ // when: parsing many arguments
+ builder.parseArguments(
+ "start",
+ "serverOne",
+ "--assign-buckets",
+ "--disable-default-server",
+ "--debug",
+ "--force",
+ "--rebalance",
+ "--redirect-output",
+ "--dir=" + rootFolder,
+ "--pid=1234",
+ "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(),
+ "--server-port=11235",
+ "--hostname-for-clients=192.168.99.100");
+
+ // then: the getters should return properly parsed values
+ assertThat(builder.getCommand()).isEqualTo(Command.START);
+ assertThat(builder.getMemberName()).isEqualTo("serverOne");
+ assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+ assertThat(builder.getAssignBuckets()).isTrue();
+ assertThat(builder.getDisableDefaultServer()).isTrue();
+ assertThat(builder.getDebug()).isTrue();
+ assertThat(builder.getForce()).isTrue();
+ assertThat(builder.getHelp()).isFalse();
+ assertThat(builder.getRebalance()).isTrue();
+ assertThat(builder.getRedirectOutput()).isTrue();
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+ assertThat(builder.getPid().intValue()).isEqualTo(1234);
+ assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+ assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
}
@Test
public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
- File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), "gemfire.properties");
- System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
-
+ // given: gemfire.properties with a name
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
- gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-
- assertTrue(propertiesFile.isFile());
- assertTrue(propertiesFile.exists());
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
+ // when: starting with null MemberName
ServerLauncher launcher = new Builder()
- .setCommand(ServerLauncher.Command.START)
- .setMemberName(null)
- .build();
+ .setCommand(Command.START)
+ .setMemberName(null)
+ .build();
- assertNotNull(launcher);
- assertEquals(ServerLauncher.Command.START, launcher.getCommand());
- assertNull(launcher.getMemberName());
+ // then: name in gemfire.properties file should be used for MemberName
+ assertThat(launcher).isNotNull();
+ assertThat(launcher.getCommand()).isEqualTo(Command.START);
+ assertThat(launcher.getMemberName()).isNull();
}
- @Test(expected = IllegalStateException.class)
- public void testBuildWithInvalidWorkingDirectoryOnStart() throws Exception {
- try {
- new Builder().setCommand(Command.START)
+ @Test
+ public void testBuildWithNoMemberNameOnStart() throws Exception {
+ // given: gemfire.properties with no name
+ useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
+
+ // when: no MemberName is specified
+ when(new Builder()
+ .setCommand(Command.START))
+ .build();
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"));
+ }
+
+ @Test
+ public void testBuilderSetAndGetWorkingDirectory() throws Exception {
+ // given: a new builder and a directory
+ String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+ Builder builder = new Builder();
+
+ // when: not setting WorkingDirectory
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(ServerLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to null
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to empty string
+ assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to white space
+ assertThat(builder.setWorkingDirectory(" ")).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+ // when: setting WorkingDirectory to a directory
+ assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
+ // then: getWorkingDirectory returns that directory
+ assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+
+ // when: setting WorkingDirectory to null (again)
+ assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+ // then: getWorkingDirectory returns default
+ assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+ }
+
+ @Test
+ public void testBuilderSetWorkingDirectoryToFile() throws Exception {
+ // given: a file instead of a directory
+ File tmpFile = this.temporaryFolder.newFile();
+
+ // when: setting WorkingDirectory to that file
+ when(new Builder())
+ .setWorkingDirectory(tmpFile.getAbsolutePath());
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+ .hasCause(new FileNotFoundException(tmpFile.getAbsolutePath()));
+ }
+
+ @Test
+ public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
+ // given: using ServerLauncher in-process
+
+ // when: setting WorkingDirectory to non-current directory
+ when(new Builder()
+ .setCommand(Command.START)
.setMemberName("serverOne")
- .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath().toString())
+ .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
.build();
- }
- catch (IllegalStateException expected) {
- assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
- .toLocalizedString("Server"), expected.getMessage());
- throw expected;
- }
+
+ // then: throw IllegalStateException
+ then(caughtException())
+ .isExactlyInstanceOf(IllegalStateException.class)
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Server"));
}
- protected File writeGemFirePropertiesToFile(final Properties gemfireProperties, final String filename, final String comment) {
- try {
- final File gemfirePropertiesFile = this.temporaryFolder.newFile(filename);
- gemfireProperties.store(new FileWriter(gemfirePropertiesFile, false), comment);
- return gemfirePropertiesFile;
- }
- catch (IOException e) {
- return null;
- }
+ @Test
+ public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
+ // when: setting WorkingDirectory to non-existing directory
+ when(new Builder())
+ .setWorkingDirectory("/path/to/non_existing/directory");
+
+ // then: throw IllegalArgumentException
+ then(caughtException())
+ .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+ .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
+ }
+
+ /**
+ * Creates a gemfire properties file in temporaryFolder:
+ * <li>creates <code>fileName</code> in <code>temporaryFolder</code>
+ * <li>sets "gemfirePropertyFile" system property
+ * <li>writes <code>gemfireProperties</code> to the file
+ */
+ private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+ File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+ System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+
+ gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+ assertThat(propertiesFile.isFile()).isTrue();
+ assertThat(propertiesFile.exists()).isTrue();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/Geode291TestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/Geode291TestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/Geode291TestSuite.java
index 93b8c19..0dbcb15 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/Geode291TestSuite.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/Geode291TestSuite.java
@@ -3,14 +3,17 @@ package com.gemstone.gemfire.test.process;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+import com.gemstone.gemfire.distributed.AbstractLauncherIntegrationJUnitTest;
import com.gemstone.gemfire.distributed.AbstractLauncherJUnitTest;
import com.gemstone.gemfire.distributed.AbstractLauncherServiceStatusJUnitTest;
import com.gemstone.gemfire.distributed.LauncherMemberMXBeanJUnitTest;
+import com.gemstone.gemfire.distributed.LocatorLauncherIntegrationJUnitTest;
import com.gemstone.gemfire.distributed.LocatorLauncherJUnitTest;
import com.gemstone.gemfire.distributed.LocatorLauncherLocalFileJUnitTest;
import com.gemstone.gemfire.distributed.LocatorLauncherLocalJUnitTest;
import com.gemstone.gemfire.distributed.LocatorLauncherRemoteFileJUnitTest;
import com.gemstone.gemfire.distributed.LocatorLauncherRemoteJUnitTest;
+import com.gemstone.gemfire.distributed.ServerLauncherIntegrationJUnitTest;
import com.gemstone.gemfire.distributed.ServerLauncherJUnitTest;
import com.gemstone.gemfire.distributed.ServerLauncherLocalFileJUnitTest;
import com.gemstone.gemfire.distributed.ServerLauncherLocalJUnitTest;
@@ -51,14 +54,17 @@ import com.gemstone.gemfire.test.golden.PassWithExpectedWarningJUnitTest;
PassWithExpectedSevereJUnitTest.class,
PassWithExpectedWarningJUnitTest.class,
AbstractLauncherJUnitTest.class,
+ AbstractLauncherIntegrationJUnitTest.class,
AbstractLauncherServiceStatusJUnitTest.class,
LauncherMemberMXBeanJUnitTest.class,
LocatorLauncherJUnitTest.class,
+ LocatorLauncherIntegrationJUnitTest.class,
LocatorLauncherLocalJUnitTest.class,
LocatorLauncherLocalFileJUnitTest.class,
LocatorLauncherRemoteJUnitTest.class,
LocatorLauncherRemoteFileJUnitTest.class,
ServerLauncherJUnitTest.class,
+ ServerLauncherIntegrationJUnitTest.class,
ServerLauncherLocalJUnitTest.class,
ServerLauncherLocalFileJUnitTest.class,
ServerLauncherRemoteJUnitTest.class,
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9b8a8be9/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index 3e6b6a5..feda580 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -6,9 +6,11 @@ activation.version = 1.1.1
annotations.version = 3.0.0
antlr.version = 2.7.7
asm.version = 5.0.3
-assertj-core.version = 2.1.0
+assertj-core.version = 3.2.0
awaitility.version = 1.6.5
bcel.version = 5.2
+catch-exception.version = 1.4.4
+catch-throwable.version = 1.4.4
cglib.version = 3.1
classmate.version = 0.9.0
commons-collections.version = 3.2.1
@@ -37,7 +39,7 @@ jline.version = 1.0.S2-B
jmock.version = 2.8.1
jna.version = 4.0.0
json4s.version = 3.2.4
-junit.version = 4.12
+junit.version = 4.13
JUnitParams.version = 1.0.4
log4j.version = 2.1
lucene.version = 5.3.0