You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by pr...@apache.org on 2017/11/06 18:01:51 UTC

[geode] branch develop updated: Geode 3539: Add missing test coverage for 'version' command. (#1009)

This is an automated email from the ASF dual-hosted git repository.

prhomberg pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 50eb158  Geode 3539: Add missing test coverage for 'version' command. (#1009)
50eb158 is described below

commit 50eb158cd863849e6546081942bff8876dda29c6
Author: Patrick Rhomberg <Pu...@users.noreply.github.com>
AuthorDate: Mon Nov 6 10:01:48 2017 -0800

    Geode 3539: Add missing test coverage for 'version' command. (#1009)
    
    * GEODE-3539: Add missing test coverage for 'version' command.
    
    * Extract inner class GemFireVersion.VersionDescription to its own class
    * Made static strings in this this class visible for internal use.
---
 .../org/apache/geode/internal/GemFireVersion.java  | 219 +++------------------
 .../apache/geode/internal/VersionDescription.java  | 213 ++++++++++++++++++++
 .../geode/internal/GemFireVersionJUnitTest.java    |  23 ++-
 .../cli/commands/VersionCommandJUnitTest.java      |  84 ++++++++
 4 files changed, 335 insertions(+), 204 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/GemFireVersion.java b/geode-core/src/main/java/org/apache/geode/internal/GemFireVersion.java
index 04b4443..c9d20b0 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/GemFireVersion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/GemFireVersion.java
@@ -14,32 +14,31 @@
  */
 package org.apache.geode.internal;
 
-import static org.apache.geode.internal.lang.SystemUtils.*;
+import static org.apache.geode.internal.VersionDescription.BUILD_DATE;
+import static org.apache.geode.internal.VersionDescription.BUILD_ID;
+import static org.apache.geode.internal.VersionDescription.BUILD_JAVA_VERSION;
+import static org.apache.geode.internal.VersionDescription.BUILD_PLATFORM;
+import static org.apache.geode.internal.VersionDescription.PRODUCT_NAME;
+import static org.apache.geode.internal.VersionDescription.PRODUCT_VERSION;
+import static org.apache.geode.internal.VersionDescription.RESOURCE_NAME;
+import static org.apache.geode.internal.VersionDescription.SOURCE_DATE;
+import static org.apache.geode.internal.VersionDescription.SOURCE_REPOSITORY;
+import static org.apache.geode.internal.VersionDescription.SOURCE_REVISION;
+import static org.apache.geode.internal.lang.SystemUtils.getBootClassPath;
+import static org.apache.geode.internal.lang.SystemUtils.getClassPath;
 
 import java.io.File;
-import java.io.InputStream;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.URL;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Properties;
 import java.util.StringTokenizer;
-import java.util.TreeMap;
-
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.SystemFailure;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.net.SocketCreator;
 
 /**
  * This class provides build and version information about GemFire. It gathers this information from
  * the resource property file for this class.
  */
 public class GemFireVersion {
-  private static String RESOURCE_NAME = "GemFireVersion.properties";
-
   /** The singleton instance */
   private static VersionDescription description;
 
@@ -54,44 +53,40 @@ public class GemFireVersion {
     return description;
   }
 
-  public static void main(String[] args) {
-    System.out.println(asString());
-  }
-
   public static String getProductName() {
-    return getDescription().getProperty(VersionDescription.PRODUCT_NAME);
+    return getDescription().getProperty(PRODUCT_NAME);
   }
 
   public static String getGemFireVersion() {
-    return getDescription().getProperty(VersionDescription.GEMFIRE_VERSION);
+    return getDescription().getProperty(PRODUCT_VERSION);
   }
 
   public static String getSourceDate() {
-    return getDescription().getProperty(VersionDescription.SOURCE_DATE);
+    return getDescription().getProperty(SOURCE_DATE);
   }
 
   public static String getSourceRepository() {
-    return getDescription().getProperty(VersionDescription.SOURCE_REPOSITORY);
+    return getDescription().getProperty(SOURCE_REPOSITORY);
   }
 
   public static String getSourceRevision() {
-    return getDescription().getProperty(VersionDescription.SOURCE_REVISION);
+    return getDescription().getProperty(SOURCE_REVISION);
   }
 
   public static String getBuildId() {
-    return getDescription().getProperty(VersionDescription.BUILD_ID);
+    return getDescription().getProperty(BUILD_ID);
   }
 
   public static String getBuildDate() {
-    return getDescription().getProperty(VersionDescription.BUILD_DATE);
+    return getDescription().getProperty(BUILD_DATE);
   }
 
   public static String getBuildPlatform() {
-    return getDescription().getProperty(VersionDescription.BUILD_PLATFORM);
+    return getDescription().getProperty(BUILD_PLATFORM);
   }
 
   public static String getBuildJavaVersion() {
-    return getDescription().getProperty(VersionDescription.BUILD_JAVA_VERSION);
+    return getDescription().getProperty(BUILD_JAVA_VERSION);
   }
 
   public static String getGemFireJarFileName() {
@@ -125,11 +120,11 @@ public class GemFireVersion {
     StringTokenizer tokenizer = new StringTokenizer(getClassPath(), File.pathSeparator);
     while (tokenizer.hasMoreTokens()) {
       String jar = tokenizer.nextToken();
-      if (jar.indexOf(getGemFireJarFileName()) != -1) {
+      if (jar.contains(getGemFireJarFileName())) {
         File gemfireJar = new File(jar);
         try {
-          csLoc = gemfireJar.toURL();
-        } catch (Exception e) {
+          csLoc = gemfireJar.toURI().toURL();
+        } catch (Exception ignored) {
         }
         break;
       }
@@ -141,175 +136,15 @@ public class GemFireVersion {
     tokenizer = new StringTokenizer(getBootClassPath(), File.pathSeparator);
     while (tokenizer.hasMoreTokens()) {
       String jar = tokenizer.nextToken();
-      if (jar.indexOf(getGemFireJarFileName()) != -1) {
+      if (jar.contains(getGemFireJarFileName())) {
         File gemfireJar = new File(jar);
         try {
-          csLoc = gemfireJar.toURL();
-        } catch (Exception e) {
+          csLoc = gemfireJar.toURI().toURL();
+        } catch (Exception ignored) {
         }
         break;
       }
     }
     return csLoc;
   }
-
-  static class VersionDescription {
-    /** Constant for the GemFire version Resource Property entry */
-    static final String PRODUCT_NAME = "Product-Name";
-
-    /** Constant for the GemFire version Resource Property entry */
-    static final String GEMFIRE_VERSION = "Product-Version";
-
-    /** Constant for the source code date Resource Property entry */
-    static final String SOURCE_DATE = "Source-Date";
-
-    /** Constant for the source code revision Resource Property entry */
-    static final String SOURCE_REVISION = "Source-Revision";
-
-    /** Constant for the source code repository Resource Property entry */
-    static final String SOURCE_REPOSITORY = "Source-Repository";
-
-    /** Constant for the build date Resource Property entry */
-    static final String BUILD_DATE = "Build-Date";
-
-    /** Constant for the build id Resource Property entry */
-    static final String BUILD_ID = "Build-Id";
-
-    /** Constant for the build Java version Resource Property entry */
-    static final String BUILD_PLATFORM = "Build-Platform";
-
-    /** Constant for the build Java version Resource Property entry */
-    static final String BUILD_JAVA_VERSION = "Build-Java-Version";
-
-    /** the version properties */
-    private final Properties description;
-
-    /** Error message to display instead of the version information */
-    private final Optional<String> error;
-
-    public VersionDescription(String name) {
-      InputStream is = ClassPathLoader.getLatest().getResourceAsStream(getClass(), name);
-      if (is == null) {
-        error = Optional
-            .of(LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0
-                .toLocalizedString(name));
-        description = null;
-        return;
-      }
-
-      description = new Properties();
-      try {
-        description.load(is);
-      } catch (Exception ex) {
-        error = Optional
-            .of(LocalizedStrings.GemFireVersion_COULD_NOT_READ_PROPERTIES_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0_BECAUSE_1
-                .toLocalizedString(new Object[] {name, ex}));
-        return;
-      }
-
-      error = validate(description);
-    }
-
-    public String getProperty(String key) {
-      return error.orElseGet(() -> description.getProperty(key));
-    }
-
-    public String getNativeCodeVersion() {
-      return SmHelper.getNativeVersion();
-    }
-
-    void print(PrintWriter pw) {
-      if (error.isPresent()) {
-        pw.println(error.get());
-      } else {
-        for (Entry<?, ?> props : new TreeMap<>(description).entrySet()) {
-          pw.println(props.getKey() + ": " + props.getValue());
-        }
-      }
-
-      // not stored in the description map
-      pw.println("Native version: " + getNativeCodeVersion());
-      printHostInfo(pw);
-    }
-
-    private void printHostInfo(PrintWriter pw)
-        throws InternalGemFireError, Error, VirtualMachineError {
-      try {
-        StringBuilder sb = new StringBuilder(SocketCreator.getLocalHost().toString()).append(", ")
-            .append(Runtime.getRuntime().availableProcessors()).append(" cpu(s), ")
-            .append(getOsArchitecture()).append(' ').append(getOsName()).append(' ')
-            .append(getOsVersion()).append(' ');
-        pw.println(LocalizedStrings.GemFireVersion_RUNNING_ON_0.toLocalizedString(sb.toString()));
-      } catch (VirtualMachineError err) {
-        SystemFailure.initiateFailure(err);
-        // If this ever returns, rethrow the error. We're poisoned
-        // now, so don't let this thread continue.
-        throw err;
-      } catch (Throwable t) {
-        // Whenever you catch Error or Throwable, you must also
-        // catch VirtualMachineError (see above). However, there is
-        // _still_ a possibility that you are dealing with a cascading
-        // error condition, so you also need to check to see if the JVM
-        // is still usable:
-        SystemFailure.checkFailure();
-      }
-    }
-
-    private Optional<String> validate(Properties props) {
-      if (props.get(PRODUCT_NAME) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {PRODUCT_NAME, RESOURCE_NAME}));
-      }
-
-      if (props.get(GEMFIRE_VERSION) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {GEMFIRE_VERSION, RESOURCE_NAME}));
-      }
-
-      if (props.get(SOURCE_DATE) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {SOURCE_DATE, RESOURCE_NAME}));
-      }
-
-      if (props.get(SOURCE_REVISION) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {SOURCE_REVISION, RESOURCE_NAME}));
-      }
-
-      if (props.get(SOURCE_REPOSITORY) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {SOURCE_REPOSITORY, RESOURCE_NAME}));
-      }
-
-      if (props.get(BUILD_DATE) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {BUILD_DATE, RESOURCE_NAME}));
-      }
-
-      if (props.get(BUILD_ID) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {BUILD_ID, RESOURCE_NAME}));
-      }
-
-      if (props.get(BUILD_PLATFORM) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {BUILD_PLATFORM, RESOURCE_NAME}));
-      }
-
-      if (props.get(BUILD_JAVA_VERSION) == null) {
-        return Optional
-            .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
-                .toLocalizedString(new Object[] {BUILD_JAVA_VERSION, RESOURCE_NAME}));
-      }
-      return Optional.empty();
-    }
-  }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java b/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java
new file mode 100644
index 0000000..84965ea
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/VersionDescription.java
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal;
+
+import static org.apache.geode.internal.lang.SystemUtils.getOsArchitecture;
+import static org.apache.geode.internal.lang.SystemUtils.getOsName;
+import static org.apache.geode.internal.lang.SystemUtils.getOsVersion;
+
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.apache.geode.SystemFailure;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.net.SocketCreator;
+
+public class VersionDescription {
+  public static final String RESOURCE_NAME = "GemFireVersion.properties";
+
+  /**
+   * Constant for the GemFire version Resource Property entry
+   */
+  public static final String PRODUCT_NAME = "Product-Name";
+
+  /**
+   * Constant for the GemFire version Resource Property entry
+   */
+  public static final String PRODUCT_VERSION = "Product-Version";
+
+  /**
+   * Constant for the source code date Resource Property entry
+   */
+  public static final String SOURCE_DATE = "Source-Date";
+
+  /**
+   * Constant for the source code revision Resource Property entry
+   */
+  public static final String SOURCE_REVISION = "Source-Revision";
+
+  /**
+   * Constant for the source code repository Resource Property entry
+   */
+  public static final String SOURCE_REPOSITORY = "Source-Repository";
+
+  /**
+   * Constant for the build date Resource Property entry
+   */
+  public static final String BUILD_DATE = "Build-Date";
+
+  /**
+   * Constant for the build id Resource Property entry
+   */
+  public static final String BUILD_ID = "Build-Id";
+
+  /**
+   * Constant for the build Java version Resource Property entry
+   */
+  public static final String BUILD_PLATFORM = "Build-Platform";
+
+  /**
+   * Constant for the build Java version Resource Property entry
+   */
+  public static final String BUILD_JAVA_VERSION = "Build-Java-Version";
+
+  /**
+   * the version properties
+   */
+  private final Properties description;
+
+  /**
+   * Error message to display instead of the version information
+   */
+  private final Optional<String> error;
+
+  public VersionDescription(String name) {
+    InputStream is = ClassPathLoader.getLatest().getResourceAsStream(getClass(), name);
+    if (is == null) {
+      error = Optional
+          .of(LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0
+              .toLocalizedString(name));
+      description = null;
+      return;
+    }
+
+    description = new Properties();
+    try {
+      description.load(is);
+    } catch (Exception ex) {
+      error = Optional
+          .of(LocalizedStrings.GemFireVersion_COULD_NOT_READ_PROPERTIES_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0_BECAUSE_1
+              .toLocalizedString(name, ex));
+      return;
+    }
+
+    error = validate(description);
+  }
+
+  public String getProperty(String key) {
+    return error.orElseGet(() -> description.getProperty(key));
+  }
+
+  private String getNativeCodeVersion() {
+    return SmHelper.getNativeVersion();
+  }
+
+  void print(PrintWriter pw) {
+    if (error.isPresent()) {
+      pw.println(error.get());
+    } else {
+      for (Entry<?, ?> props : new TreeMap<>(description).entrySet()) {
+        pw.println(props.getKey() + ": " + props.getValue());
+      }
+    }
+
+    // not stored in the description map
+    pw.println("Native version: " + getNativeCodeVersion());
+    printHostInfo(pw);
+  }
+
+  private void printHostInfo(PrintWriter pw) throws Error {
+    try {
+      String sb = SocketCreator.getLocalHost().toString() + ", "
+          + Runtime.getRuntime().availableProcessors() + " cpu(s), " + getOsArchitecture() + ' '
+          + getOsName() + ' ' + getOsVersion() + ' ';
+      pw.println(LocalizedStrings.GemFireVersion_RUNNING_ON_0.toLocalizedString(sb));
+    } catch (VirtualMachineError err) {
+      SystemFailure.initiateFailure(err);
+      // If this ever returns, rethrow the error. We're poisoned
+      // now, so don't let this thread continue.
+      throw err;
+    } catch (Throwable t) {
+      // Whenever you catch Error or Throwable, you must also
+      // catch VirtualMachineError (see above). However, there is
+      // _still_ a possibility that you are dealing with a cascading
+      // error condition, so you also need to check to see if the JVM
+      // is still usable:
+      SystemFailure.checkFailure();
+    }
+  }
+
+  private Optional<String> validate(Properties props) {
+    if (props.get(PRODUCT_NAME) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(PRODUCT_NAME, RESOURCE_NAME));
+    }
+
+    if (props.get(PRODUCT_VERSION) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(PRODUCT_VERSION, RESOURCE_NAME));
+    }
+
+    if (props.get(SOURCE_DATE) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(SOURCE_DATE, RESOURCE_NAME));
+    }
+
+    if (props.get(SOURCE_REVISION) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(SOURCE_REVISION, RESOURCE_NAME));
+    }
+
+    if (props.get(SOURCE_REPOSITORY) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(SOURCE_REPOSITORY, RESOURCE_NAME));
+    }
+
+    if (props.get(BUILD_DATE) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(BUILD_DATE, RESOURCE_NAME));
+    }
+
+    if (props.get(BUILD_ID) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(BUILD_ID, RESOURCE_NAME));
+    }
+
+    if (props.get(BUILD_PLATFORM) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(BUILD_PLATFORM, RESOURCE_NAME));
+    }
+
+    if (props.get(BUILD_JAVA_VERSION) == null) {
+      return Optional
+          .of(LocalizedStrings.GemFireVersion_MISSING_PROPERTY_0_FROM_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_1
+              .toLocalizedString(BUILD_JAVA_VERSION, RESOURCE_NAME));
+    }
+    return Optional.empty();
+  }
+}
+
diff --git a/geode-core/src/test/java/org/apache/geode/internal/GemFireVersionJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/GemFireVersionJUnitTest.java
index b7bbdf8..c353bef 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/GemFireVersionJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/GemFireVersionJUnitTest.java
@@ -14,8 +14,8 @@
  */
 package org.apache.geode.internal;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -23,7 +23,6 @@ import java.io.StringWriter;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.internal.GemFireVersion.VersionDescription;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.test.junit.categories.UnitTest;
 
