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

[2/5] geode git commit: GEODE-2966: RefactorLauncherLifecycleCommands

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandJUnitTest.java
new file mode 100644
index 0000000..8ee27a6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandJUnitTest.java
@@ -0,0 +1,397 @@
+/*
+ * 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.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 org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionService;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.lang.StringUtils;
+import org.apache.geode.internal.util.CollectionUtils;
+import org.apache.geode.management.cli.CliMetaData;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.apache.geode.management.internal.cli.util.MemberNotFoundException;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.concurrent.Synchroniser;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * The GfshCommandJUnitTest class is a test suite of test cases testing the contract and
+ * functionality of the GfshCommand class for implementing GemFire shell (Gfsh) commands.
+ *
+ * @see GfshCommand
+ * @see org.jmock.Expectations
+ * @see org.jmock.Mockery
+ * @see org.jmock.lib.legacy.ClassImposteriser
+ * @see org.junit.Assert
+ * @see org.junit.Test
+ * @since GemFire 7.0
+ */
+@Category(UnitTest.class)
+public class GfshCommandJUnitTest {
+
+  private Mockery mockContext;
+
+  private static class DefaultGfshCommmand implements GfshCommand {
+  }
+
+  private DefaultGfshCommmand defaultGfshCommmand;
+
+  @Before
+  public void setup() {
+    mockContext = new Mockery();
+    mockContext.setImposteriser(ClassImposteriser.INSTANCE);
+    mockContext.setThreadingPolicy(new Synchroniser());
+
+    defaultGfshCommmand = new DefaultGfshCommmand();
+  }
+
+  @After
+  public void tearDown() {
+    mockContext.assertIsSatisfied();
+    mockContext = null;
+  }
+
+  private GfshCommand createAbstractCommandsSupport(final InternalCache cache) {
+    return new TestCommands(cache);
+  }
+
+  private DistributedMember createMockMember(final String memberId, final String memberName) {
+    final DistributedMember mockMember =
+        mockContext.mock(DistributedMember.class, "DistributedMember " + memberId);
+
+    mockContext.checking(new Expectations() {
+      {
+        allowing(mockMember).getName();
+        will(returnValue(memberName));
+        allowing(mockMember).getId();
+        will(returnValue(memberId));
+      }
+    });
+
+    return mockMember;
+  }
+
+  @Test
+  public void testConvertDefaultValue() {
+    assertNull(defaultGfshCommmand.convertDefaultValue(null, StringUtils.EMPTY));
+    assertEquals(StringUtils.EMPTY,
+        defaultGfshCommmand.convertDefaultValue(StringUtils.EMPTY, "test"));
+    assertEquals(StringUtils.SPACE,
+        defaultGfshCommmand.convertDefaultValue(StringUtils.SPACE, "testing"));
+    assertEquals("tested",
+        defaultGfshCommmand.convertDefaultValue(CliMetaData.ANNOTATION_DEFAULT_VALUE, "tested"));
+  }
+
+  @Test
+  public void testGetMemberWithMatchingMemberId() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+    final DistributedMember mockMemberOne = createMockMember("1", "One");
+    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    assertSame(mockMemberTwo, commands.getMember(mockCache, "2"));
+  }
+
+  @Test
+  public void testGetMemberWithMatchingMemberName() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+    final DistributedMember mockMemberOne = createMockMember("1", "One");
+    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    assertSame(mockMemberOne, commands.getMember(mockCache, "One"));
+  }
+
+  @Test
+  public void testGetMemberWithMatchingMemberNameCaseInsensitive() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+    final DistributedMember mockMemberOne = createMockMember("1", "One");
+    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    assertSame(mockMemberSelf, commands.getMember(mockCache, "self"));
+  }
+
+  @Test(expected = MemberNotFoundException.class)
+  public void testGetMemberThrowsMemberNotFoundException() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+    final DistributedMember mockMemberOne = createMockMember("1", "One");
+    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    try {
+      commands.getMember(mockCache, "zero");
+    } catch (MemberNotFoundException expected) {
+      assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, "zero"),
+          expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testGetMembers() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+    final DistributedMember mockMemberOne = createMockMember("1", "One");
+    final DistributedMember mockMemberTwo = createMockMember("2", "Two");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(CollectionUtils.asSet(mockMemberOne, mockMemberTwo)));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    final Set<DistributedMember> expectedMembers =
+        CollectionUtils.asSet(mockMemberOne, mockMemberTwo, mockMemberSelf);
+    final Set<DistributedMember> actualMembers = commands.getMembers(mockCache);
+
+    assertNotNull(actualMembers);
+    assertEquals(expectedMembers.size(), actualMembers.size());
+    assertTrue(actualMembers.containsAll(expectedMembers));
+  }
+
+  @Test
+  public void testGetMembersContainsOnlySelf() {
+    final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
+
+    final DistributedSystem mockDistributedSystem =
+        mockContext.mock(DistributedSystem.class, "DistributedSystem");
+    final DistributedMember mockMemberSelf = createMockMember("S", "Self");
+
+    mockContext.checking(new Expectations() {
+      {
+        oneOf(mockCache).getMembers();
+        will(returnValue(Collections.emptySet()));
+        oneOf(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        oneOf(mockDistributedSystem).getDistributedMember();
+        will(returnValue(mockMemberSelf));
+      }
+    });
+
+    final GfshCommand commands = createAbstractCommandsSupport(mockCache);
+
+    final Set<DistributedMember> expectedMembers = CollectionUtils.asSet(mockMemberSelf);
+    final Set<DistributedMember> actualMembers = commands.getMembers(mockCache);
+
+    assertNotNull(actualMembers);
+    assertEquals(expectedMembers.size(), actualMembers.size());
+    assertTrue(actualMembers.containsAll(expectedMembers));
+  }
+
+  @Test
+  public void testRegister() {
+    try {
+      final Function mockFunction = mockContext.mock(Function.class, "Function");
+
+      mockContext.checking(new Expectations() {
+        {
+          exactly(3).of(mockFunction).getId();
+          will(returnValue("testRegister"));
+          oneOf(mockFunction).isHA();
+          will(returnValue(true));
+          oneOf(mockFunction).hasResult();
+          will(returnValue(true));
+        }
+      });
+
+      final GfshCommand commands =
+          createAbstractCommandsSupport(mockContext.mock(InternalCache.class));
+
+      assertFalse(FunctionService.isRegistered("testRegister"));
+      assertSame(mockFunction, commands.register(mockFunction));
+      assertTrue(FunctionService.isRegistered("testRegister"));
+    } finally {
+      FunctionService.unregisterFunction("testRegister");
+    }
+  }
+
+  @Test
+  public void testRegisteredAlready() {
+    try {
+      final Function registeredFunction = mockContext.mock(Function.class, "Registered Function");
+      final Function unregisteredFunction =
+          mockContext.mock(Function.class, "Unregistered Function");
+
+      mockContext.checking(new Expectations() {
+        {
+          exactly(2).of(registeredFunction).getId();
+          will(returnValue("testRegisteredAlready"));
+          oneOf(registeredFunction).isHA();
+          will(returnValue(false));
+          exactly(2).of(unregisteredFunction).getId();
+          will(returnValue("testRegisteredAlready"));
+        }
+      });
+
+      final GfshCommand commands =
+          createAbstractCommandsSupport(mockContext.mock(InternalCache.class));
+
+      FunctionService.registerFunction(registeredFunction);
+
+      assertTrue(FunctionService.isRegistered("testRegisteredAlready"));
+      assertSame(registeredFunction, commands.register(unregisteredFunction));
+      assertTrue(FunctionService.isRegistered("testRegisteredAlready"));
+    } finally {
+      FunctionService.unregisterFunction("testRegisteredAlready");
+    }
+  }
+
+  @Test
+  public void testToStringOnBoolean() {
+    assertEquals("false", defaultGfshCommmand.toString(null, null, null));
+    assertEquals("true", defaultGfshCommmand.toString(true, null, null));
+    assertEquals("true", defaultGfshCommmand.toString(Boolean.TRUE, null, null));
+    assertEquals("false", defaultGfshCommmand.toString(false, null, null));
+    assertEquals("false", defaultGfshCommmand.toString(Boolean.FALSE, null, null));
+    assertEquals("false", defaultGfshCommmand.toString(true, "false", "true"));
+    assertEquals("true", defaultGfshCommmand.toString(false, "false", "true"));
+    assertEquals("Yes", defaultGfshCommmand.toString(true, "Yes", "No"));
+    assertEquals("Yes", defaultGfshCommmand.toString(false, "No", "Yes"));
+    assertEquals("TRUE", defaultGfshCommmand.toString(Boolean.TRUE, "TRUE", "FALSE"));
+    assertEquals("FALSE", defaultGfshCommmand.toString(Boolean.FALSE, "TRUE", "FALSE"));
+  }
+
+  @Test
+  public void testToStringOnThrowable() {
+    assertEquals("test", defaultGfshCommmand.toString(new Throwable("test"), false));
+  }
+
+  @Test
+  public void testToStringOnThrowablePrintingStackTrace() {
+    final StringWriter writer = new StringWriter();
+    final Throwable t = new Throwable("test");
+
+    t.printStackTrace(new PrintWriter(writer));
+
+    assertEquals(writer.toString(), defaultGfshCommmand.toString(t, true));
+  }
+
+  private static class TestCommands implements GfshCommand {
+
+    private final InternalCache cache;
+
+    protected TestCommands(final InternalCache cache) {
+      assert cache != null : "The InternalCache cannot be null!";
+      this.cache = cache;
+    }
+
+    @Override
+    public InternalCache getCache() {
+      return this.cache;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsJUnitTest.java
index e3a644d..0d1f340 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsJUnitTest.java
@@ -203,18 +203,18 @@ public class IndexCommandsJUnitTest {
     }
 
     @Override
-    protected InternalCache getCache() {
+    public InternalCache getCache() {
       return this.cache;
     }
 
     @Override
-    protected Set<DistributedMember> getMembers(final InternalCache cache) {
+    public Set<DistributedMember> getMembers(final InternalCache cache) {
       assertSame(getCache(), cache);
       return Collections.emptySet();
     }
 
     @Override
-    protected Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
+    public Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
       Assert.assertNotNull(members);
       return functionExecutor;
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommandTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommandTest.java
new file mode 100644
index 0000000..32dc93c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/StartJConsoleCommandTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.lifecycle;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class StartJConsoleCommandTest {
+  @Test
+  public void testCreateJmxServerUrlWithMemberName() {
+    assertEquals("service:jmx:rmi://localhost:8192/jndi/rmi://localhost:8192/jmxrmi",
+        new StartJConsoleCommand().getJmxServiceUrlAsString("localhost[8192]"));
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testCreateJmxServiceUrlWithInvalidMemberName() {
+    try {
+      System.err.println(new StartJConsoleCommand().getJmxServiceUrlAsString("memberOne[]"));
+    } catch (IllegalArgumentException expected) {
+      assertEquals(CliStrings.START_JCONSOLE__CONNECT_BY_MEMBER_NAME_ID_ERROR_MESSAGE,
+          expected.getMessage());
+      throw expected;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/HostUtilsTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/HostUtilsTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/HostUtilsTest.java
new file mode 100644
index 0000000..55d6d54
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/HostUtilsTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.geode.cache.server.CacheServer;
+import org.apache.geode.internal.DistributionLocator;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class HostUtilsTest {
+
+  @Test
+  public void testGetLocatorId() {
+    assertEquals("machine[11235]", HostUtils.getLocatorId("machine", 11235));
+    assertEquals("machine.domain.org[11235]", HostUtils.getLocatorId("machine.domain.org", 11235));
+    assertEquals("machine[" + DistributionLocator.DEFAULT_LOCATOR_PORT + "]",
+        HostUtils.getLocatorId("machine", null));
+  }
+
+  @Test
+  public void testGetServerId() {
+    assertEquals("machine[12480]", HostUtils.getServerId("machine", 12480));
+    assertEquals("machine.domain.org[12480]", HostUtils.getServerId("machine.domain.org", 12480));
+    assertEquals("machine[" + CacheServer.DEFAULT_PORT + "]",
+        HostUtils.getServerId("machine", null));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/JdkToolTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/JdkToolTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/JdkToolTest.java
new file mode 100644
index 0000000..9d0c7fc
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/JdkToolTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.geode.GemFireException;
+import org.apache.geode.internal.util.IOUtils;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.Stack;
+
+@Category(UnitTest.class)
+public class JdkToolTest {
+
+  @Test
+  public void testGetJavaPathname() {
+    assertEquals(
+        IOUtils.appendToPath(System.getProperty("java.home"), "bin",
+            "java" + JdkTool.getExecutableSuffix()),
+        JdkTool.getJdkToolPathname("java" + JdkTool.getExecutableSuffix(),
+            new GemFireException() {}));
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testGetJdkToolPathnameWithNullPathnames() {
+    try {
+      JdkTool.getJdkToolPathname((Stack<String>) null, new GemFireException() {});
+    } catch (NullPointerException expected) {
+      assertEquals("The JDK tool executable pathnames cannot be null!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testGetJdkToolPathnameWithNullGemFireException() {
+    try {
+      JdkTool.getJdkToolPathname(new Stack<String>(), null);
+    } catch (NullPointerException expected) {
+      assertEquals("The GemFireException cannot be null!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testGetJdkToolPathnameForNonExistingTool() {
+    try {
+      final GemFireException expected = new GemFireException() {
+        @Override
+        public String getMessage() {
+          return "expected";
+        }
+      };
+
+      JdkTool.getJdkToolPathname("nonExistingTool.exe", expected);
+    } catch (GemFireException expected) {
+      assertEquals("expected", expected.getMessage());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
index 2fa9356..da0dfa2 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java
@@ -36,7 +36,7 @@ import org.apache.geode.management.cli.ConverterHint;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.CliUtil;
 import org.apache.geode.management.internal.cli.LogWrapper;
-import org.apache.geode.management.internal.cli.commands.AbstractCommandsSupport;
+import org.apache.geode.management.internal.cli.commands.GfshCommand;
 import org.apache.geode.management.internal.cli.functions.CliFunctionResult;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.CommandResult;
@@ -64,12 +64,12 @@ import java.util.stream.Collectors;
  * The LuceneIndexCommands class encapsulates all Geode shell (Gfsh) commands related to Lucene
  * indexes defined in Geode.
  *
- * @see AbstractCommandsSupport
+ * @see GfshCommand
  * @see LuceneIndexDetails
  * @see LuceneListIndexFunction
  */
 @SuppressWarnings("unused")
-public class LuceneIndexCommands extends AbstractCommandsSupport {
+public class LuceneIndexCommands implements GfshCommand {
   private static final LuceneCreateIndexFunction createIndexFunction =
       new LuceneCreateIndexFunction();
   private static final LuceneDescribeIndexFunction describeIndexFunction =

http://git-wip-us.apache.org/repos/asf/geode/blob/9046c8dc/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
index 66e15bb..8deac25 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsJUnitTest.java
@@ -643,18 +643,18 @@ public class LuceneIndexCommandsJUnitTest {
     }
 
     @Override
-    protected InternalCache getCache() {
+    public InternalCache getCache() {
       return this.cache;
     }
 
     @Override
-    protected Set<DistributedMember> getMembers(final InternalCache cache) {
+    public Set<DistributedMember> getMembers(final InternalCache cache) {
       assertSame(getCache(), cache);
       return Collections.emptySet();
     }
 
     @Override
-    protected Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
+    public Execution getMembersFunctionExecutor(final Set<DistributedMember> members) {
       Assert.assertNotNull(members);
       return functionExecutor;
     }