geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [01/12] incubator-geode git commit: Fixing tests
Date Mon, 02 May 2016 16:58:36 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1255 68ddd58be -> cd02af01c


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
index 70f3e70..75c0286 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
@@ -16,22 +16,11 @@
  */
 package com.gemstone.gemfire.management.internal.configuration;
 
-import com.gemstone.gemfire.cache.Region;
-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.AvailablePortHelper;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import com.gemstone.gemfire.util.test.TestUtil;
-import com.jayway.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
+import static java.util.stream.Collectors.*;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -43,9 +32,20 @@ import java.util.Arrays;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
-import static java.util.stream.Collectors.joining;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import com.jayway.awaitility.Awaitility;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.distributed.Locator;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.util.test.TestUtil;
 
 @Category(DistributedTest.class)
 public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
@@ -53,7 +53,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
   @After
   public void teardown() throws Exception {
     for (int i = 0; i < 2; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       vm.invoke("Removing shared configuration", () -> {
         InternalLocator locator = InternalLocator.getLocator();
         if (locator == null) {
@@ -62,7 +62,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
         if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration();
+          sharedConfig.destroySharedConfiguration_forTestsOnly();
         }
       });
     }
@@ -70,18 +70,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
   @Test
   public void basicClusterConfigDirWithOneLocator() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
+    final int[] ports = getRandomAvailableTCPPorts(1);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -92,18 +92,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
   @Test
   public void basicClusterConfigDirWithTwoLocators() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -115,18 +115,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
   @Category(FlakyTest.class) // GEODE-1165: random ports, BindException, time sensitive,
awaitility
   @Test
   public void updateClusterConfigDirWithTwoLocatorsNoRollingServerRestart() throws Exception
{
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -139,24 +139,24 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
     // Unless we start them asynchronously, the older one will want to wait for a new diskstore
     // to become available and will time out.
     for (int i = locatorCount; i > 0; i--) {
-      VM vm = Host.getHost(0).getVM(i - 1);
+      VM vm = getHost(0).getVM(i - 1);
       stopLocator(vm);
     }
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       vm.invoke(() -> disconnectFromDS());
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -167,18 +167,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
   @Test
   public void updateClusterConfigDirWithTwoLocatorsAndRollingServerRestart() throws Exception
{
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -191,19 +191,19 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
     // Unless we start them asynchronously, the older one will want to wait for a new diskstore
     // to become available and will time out.
     for (int i = locatorCount; i > 0; i--) {
-      VM vm = Host.getHost(0).getVM(i - 1);
+      VM vm = getHost(0).getVM(i - 1);
       stopLocator(vm);
     }
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -214,18 +214,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
   @Test
   public void updateClusterConfigDirWithTwoLocatorsRollingRestartAndRollingServerRestart()
throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -236,7 +236,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
     // Roll the locators
     for (int i = locatorCount - 1; i >= 0; i--) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       stopLocator(vm);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
@@ -245,7 +245,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
 
     // Roll the servers
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -269,14 +269,14 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
       final String locatorName = "locator" + i;
       final File logFile = new File("locator-" + i + ".log");
       final Properties props = new Properties();
-      props.setProperty(DistributionConfig.NAME_NAME, locatorName);
-      props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-      props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-      props.setProperty(DistributionConfig.LOAD_CLUSTER_CONFIG_FROM_DIR_NAME, "true");
+      props.setProperty(NAME_NAME, locatorName);
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(LOAD_CLUSTER_CONFIG_FROM_DIR_NAME, "true");
 
       if (locatorPorts.length > 1) {
         int otherLocatorPort = locatorPorts[(i + 1) % locatorPorts.length];
-        props.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + otherLocatorPort
+ "]");
+        props.setProperty(LOCATORS_NAME, "localhost[" + otherLocatorPort + "]");
       }
 
       Locator.startLocatorAndDS(locatorPorts[i], logFile, props);
@@ -306,12 +306,12 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase
{
       disconnectFromDS();
 
       final Properties props = new Properties();
-      props.setProperty(DistributionConfig.NAME_NAME, "member" + i);
-      props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-      props.setProperty(DistributionConfig.LOCATORS_NAME, getLocatorStr(locatorPorts));
-      props.setProperty(DistributionConfig.LOG_FILE_NAME, "server-" + i + ".log");
-      props.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
-      props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(NAME_NAME, "member" + i);
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, getLocatorStr(locatorPorts));
+      props.setProperty(LOG_FILE_NAME, "server-" + i + ".log");
+      props.setProperty(USE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
 
       getSystem(props);
       getCache();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
index a9324db..27a9757 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="DEBUG" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
     <Appenders>
         <Console name="STDOUT" target="SYSTEM_OUT">
             <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n
%throwable%n"/>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
b/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
index 4ff9a73..07a2ed1 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
@@ -83,6 +83,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
+
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
   private static final String REPLICATE_REGION = "ReplicateRegion1";
@@ -97,18 +98,16 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
   private static final String JAR3 = "D3.jar";
   private static final String AsyncEventQueue1 = "Q1";
   
-  private transient ClassBuilder classBuilder = new ClassBuilder();
-  
   public static Set<String> serverNames = new HashSet<String>();
   public static Set<String> jarFileNames = new HashSet<String>();
   
   public static String dataMember = "DataMember";
   public static String newMember = "NewMember";
   
-  private static final long serialVersionUID = 1L;
+  private transient ClassBuilder classBuilder = new ClassBuilder();
 
   @Test
-  public void testConfigDistribution() throws IOException {
+  public void testConfigDistribution() throws Exception {
     IgnoredException.addIgnoredException("could not get remote locator");
     try {
       Object[] result = setup();
@@ -213,12 +212,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
           assertTrue(aeq.getBatchSize() == 1000);
           assertTrue(aeq.getMaximumQueueMemory() == 1000);
         
-          //GatewayReviever verification
+          //GatewayReceiver verification
           Set<GatewayReceiver> gatewayReceivers = cache.getGatewayReceivers();
           assertFalse(gatewayReceivers.isEmpty());
           assertTrue(gatewayReceivers.size() == 1);
           
-          //Gateway Sender verfication
+          //Gateway Sender verification
           GatewaySender gs = cache.getGatewaySender(gsId);
           assertNotNull(gs);
           assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold())));
@@ -246,14 +245,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
   /**
    * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser},
    * {@link XmlGenerator}, {@link XmlEntity} as it applies to Extensions.
-   * Asserts that Mock Entension is created and altered on region and cache.
+   * Asserts that Mock Extension is created and altered on region and cache.
    * 
-   * @throws IOException
    * @since 8.1
    */
   @Test
-  public void testCreateExtensions() throws IOException {
-    
+  public void testCreateExtensions() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -322,12 +319,10 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
    * {@link XmlGenerator}, {@link XmlEntity} as it applies to Extensions.
    * Asserts that Mock Entension is created and destroyed on region and cache.
    * 
-   * @throws IOException
    * @since 8.1
    */
   @Test
-  public void testDestroyExtensions() throws IOException {
-    
+  public void testDestroyExtensions() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -389,7 +384,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
 
   @Ignore("disabled for unknown reason")
   @Test
-  public void testCreateDiskStore () throws IOException {
+  public void testCreateDiskStore () throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -493,12 +488,11 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     } finally {
       shutdownAll();
     }
-   
   }
 
   @Ignore("disabled for unknown reason")
   @Test
-  public void testConfigurePDX() throws IOException {
+  public void testConfigurePDX() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -527,35 +521,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     }
   }
   
-  private void shutdownAll() throws IOException {
-    VM locatorAndMgr = Host.getHost(0).getVM(3);
-    locatorAndMgr.invoke(new SerializableCallable() {
-      /**
-       * 
-       */
-      private static final long serialVersionUID = 1L;
-
-      @Override
-      public Object call() throws Exception {
-        GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
-        ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1);
-        return null;
-      }
-    });
-    
-    locatorAndMgr.invoke(SharedConfigurationDUnitTest.locatorCleanup);
-    //Clean up the directories
-    if (serverNames != null && !serverNames.isEmpty()) {
-     for (String serverName : serverNames) {
-       final File serverDir = new File(serverName);
-       FileUtils.cleanDirectory(serverDir);
-       FileUtils.deleteDirectory(serverDir);
-     }
-    }
-  }
-
   @Test
-  public void testClusterConfigDir() {
+  public void testClusterConfigDir() throws Exception {
     disconnectAllFromDS();
     final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
@@ -571,8 +538,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         
         try {
           jmxHost = InetAddress.getLocalHost().getHostName();
-        }
-        catch (UnknownHostException ignore) {
+        } catch (UnknownHostException ignore) {
           jmxHost = "localhost";
         }
 
@@ -581,7 +547,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         jmxPort = ports[0];
         httpPort = ports[1];
         
-       
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
@@ -601,25 +566,19 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         
         locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
locatorLogFile, null,
-              locatorProps);
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
-        
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
locatorLogFile, null, locatorProps);
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+
         assertTrue(clusterConfigDir.list().length > 0);
 
         final Object[] result = new Object[4];
@@ -632,7 +591,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     });
   }
   
