geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [4/9] incubator-geode git commit: GEODE-563: Moving gfsh tests from closed
Date Tue, 08 Dec 2015 17:24:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eddef322/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
new file mode 100644
index 0000000..1e234c5
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest.java
@@ -0,0 +1,371 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.cli.commands;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheLoader;
+import com.gemstone.gemfire.cache.CacheLoaderException;
+import com.gemstone.gemfire.cache.LoaderHelper;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.management.DistributedRegionMXBean;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.management.ManagerMXBean;
+import com.gemstone.gemfire.management.cli.Result;
+import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
+import com.gemstone.gemfire.management.internal.cli.result.CompositeResultData;
+import com.gemstone.gemfire.management.internal.cli.result.ResultData;
+import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+import dunit.DistributedTestCase;
+import dunit.Host;
+import dunit.SerializableRunnable;
+import dunit.VM;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest class is test suite of test cases testing the Gfsh
+ * 'get' data command when a cache miss occurs on data in a Region with a CacheLoader defined.
+ * <p>
+ *
+ * @author John Blum
+ * @see com.gemstone.gemfire.management.internal.cli.commands.CliCommandTestBase
+ * @see com.gemstone.gemfire.management.internal.cli.commands.DataCommands
+ * @since 8.0
+ */
+@SuppressWarnings("unused")
+public class GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest extends CliCommandTestBase {
+
+  private static final String GEMFIRE_MANAGER_NAME = "GemManagerNode";
+  private static final String GEMFIRE_SERVER_NAME = "GemServerDataNode";
+  private static final String GEMFIRE_LOG_LEVEL = System.getProperty("logLevel", "config");
+  private static final String USERS_REGION_NAME = "Users";
+
+  protected static String getRegionPath(final String regionName) {
+    return (regionName.startsWith(Region.SEPARATOR) ? regionName : String.format("%1$s%2$s", Region.SEPARATOR,
+        regionName));
+  }
+
+  protected static String toString(final Result result) {
+    assert result != null : "The Result object from the command execution was null!";
+
+    StringBuilder buffer = new StringBuilder(System.getProperty("line.separator"));
+
+    while (result.hasNextLine()) {
+      buffer.append(result.nextLine());
+      buffer.append(System.getProperty("line.separator"));
+    }
+
+    return buffer.toString();
+  }
+
+  public GetCommandOnRegionWithCacheLoaderDuringCacheMissDUnitTest(final String testName) {
+    super(testName);
+  }
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+
+    Properties managerDistributedSystemProperties = createDistributedSystemProperties(GEMFIRE_MANAGER_NAME);
+    HeadlessGfsh gfsh = createDefaultSetup(managerDistributedSystemProperties);
+
+    assertNotNull(gfsh);
+    assertTrue(gfsh.isConnectedAndReady());
+
+    setupGemFire();
+    verifyGemFireSetup(createPeer(Host.getHost(0).getVM(0), managerDistributedSystemProperties));
+  }
+
+  private void setupGemFire() {
+    initializePeer(createPeer(Host.getHost(0).getVM(1), createDistributedSystemProperties(GEMFIRE_SERVER_NAME)));
+  }
+
+  protected Properties createDistributedSystemProperties(final String gemfireName) {
+    Properties distributedSystemProperties = new Properties();
+
+    distributedSystemProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME, GEMFIRE_LOG_LEVEL);
+    distributedSystemProperties.setProperty(DistributionConfig.NAME_NAME, gemfireName);
+
+    return distributedSystemProperties;
+  }
+
+  protected Peer createPeer(final VM vm, final Properties distributedSystemProperties) {
+    return new Peer(vm, distributedSystemProperties);
+  }
+
+  protected void initializePeer(final Peer peer) {
+    peer.run(new SerializableRunnable(
+        String.format("Initializes the '%1$s' with the '%2$s' Region having a CacheLoader.", GEMFIRE_SERVER_NAME,
+            USERS_REGION_NAME)) {
+      @Override
+      public void run() {
+        // create the GemFire Distributed System with custom distribution configuration properties and settings
+        getSystem(peer.getConfiguration());
+
+        Cache cache = getCache();
+        RegionFactory<String, User> regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
+
+        regionFactory.setCacheLoader(new UserDataStoreCacheLoader());
+        regionFactory.setInitialCapacity(51);
+        regionFactory.setKeyConstraint(String.class);
+        regionFactory.setLoadFactor(0.75f);
+        regionFactory.setStatisticsEnabled(false);
+        regionFactory.setValueConstraint(User.class);
+
+        Region<String, User> users = regionFactory.create(USERS_REGION_NAME);
+
+        assertNotNull(users);
+        assertEquals("Users", users.getName());
+        assertEquals("/Users", users.getFullPath());
+        assertTrue(users.isEmpty());
+        assertNull(users.put("jonbloom", new User("jonbloom")));
+        assertFalse(users.isEmpty());
+        assertEquals(1, users.size());
+        assertEquals(new User("jonbloom"), users.get("jonbloom"));
+      }
+    });
+  }
+
+  private void verifyGemFireSetup(final Peer manager) {
+    manager.run(new SerializableRunnable("Verifies the GemFire Cluster was properly configured and initialized!") {
+      @Override
+      public void run() {
+        final ManagementService managementService = ManagementService.getExistingManagementService(getCache());
+
+        WaitCriterion waitOnManagerCriterion = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            ManagerMXBean managerBean = managementService.getManagerMXBean();
+            DistributedRegionMXBean usersRegionBean = managementService.getDistributedRegionMXBean(
+                getRegionPath(USERS_REGION_NAME));
+
+            return !(managerBean == null || usersRegionBean == null);
+          }
+
+          @Override
+          public String description() {
+            return String.format("Probing for the GemFire Manager '%1$s' and '%2$s' Region MXBeans...",
+                manager.getName(), USERS_REGION_NAME);
+          }
+        };
+
+        DistributedTestCase.waitForCriterion(waitOnManagerCriterion, 30000, 2000, true);
+      }
+    });
+  }
+
+  protected void doHousekeeping() {
+    runCommand(CliStrings.LIST_MEMBER);
+
+    runCommand(new CommandStringBuilder(CliStrings.DESCRIBE_MEMBER).addOption(CliStrings.DESCRIBE_MEMBER__IDENTIFIER,
+        GEMFIRE_SERVER_NAME).toString());
+
+    runCommand(CliStrings.LIST_REGION);
+
+    runCommand(new CommandStringBuilder(CliStrings.DESCRIBE_REGION).addOption(CliStrings.DESCRIBE_REGION__NAME,
+        USERS_REGION_NAME).toString());
+  }
+
+  protected void log(final Result result) {
+    log("Result", toString(result));
+  }
+
+  protected void log(final String tag, final String message) {
+    //System.out.printf("%1$s (%2$s)%n", tag, message);
+    getLogWriter().info(String.format("%1$s (%2$s)%n", tag, message));
+  }
+
+  protected CommandResult runCommand(final String command) {
+    CommandResult result = executeCommand(command);
+
+    assertNotNull(result);
+    assertEquals(Result.Status.OK, result.getStatus());
+
+    log(result);
+
+    return result;
+  }
+
+  protected void assertResult(final boolean expectedResult, final CommandResult commandResult) {
+    if (ResultData.TYPE_COMPOSITE.equals(commandResult.getType())) {
+      boolean actualResult = (Boolean) ((CompositeResultData) commandResult.getResultData()).retrieveSectionByIndex(
+          0).retrieveObject("Result");
+      assertEquals(expectedResult, actualResult);
+    } else {
+      fail(String.format("Expected composite result data; but was '%1$s'!%n", commandResult.getType()));
+    }
+  }
+
+  public void testGetOnCacheMiss() {
+    doHousekeeping();
+
+    CommandStringBuilder command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
+    command.addOption(CliStrings.GET__KEY, "jonbloom");
+
+    assertResult(true, runCommand(command.toString()));
+
+    command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
+    command.addOption(CliStrings.GET__KEY, "jondoe");
+    command.addOption(CliStrings.GET__LOAD, "false");
+
+    assertResult(false, runCommand(command.toString()));
+
+    command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
+    command.addOption(CliStrings.GET__KEY, "jondoe");
+    command.addOption(CliStrings.GET__LOAD, "true");
+
+    assertResult(true, runCommand(command.toString()));
+
+    // NOTE test the unspecified default value for the --load-on-cache-miss
+    command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
+    command.addOption(CliStrings.GET__KEY, "janedoe");
+
+    assertResult(true, runCommand(command.toString()));
+
+    // NOTE now test an absolute cache miss both for in the Region as well as the CacheLoader
+    command = new CommandStringBuilder(CliStrings.GET);
+    command.addOption(CliStrings.GET__REGIONNAME, USERS_REGION_NAME);
+    command.addOption(CliStrings.GET__KEY, "nonexistinguser");
+    command.addOption(CliStrings.GET__LOAD, "true");
+
+    assertResult(false, runCommand(command.toString()));
+  }
+
+  protected static final class Peer implements Serializable {
+
+    private final Properties distributedSystemProperties;
+    private final VM vm;
+
+    public Peer(final VM vm, final Properties distributedSystemProperties) {
+      assert distributedSystemProperties != null : "The GemFire Distributed System configuration properties and settings cannot be null!";
+      this.vm = vm;
+      this.distributedSystemProperties = distributedSystemProperties;
+    }
+
+    public Properties getConfiguration() {
+      return this.distributedSystemProperties;
+    }
+
+    public String getName() {
+      return getConfiguration().getProperty(DistributionConfig.NAME_NAME);
+    }
+
+    public VM getVm() {
+      return vm;
+    }
+
+    public void run(final Runnable runnable) {
+      if (getVm() == null) {
+        runnable.run();
+      } else {
+        getVm().invoke(runnable);
+      }
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+
+      buffer.append(" {configuration = ").append(getConfiguration());
+      buffer.append(", name = ").append(getName());
+      buffer.append(", pid = ").append(getVm().getPid());
+      buffer.append("}");
+
+      return buffer.toString();
+    }
+  }
+
+  protected static class User implements Serializable {
+
+    private final String username;
+
+    public User(final String username) {
+      assert username != null : "The username cannot be null!";
+      this.username = username;
+    }
+
+    public String getUsername() {
+      return username;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+      if (obj == this) {
+        return true;
+      }
+
+      if (!(obj instanceof User)) {
+        return false;
+      }
+
+      User that = (User) obj;
+
+      return this.getUsername().equals(that.getUsername());
+    }
+
+    @Override
+    public int hashCode() {
+      int hashValue = 17;
+      hashValue = 37 * hashValue + getUsername().hashCode();
+      return hashValue;
+    }
+
+    @Override
+    public String toString() {
+      return getUsername();
+    }
+  }
+
+  protected static class UserDataStoreCacheLoader implements CacheLoader<String, User>, Serializable {
+
+    private static final Map<String, User> userDataStore = new HashMap<String, User>(5);
+
+    static {
+      userDataStore.put("jackhandy", createUser("jackhandy"));
+      userDataStore.put("janedoe", createUser("janedoe"));
+      userDataStore.put("jondoe", createUser("jondoe"));
+      userDataStore.put("piedoe", createUser("piedoe"));
+      userDataStore.put("supertool", createUser("supertool"));
+    }
+
+    protected static User createUser(final String username) {
+      return new User(username);
+    }
+
+    @Override
+    public User load(final LoaderHelper<String, User> helper) throws CacheLoaderException {
+      return userDataStore.get(helper.getKey());
+    }
+
+    @Override
+    public void close() {
+      userDataStore.clear();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eddef322/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/IndexCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/IndexCommandsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/IndexCommandsDUnitTest.java
new file mode 100644
index 0000000..bb99dc2
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/IndexCommandsDUnitTest.java
@@ -0,0 +1,817 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.cli.commands;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.DiskStoreFactory;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.query.Index;
+import com.gemstone.gemfire.distributed.Locator;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.management.cli.Result;
+import com.gemstone.gemfire.management.cli.Result.Status;
+import com.gemstone.gemfire.management.internal.cli.domain.Stock;
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
+import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+import dunit.DistributedTestCase;
+import dunit.Host;
+import dunit.SerializableCallable;
+import dunit.SerializableRunnable;
+import dunit.VM;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+public class IndexCommandsDUnitTest extends CliCommandTestBase {
+
+  private static final long serialVersionUID = 1L;
+  private static final String VM1Name = "VM1";
+  private static final String group1 = "G1";
+  private static final String indexName = "Id1";
+  private static final String parRegPersName = "ParRegPers";
+  private static final String repRegPersName = "RepRegPer";
+
+  public IndexCommandsDUnitTest(String name) {
+    super(name);
+    // TODO Auto-generated constructor stub
+  }
+
+  Region<?, ?> createParReg(String regionName, Cache cache, Class keyConstraint, Class valueConstraint) {
+    RegionFactory regionFactory = cache.createRegionFactory();
+    regionFactory.setDataPolicy(DataPolicy.PARTITION);
+    regionFactory.setKeyConstraint(keyConstraint);
+    regionFactory.setValueConstraint(valueConstraint);
+    return regionFactory.create(regionName);
+  }
+
+  private Region<?, ?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
+    Cache cache = getCache();
+    File diskStoreDirFile = new File(diskDirName);
+    diskStoreDirFile.deleteOnExit();
+
+    if (!diskStoreDirFile.exists()) {
+      diskStoreDirFile.mkdirs();
+    }
+
+    DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
+    diskStoreFactory.setDiskDirs(new File[]{diskStoreDirFile});
+    diskStoreFactory.setMaxOplogSize(1);
+    diskStoreFactory.setAllowForceCompaction(true);
+    diskStoreFactory.setAutoCompact(false);
+    diskStoreFactory.create(diskStoreName);
+
+    /****
+     * Eviction Attributes
+     */
+    EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
+
+    RegionFactory regionFactory = cache.createRegionFactory();
+    regionFactory.setDiskStoreName(diskStoreName);
+    regionFactory.setDiskSynchronous(true);
+    regionFactory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
+    regionFactory.setEvictionAttributes(ea);
+
+    return regionFactory.create(regionName);
+  }
+
+  private Region<?, ?> createRepRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
+    Cache cache = getCache();
+    File diskStoreDirFile = new File(diskDirName);
+    diskStoreDirFile.deleteOnExit();
+
+    if (!diskStoreDirFile.exists()) {
+      diskStoreDirFile.mkdirs();
+    }
+
+    DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
+    diskStoreFactory.setDiskDirs(new File[]{diskStoreDirFile});
+    diskStoreFactory.setMaxOplogSize(1);
+    diskStoreFactory.setAllowForceCompaction(true);
+    diskStoreFactory.setAutoCompact(false);
+    diskStoreFactory.create(diskStoreName);
+
+    /****
+     * Eviction Attributes
+     */
+    EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
+
+    RegionFactory regionFactory = cache.createRegionFactory();
+    regionFactory.setDiskStoreName(diskStoreName);
+    regionFactory.setDiskSynchronous(true);
+    regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
+    regionFactory.setEvictionAttributes(ea);
+
+    return regionFactory.create(regionName);
+  }
+
+  public void testCreateKeyIndexOnRegionWithPersistence() {
+    setupSystemPersist();
+
+    //Creating key indexes on Persistent Partitioned Region
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, "id1");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "ty");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + parRegPersName);
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "key");
+    String commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("Command Result :\n", resultAsString);
+    assertTrue(Status.OK.equals(commandResult.getStatus()));
+    //Creating key indexes on Persistent Replicated Regions
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, "id2");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "ee");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + repRegPersName);
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "key");
+    commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command Result :\n", resultAsString);
+    assertTrue(Status.OK.equals(commandResult.getStatus()));
+  }
+
+  public void testCreateAndDestroyIndex() {
+    setupSystem();
+    /***
+     * Basic Create and Destroy 
+     */
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+
+    String commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("testCreateAndDestroyIndex", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(resultAsString.contains(indexName));
+
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
+    commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("testCreateAndDestroyIndex", resultAsString);
+    assertEquals(commandResult.getStatus(), Status.OK);
+
+    commandResult = executeCommand(CliStrings.LIST_INDEX);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(commandResult.getStatus(), Status.OK);
+    assertFalse(resultAsString.contains(indexName));
+  }
+
+  public void testCreateIndexMultipleIterators() {
+    setupSystem();
+
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "\"h.low\"");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "\"/StocksParReg s, s.history h\"");
+
+    String commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("testCreateIndexMultipleIterators", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("testCreateIndexMultipleIterators", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(resultAsString.contains(indexName));
+  }
+
+  public void testCreateMultipleIndexes() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+
+    String commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("testCreateMultipleIndexes", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName + "2");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+
+    csb = new CommandStringBuilder(CliStrings.CREATE_DEFINED_INDEXES);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(resultAsString.contains(indexName));
+  }
+
+  public void testClearMultipleIndexes() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+
+    String commandString = csb.toString();
+    writeToLog("Command String :\n ", commandString);
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("testClearMultipleIndexes", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName + "2");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+
+    csb = new CommandStringBuilder(CliStrings.CLEAR_DEFINED_INDEXES);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(!resultAsString.contains(indexName));
+  }
+
+  public void testCreateAndDestroyIndexOnMember() {
+    setupSystem();
+    /***
+     * Basic Create and Destroy 
+     */
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__MEMBER, VM1Name);
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "key");
+
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnMember", resultAsString);
+
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnMember", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(resultAsString.contains(indexName));
+    assertTrue(resultAsString.contains(VM1Name));
+
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.DESTROY_INDEX__MEMBER, VM1Name);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnMember", resultAsString);
+    assertEquals(commandResult.getStatus(), Status.OK);
+
+    commandResult = executeCommand(CliStrings.LIST_INDEX);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnMember", resultAsString);
+    assertEquals(commandResult.getStatus(), Status.OK);
+    assertFalse(resultAsString.contains(VM1Name));
+  }
+
+  public void testCreateAndDestroyIndexOnGroup() {
+    setupSystem();
+    /***
+     * Basic Create and Destroy 
+     */
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+    csb.addOption(CliStrings.CREATE_INDEX__GROUP, group1);
+
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertEquals(true, resultAsString.contains(indexName));
+    assertEquals(true, resultAsString.contains(VM1Name));
+
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group1);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
+    assertEquals(commandResult.getStatus(), Status.OK);
+
+    commandResult = executeCommand(CliStrings.LIST_INDEX);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(commandResult.getStatus(), Status.OK);
+    assertFalse(resultAsString.contains(VM1Name));
+
+    /***
+     * In case of a partitioned region , the index might get created on a 
+     * member which hosts the region and is not the member of the group1
+     */
+    if (resultAsString.contains(indexName)) {
+      csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+      csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+      csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
+      commandString = csb.toString();
+      commandResult = executeCommand(commandString);
+      resultAsString = commandResultToString(commandResult);
+      assertEquals(commandResult.getStatus(), Status.OK);
+
+      commandResult = executeCommand(CliStrings.LIST_INDEX);
+      resultAsString = commandResultToString(commandResult);
+      writeToLog("Command String :\n ", commandString);
+      writeToLog("testCreateAndDestroyIndexOnGroup", resultAsString);
+
+      assertEquals(commandResult.getStatus(), Status.OK);
+      assertFalse(resultAsString.contains(indexName));
+      assertTrue(resultAsString.contains(CliStrings.LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE));
+    }
+  }
+
+  public void testCreateAndDestroyIndexWithIncorrectInput() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+
+    assertEquals(commandResult.getStatus(), Status.OK);
+
+    //CREATE the same index 
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+    //assertTrue(resultAsString.contains(CliStrings.format(CliStrings.CREATE_INDEX__NAME__CONFLICT, indexName)));
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+
+
+    //Create index on a wrong regionPath
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocsParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+    //assertTrue(resultAsString.contains(CliStrings.format(CliStrings.CREATE_INDEX__INVALID__REGIONPATH, "/StocsParReg")));
+
+    //Create index with wrong expression 
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, "Id2");
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "rey");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+
+    //Create index with wrong type 
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "bash");
+
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(resultAsString.contains(CliStrings.CREATE_INDEX__INVALID__INDEX__TYPE__MESSAGE));
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+
+    //Destroy index with incorrect indexName 
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, "Id2");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+    assertTrue(resultAsString.contains(CliStrings.format(CliStrings.DESTROY_INDEX__INDEX__NOT__FOUND, "Id2")));
+
+    //Destroy index with incorrect region 
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "Region");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+    assertTrue(resultAsString.contains(CliStrings.format(CliStrings.DESTROY_INDEX__REGION__NOT__FOUND, "Region")));
+
+    //Destroy index with incorrect memberName
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "Region");
+    csb.addOption(CliStrings.DESTROY_INDEX__MEMBER, "wrongOne");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+
+    //Destroy index with no option
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    writeToLog("Command String :\n ", commandString);
+    writeToLog("testCreateAndDestroyIndexWithIncorrectInput", resultAsString);
+    assertTrue(commandResult.getStatus().equals(Status.ERROR));
+  }
+
+  public void testDestroyIndexWithoutIndexName() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String resultAsString = commandResultToString(commandResult);
+    assertEquals(commandResult.getStatus(), Status.OK);
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertEquals(true, resultAsString.contains(indexName));
+    assertEquals(true, resultAsString.contains(VM1Name));
+
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group1);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
+    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "StocksParReg");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+
+    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    resultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(resultAsString.contains(CliStrings.LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE));
+  }
+
+  /**
+   * Asserts that creating and destroying indexes correctly updates the shared configuration.
+   */
+  public void testCreateDestroyUpdatesSharedConfig() {
+    disconnectAllFromDS();
+
+    final String regionName = "testIndexSharedConfigRegion";
+    final String groupName = "testIndexSharedConfigGroup";
+
+    // Start the Locator and wait for shared configuration to be available
+    final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+
+        final File locatorLogFile = new File("locator-" + locatorPort + ".log");
+        final Properties locatorProps = new Properties();
+        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator");
+        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
+        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        try {
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locatorPort, locatorLogFile, null,
+              locatorProps);
+
+          DistributedTestCase.WaitCriterion wc = new DistributedTestCase.WaitCriterion() {
+            @Override
+            public boolean done() {
+              return locator.isSharedConfigurationRunning();
+            }
+
+            @Override
+            public String description() {
+              return "Waiting for shared configuration to be started";
+            }
+          };
+          DistributedTestCase.waitForCriterion(wc, 5000, 500, true);
+        } catch (IOException ioex) {
+          fail("Unable to create a locator with a shared configuration");
+        }
+      }
+    });
+
+    // Start the default manager
+    Properties managerProps = new Properties();
+    managerProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+    managerProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+    createDefaultSetup(managerProps);
+
+    // Create a cache in VM 1
+    VM vm = Host.getHost(0).getVM(1);
+    vm.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        Properties localProps = new Properties();
+        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+        getSystem(localProps);
+        assertNotNull(getCache());
+
+        Region parReg = createParReg(regionName, getCache(), String.class, Stock.class);
+        parReg.put("VMW", new Stock("VMW", 98));
+      }
+    });
+
+    // Test creating the index
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_INDEX);
+    commandStringBuilder.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
+    commandStringBuilder.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
+    commandStringBuilder.addOption(CliStrings.CREATE_INDEX__GROUP, groupName);
+    commandStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION, "\"/" + regionName + " p\"");
+    CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Make sure the index exists in the shared config
+    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+        String xmlFromConfig;
+        try {
+          xmlFromConfig = sharedConfig.getConfiguration(groupName).getCacheXmlContent();
+          assertTrue(xmlFromConfig.contains(indexName));
+        } catch (Exception e) {
+          fail("Error occurred in cluster configuration service", e);
+        }
+      }
+    });
+
+    //Restart a member and make sure he gets the shared configuration
+    vm = Host.getHost(0).getVM(1);
+    vm.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        getCache().close();
+
+        Properties localProps = new Properties();
+        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+        localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
+        getSystem(localProps);
+        Cache cache = getCache();
+        assertNotNull(cache);
+        Region region = cache.getRegion(regionName);
+        assertNotNull(region);
+        Index index = cache.getQueryService().getIndex(region, indexName);
+        assertNotNull(index);
+      }
+    });
+
+    // Test destroying the index
+    commandStringBuilder = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
+    commandStringBuilder.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
+    commandStringBuilder.addOption(CliStrings.DESTROY_INDEX__GROUP, groupName);
+    commandStringBuilder.addOption(CliStrings.DESTROY_INDEX__REGION, "/" + regionName);
+    cmdResult = executeCommand(commandStringBuilder.toString());
+    assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+    // Make sure the index was removed from the shared config
+    Host.getHost(0).getVM(3).invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        SharedConfiguration sharedConfig = ((InternalLocator) Locator.getLocator()).getSharedConfiguration();
+        String xmlFromConfig;
+        try {
+          xmlFromConfig = sharedConfig.getConfiguration(groupName).getCacheXmlContent();
+          assertFalse(xmlFromConfig.contains(indexName));
+        } catch (Exception e) {
+          fail("Error occurred in cluster configuration service", e);
+        }
+      }
+    });
+
+    //Restart the data member cache to make sure that the index is destroyed.
+    vm = Host.getHost(0).getVM(1);
+    vm.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        getCache().close();
+
+        Properties localProps = new Properties();
+        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locatorPort);
+        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
+        localProps.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
+        getSystem(localProps);
+        Cache cache = getCache();
+        assertNotNull(cache);
+        Region region = cache.getRegion(regionName);
+        assertNotNull(region);
+        Index index = cache.getQueryService().getIndex(region, indexName);
+        assertNull(index);
+      }
+    });
+  }
+
+  private void writeToLog(String text, String resultAsString) {
+    getLogWriter().info(testName + "\n");
+    getLogWriter().info(resultAsString);
+  }
+
+  private void setupSystem() {
+    disconnectAllFromDS();
+    createDefaultSetup(null);
+    final String parRegName = "StocksParReg";
+
+    final VM manager = Host.getHost(0).getVM(0);
+    final VM vm1 = Host.getHost(0).getVM(1);
+
+    manager.invoke(new SerializableCallable() {
+      public Object call() {
+        Region parReg = createParReg(parRegName, getCache(), String.class, Stock.class);
+        parReg.put("VMW", new Stock("VMW", 98));
+        return parReg.put("APPL", new Stock("APPL", 600));
+      }
+    });
+
+    vm1.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        Properties props = new Properties();
+        props.setProperty(DistributionConfig.NAME_NAME, VM1Name);
+        props.setProperty(DistributionConfig.GROUPS_NAME, group1);
+        getSystem(props);
+        Region parReg = createParReg(parRegName, getCache(), String.class, Stock.class);
+        parReg.put("MSFT", new Stock("MSFT", 27));
+        return parReg.put("GOOG", new Stock("GOOG", 540));
+      }
+    });
+  }
+
+  private void setupSystemPersist() {
+    disconnectAllFromDS();
+    createDefaultSetup(null);
+    final String parRegName = "StocksParReg";
+
+    final VM manager = Host.getHost(0).getVM(0);
+    final VM vm1 = Host.getHost(0).getVM(1);
+
+    manager.invoke(new SerializableCallable() {
+      public Object call() {
+        Region parReg = createParReg(parRegName, getCache(), String.class, Stock.class);
+        parReg.put("VMW", new Stock("VMW", 98));
+        Region parRegPers = createParRegWithPersistence(parRegPersName, "testCreateIndexDiskstore1",
+            "testCreateIndexDiskDir1");
+        Region repRegPers = createRepRegWithPersistence(repRegPersName, "testCreateIndexDiskstore1",
+            "testCreateIndexDiskDir1");
+        return parReg.put("APPL", new Stock("APPL", 600));
+      }
+    });
+
+    vm1.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        Properties props = new Properties();
+        props.setProperty(DistributionConfig.NAME_NAME, VM1Name);
+        props.setProperty(DistributionConfig.GROUPS_NAME, group1);
+        getSystem(props);
+        Region parReg = createParReg(parRegName, getCache(), String.class, Stock.class);
+        parReg.put("MSFT", new Stock("MSFT", 27));
+        Region parRegPers = createParRegWithPersistence(parRegPersName, "testCreateIndexDiskstore2",
+            "testCreateIndexDiskDir2");
+        Region repRegPers = createRepRegWithPersistence(repRegPersName, "testCreateIndexDiskstore2",
+            "testCreateIndexDiskDir2");
+        return parReg.put("GOOG", new Stock("GOOG", 540));
+      }
+    });
+  }
+
+  @Override
+  public void tearDown2() throws Exception {
+    super.tearDown2();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eddef322/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
new file mode 100644
index 0000000..e7bc575
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeDiskStoreCommandsDUnitTest.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.cli.commands;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.DiskStore;
+import com.gemstone.gemfire.cache.DiskStoreFactory;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.management.cli.Result;
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import dunit.Host;
+import dunit.SerializableRunnable;
+import dunit.VM;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * The ListAndDescribeDiskStoreCommandsDUnitTest class is a test suite of functional tests cases testing the proper
+ * functioning of the 'list disk-store' and 'describe disk-store' commands. </p>
+ *
+ * @author John Blum
+ * @see com.gemstone.gemfire.management.internal.cli.commands.CliCommandTestBase
+ * @see com.gemstone.gemfire.management.internal.cli.commands.DiskStoreCommands
+ * @since 7.0
+ */
+public class ListAndDescribeDiskStoreCommandsDUnitTest extends CliCommandTestBase {
+
+  protected static String toString(final Result result) {
+    assert result != null : "The Result object from the command execution cannot be null!";
+
+    final StringBuilder buffer = new StringBuilder(System.getProperty("line.separator"));
+
+    while (result.hasNextLine()) {
+      buffer.append(result.nextLine());
+      buffer.append(System.getProperty("line.separator"));
+    }
+
+    return buffer.toString().trim();
+  }
+
+  public ListAndDescribeDiskStoreCommandsDUnitTest(final String testName) {
+    super(testName);
+  }
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    createDefaultSetup(null);
+    setupGemFire();
+  }
+
+  @Override
+  public void tearDown2() throws Exception {
+    super.tearDown2();
+  }
+
+  protected Peer createPeer(final Properties distributedSystemConfiguration, final VM vm) {
+    return new Peer(distributedSystemConfiguration, vm);
+  }
+
+  protected void setupGemFire() throws Exception {
+    final Host host = Host.getHost(0);
+
+    final VM vm1 = host.getVM(1);
+    final VM vm2 = host.getVM(2);
+
+    final Peer peer1 = createPeer(createDistributedSystemProperties("consumerServer"), vm1);
+    final Peer peer2 = createPeer(createDistributedSystemProperties("producerServer"), vm2);
+
+    createPersistentRegion(peer1, "consumers", "consumerData");
+    createPersistentRegion(peer1, "observers", "observerData");
+    createPersistentRegion(peer2, "producer", "producerData");
+    createPersistentRegion(peer2, "producer-factory", "producerData");
+  }
+
+  protected Properties createDistributedSystemProperties(final String gemfireName) {
+    final Properties distributedSystemProperties = new Properties();
+
+    distributedSystemProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME, getDUnitLogLevel());
+    distributedSystemProperties.setProperty(DistributionConfig.NAME_NAME, gemfireName);
+
+    return distributedSystemProperties;
+  }
+
+  protected void createPersistentRegion(final Peer peer, final String regionName, final String diskStoreName) {
+    peer.run(new SerializableRunnable("Creating Persistent Region for Member " + peer.getName()) {
+      @Override
+      public void run() {
+        getSystem(peer.getDistributedSystemConfiguration());
+
+        final Cache cache = getCache();
+
+        DiskStore diskStore = cache.findDiskStore(diskStoreName);
+
+        if (diskStore == null) {
+          final DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
+          diskStoreFactory.setDiskDirs(getDiskDirs());
+          diskStore = diskStoreFactory.create(diskStoreName);
+        }
+
+        final RegionFactory regionFactory = cache.createRegionFactory();
+
+        regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
+        regionFactory.setDiskStoreName(diskStore.getName());
+        regionFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
+        regionFactory.create(regionName);
+      }
+    });
+  }
+
+  public void testListDiskStore() throws Exception {
+    final Result result = executeCommand(CliStrings.LIST_DISK_STORE);
+
+    assertNotNull(result);
+    getLogWriter().info(toString(result));
+    assertEquals(Result.Status.OK, result.getStatus());
+  }
+
+  public void testDescribeDiskStore() throws Exception {
+    final Result result = executeCommand(
+        CliStrings.DESCRIBE_DISK_STORE + " --member=producerServer --name=producerData");
+
+    assertNotNull(result);
+    getLogWriter().info(toString(result));
+    assertEquals(Result.Status.OK, result.getStatus());
+  }
+
+  public void testDescribeDiskStoreWithInvalidMemberName() throws Exception {
+    final Result commandResult = executeCommand(
+        CliStrings.DESCRIBE_DISK_STORE + " --member=badMemberName --name=producerData");
+
+    assertNotNull(commandResult);
+    assertEquals(Result.Status.ERROR, commandResult.getStatus());
+    assertEquals(CliStrings.format(CliStrings.MEMBER_NOT_FOUND_ERROR_MESSAGE, "badMemberName"),
+        toString(commandResult));
+  }
+
+  public void testDescribeDiskStoreWithInvalidDiskStoreName() {
+    final Result commandResult = executeCommand(
+        CliStrings.DESCRIBE_DISK_STORE + " --member=producerServer --name=badDiskStoreName");
+
+    assertNotNull(commandResult);
+    assertEquals(Result.Status.ERROR, commandResult.getStatus());
+    assertEquals("A disk store with name (badDiskStoreName) was not found on member (producerServer).",
+        toString(commandResult));
+  }
+
+  protected static class Peer implements Serializable {
+
+    private final Properties distributedSystemConfiguration;
+    private final VM vm;
+
+    protected Peer(final Properties distributedSystemConfiguration, final VM vm) {
+      assert distributedSystemConfiguration != null : "The GemFire distributed system configuration properties cannot be null!";
+      this.distributedSystemConfiguration = distributedSystemConfiguration;
+      this.vm = vm;
+    }
+
+    public Properties getDistributedSystemConfiguration() {
+      return distributedSystemConfiguration;
+    }
+
+    public String getName() {
+      return getDistributedSystemConfiguration().getProperty(DistributionConfig.NAME_NAME);
+    }
+
+    public VM getVm() {
+      return vm;
+    }
+
+    public void run(final Runnable runnable) {
+      if (getVm() == null) {
+        runnable.run();
+      } else {
+        getVm().invoke(runnable);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eddef322/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
new file mode 100644
index 0000000..5c172cc
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.management.internal.cli.commands;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.FixedPartitionAttributes;
+import com.gemstone.gemfire.cache.PartitionAttributes;
+import com.gemstone.gemfire.cache.PartitionAttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
+import com.gemstone.gemfire.compression.SnappyCompressor;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.cache.RegionEntryContext;
+import com.gemstone.gemfire.management.cli.Result.Status;
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
+import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+import com.gemstone.gemfire.management.internal.cli.util.RegionAttributesNames;
+import dunit.Host;
+import dunit.SerializableRunnable;
+import dunit.VM;
+
+import java.util.Properties;
+
+public class ListAndDescribeRegionDUnitTest extends CliCommandTestBase {
+
+  public ListAndDescribeRegionDUnitTest(String name) {
+    super(name);
+    // TODO Auto-generated constructor stub
+  }
+
+  private static final String REGION1 = "region1";
+  private static final String REGION2 = "region2";
+  private static final String REGION3 = "region3";
+  private static final String SUBREGION1A = "subregion1A";
+  private static final String SUBREGION1B = "subregion1B";
+  private static final String SUBREGION1C = "subregion1C";
+  private static final String PR1 = "PR1";
+  private static final String LOCALREGIONONMANAGER = "LocalRegionOnManager";
+
+
+  static class CacheListener2 extends CacheListenerAdapter {
+  }
+
+  static class CacheListener1 extends CacheListenerAdapter {
+  }
+
+  private Properties createProperties(String name, String groups) {
+    Properties props = new Properties();
+    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
+    props.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
+    props.setProperty(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME, "true");
+    props.setProperty(DistributionConfig.ENABLE_TIME_STATISTICS_NAME, "true");
+    props.setProperty(DistributionConfig.NAME_NAME, name);
+    props.setProperty(DistributionConfig.GROUPS_NAME, groups);
+    return props;
+  }
+
+  private void createPartitionedRegion1() {
+    final Cache cache = getCache();
+    // Create the data region
+    RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
+    dataRegionFactory.create(PR1);
+  }
+
+  private void setupSystem() {
+    final Properties managerProps = createProperties("Manager", "G1");
+    createDefaultSetup(managerProps);
+
+    final Properties server1Props = createProperties("Server1", "G2");
+    final Host host = Host.getHost(0);
+    final VM[] servers = {host.getVM(0), host.getVM(1)};
+
+    //The mananger VM
+    servers[0].invoke(new SerializableRunnable() {
+      public void run() {
+        final Cache cache = getCache();
+        RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
+        dataRegionFactory.setConcurrencyLevel(4);
+        EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
+        dataRegionFactory.setEvictionAttributes(ea);
+        dataRegionFactory.setEnableAsyncConflation(true);
+
+        FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true);
+        PartitionAttributes pa = new PartitionAttributesFactory().setLocalMaxMemory(100).setRecoveryDelay(
+            2).setTotalMaxMemory(200).setRedundantCopies(1).addFixedPartitionAttributes(fpa).create();
+        dataRegionFactory.setPartitionAttributes(pa);
+
+        dataRegionFactory.create(PR1);
+        createLocalRegion(LOCALREGIONONMANAGER);
+      }
+    });
+
+    servers[1].invoke(new SerializableRunnable() {
+      public void run() {
+        getSystem(server1Props);
+        final Cache cache = getCache();
+        RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
+        dataRegionFactory.setConcurrencyLevel(4);
+        EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
+        dataRegionFactory.setEvictionAttributes(ea);
+        dataRegionFactory.setEnableAsyncConflation(true);
+
+        FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par2", 4);
+        PartitionAttributes pa = new PartitionAttributesFactory().setLocalMaxMemory(150).setRecoveryDelay(
+            4).setTotalMaxMemory(200).setRedundantCopies(1).addFixedPartitionAttributes(fpa).create();
+        dataRegionFactory.setPartitionAttributes(pa);
+
+        dataRegionFactory.create(PR1);
+        createRegionsWithSubRegions();
+      }
+    });
+  }
+
+  private void createPartitionedRegion(String regionName) {
+
+    final Cache cache = getCache();
+    // Create the data region
+    RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
+    dataRegionFactory.setConcurrencyLevel(4);
+    EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
+    dataRegionFactory.setEvictionAttributes(ea);
+    dataRegionFactory.setEnableAsyncConflation(true);
+
+    FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true);
+    PartitionAttributes pa = new PartitionAttributesFactory().setLocalMaxMemory(100).setRecoveryDelay(
+        2).setTotalMaxMemory(200).setRedundantCopies(1).addFixedPartitionAttributes(fpa).create();
+    dataRegionFactory.setPartitionAttributes(pa);
+    dataRegionFactory.addCacheListener(new CacheListener1());
+    dataRegionFactory.addCacheListener(new CacheListener2());
+    dataRegionFactory.create(regionName);
+  }
+
+
+  private void createLocalRegion(final String regionName) {
+    final Cache cache = getCache();
+    // Create the data region
+    RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.LOCAL);
+    dataRegionFactory.create(regionName);
+  }
+
+  /**
+   * Creates a region that uses compression on region entry values.
+   *
+   * @param regionName a unique region name.
+   */
+  private void createCompressedRegion(final String regionName) {
+    final Cache cache = getCache();
+
+    RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    dataRegionFactory.setCompressor(SnappyCompressor.getDefaultInstance());
+    dataRegionFactory.create(regionName);
+  }
+
+  @SuppressWarnings("deprecation")
+  private void createRegionsWithSubRegions() {
+    final Cache cache = getCache();
+
+    RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
+    dataRegionFactory.setConcurrencyLevel(3);
+    Region<String, Integer> region1 = dataRegionFactory.create(REGION1);
+    region1.createSubregion(SUBREGION1C, region1.getAttributes());
+    Region<String, Integer> subregion2 = region1.createSubregion(SUBREGION1A, region1.getAttributes());
+
+    subregion2.createSubregion(SUBREGION1B, subregion2.getAttributes());
+    dataRegionFactory.create(REGION2);
+    dataRegionFactory.create(REGION3);
+  }
+
+
+  public void testListRegion() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
+    assertTrue(commandResultAsString.contains(REGION1));
+    assertTrue(commandResultAsString.contains(REGION2));
+    assertTrue(commandResultAsString.contains(REGION3));
+
+
+    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    csb.addOption(CliStrings.LIST_REGION__MEMBER, "Manager");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
+
+    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    csb.addOption(CliStrings.LIST_REGION__MEMBER, "Server1");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains(REGION1));
+    assertTrue(commandResultAsString.contains(REGION2));
+    assertTrue(commandResultAsString.contains(REGION3));
+    assertTrue(commandResultAsString.contains(SUBREGION1A));
+
+    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    csb.addOption(CliStrings.LIST_REGION__GROUP, "G1");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
+
+    csb = new CommandStringBuilder(CliStrings.LIST_REGION);
+    csb.addOption(CliStrings.LIST_REGION__GROUP, "G2");
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains(REGION1));
+    assertTrue(commandResultAsString.contains(REGION2));
+    assertTrue(commandResultAsString.contains(REGION3));
+    assertTrue(commandResultAsString.contains(SUBREGION1A));
+  }
+
+  public void testDescribeRegion() {
+    setupSystem();
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
+    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, PR1);
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(PR1));
+    assertTrue(commandResultAsString.contains("Server1"));
+
+    csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
+    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, LOCALREGIONONMANAGER);
+    commandString = csb.toString();
+    commandResult = executeCommand(commandString);
+    commandResultAsString = commandResultToString(commandResult);
+    getLogWriter().info("Command String : " + commandString);
+    getLogWriter().info("Output : \n" + commandResultAsString);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(LOCALREGIONONMANAGER));
+    assertTrue(commandResultAsString.contains("Manager"));
+  }
+
+  /**
+   * Asserts that a describe region command issued on a region with compression returns the correct non default region
+   * attribute for compression and the correct codec value.
+   */
+  public void testDescribeRegionWithCompressionCodec() {
+    final String regionName = "compressedRegion";
+    VM vm = Host.getHost(0).getVM(1);
+
+    setupSystem();
+
+    // Create compressed region
+    vm.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        createCompressedRegion(regionName);
+      }
+    });
+
+    // Test the describe command; look for compression
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
+    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
+    String commandString = csb.toString();
+    CommandResult commandResult = executeCommand(commandString);
+    String commandResultAsString = commandResultToString(commandResult);
+    assertEquals(Status.OK, commandResult.getStatus());
+    assertTrue(commandResultAsString.contains(regionName));
+    assertTrue(commandResultAsString.contains(RegionAttributesNames.COMPRESSOR));
+    assertTrue(commandResultAsString.contains(RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER));
+
+    // Destroy compressed region
+    vm.invoke(new SerializableRunnable() {
+      @Override
+      public void run() {
+        Region region = getCache().getRegion(regionName);
+        assertNotNull(region);
+        region.destroyRegion();
+      }
+    });
+  }
+}


Mime
View raw message