@@ -39,15 +38,15 @@ public class GemFireVersionJUnitTest {
     final String versionOutput = GemFireVersion.asString();
     System.out.println(versionOutput);
 
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.PRODUCT_NAME));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.GEMFIRE_VERSION));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_DATE));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_REVISION));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.SOURCE_REPOSITORY));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_DATE));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_ID));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_PLATFORM));
-    assertTrue(versionOutput.contains(GemFireVersion.VersionDescription.BUILD_JAVA_VERSION));
+    assertTrue(versionOutput.contains(VersionDescription.PRODUCT_NAME));
+    assertTrue(versionOutput.contains(VersionDescription.PRODUCT_VERSION));
+    assertTrue(versionOutput.contains(VersionDescription.SOURCE_DATE));
+    assertTrue(versionOutput.contains(VersionDescription.SOURCE_REVISION));
+    assertTrue(versionOutput.contains(VersionDescription.SOURCE_REPOSITORY));
+    assertTrue(versionOutput.contains(VersionDescription.BUILD_DATE));
+    assertTrue(versionOutput.contains(VersionDescription.BUILD_ID));
+    assertTrue(versionOutput.contains(VersionDescription.BUILD_PLATFORM));
+    assertTrue(versionOutput.contains(VersionDescription.BUILD_JAVA_VERSION));
   }
 
   @Test