-  public Object[] setup() {
+  private Object[] setup() {
     disconnectAllFromDS();
     final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
@@ -641,15 +600,14 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     
     Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
       @Override
-      public Object call() {
+      public Object call() throws IOException {
         int httpPort;
         int jmxPort;
         String jmxHost;
         
         try {
           jmxHost = InetAddress.getLocalHost().getHostName();
-        }
-        catch (UnknownHostException ignore) {
+        } catch (UnknownHostException ignore) {
           jmxHost = "localhost";
         }
 
@@ -658,7 +616,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         jmxPort = ports[0];
         httpPort = ports[1];
         
-       
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
@@ -672,24 +629,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         locatorProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
         locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
locatorLogFile, null,
-              locatorProps);
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port,
locatorLogFile, null, locatorProps);
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
 
         final Object[] result = new Object[4];
         result[0] = locator1Port;
@@ -708,6 +659,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
     // Create a cache in VM 1
     VM dataMember = Host.getHost(0).getVM(1);
+
     dataMember.invoke(new SerializableCallable() {
       @Override
       public Object call() throws IOException {
@@ -728,14 +680,10 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
         return CliUtil.getAllNormalMembers(cache);
       }
     });
+
     return result;
   }
   
-  
-  /*********************************
-   * Region commands 
-   */
-  
   private void createRegion(String regionName, RegionShortcut regionShortCut, String group)
{
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
@@ -781,32 +729,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     executeAndVerifyCommand(csb.toString());
   }
 
-  class CommandBuilder {
-    private CommandStringBuilder csb;
-    
-    public CommandBuilder(String commandName, Map<String, String> options) {
-      csb = new CommandStringBuilder(commandName);
-      
-      Set<Entry<String, String>> entries = options.entrySet();
-      
-      Iterator<Entry<String, String>> iter = entries.iterator();
-      
-      while (iter.hasNext()) {
-        Entry<String, String> entry = iter.next();
-        String option = entry.getKey();
-        
-        if (StringUtils.isBlank(option)) {
-          csb.addOption(option, entry.getValue());
-        }
-      }
-    }
-    
-    public String getCommandString() {
-      return csb.toString();
-    }
-  }
-  
-  
   private void createPersistentRegion(String regionName, RegionShortcut regionShortCut, String
group, String diskStoreName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOptionWithValueCheck(CliStrings.CREATE_REGION__REGION, regionName);
@@ -823,15 +745,16 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
   }
   
   private void alterRegion(String regionName,
-      String cloningEnabled, 
-      String aeqId,
-      String cacheListener, 
-      String cacheWriter, 
-      String cacheLoader, 
-      String entryExpIdleTime, 
-      String entryExpIdleTimeAction,
-      String evictionMax,
-      String gsId) {
+                           String cloningEnabled,
+                           String aeqId,
+                           String cacheListener,
+                           String cacheWriter,
+                           String cacheLoader,
+                           String entryExpIdleTime,
+                           String entryExpIdleTimeAction,
+                           String evictionMax,
+                           String gsId) {
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_REGION);
     csb.addOptionWithValueCheck(CliStrings.ALTER_REGION__CLONINGENABLED, "false");
     csb.addOptionWithValueCheck(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, aeqId);
@@ -846,7 +769,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
 
     executeAndVerifyCommand(csb.getCommandString());
   }
