You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2015/07/09 19:03:10 UTC
[52/57] incubator-geode git commit: Merge branch 'develop' into
feature/GEODE-8. Resolved conflicts and did a build. Unit test have not yet
been run.
Merge branch 'develop' into feature/GEODE-8.
Resolved conflicts and did a build. Unit test have not yet been run.
Conflicts:
RUNNING.txt
build.gradle
gemfire-assembly/build.gradle
gemfire-core/build.gradle
gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java
gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/RestAgent.java
gradle.properties
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/221cce70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/221cce70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/221cce70
Branch: refs/heads/develop
Commit: 221cce709af662c6633f72835cbb21ce967740c8
Parents: 31d1b20 1219783
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Jul 1 09:23:39 2015 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Jul 1 09:23:39 2015 -0700
----------------------------------------------------------------------
.gitignore | 2 +
COMPILING.txt | 9 +
README.md | 14 +-
RUNNING.txt | 2 +-
build.gradle | 2 +-
gemfire-assembly/build.gradle | 46 +-
.../src/test/java/AgentUtilJUnitTest.java | 109 +++++
gemfire-core/build.gradle | 2 +-
.../gemfire/distributed/ServerLauncher.java | 15 +-
.../gemfire/internal/i18n/LocalizedStrings.java | 1 +
.../gemfire/management/internal/AgentUtil.java | 152 ++++++
.../management/internal/ManagementAgent.java | 365 +++++++--------
.../gemfire/management/internal/RestAgent.java | 151 +++---
.../cli/commands/LauncherLifecycleCommands.java | 6 +
.../management/internal/cli/shell/Gfsh.java | 21 +
.../internal/cli/shell/GfshConfig.java | 50 +-
.../distributed/ServerLauncherJUnitTest.java | 14 +-
.../cli/shell/GfshConfigInitFileJUnitTest.java | 170 +++++++
.../cli/shell/GfshInitFileJUnitTest.java | 460 +++++++++++++++++++
gemfire-site/build.gradle | 37 ++
gemfire-site/src/jbake.zip | Bin 0 -> 207030 bytes
gemfire-site/src/jbake/assets/favicon.ico | Bin 0 -> 1150 bytes
.../src/jbake/assets/images/bg-billboard.png | Bin 0 -> 25538 bytes
.../jbake/assets/images/bg-crystals-home.png | Bin 0 -> 41684 bytes
.../assets/images/bg-crystals-secondary.png | Bin 0 -> 26046 bytes
.../src/jbake/assets/images/egg-logo1.png | Bin 0 -> 8626 bytes
.../jbake/assets/images/events/apachecon.png | Bin 0 -> 4528 bytes
.../src/jbake/assets/images/events/oscon.png | Bin 0 -> 26024 bytes
.../src/jbake/assets/images/geode-banner.png | Bin 0 -> 7916 bytes
.../assets/images/logo-apache-geode-white.png | Bin 0 -> 2336 bytes
.../jbake/assets/images/logo-apache-geode.png | Bin 0 -> 3200 bytes
.../jbake/assets/images/logo-geode-white.png | Bin 0 -> 1620 bytes
.../src/jbake/assets/images/logo-geode.png | Bin 0 -> 3345 bytes
.../src/jbake/assets/javascripts/master.js | 121 +++++
.../src/jbake/assets/javascripts/scale.fix.js | 20 +
.../jbake/assets/stylesheets/pygment_trac.css | 60 +++
.../src/jbake/assets/stylesheets/styles.css | 319 +++++++++++++
gemfire-site/src/jbake/content/404.md | 9 +
gemfire-site/src/jbake/content/README.md | 36 ++
gemfire-site/src/jbake/content/about/index.md | 31 ++
.../src/jbake/content/community/index.md | 82 ++++
.../src/jbake/content/contribute/index.md | 47 ++
gemfire-site/src/jbake/content/docs/index.md | 23 +
.../src/jbake/content/download/index.md | 13 +
.../src/jbake/content/getting-started/index.md | 88 ++++
gemfire-site/src/jbake/content/index.md | 76 +++
gemfire-site/src/jbake/jbake.properties | 6 +
gemfire-site/src/jbake/templates/page.groovy | 80 ++++
settings.gradle | 5 +
49 files changed, 2321 insertions(+), 323 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/build.gradle
----------------------------------------------------------------------
diff --cc build.gradle
index 61a35c7,bd0ec18..3bad39c
--- a/build.gradle
+++ b/build.gradle
@@@ -32,16 -31,9 +32,16 @@@ allprojects
tar.compression = Compression.GZIP
tar.extension = 'tar.gz'
}
- } )
+ })
}
+task clean (type: Delete) {
+ delete rootProject.buildDir
+ if (!buildRoot.isEmpty()) {
+ delete buildRoot
+ }
+}
+
def testResultsDir(def parent, def name) {
new File(parent, name)
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-assembly/build.gradle
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java
----------------------------------------------------------------------
diff --cc gemfire-assembly/src/test/java/AgentUtilJUnitTest.java
index 0000000,925a985..0f7563b
mode 000000,100644..100644
--- a/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java
+++ b/gemfire-assembly/src/test/java/AgentUtilJUnitTest.java
@@@ -1,0 -1,109 +1,109 @@@
+ /*
+ * 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.
+ */
+
+ import com.gemstone.gemfire.management.internal.AgentUtil;
-import com.gemstone.junit.IntegrationTest;
++import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+ import org.junit.Before;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.util.Iterator;
+ import java.util.Map;
+ import java.util.Properties;
+ import java.util.Set;
+
+ import static org.junit.Assert.*;
+
+ @Category(IntegrationTest.class)
+ public class AgentUtilJUnitTest {
+
+ private AgentUtil agentUtil;
+ private String version;
+
+ @Before
+ public void setUp() {
+ version = getGemfireVersion();
+ agentUtil = new AgentUtil(version);
+ }
+
+ @Test
+ public void testRESTApiExists() {
+ String gemFireWarLocation = agentUtil.getGemFireWebApiWarLocation();
+ assertNotNull(gemFireWarLocation, "GemFire REST API WAR File was not found");
+ }
+
+ /*
+ * This test should be activated when pulse gets added to Geode
+ */
+ // @Test
+ // public void testPulseWarExists() {
+ // String gemFireWarLocation = agentUtil.getPulseWarLocation();
+ // assertNotNull(gemFireWarLocation, "Pulse WAR File was not found");
+ // }
+
+ private String getGemfireVersion() {
+ String version = null;
+
+ Properties prop = new Properties();
+ InputStream inputStream = null;
+ String pathPrefix = null;
+ try {
+ pathPrefix = calculatePathPrefixToProjectRoot("gemfire-assembly/");
+ inputStream = new FileInputStream(pathPrefix + "gradle.properties");
+ } catch (FileNotFoundException e1) {
+ try {
+ pathPrefix = calculatePathPrefixToProjectRoot("gemfire-core/");
+ inputStream = new FileInputStream(pathPrefix + "gradle.properties");
+ } catch (FileNotFoundException e) {
+ }
+ }
+
+ if (inputStream != null) {
+ try {
+ prop.load(inputStream);
+ version = prop.getProperty("version");
+ } catch (FileNotFoundException e) {
+ } catch (IOException e) {
+ }
+ }
+ return version;
+ }
+
+ private String calculatePathPrefixToProjectRoot(String subDirectory) {
+ String pathPrefix = "";
+
+ String currentDirectoryPath = new File(".").getAbsolutePath();
+ int gemfireCoreLocationIx = currentDirectoryPath.indexOf(subDirectory);
+ if (gemfireCoreLocationIx < 0) {
+ return pathPrefix;
+ }
+
+ String pathFromRoot = currentDirectoryPath.substring(gemfireCoreLocationIx);
+ int segmentsCount = pathFromRoot.split("/").length - 1;
+
+ for (int i = 0; i < segmentsCount; i++) {
+ pathPrefix = pathPrefix + "../";
+ }
+ return pathPrefix;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --cc gemfire-core/build.gradle
index 3319f24,0fff1e6..6b8a1df
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@@ -84,93 -62,69 +84,93 @@@ dependencies
provided project(path: ':gemfire-junit', configuration: 'testOutput')
}
+def generatedResources = "$buildDir/generated-resources/main"
+
+sourceSets {
+ main {
+ output.dir(generatedResources, builtBy: 'createVersionPropertiesFile')
+ }
+}
+
+
+// task rerunTest(type:Test) {
+// include '**/CacheXml81DUnitTest.class'
+// include '**/CacheXml82DUnitTest.class'
+// include '**/ServerLauncherLocalDUnitTest.class'
+// include '**/ServerLauncherLocalFileDUnitTest.class'
+// include '**/JSONPdxClientServerDUnitTest.class'
+// include '**/PRColocatedEquiJoinDUnitTest.class'
+// }
+
// Creates the version properties file and writes it to the classes dir
-task createVersionPropertiesFile << {
-
- def gitFolder = new File ("${rootProject.projectDir}/.git")
- if ( gitFolder.exists() ) {
- new ByteArrayOutputStream().withStream { gitBranchStream ->
- def result = exec {
- standardOutput = gitBranchStream
- executable = "git"
- args = ['rev-parse', '--abbrev-ref', 'HEAD']
+task createVersionPropertiesFile {
+ def propertiesFile = file(generatedResources + "/com/gemstone/gemfire/internal/GemFireVersion.properties");
+ outputs.file propertiesFile
+ inputs.dir compileJava.destinationDir
+
+ doLast {
- def gitFolder = new File ("${rootProject.projectDir}/../.git")
++ def gitFolder = new File ("${rootProject.projectDir}/.git")
+ if ( gitFolder.exists() ) {
+ new ByteArrayOutputStream().withStream { gitBranchStream ->
+ def result = exec {
+ standardOutput = gitBranchStream
+ executable = "git"
+ args = ['rev-parse', '--abbrev-ref', 'HEAD']
+ }
+ ext.gitBranchString = gitBranchStream.toString()
+ ext.gitBranch = ext.gitBranchString.trim()
}
- ext.gitBranchString = gitBranchStream.toString()
- ext.gitBranch = ext.gitBranchString.trim()
- }
- new ByteArrayOutputStream().withStream { commitStream ->
- def result = exec {
- standardOutput = commitStream
- executable = "git"
- args = ['rev-parse', 'HEAD']
+ new ByteArrayOutputStream().withStream { commitStream ->
+ def result = exec {
+ standardOutput = commitStream
+ executable = "git"
+ args = ['rev-parse', 'HEAD']
+ }
+ ext.commitIdString = commitStream.toString()
+ ext.commitId = ext.commitIdString.trim()
}
- ext.commitIdString = commitStream.toString()
- ext.commitId = ext.commitIdString.trim()
- }
- new ByteArrayOutputStream().withStream { sourceDateStream ->
- def result = exec {
- standardOutput = sourceDateStream
- executable = "git"
- args = ['show', '-s', '--format=%ci', "${ext.commitId}"]
+ new ByteArrayOutputStream().withStream { sourceDateStream ->
+ def result = exec {
+ standardOutput = sourceDateStream
+ executable = "git"
+ args = ['show', '-s', '--format=%ci', "${ext.commitId}"]
+ }
+ ext.sourceDateString = sourceDateStream.toString()
+ ext.sourceDate = ext.sourceDateString.trim()
}
- ext.sourceDateString = sourceDateStream.toString()
- ext.sourceDate = ext.sourceDateString.trim()
}
- }
- else {
- // Not in SCM workspace, use default values
- ext.gitBranch = 'UNKNOWN'
- ext.commitId = 'UNKNOWN'
- ext.sourceDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
- }
+ else {
+ // Not in SCM workspace, use default values
+ ext.gitBranch = 'UNKNOWN'
+ ext.commitId = 'UNKNOWN'
+ ext.sourceDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
+ }
- ext.osArch = System.getProperty('os.arch')
- ext.osName = System.getProperty('os.name')
- ext.osVersion = System.getProperty('os.version')
- ext.buildDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
- ext.buildNumber = new Date().format('MMddyy')
- ext.jdkVersion = System.getProperty('java.version')
-
- def props = [
- "Product-Name" : "Pivotal GemFire",
- "Product-Version" : version,
- "Build-Id" : System.env.USER + ' ' + ext.buildNumber,
- "Build-Date" : ext.buildDate,
- "Build-Platform" : ext.osName + ' ' + ext.osVersion + ' ' + ext.osArch,
- "Build-Java-Version": ext.jdkVersion,
- "Source-Date" : ext.sourceDate,
- "Source-Revision" : ext.commitId,
- "Source-Repository" : ext.gitBranch
- ] as Properties
-
- new FileOutputStream(file("$buildDir/classes/main/com/gemstone/gemfire/internal/GemFireVersion.properties")).withStream { fos ->
- props.store(fos, '')
+ ext.osArch = System.getProperty('os.arch')
+ ext.osName = System.getProperty('os.name')
+ ext.osVersion = System.getProperty('os.version')
+ ext.buildDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
+ ext.buildNumber = new Date().format('MMddyy')
+ ext.jdkVersion = System.getProperty('java.version')
+
+ def props = [
+ "Product-Name" : "Pivotal GemFire",
+ "Product-Version" : version,
+ "Build-Id" : System.env.USER + ' ' + ext.buildNumber,
+ "Build-Date" : ext.buildDate,
+ "Build-Platform" : ext.osName + ' ' + ext.osVersion + ' ' + ext.osArch,
+ "Build-Java-Version": ext.jdkVersion,
+ "Source-Date" : ext.sourceDate,
+ "Source-Revision" : ext.commitId,
+ "Source-Repository" : ext.gitBranch
+ ] as Properties
+
+ propertiesFile.getParentFile().mkdirs();
+ new FileOutputStream(propertiesFile).withStream { fos ->
+ props.store(fos, '')
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/ServerLauncher.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java
----------------------------------------------------------------------
diff --cc gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java
index bcceef5,72afd5c..43bfe73
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/ManagementAgent.java
@@@ -178,29 -179,29 +179,28 @@@ public class ManagementAgent
}
// Find the Management WAR file
- final String gemfireWar = getGemFireWarLocation(gemfireHome);
-
+ final String gemfireWar = agentUtil.getGemFireWebWarLocation();
if (gemfireWar == null) {
if (logger.isDebugEnabled()) {
- logger
- .debug("Unable to find GemFire REST API WAR file; the REST API to GemFire will not be exported and accessible.");
+ logger.debug("Unable to find GemFire Management REST API WAR file; the Management REST Interface for GemFire will not be accessible.");
}
}
// Find the Pulse WAR file
- final String pulseWar = getPulseWarLocation(gemfireHome);
+ final String pulseWar = agentUtil.getPulseWarLocation();
if (pulseWar == null) {
- final String message = "Unable to find Pulse web application WAR file; Pulse will not start in embeded mode";
+ final String message = "Unable to find Pulse web application WAR file; Pulse for GemFire will not be accessible";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
}
}
-
- //Find developer REST WAR file
- final String gemfireAPIWar = getGemFireAPIWarLocation(gemfireHome);
+
+ // Find developer REST WAR file
+ final String gemfireAPIWar = agentUtil.getGemFireWebApiWarLocation();
if (gemfireAPIWar == null) {
- final String message = "Unable to find developer REST web application WAR file; developer REST will not start in embeded mode";
+ final String message = "Unable to find GemFire Developer REST API WAR file; the Developer REST Interface for GemFire will not be accessible.";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
@@@ -214,29 -215,30 +214,30 @@@
final int port = this.config.getHttpServicePort();
boolean isRestWebAppAdded = false;
-
- this.httpServer = JettyHelper.initJetty(bindAddress, port,
+
+ this.httpServer = JettyHelper.initJetty(bindAddress, port,
this.config.getHttpServiceSSLEnabled(),
- this.config.getHttpServiceSSLRequireAuthentication(),
- this.config.getHttpServiceSSLProtocols(),
- this.config.getHttpServiceSSLCiphers(),
+ this.config.getHttpServiceSSLRequireAuthentication(),
+ this.config.getHttpServiceSSLProtocols(), this.config.getHttpServiceSSLCiphers(),
this.config.getHttpServiceSSLProperties());
- if (isWebApplicationAvailable(gemfireWar)) {
- this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/gemfire", gemfireWar);
+ if (agentUtil.isWebApplicationAvailable(gemfireWar)) {
+ this.httpServer = JettyHelper
+ .addWebApplication(this.httpServer, "/gemfire", gemfireWar);
}
- if (isWebApplicationAvailable(pulseWar)) {
+ if (agentUtil.isWebApplicationAvailable(pulseWar)) {
this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/pulse", pulseWar);
}
-
- if(isServer && this.config.getStartDevRestApi()) {
- if (isWebApplicationAvailable(gemfireAPIWar) ) {
- this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/gemfire-api", gemfireAPIWar);
+
+ if (isServer && this.config.getStartDevRestApi()) {
+ if (agentUtil.isWebApplicationAvailable(gemfireAPIWar)) {
+ this.httpServer = JettyHelper.addWebApplication(this.httpServer, "/gemfire-api",
+ gemfireAPIWar);
isRestWebAppAdded = true;
}
- }else {
+ } else {
- final String message = "developer REST web application will not start when start-dev-rest-api is not set and node is not server";
+ final String message = "Developer REST API web application will not start when start-dev-rest-api is not set and node is not server";
setStatusMessage(managerBean, message);
if (logger.isDebugEnabled()) {
logger.debug(message);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/RestAgent.java
----------------------------------------------------------------------
diff --cc gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/RestAgent.java
index 6893576,cd9d2c6..74695ee
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/RestAgent.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/RestAgent.java
@@@ -110,45 -96,28 +96,26 @@@ public class RestAgent
private boolean isRunningInTomcat() {
return (System.getProperty("catalina.base") != null || System.getProperty("catalina.home") != null);
}
-
- private boolean isWebApplicationAvailable(final String warFileLocation) {
- return !StringUtils.isBlank(warFileLocation);
- }
-
- //Start HTTP service in embedded mode
+
+ // Start HTTP service in embedded mode
public void startHttpService() {
- //TODO: add a check that will make sure that we start HTTP service on non-manager data node
+ // TODO: add a check that will make sure that we start HTTP service on
+ // non-manager data node
logger.info("Attempting to start HTTP service on port ({}) at bind-address ({})...",
this.config.getHttpServicePort(), this.config.getHttpServiceBindAddress());
-
- String gemfireHome = System.getenv("GEMFIRE");
-
- // Check for empty variable. if empty, then log message and exit HTTP server startup
- if (StringUtils.isBlank(gemfireHome)) {
- String gemfire = System.getProperty("gemfire.home");
- logger.info("Reading gemfire.home System Property -> {}", gemfire);
- if (StringUtils.isBlank(gemfire)) {
- logger.info("GEMFIRE environment variable not set; HTTP service will not start.");
- return;
- } else {
- gemfireHome = gemfire;
- }
- }
-
+
// Find the developer REST WAR file
- final String gemfireAPIWar = getGemFireAPIWarLocation(gemfireHome);
-
- if(gemfireAPIWar == null){
+ final String gemfireAPIWar = agentUtil.getGemFireWebApiWarLocation();
+ if (gemfireAPIWar == null) {
- logger
- .info("Unable to find GemFire Developer REST API WAR file; the Developer REST API for GemFire will not be exported and accessible.");
+ logger.info("Unable to find GemFire Developer REST API WAR file; the Developer REST Interface for GemFire will not be accessible.");
}
-
+
try {
// Check if we're already running inside Tomcat
if (isRunningInTomcat()) {
- logger
- .warn("Detected presence of catalina system properties. HTTP service will not be started. To enable the GemFire developer REST API, please deploy the gemfire-web.war file in your application server.");
+ logger.warn("Detected presence of catalina system properties. HTTP service will not be started. To enable the GemFire Developer REST API, please deploy the /gemfire-api WAR file in your application server.");
- }
- else if (isWebApplicationAvailable(gemfireAPIWar)) {
-
+ } else if (agentUtil.isWebApplicationAvailable(gemfireAPIWar)) {
+
final String bindAddress = this.config.getHttpServiceBindAddress();
final int port = this.config.getHttpServicePort();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --cc gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
index d466ddc,170f330..e1f42e9
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/LauncherLifecycleCommands.java
@@@ -1560,13 -1462,64 +1560,14 @@@ public class LauncherLifecycleCommands
unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
help = CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE__HELP)
final String statisticsArchivePathname,
- @CliOption(key = CliStrings.START_SERVER__DIR,
- optionContext = ConverterHint.DIR_PATHSTRING,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__DIR__HELP)
- String workingDirectory,
- @CliOption(key = CliStrings.START_SERVER__INITIAL_HEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__INITIAL_HEAP__HELP)
- final String initialHeap,
- @CliOption(key = CliStrings.START_SERVER__MAXHEAP,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__MAXHEAP__HELP)
- final String maxHeap,
- @CliOption(key = CliStrings.START_SERVER__REQUEST_SHARED_CONFIGURATION,
+ @CliOption(key = CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION,
unspecifiedDefaultValue = "true",
specifiedDefaultValue = "true",
- help = CliStrings.START_SERVER__REQUEST_SHARED_CONFIGURATION__HELP)
- final Boolean requestSharedConfiguration,
- @CliOption(key = CliStrings.START_SERVER__J,
- optionContext = ConverterHint.STRING_LIST,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__J__HELP)
- @CliMetaData(valueSeparator = ",")
- final String[] jvmArgsOpts,
- @CliOption(key = CliStrings.START_SERVER__CRITICAL__HEAP__PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__CRITICAL__HEAP__HELP)
- final Float criticalHeapPercentage,
- @CliOption(key = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE__HELP)
- final Float evictionHeapPercentage,
- @CliOption(key = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS__HELP)
- final String hostNameForClients,
- @CliOption(key = CliStrings.START_SERVER__MAX__CONNECTIONS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__MAX__CONNECTIONS__HELP)
- final Integer maxConnections,
- @CliOption(key = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE__HELP)
- final Integer messageTimeToLive,
- @CliOption(key = CliStrings.START_SERVER__MAX__MESSAGE__COUNT,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__MAX__MESSAGE__COUNT__HELP)
- final Integer maxMessageCount,
- @CliOption(key = CliStrings.START_SERVER__MAX__THREADS,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__MAX__THREADS__HELP)
- final Integer maxThreads,
- @CliOption(key = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE,
- unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
- help = CliStrings.START_SERVER__SOCKET__BUFFER__SIZE__HELP)
- final Integer socketBufferSize)
+ help = CliStrings.START_SERVER__USE_CLUSTER_CONFIGURATION__HELP)
+ final Boolean requestSharedConfiguration)
+ // NOTICE: keep the parameters in alphabetical order based on their CliStrings.START_SERVER_* text
{
+
try {
if (workingDirectory == null) {
// attempt to use or make sub-directory using memberName...
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/shell/Gfsh.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshConfigInitFileJUnitTest.java
----------------------------------------------------------------------
diff --cc gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshConfigInitFileJUnitTest.java
index 0000000,c956a0d..50a050a
mode 000000,100755..100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshConfigInitFileJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshConfigInitFileJUnitTest.java
@@@ -1,0 -1,170 +1,170 @@@
+ package com.gemstone.gemfire.management.internal.cli.shell;
+
+ import static org.junit.Assert.*;
+
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ import org.junit.rules.TemporaryFolder;
+
-import com.gemstone.junit.UnitTest;
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+ @Category(UnitTest.class)
+ public class GfshConfigInitFileJUnitTest {
+ private static final String INIT_FILE_NAME = GfshConfig.DEFAULT_INIT_FILE_NAME;
+ private static final String INIT_FILE_PROPERTY = GfshConfig.INIT_FILE_PROPERTY;
+
+ private static String saveUserDir;
+ private static String saveUserHome;
+
+ @Rule
+ public TemporaryFolder temporaryFolder_HomeDirectory = new TemporaryFolder();
+ @Rule
+ public TemporaryFolder temporaryFolder_CurrentDirectory = new TemporaryFolder();
+ @Rule
+ public TemporaryFolder temporaryFolder_AnotherDirectory = new TemporaryFolder();
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ saveUserDir = System.getProperty("user.dir");
+ saveUserHome = System.getProperty("user.home");
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (saveUserDir == null) {
+ System.clearProperty("user.dir");
+ } else {
+ System.setProperty("user.dir", saveUserDir);
+ }
+ if (saveUserHome == null) {
+ System.clearProperty("user.home");
+ } else {
+ System.setProperty("user.home", saveUserHome);
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ String userDir = temporaryFolder_CurrentDirectory.getRoot()
+ .getAbsolutePath();
+ String userHome = temporaryFolder_HomeDirectory.getRoot().getAbsolutePath();
+
+ System.setProperty("user.dir", userDir);
+ System.setProperty("user.home", userHome);
+
+ // Abort all tests if system properties cannot be overridden
+ assertEquals("user.dir", System.getProperty("user.dir"), userDir);
+ assertEquals("user.home", System.getProperty("user.home"), userHome);
+ }
+
+ // If a file is given to the constructor, all other options should be ignored
+ @Test
+ public void constructorArgumentUsed() throws Exception {
+ temporaryFolder_HomeDirectory.newFile(INIT_FILE_NAME);
+ temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ System.setProperty(INIT_FILE_PROPERTY, temporaryFolder_AnotherDirectory
+ .newFile(INIT_FILE_NAME).getAbsolutePath());
+
+ String argument = temporaryFolder_AnotherDirectory.newFile("junit")
+ .getAbsolutePath();
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig("historyFileName", "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, argument);
+
+ String result = gfshConfig.getInitFileName();
+
+ assertEquals(argument, result);
+ }
+
+ // System property should be chosen ahead of current and home directories
+ @Test
+ public void systemPropertySelectedFirst() throws Exception {
+ temporaryFolder_HomeDirectory.newFile(INIT_FILE_NAME);
+ temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ String fileName = temporaryFolder_AnotherDirectory.newFile(INIT_FILE_NAME)
+ .getAbsolutePath();
+ System.setProperty(INIT_FILE_PROPERTY, fileName);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig("historyFileName", "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, null);
+
+ String result = gfshConfig.getInitFileName();
+
+ assertEquals(fileName, result);
+ }
+
+ // Current directory file selected ahead of home directory file
+ @Test
+ public void currentDirectorySelectedSecond() throws Exception {
+ temporaryFolder_HomeDirectory.newFile(INIT_FILE_NAME);
+ String fileName = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME)
+ .getAbsolutePath();
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig("historyFileName", "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, null);
+
+ String result = gfshConfig.getInitFileName();
+
+ assertEquals(fileName, result);
+ }
+
+ // Home directory file selected if only one present
+ @Test
+ public void homeDirectorySelectedThird() throws Exception {
+ String fileName = temporaryFolder_HomeDirectory.newFile(INIT_FILE_NAME)
+ .getAbsolutePath();
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig("historyFileName", "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, null);
+
+ String result = gfshConfig.getInitFileName();
+
+ assertEquals(fileName, result);
+ }
+
+ // No files need match
+ @Test
+ public void noMatches() throws Exception {
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig("historyFileName", "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, null);
+
+ String result = gfshConfig.getInitFileName();
+
+ assertNull(result);
+ }
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/221cce70/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshInitFileJUnitTest.java
----------------------------------------------------------------------
diff --cc gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshInitFileJUnitTest.java
index 0000000,9cbc9b9..da567e3
mode 000000,100755..100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshInitFileJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/shell/GfshInitFileJUnitTest.java
@@@ -1,0 -1,460 +1,460 @@@
+ package com.gemstone.gemfire.management.internal.cli.shell;
+
+ import static org.junit.Assert.*;
+
+ import java.io.ByteArrayOutputStream;
+ import java.io.File;
+ import java.io.PrintStream;
+ import java.lang.reflect.Field;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.logging.Handler;
+ import java.util.logging.LogRecord;
+
+ import org.apache.commons.io.FileUtils;
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.core.LoggerContext;
+ import org.apache.logging.log4j.core.config.ConfigurationFactory;
+ import org.junit.After;
+ import org.junit.AfterClass;
+ import org.junit.Before;
+ import org.junit.BeforeClass;
+ import org.junit.ClassRule;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ import org.junit.rules.TemporaryFolder;
+
+ import com.gemstone.gemfire.management.internal.cli.LogWrapper;
-import com.gemstone.junit.UnitTest;
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+ /**
+ * <P>
+ * Unit tests for supplying an init file to Gfsh.
+ * </P>
+ * <P>
+ * Makes use of reflection to reset private static variables on some classes to
+ * replace loggers that would otherwise clutter the console.
+ * </P>
+ */
+ @Category(UnitTest.class)
+ public class GfshInitFileJUnitTest {
+ private static final String INIT_FILE_NAME = GfshConfig.DEFAULT_INIT_FILE_NAME;
+ private static final boolean APPEND = true;
+ private static final int BANNER_LINES = 1;
+ private static final int INIT_FILE_CITATION_LINES = 1;
+
+ private static String saveLog4j2Config;
+ private static String saveUserDir;
+ private static String saveUserHome;
+ private static java.util.logging.Logger julLogger;
+ private static Handler[] saveHandlers;
+
+ @ClassRule
+ public static TemporaryFolder temporaryFolder_Config = new TemporaryFolder();
+ @Rule
+ public TemporaryFolder temporaryFolder_CurrentDirectory = new TemporaryFolder();
+
+ private ByteArrayOutputStream sysout = new ByteArrayOutputStream();
+ private String gfshHistoryFileName;
+ private LogWrapper gfshFileLogger;
+ private JUnitLoggerHandler junitLoggerHandler;
+
+ /*
+ * Turn off console logging from JUL and Log4j2 for the duration of this
+ * class's tests, to reduce noise level of output in automated build.
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ saveLog4j2Config = System
+ .getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ saveUserDir = System.getProperty("user.dir");
+ saveUserHome = System.getProperty("user.home");
+
+ julLogger = java.util.logging.Logger.getLogger("");
+ saveHandlers = julLogger.getHandlers();
+ for (Handler handler : saveHandlers) {
+ julLogger.removeHandler(handler);
+ }
+
+ File log4j2XML = temporaryFolder_Config.newFile("log4j2.xml");
+ FileUtils.writeStringToFile(log4j2XML, "<Configuration/>", APPEND);
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
+ log4j2XML.toURI().toString());
+ }
+
+ /*
+ * Restore logging to state prior to the execution of this class
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ for (Handler handler : saveHandlers) {
+ julLogger.addHandler(handler);
+ }
+
+ if (saveLog4j2Config == null) {
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ } else {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
+ saveLog4j2Config);
+ ((LoggerContext) LogManager.getContext(false)).reconfigure();
+ }
+
+ if (saveUserDir == null) {
+ System.clearProperty("user.dir");
+ } else {
+ System.setProperty("user.dir", saveUserDir);
+ }
+ if (saveUserHome == null) {
+ System.clearProperty("user.home");
+ } else {
+ System.setProperty("user.home", saveUserHome);
+ }
+ }
+
+ /*
+ * Reset $HOME and current directory for tests, and confirm this has been
+ * accepted.
+ */
+ @Before
+ public void setUp() throws Exception {
+ // Fake running from home directory
+ String userDir = temporaryFolder_CurrentDirectory.getRoot()
+ .getAbsolutePath();
+ String userHome = userDir;
+
+ System.setProperty("user.dir", userDir);
+ System.setProperty("user.home", userHome);
+
+ // Abort all tests if system properties cannot be overridden
+ assertEquals("user.dir", System.getProperty("user.dir"), userDir);
+ assertEquals("user.home", System.getProperty("user.home"), userHome);
+ }
+
+ @Before
+ public void setUp2() throws Exception {
+
+ // Null out static instance so can reinitialise
+ Field gfsh_instance = Gfsh.class.getDeclaredField("instance");
+ gfsh_instance.setAccessible(true);
+ gfsh_instance.set(null, null);
+
+ this.junitLoggerHandler = new JUnitLoggerHandler();
+
+ this.gfshFileLogger = LogWrapper.getInstance();
+ Field logWrapper_INSTANCE = LogWrapper.class.getDeclaredField("INSTANCE");
+ logWrapper_INSTANCE.setAccessible(true);
+ logWrapper_INSTANCE.set(null, this.gfshFileLogger);
+
+ Field logWrapper_logger = LogWrapper.class.getDeclaredField("logger");
+ logWrapper_logger.setAccessible(true);
+ julLogger.addHandler(this.junitLoggerHandler);
+ logWrapper_logger.set(this.gfshFileLogger, julLogger);
+
+ Gfsh.gfshout = new PrintStream(sysout);
+ this.gfshHistoryFileName = temporaryFolder_CurrentDirectory.newFile(
+ "historyFile").getAbsolutePath();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ julLogger.removeHandler(this.junitLoggerHandler);
+ }
+
+ @Test
+ public void testInitFile_NotProvided() throws Exception {
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, null);
+ assertNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertEquals("Status 0==success", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_NotFound() throws Exception {
+ // Construct the file name but not the file
+ String initFileName = temporaryFolder_CurrentDirectory.getRoot()
+ .getAbsolutePath() + File.separator + INIT_FILE_NAME;
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFileName);
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertNotEquals("Status <0==failure", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ Throwable exception = null;
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ if (logRecord.getThrown() != null) {
+ exception = logRecord.getThrown();
+ break;
+ }
+ }
+ assertNotNull("Exceptions in log", exception);
+ }
+
+ @Test
+ public void testInitFile_Empty() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertEquals("Status 0==success", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_OneGoodCommand() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ FileUtils.writeStringToFile(initFile, "echo --string=hello"
+ + Gfsh.LINE_SEPARATOR, APPEND);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertEquals("Status 0==success", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_TwoGoodCommands() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ FileUtils.writeStringToFile(initFile, "echo --string=hello"
+ + Gfsh.LINE_SEPARATOR, APPEND);
+ FileUtils.writeStringToFile(initFile, "echo --string=goodbye"
+ + Gfsh.LINE_SEPARATOR, APPEND);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertEquals("Status 0==success", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_OneBadCommand() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ FileUtils.writeStringToFile(initFile, "fail" + Gfsh.LINE_SEPARATOR, APPEND);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertNotEquals("Status <0==failure", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_TwoBadCommands() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ FileUtils.writeStringToFile(initFile, "fail" + Gfsh.LINE_SEPARATOR, APPEND);
+ FileUtils.writeStringToFile(initFile, "fail" + Gfsh.LINE_SEPARATOR, APPEND);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertNotEquals("Status <0==failure", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ @Test
+ public void testInitFile_BadAndGoodCommands() throws Exception {
+ File initFile = temporaryFolder_CurrentDirectory.newFile(INIT_FILE_NAME);
+ FileUtils.writeStringToFile(initFile, "fail" + Gfsh.LINE_SEPARATOR, APPEND);
+ FileUtils.writeStringToFile(initFile, "echo --string=goodbye"
+ + Gfsh.LINE_SEPARATOR, APPEND);
+
+ /*
+ * String historyFileName, String defaultPrompt, int historySize, String
+ * logDir, Level logLevel, Integer logLimit, Integer logCount, String
+ * initFileName
+ */
+ GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
+ temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null,
+ null, null, initFile.getAbsolutePath());
+ assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());
+
+ /*
+ * boolean launchShell, String[] args, GfshConfig gfshConfig
+ */
+ Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);
+
+ int actualStatus = gfsh.getLastExecutionStatus();
+ int expectedStatus = 0;
+ assertNotEquals("Status <0==failure", expectedStatus, actualStatus);
+
+ int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
+ assertEquals("Log records written", expectedLogCount,
+ this.junitLoggerHandler.getLog().size());
+ for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
+ assertNull("No exceptions in log", logRecord.getThrown());
+ }
+ }
+
+ /**
+ * <P>
+ * Log handler for testing. Capture logged messages for later inspection.
+ * </P>
+ *
+ * @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
+ */
+ private class JUnitLoggerHandler extends Handler {
+ private List<LogRecord> log;
+
+ public JUnitLoggerHandler() {
+ log = new ArrayList<>();
+ }
+
+ public List<LogRecord> getLog() {
+ return log;
+ }
+
+ @Override
+ public void publish(LogRecord record) {
+ log.add(record);
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() throws SecurityException {
+ }
+ }
+ }