@@ -73,6 +72,6 @@ public class GemFireVersionJUnitTest {
     String err =
         LocalizedStrings.GemFireVersion_COULD_NOT_FIND_RESOURCE_COM_GEMSTONE_GEMFIRE_INTERNAL_0
             .toLocalizedString(noFile);
-    assertEquals(err, noVersion.getProperty(VersionDescription.GEMFIRE_VERSION));
+    assertEquals(err, noVersion.getProperty(VersionDescription.PRODUCT_VERSION));
   }
 }
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/VersionCommandJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/VersionCommandJUnitTest.java
new file mode 100644
index 0000000..6a23b1c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/VersionCommandJUnitTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.internal.VersionDescription.BUILD_DATE;
+import static org.apache.geode.internal.VersionDescription.BUILD_ID;
+import static org.apache.geode.internal.VersionDescription.BUILD_JAVA_VERSION;
+import static org.apache.geode.internal.VersionDescription.BUILD_PLATFORM;
+import static org.apache.geode.internal.VersionDescription.PRODUCT_NAME;
+import static org.apache.geode.internal.VersionDescription.PRODUCT_VERSION;
+import static org.apache.geode.internal.VersionDescription.SOURCE_DATE;
+import static org.apache.geode.internal.VersionDescription.SOURCE_REPOSITORY;
+import static org.apache.geode.internal.VersionDescription.SOURCE_REVISION;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.junit.rules.LocatorStarterRule;
+
+@Category(IntegrationTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class VersionCommandJUnitTest {
+  private static final String[] EXPECTED_FULL_DATA =
+      {BUILD_DATE, BUILD_ID, BUILD_JAVA_VERSION, BUILD_PLATFORM, PRODUCT_NAME, PRODUCT_VERSION,
+          SOURCE_DATE, SOURCE_REPOSITORY, SOURCE_REVISION, "Native version", "Running on"};
+
+  @ClassRule
+  public static LocatorStarterRule locator = new LocatorStarterRule().withAutoStart();
+
+  @Rule
+  public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+
+  @Test
+  @Parameters({"version", "version --full=false"})
+  public void versionShort(String versionCommand) throws Exception {
+    String result = gfsh.execute(versionCommand);
+    assertThat(result).contains(GemFireVersion.getGemFireVersion());
+  }
+
+  @Test
+  @Parameters({"version", "version --full=false"})
+  public void versionShortConnected(String versionCommand) throws Exception {
+    gfsh.connectAndVerify(locator);
+    // Behavior should be the same while connected
+    versionShort(versionCommand);
+  }
+
+  @Test
+  @Parameters({"version --full", "version --full=true"})
+  public void versionFull(String versionCommand) throws Exception {
+    String result = gfsh.execute(versionCommand);
+    for (String datum : EXPECTED_FULL_DATA)
+      assertThat(result).contains(datum);
+  }
+
+  @Test
+  @Parameters({"version --full", "version --full=true"})
+  public void versionFullConnected(String versionCommand) throws Exception {
+    gfsh.connectAndVerify(locator);
+    // Behavior should be the same while connected
+    versionFull(versionCommand);
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].