-  protected void executeAndVerifyCommand(String commandString) {
+
+  private void executeAndVerifyCommand(String commandString) {
     CommandResult cmdResult = executeCommand(commandString);
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Command : " + commandString);
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Command Result :
" + commandResultToString(cmdResult));
@@ -854,20 +778,15 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     assertFalse(cmdResult.failedToPersist());
   }
   
-  
-  /****************
-   * CREATE/DESTROY INDEX
-   */
-  
-  public void createIndex(String indexName, String expression, String regionName, String
group) {
+  private void createIndex(String indexName, String expression, String regionName, String
group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
     csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
     csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, expression);
     csb.addOption(CliStrings.CREATE_INDEX__REGION, regionName);
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  public void destroyIndex(String indexName, String regionName, String group) {
+
+  private void destroyIndex(String indexName, String regionName, String group) {
     if (StringUtils.isBlank(indexName) && StringUtils.isBlank(regionName) &&
StringUtils.isBlank(group)) {
       return;
     }
@@ -878,20 +797,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     executeAndVerifyCommand(csb.getCommandString());
   }
   
-  /*******
-   * CREATE/DESTROY DISK-STORE 
-   */
-  private void createDiskStore(String diskStoreName, 
-      String diskDirs, 
-      String autoCompact, 
-      String allowForceCompaction, 
-      String compactionThreshold, 
-      String duCritical, 
-      String duWarning,
-      String maxOplogSize,
-      String queueSize,
-      String timeInterval,
-      String writeBufferSize) {
+  private void createDiskStore(String diskStoreName,
+                               String diskDirs,
+                               String autoCompact,
+                               String allowForceCompaction,
+                               String compactionThreshold,
+                               String duCritical,
+                               String duWarning,
+                               String maxOplogSize,
+                               String queueSize,
+                               String timeInterval,
+                               String writeBufferSize) {
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
     csb.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreName);
     csb.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, diskDirs);
@@ -914,14 +831,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     executeAndVerifyCommand(csb.toString());
   }
   
-  /*********
-   * 
-   * CREATE GATEWAY-RECEIVER
-   * 
-   */
-  
-  private void createGatewayReceiver(String manualStart, String bindAddress,
-      String startPort, String endPort, String maxTimeBetweenPings, String group) {
+  private void createGatewayReceiver(String manualStart, String bindAddress, String startPort,
String endPort, String maxTimeBetweenPings, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYRECEIVER);
     csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, manualStart);
     csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, startPort);
@@ -933,18 +843,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
   }
   
   private void createGatewaySender(String id, 
-      String batchSize, 
-      String alertThreshold, 
-      String batchTimeInterval, 
-      String dispatcherThreads,
-      String enableConflation, 
-      String manualStart,
-      String maxQueueMemory, 
-      String orderPolicy, 
-      String parallel, 
-      String rmDsId, 
-      String socketBufferSize, 
-      String socketReadTimeout) {
+                                   String batchSize,
+                                   String alertThreshold,
+                                   String batchTimeInterval,
+                                   String dispatcherThreads,
+                                   String enableConflation,
+                                   String manualStart,
+                                   String maxQueueMemory,
+                                   String orderPolicy,
+                                   String parallel,
+                                   String rmDsId,
+                                   String socketBufferSize,
+                                   String socketReadTimeout) {
     
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER);
     csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ID, id);
@@ -964,12 +874,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     executeAndVerifyCommand(csb.getCommandString());
   }
   
-  
-  /*******
-   * CREATE ASYNC-EVENT-QUEUE 
-   */
-  
-  public void createAsyncEventQueue(String id, String persistent , String diskStoreName,
String batchSize, String maxQueueMemory, String group) {
+  private void createAsyncEventQueue(String id, String persistent , String diskStoreName,
String batchSize, String maxQueueMemory, String group) throws IOException {
     String queueCommandsJarName = "testEndToEndSC-QueueCommands.jar";
     final File jarFile = new File(queueCommandsJarName);
 
@@ -1002,14 +907,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
       csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY,
maxQueueMemory);
       executeAndVerifyCommand(csb.getCommandString());
       
-    } catch (IOException e) {
-      e.printStackTrace();
     } finally {
       FileUtils.deleteQuietly(jarFile);
     }
   }
-  
-  public void configurePDX(String autoSerializerClasses, String ignoreUnreadFields, String
persistent, String portableAutoSerializerClasses, String readSerialized) {
+
+  private void configurePDX(String autoSerializerClasses, String ignoreUnreadFields, String
persistent, String portableAutoSerializerClasses, String readSerialized) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX);
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, autoSerializerClasses);
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, ignoreUnreadFields);
@@ -1018,25 +921,20 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, readSerialized);
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  //DEPLOY AND UNDEPLOY JAR
-  public void createAndDeployJar(String jarName, String group) {
+
+  private void createAndDeployJar(String jarName, String group) throws IOException {
     File newDeployableJarFile = new File(jarName);
-    try {
-      this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
-      CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
-      csb.addOption(CliStrings.DEPLOY__JAR, jarName);
-      if (!StringUtils.isBlank(group)) {
-        csb.addOption(CliStrings.DEPLOY__GROUP, group);
-      }
-      executeAndVerifyCommand(csb.getCommandString());
-      jarFileNames.add(jarName);
-    } catch (IOException e) {
-      e.printStackTrace();
+    this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
+    csb.addOption(CliStrings.DEPLOY__JAR, jarName);
+    if (!StringUtils.isBlank(group)) {
+      csb.addOption(CliStrings.DEPLOY__GROUP, group);
     }
+    executeAndVerifyCommand(csb.getCommandString());
+    jarFileNames.add(jarName);
   }
-  
-  public void undeployJar(String jarName, String group) {
+
+  private void undeployJar(String jarName, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.UNDEPLOY);
     if (!StringUtils.isBlank(jarName)) {
       csb.addOption(CliStrings.UNDEPLOY__JAR, jarName);
@@ -1046,8 +944,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     }
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  public void alterRuntime(String copyOnRead, String lockLease, String lockTimeout, String
messageSyncInterval) {
+
+  private void alterRuntime(String copyOnRead, String lockLease, String lockTimeout, String
messageSyncInterval) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ, copyOnRead);
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE, lockLease);
@@ -1055,13 +953,56 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase
{
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL,
messageSyncInterval);
     executeAndVerifyCommand(csb.toString());
   }
-  public void deleteSavedJarFiles() {
-    try {
-      FileUtil.deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
-      FileUtil.delete(new File("Deploy1.jar"));
-    } catch (IOException ioe) {
-      ioe.printStackTrace();
+
+  private void deleteSavedJarFiles() throws IOException {
+    FileUtil.deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
+    FileUtil.delete(new File("Deploy1.jar"));
+  }
+
+  private void shutdownAll() throws IOException {
+    VM locatorAndMgr = Host.getHost(0).getVM(3);
+    locatorAndMgr.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
+        ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1);
+        return null;
+      }
+    });
+
+    locatorAndMgr.invoke(SharedConfigurationTestUtils.cleanupLocator);
+    //Clean up the directories
+    if (serverNames != null && !serverNames.isEmpty()) {
+      for (String serverName : serverNames) {
+        final File serverDir = new File(serverName);
+        FileUtils.cleanDirectory(serverDir);
+        FileUtils.deleteDirectory(serverDir);
+      }
+    }
+  }
+
+  class CommandBuilder {
+    private CommandStringBuilder csb;
+
+    public CommandBuilder(String commandName, Map<String, String> options) {
+      csb = new CommandStringBuilder(commandName);
+
+      Set<Entry<String, String>> entries = options.entrySet();
+
+      Iterator<Entry<String, String>> iter = entries.iterator();
+
+      while (iter.hasNext()) {
+        Entry<String, String> entry = iter.next();
+        String option = entry.getKey();
+
+        if (StringUtils.isBlank(option)) {
+          csb.addOption(option, entry.getValue());
+        }
+      }
+    }
+
+    public String getCommandString() {
+      return csb.toString();
     }
   }
-  
 }



Mime
View raw message