geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [10/15] geode git commit: Convert from ManagementTestCase to ManagementTestRule
Date Mon, 30 Jan 2017 20:52:57 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/662b500e/geode-core/src/test/java/org/apache/geode/management/RegionManagementDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/RegionManagementDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/RegionManagementDUnitTest.java
index fcdc3a4..3dc92b6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/RegionManagementDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/RegionManagementDUnitTest.java
@@ -12,22 +12,44 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
 package org.apache.geode.management;
 
-import static org.junit.Assert.*;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.Region.*;
+import static org.apache.geode.test.dunit.Host.*;
+import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
+import static org.assertj.core.api.Assertions.*;
 
+import java.lang.management.ManagementFactory;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
 
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 
+import com.jayway.awaitility.Awaitility;
+import com.jayway.awaitility.core.ConditionFactory;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -41,1325 +63,1156 @@ import org.apache.geode.cache.PartitionAttributes;
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.Scope;
 import org.apache.geode.cache.query.data.Portfolio;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.DM;
+import org.apache.geode.internal.cache.AbstractRegion;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.TestObjectSizerImpl;
 import org.apache.geode.internal.cache.lru.LRUStatistics;
 import org.apache.geode.internal.cache.partitioned.fixed.SingleHopQuarterPartitionResolver;
 import org.apache.geode.management.internal.MBeanJMXAdapter;
 import org.apache.geode.management.internal.SystemManagementService;
-import org.apache.geode.test.dunit.Assert;
 import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.SerializableRunnable;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.Wait;
 import org.apache.geode.test.dunit.WaitCriterion;
 import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.categories.FlakyTest;
 
 /**
  * This class checks and verifies various data and operations exposed through RegionMXBean
  * interface.
- * 
+ * <p>
  * Goal of the Test : RegionMBean gets created once region is created. Data like Region Attributes
  * data and stats are of proper value
- * 
- * 
  */
 @Category(DistributedTest.class)
+@SuppressWarnings({"serial", "unused"})
 public class RegionManagementDUnitTest extends ManagementTestBase {
 
-  private static final long serialVersionUID = 1L;
-
-  private final String VERIFY_CONFIG_METHOD = "verifyConfigData";
+  private static final String REGION_NAME = "MANAGEMENT_TEST_REGION";
+  private static final String PARTITIONED_REGION_NAME = "MANAGEMENT_PAR_REGION";
+  private static final String FIXED_PR_NAME = "MANAGEMENT_FIXED_PR";
+  private static final String LOCAL_REGION_NAME = "TEST_LOCAL_REGION";
+  private static final String LOCAL_SUB_REGION_NAME = "TEST_LOCAL_SUB_REGION";
 
-  private final String VERIFY_REMOTE_CONFIG_METHOD = "verifyConfigDataRemote";
+  private static final String REGION_PATH = SEPARATOR + REGION_NAME;
+  private static final String PARTITIONED_REGION_PATH = SEPARATOR + PARTITIONED_REGION_NAME;
+  private static final String FIXED_PR_PATH = SEPARATOR + FIXED_PR_NAME;
+  private static final String LOCAL_SUB_REGION_PATH =
+      SEPARATOR + LOCAL_REGION_NAME + SEPARATOR + LOCAL_SUB_REGION_NAME;
 
-  static final String REGION_NAME = "MANAGEMENT_TEST_REGION";
+  // field used in manager VM
+  private static Region fixedPartitionedRegion;
 
-  static final String PARTITIONED_REGION_NAME = "MANAGEMENT_PAR_REGION";
+  private static final AtomicReference<List<Notification>> MEMBER_NOTIFICATIONS_REF =
+      new AtomicReference<>();
+  private static final AtomicReference<List<Notification>> SYSTEM_NOTIFICATIONS_REF =
+      new AtomicReference<>();
 
-  static final String FIXED_PR_NAME = "MANAGEMENT_FIXED_PR";
+  @Manager
+  private VM managerVM;
 
-  static final String REGION_PATH = "/MANAGEMENT_TEST_REGION";
+  @Member
+  private VM[] memberVMs;
 
-  static final String PARTITIONED_REGION_PATH = "/MANAGEMENT_PAR_REGION";
+  @Before
+  public void before() throws Exception {
+    this.managerVM = getHost(0).getVM(0);
 
-  static final String FIXED_PR_PATH = "/MANAGEMENT_FIXED_PR";
-
-  static final String LOCAL_REGION_NAME = "TEST_LOCAL_REGION";
-  static final String LOCAL_SUB_REGION_NAME = "TEST_LOCAL_SUB_REGION";
-  static final String LOCAL_REGION_PATH = "/TEST_LOCAL_REGION";
-  static final String LOCAL_SUB_REGION_PATH = "/TEST_LOCAL_REGION/TEST_LOCAL_SUB_REGION";
-
-  private static final int MAX_WAIT = 70 * 1000;
-
-  protected static final Region DiskRegion = null;
+    this.memberVMs = new VM[3];
+    this.memberVMs[0] = getHost(0).getVM(1);
+    this.memberVMs[1] = getHost(0).getVM(2);
+    this.memberVMs[2] = getHost(0).getVM(3);
+  }
 
-  static List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
+  @After
+  public void after() throws Exception {
+    invokeInEveryVM(() -> MEMBER_NOTIFICATIONS_REF.set(null));
+    invokeInEveryVM(() -> SYSTEM_NOTIFICATIONS_REF.set(null));
+    disconnectAllFromDS_tmp();
+  }
 
+  private void createMembersAndThenManagers_tmp() throws Exception {
+    initManagement(false);
+  }
 
-  private static Region fixedPrRegion;
+  private void createManagersAndThenMembers_tmp() throws Exception {
+    initManagement(true);
+  }
 
+  private void disconnectAllFromDS_tmp() {
+    disconnectAllFromDS();
+  }
 
-  public RegionManagementDUnitTest() {
-    super();
+  private ManagementService getManagementService_tmp() {
+    return getManagementService();
+  }
 
+  private Cache getCache_tmp() {
+    return getCache();
   }
 
   /**
    * Tests all Region MBean related Management APIs
-   * 
+   * <p>
    * a) Notification propagated to member MBean while a region is created
-   * 
+   * <p>
    * b) Creates and check a Distributed Region
-   * 
-   * 
-   * @throws Exception
    */
-
-  @Category(FlakyTest.class) // GEODE-1538
   @Test
   public void testDistributedRegion() throws Exception {
+    createMembersAndThenManagers_tmp();
 
-    initManagement(false);
-
-
-    VM[] managedNodes = new VM[getManagedNodeList().size()];
-
-    getManagedNodeList().toArray(managedNodes);
-    // Adding notif listener for remote cache members
-    addMemberListener(managingNode);
-
-    for (int j = 0; j < managedNodes.length; j++) {
-
-      VM vm = managedNodes[j];
-
-      createDistributedRegion(vm, REGION_NAME);
-      validateReplicateRegionAfterCreate(vm);
+    // Adding notification listener for remote cache memberVMs
+    addMemberNotificationListener(this.managerVM, 3); // TODO: why?
 
+    for (VM memberVM : this.memberVMs) {
+      createDistributedRegion_tmp(memberVM, REGION_NAME);
+      verifyReplicateRegionAfterCreate(memberVM);
     }
 
-    verifyRemoteDistributedRegion(managingNode, 3);
-
+    verifyRemoteDistributedRegion(this.managerVM, 3);
 
-    for (VM vm : getManagedNodeList()) {
-      closeRegion(vm, REGION_PATH);
-      validateReplicatedRegionAfterClose(vm);
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, REGION_PATH);
+      verifyReplicatedRegionAfterClose(memberVM);
     }
 
-    ensureProxyCleanup(managingNode);
+    verifyProxyCleanup(this.managerVM);
+
+    verifyMemberNotifications(this.managerVM, REGION_NAME, 3);
   }
 
   /**
    * Tests all Region MBean related Management APIs
-   * 
+   * <p>
    * a) Notification propagated to member MBean while a region is created
-   * 
+   * <p>
    * b) Created and check a Partitioned Region
-   * 
-   * @throws Exception
    */
   @Test
   public void testPartitionedRegion() throws Exception {
-    initManagement(false);
-
-    VM managingNode = getManagingNode();
-
-    VM[] managedNodes = new VM[getManagedNodeList().size()];
+    createMembersAndThenManagers_tmp();
 
-    getManagedNodeList().toArray(managedNodes);
-    // Adding notif listener for remote cache members
+    // Adding notification listener for remote cache memberVMs
+    addMemberNotificationListener(this.managerVM, 3); // TODO: why?
 
-    addMemberListener(managingNode);
-
-    for (int j = 0; j < managedNodes.length; j++) {
-
-      VM vm = managedNodes[j];
-      createPartitionRegion(vm, PARTITIONED_REGION_NAME);
-      validatePartitionRegionAfterCreate(vm);
+    for (VM memberVM : this.memberVMs) {
+      createPartitionRegion_tmp(memberVM, PARTITIONED_REGION_NAME);
+      verifyPartitionRegionAfterCreate(memberVM);
     }
 
+    verifyRemotePartitionRegion(this.managerVM);
 
-    validateRemotePartitionRegion(managingNode);
-
-    for (VM vm : getManagedNodeList()) {
-
-      closeRegion(vm, PARTITIONED_REGION_PATH);
-      validatePartitionRegionAfterClose(vm);
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, PARTITIONED_REGION_PATH);
+      verifyPartitionRegionAfterClose(memberVM);
     }
+
+    verifyMemberNotifications(this.managerVM, PARTITIONED_REGION_NAME, 3);
   }
 
   /**
    * Tests all Region MBean related Management APIs
-   * 
+   * <p>
    * a) Notification propagated to member MBean while a region is created
-   * 
+   * <p>
    * b) Creates and check a Fixed Partitioned Region
-   * 
-   * @throws Exception
    */
   @Test
   public void testFixedPRRegionMBean() throws Exception {
+    createMembersAndThenManagers_tmp();
 
-    initManagement(false);
-
-    VM managingNode = getManagingNode();
-
-    VM[] managedNodes = new VM[getManagedNodeList().size()];
-
-    getManagedNodeList().toArray(managedNodes);
-    // Adding notif listener for remote cache members
-    addMemberListener(managingNode);
-
-    for (int j = 0; j < managedNodes.length; j++) {
+    // Adding notification listener for remote cache memberVMs
+    addMemberNotificationListener(this.managerVM, 3); // TODO: why?
 
-      VM vm = managedNodes[j];
+    int primaryIndex = 0;
+    for (VM memberVM : this.memberVMs) {
+      List<FixedPartitionAttributes> fixedPartitionAttributesList =
+          createFixedPartitionList(primaryIndex + 1);
+      memberVM.invoke(() -> createFixedPartitionRegion(fixedPartitionAttributesList));
+      primaryIndex++;
+    }
 
-      createFixedPartitionList(j + 1);
-      Object[] args = new Object[1];
-      args[0] = fpaList;
-      vm.invoke(RegionManagementDUnitTest.class, "createFixedPartitionRegion", args);
+    // // TODO: Workaround for bug 46683. Reenable validation when bug is fixed.
+    verifyRemoteFixedPartitionRegion(this.managerVM);
 
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, FIXED_PR_PATH);
     }
-    // Workaround for bug 46683. Renable validation when bug is fixed.
-    validateRemoteFixedPartitionRegion(managingNode);
 
-    for (VM vm : getManagedNodeList()) {
-      closeFixedPartitionRegion(vm);
-    }
+    verifyMemberNotifications(this.managerVM, FIXED_PR_PATH, 3);
   }
 
   /**
    * Tests a Distributed Region at Managing Node side while region is created in a member node
    * asynchronously.
-   * 
-   * @throws Exception
    */
   @Test
   public void testRegionAggregate() throws Exception {
-    initManagement(true);
-
-    VM managingNode = getManagingNode();
-
-    VM[] managedNodes = new VM[getManagedNodeList().size()];
+    createManagersAndThenMembers_tmp();
 
-    getManagedNodeList().toArray(managedNodes);
-    // Adding notif listener for remote cache members
-    addDistrListener(managingNode);
-
-
-    for (int j = 0; j < managedNodes.length; j++) {
-
-      VM vm = managedNodes[j];
-
-      createDistributedRegion(vm, REGION_NAME);
+    // Adding notification listener for remote cache memberVMs
+    addSystemNotificationListener(this.managerVM); // TODO: why?
 
+    for (VM memberVM : this.memberVMs) {
+      createDistributedRegion_tmp(memberVM, REGION_NAME);
     }
 
+    verifyDistributedMBean(this.managerVM, 3);
+    createDistributedRegion_tmp(this.managerVM, REGION_NAME);
+    verifyDistributedMBean(this.managerVM, 4);
 
-    validateDistributedMBean(managingNode, 3);
-
-    createDistributedRegion(managingNode, REGION_NAME);
-    validateDistributedMBean(managingNode, 4);
-
-
-
-    for (int j = 0; j < managedNodes.length; j++) {
-
-      VM vm = managedNodes[j];
-
-      closeRegion(vm, REGION_PATH);
-
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, REGION_PATH);
     }
-    ensureProxyCleanup(managingNode);
-
-    validateDistributedMBean(managingNode, 1);
 
-    closeRegion(managingNode, REGION_PATH);
-    validateDistributedMBean(managingNode, 0);
+    verifyProxyCleanup(this.managerVM);
 
+    verifyDistributedMBean(this.managerVM, 1);
+    closeRegion(this.managerVM, REGION_PATH);
+    verifyDistributedMBean(this.managerVM, 0);
 
+    verifySystemNotifications(this.managerVM, REGION_NAME, 3);
   }
 
   @Test
   public void testNavigationAPIS() throws Exception {
-    initManagement(true);
-    for (VM vm : managedNodeList) {
-      createDistributedRegion(vm, REGION_NAME);
-      createPartitionRegion(vm, PARTITIONED_REGION_NAME);
-    }
-    createDistributedRegion(managingNode, REGION_NAME);
-    createPartitionRegion(managingNode, PARTITIONED_REGION_NAME);
-    List<String> memberIds = new ArrayList<String>();
+    createManagersAndThenMembers_tmp();
 
-    for (VM vm : managedNodeList) {
-      memberIds.add(getMemberId(vm));
+    for (VM memberVM : this.memberVMs) {
+      createDistributedRegion_tmp(memberVM, REGION_NAME);
+      createPartitionRegion_tmp(memberVM, PARTITIONED_REGION_NAME);
     }
-    checkNavigationAPIS(managingNode, memberIds);
-
 
+    createDistributedRegion_tmp(this.managerVM, REGION_NAME);
+    createPartitionRegion_tmp(this.managerVM, PARTITIONED_REGION_NAME);
+    List<String> memberIds = new ArrayList<>();
 
-    for (VM vm : managedNodeList) {
-      closeRegion(vm, REGION_PATH);
+    for (VM memberVM : this.memberVMs) {
+      memberIds.add(getDistributedMemberId_tmp(memberVM));
     }
 
-    closeRegion(managingNode, REGION_PATH);
+    verifyNavigationApis(this.managerVM, memberIds);
 
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, REGION_PATH);
+    }
+    closeRegion(this.managerVM, REGION_PATH);
   }
 
-
-
   @Test
   public void testSubRegions() throws Exception {
-    initManagement(false);
-    for (VM vm : managedNodeList) {
-      createLocalRegion(vm, LOCAL_REGION_NAME);
-      createSubRegion(vm, LOCAL_REGION_NAME, LOCAL_SUB_REGION_NAME);
-    }
+    createMembersAndThenManagers_tmp();
 
-    for (VM vm : managedNodeList) {
-      checkSubRegions(vm, LOCAL_SUB_REGION_PATH);
+    for (VM memberVM : this.memberVMs) {
+      createLocalRegion_tmp(memberVM, LOCAL_REGION_NAME);
+      createSubRegion_tmp(memberVM, LOCAL_REGION_NAME, LOCAL_SUB_REGION_NAME);
     }
 
-    for (VM vm : managedNodeList) {
-      closeRegion(vm, LOCAL_REGION_NAME);
-      checkNullRegions(vm, LOCAL_SUB_REGION_NAME);
+    for (VM memberVM : this.memberVMs) {
+      verifySubRegions(memberVM, LOCAL_SUB_REGION_PATH);
     }
 
+    for (VM memberVM : this.memberVMs) {
+      closeRegion(memberVM, LOCAL_REGION_NAME);
+      verifyNullRegions(memberVM, LOCAL_SUB_REGION_NAME);
+    }
   }
 
-
-
   @Test
   public void testSpecialRegions() throws Exception {
-    initManagement(false);
-    createSpecialRegion(managedNodeList.get(0));
-    DistributedMember member = getMember(managedNodeList.get(0));
-    checkSpecialRegion(managingNode, member);
-  }
-
-
-  public void createSpecialRegion(VM vm1) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
-
-        public void run() {
-          Cache cache = getCache();
-          AttributesFactory attributesFactory = new AttributesFactory();
-          attributesFactory.setValueConstraint(Portfolio.class);
-          RegionAttributes regionAttributes = attributesFactory.create();
-
-          cache.createRegion("p-os", regionAttributes);
-          cache.createRegion("p_os", regionAttributes);
-        }
-      });
-
-    }
-  }
-
-  public void checkSpecialRegion(VM vm1, final DistributedMember member) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
-
-        public void run() {
-
-          ManagementService service = getManagementService();
-
-          try {
-            MBeanUtil.getDistributedRegionMbean("/p-os", 1);
-            MBeanUtil.getDistributedRegionMbean("/p_os", 1);
-
-          } catch (Exception e) {
-            InternalDistributedSystem.getLoggerI18n()
-                .fine("Undesired Result , DistributedRegionMXBean Should not be null" + e);
-          }
-
-        }
-      });
-
-    }
-
+    createMembersAndThenManagers_tmp();
+    createSpecialRegion(this.memberVMs[0]);
+    verifySpecialRegion(this.managerVM);
   }
 
   @Test
   public void testLruStats() throws Exception {
-    initManagement(false);
-    for (VM vm : managedNodeList) {
-      createDiskRegion(vm);
-
+    createMembersAndThenManagers_tmp();
+    for (VM memberVM : this.memberVMs) {
+      createDiskRegion(memberVM);
     }
-    checkEntrySize(managingNode, 3);
+    verifyEntrySize(this.managerVM, 3);
   }
 
-  public void createDiskRegion(VM vm1) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
-
-        public void run() {
-          AttributesFactory factory = new AttributesFactory();
-          factory.setScope(Scope.LOCAL);
-          factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(20,
-              new TestObjectSizerImpl(), EvictionAction.LOCAL_DESTROY));
-          /*
-           * File d = new File("DiskRegions" + OSProcess.getId()); d.mkdirs();
-           * 
-           * DiskStoreFactory dsf = getCache().createDiskStoreFactory(); dsf.setDiskDirs(new
-           * File[]{d}); factory.setDiskSynchronous(true); DiskStore ds = dsf.create(REGION_NAME);
-           * factory.setDiskStoreName(ds.getName());
-           */
-          Region region = getCache().createRegion(REGION_NAME, factory.create());
-
-          LRUStatistics lruStats = getLRUStats(region);
-
-          assertNotNull(lruStats);
-
-          RegionMXBean bean = managementService.getLocalRegionMBean(REGION_PATH);
-
-          assertNotNull(bean);
-
-          int total;
-          for (total = 0; total < 10000; total++) {
-            int[] array = new int[250];
-            array[0] = total;
-            region.put(new Integer(total), array);
-          }
-          assertTrue(bean.getEntrySize() > 0);
-          LogWriterUtils.getLogWriter().info("DEBUG: EntrySize =" + bean.getEntrySize());
-
-
-
-        }
-      });
+  private void closeRegion(final VM anyVM, final String regionPath) {
+    anyVM.invoke("closeRegion", () -> getCache_tmp().getRegion(regionPath).close());
+  }
 
-    }
+  private void createSpecialRegion(final VM memberVM) throws Exception {
+    memberVM.invoke("createSpecialRegion", () -> {
+      AttributesFactory attributesFactory = new AttributesFactory();
+      attributesFactory.setValueConstraint(Portfolio.class);
+      RegionAttributes regionAttributes = attributesFactory.create();
 
+      Cache cache = getCache_tmp();
+      cache.createRegion("p-os", regionAttributes);
+      cache.createRegion("p_os", regionAttributes);
+    });
   }
 
-  public void checkEntrySize(VM vm1, final int expectedMembers) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
+  private void verifySpecialRegion(final VM managerVM) throws Exception {
+    managerVM.invoke("verifySpecialRegion", () -> {
+      awaitDistributedRegionMXBean("/p-os", 1); // TODO: why?
+      awaitDistributedRegionMXBean("/p_os", 1);
+    });
+  }
 
-        public void run() {
+  private void createDiskRegion(final VM memberVM) throws Exception {
+    memberVM.invoke("createDiskRegion", () -> {
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(20,
+          new TestObjectSizerImpl(), EvictionAction.LOCAL_DESTROY));
 
-          DistributedRegionMXBean bean = null;
-          try {
-            bean = MBeanUtil.getDistributedRegionMbean(REGION_PATH, expectedMembers);
-          } catch (Exception e) {
-            InternalDistributedSystem.getLoggerI18n()
-                .fine("Undesired Result , DistributedRegionMXBean Should not be null" + e);
-          }
+      Region region = getCache_tmp().createRegion(REGION_NAME, factory.create());
 
-          assertNotNull(bean);
+      LRUStatistics lruStats =
+          ((AbstractRegion) region).getEvictionController().getLRUHelper().getStats();
+      assertThat(lruStats).isNotNull();
 
-          assertTrue(bean.getEntrySize() > 0);
-          LogWriterUtils.getLogWriter().info("DEBUG: EntrySize =" + bean.getEntrySize());
-        }
-      });
-
-    }
+      RegionMXBean regionMXBean = getManagementService_tmp().getLocalRegionMBean(REGION_PATH);
+      assertThat(regionMXBean).isNotNull();
 
+      int total;
+      for (total = 0; total < 10000; total++) { // TODO: why so many?
+        int[] array = new int[250];
+        array[0] = total;
+        region.put(new Integer(total), array);
+      }
+      assertThat(regionMXBean.getEntrySize()).isGreaterThan(0);
+    });
   }
 
-  protected LRUStatistics getLRUStats(Region region) {
-    final LocalRegion l = (LocalRegion) region;
-    return l.getEvictionController().getLRUHelper().getStats();
+  private void verifyEntrySize(final VM managerVM, final int expectedMembers) throws Exception {
+    managerVM.invoke("verifyEntrySize", () -> {
+      DistributedRegionMXBean distributedRegionMXBean =
+          awaitDistributedRegionMXBean(REGION_PATH, expectedMembers);
+      assertThat(distributedRegionMXBean).isNotNull();
+      assertThat(distributedRegionMXBean.getEntrySize()).isGreaterThan(0);
+    });
   }
 
-  @SuppressWarnings("serial")
-  public void checkSubRegions(VM vm1, final String subRegionPath) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
-
-        public void run() {
-
-          RegionMXBean bean = managementService.getLocalRegionMBean(subRegionPath);
-          assertNotNull(bean);
-
-        }
-      });
-
-    }
+  private void verifySubRegions(final VM memberVM, final String subRegionPath) throws Exception {
+    memberVM.invoke("verifySubRegions", () -> {
+      RegionMXBean regionMXBean = getManagementService_tmp().getLocalRegionMBean(subRegionPath);
+      assertThat(regionMXBean).isNotNull();
+    });
   }
 
-  @SuppressWarnings("serial")
-  public void checkNullRegions(VM vm1, final String subRegionPath) throws Exception {
-    {
-      vm1.invoke(new SerializableRunnable("Check Sub Regions") {
-
-        public void run() {
+  private void verifyNullRegions(final VM memberVM, final String subRegionPath) throws Exception {
+    memberVM.invoke("verifyNullRegions", () -> {
+      RegionMXBean regionMXBean = getManagementService_tmp().getLocalRegionMBean(subRegionPath);
+      assertThat(regionMXBean).isNull();
+    });
+  }
 
-          RegionMXBean bean = managementService.getLocalRegionMBean(subRegionPath);
-          assertNull(bean);
+  private void verifyNavigationApis(final VM managerVM, final List<String> memberIds) {
+    managerVM.invoke("verifyNavigationApis", () -> {
+      ManagementService service = getManagementService_tmp();
+      assertThat(service.getDistributedSystemMXBean()).isNotNull();
 
-        }
-      });
+      awaitMemberCount(4);
 
-    }
-  }
+      DistributedSystemMXBean distributedSystemMXBean = service.getDistributedSystemMXBean();
+      assertThat(distributedSystemMXBean.listDistributedRegionObjectNames()).hasSize(2);
 
+      assertThat(distributedSystemMXBean.fetchDistributedRegionObjectName(PARTITIONED_REGION_PATH))
+          .isNotNull();
+      assertThat(distributedSystemMXBean.fetchDistributedRegionObjectName(REGION_PATH)).isNotNull();
 
+      ObjectName actualName =
+          distributedSystemMXBean.fetchDistributedRegionObjectName(PARTITIONED_REGION_PATH);
+      ObjectName expectedName =
+          MBeanJMXAdapter.getDistributedRegionMbeanName(PARTITIONED_REGION_PATH);
+      assertThat(actualName).isEqualTo(expectedName);
 
-  protected void checkNavigationAPIS(final VM vm, final List<String> managedNodeMemberIds) {
-    SerializableRunnable checkNavigationAPIS = new SerializableRunnable("checkNavigationAPIS") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        ManagementService service = getManagementService();
-        final DistributedSystemMXBean bean = service.getDistributedSystemMXBean();
+      actualName = distributedSystemMXBean.fetchDistributedRegionObjectName(REGION_PATH);
+      expectedName = MBeanJMXAdapter.getDistributedRegionMbeanName(REGION_PATH);
+      assertThat(actualName).isEqualTo(expectedName);
 
-        assertNotNull(service.getDistributedSystemMXBean());
+      for (String memberId : memberIds) {
+        ObjectName objectName = MBeanJMXAdapter.getMemberMBeanName(memberId);
+        awaitMemberMXBeanProxy(objectName);
 
-        waitForAllMembers(4);
-        assertTrue(bean.listDistributedRegionObjectNames().length == 2);
-        try {
-          assertNotNull(bean.fetchDistributedRegionObjectName(PARTITIONED_REGION_PATH));
-          assertNotNull(bean.fetchDistributedRegionObjectName(REGION_PATH));
-          ObjectName actualName = bean.fetchDistributedRegionObjectName(PARTITIONED_REGION_PATH);
-          ObjectName expectedName =
-              MBeanJMXAdapter.getDistributedRegionMbeanName(PARTITIONED_REGION_PATH);
-          assertEquals(expectedName, actualName);
+        ObjectName[] objectNames = distributedSystemMXBean.fetchRegionObjectNames(objectName);
+        assertThat(objectNames).isNotNull();
+        assertThat(objectNames).hasSize(2);
 
-          actualName = bean.fetchDistributedRegionObjectName(REGION_PATH);
-          expectedName = MBeanJMXAdapter.getDistributedRegionMbeanName(REGION_PATH);
-          assertEquals(expectedName, actualName);
+        List<ObjectName> listOfNames = Arrays.asList(objectNames);
 
-        } catch (Exception e) {
-          fail("fetchDistributedRegionObjectName () Unsuccessful " + e);
-        }
+        expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, PARTITIONED_REGION_PATH);
+        assertThat(listOfNames).contains(expectedName);
 
-        for (String memberId : managedNodeMemberIds) {
-          ObjectName memberMBeanName = MBeanJMXAdapter.getMemberMBeanName(memberId);
-          ObjectName expectedName;
-          try {
-            waitForProxy(memberMBeanName, MemberMXBean.class);
-
-            ObjectName[] regionMBeanNames = bean.fetchRegionObjectNames(memberMBeanName);
-            assertNotNull(regionMBeanNames);
-            assertTrue(regionMBeanNames.length == 2);
-            List<ObjectName> listOfNames = Arrays.asList(regionMBeanNames);
-
-            expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, PARTITIONED_REGION_PATH);
-            listOfNames.contains(expectedName);
-            expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, REGION_PATH);
-            listOfNames.contains(expectedName);
-          } catch (Exception e) {
-            fail("fetchRegionObjectNames () Unsuccessful " + e);
-          }
-        }
+        expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, REGION_PATH);
+        assertThat(listOfNames).contains(expectedName);
+      }
 
-        for (String memberId : managedNodeMemberIds) {
-          ObjectName expectedName;
-          ObjectName actualName;
-          ObjectName memberMBeanName = MBeanJMXAdapter.getMemberMBeanName(memberId);
-          try {
-            waitForProxy(memberMBeanName, MemberMXBean.class);
-            expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, PARTITIONED_REGION_PATH);
-            waitForProxy(expectedName, RegionMXBean.class);
-            actualName = bean.fetchRegionObjectName(memberId, PARTITIONED_REGION_PATH);
-
-            assertEquals(expectedName, actualName);
-            expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, REGION_PATH);
-            waitForProxy(expectedName, RegionMXBean.class);
-            actualName = bean.fetchRegionObjectName(memberId, REGION_PATH);
-
-            assertEquals(expectedName, actualName);
-          } catch (Exception e) {
-            fail("fetchRegionObjectName () Unsuccessful ");
-          }
-        }
+      for (String memberId : memberIds) {
+        ObjectName objectName = MBeanJMXAdapter.getMemberMBeanName(memberId);
+        awaitMemberMXBeanProxy(objectName);
 
-      }
-    };
-    vm.invoke(checkNavigationAPIS);
-  }
+        expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, PARTITIONED_REGION_PATH);
+        awaitRegionMXBeanProxy(expectedName);
 
+        actualName =
+            distributedSystemMXBean.fetchRegionObjectName(memberId, PARTITIONED_REGION_PATH);
+        assertThat(actualName).isEqualTo(expectedName);
 
-  protected void putBulkData(final VM vm, final int numKeys) {
-    SerializableRunnable putBulkData = new SerializableRunnable("putBulkData") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        Region region = cache.getRegion(REGION_PATH);
-        for (int i = 0; i < numKeys; i++) {
-          region.put(i, i * i);
-        }
+        expectedName = MBeanJMXAdapter.getRegionMBeanName(memberId, REGION_PATH);
+        awaitRegionMXBeanProxy(expectedName);
 
+        actualName = distributedSystemMXBean.fetchRegionObjectName(memberId, REGION_PATH);
+        assertThat(actualName).isEqualTo(expectedName);
       }
-    };
-    vm.invoke(putBulkData);
+    });
   }
 
-
-
   /**
-   * creates a Fixed Partition List to be used for Fixed Partition Region
-   * 
-   * @param primaryIndex index for each fixed partition
+   * Invoked in controller VM
    */
-  private static void createFixedPartitionList(int primaryIndex) {
-    fpaList.clear();
+  private List<FixedPartitionAttributes> createFixedPartitionList(final int primaryIndex) {
+    List<FixedPartitionAttributes> fixedPartitionAttributesList = new ArrayList<>();
     if (primaryIndex == 1) {
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q1", true, 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q2", 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q3", 3));
+      fixedPartitionAttributesList
+          .add(FixedPartitionAttributes.createFixedPartition("Q1", true, 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q2", 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q3", 3));
     }
     if (primaryIndex == 2) {
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q1", 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q2", true, 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q3", 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q1", 3));
+      fixedPartitionAttributesList
+          .add(FixedPartitionAttributes.createFixedPartition("Q2", true, 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q3", 3));
     }
     if (primaryIndex == 3) {
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q1", 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q2", 3));
-      fpaList.add(FixedPartitionAttributes.createFixedPartition("Q3", true, 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q1", 3));
+      fixedPartitionAttributesList.add(FixedPartitionAttributes.createFixedPartition("Q2", 3));
+      fixedPartitionAttributesList
+          .add(FixedPartitionAttributes.createFixedPartition("Q3", true, 3));
     }
-
+    return fixedPartitionAttributesList;
   }
 
-
-
   /**
-   * Creates a Fixed Partitioned Region
-   * 
-   * @param fpaList partition list
+   * Invoked in member VMs
    */
-  protected static void createFixedPartitionRegion(List<FixedPartitionAttributes> fpaList) {
-    GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-    SystemManagementService service = (SystemManagementService) getManagementService();
+  private void createFixedPartitionRegion(
+      final List<FixedPartitionAttributes> fixedPartitionAttributesList) {
+    SystemManagementService service = getSystemManagementService_tmp();
 
-    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
 
-    paf.setRedundantCopies(2).setTotalNumBuckets(12);
-    for (FixedPartitionAttributes fpa : fpaList) {
-      paf.addFixedPartitionAttributes(fpa);
+    partitionAttributesFactory.setRedundantCopies(2).setTotalNumBuckets(12);
+    for (FixedPartitionAttributes fixedPartitionAttributes : fixedPartitionAttributesList) {
+      partitionAttributesFactory.addFixedPartitionAttributes(fixedPartitionAttributes);
     }
-    paf.setPartitionResolver(new SingleHopQuarterPartitionResolver());
-
-    AttributesFactory attr = new AttributesFactory();
-    attr.setPartitionAttributes(paf.create());
-    fixedPrRegion = cache.createRegion(FIXED_PR_NAME, attr.create());
-    assertNotNull(fixedPrRegion);
-    LogWriterUtils.getLogWriter().info("Partitioned Region " + FIXED_PR_NAME
-        + " created Successfully :" + fixedPrRegion.toString());
-
-    RegionMXBean bean = service.getLocalRegionMBean(FIXED_PR_PATH);
-    RegionAttributes regAttrs = fixedPrRegion.getAttributes();
-
-    LogWriterUtils.getLogWriter().info("FixedPartitionAttribute From GemFire :"
-        + regAttrs.getPartitionAttributes().getFixedPartitionAttributes());
+    partitionAttributesFactory.setPartitionResolver(new SingleHopQuarterPartitionResolver());
 
-    RegionAttributesData data = bean.listRegionAttributes();
+    AttributesFactory attributesFactory = new AttributesFactory();
+    attributesFactory.setPartitionAttributes(partitionAttributesFactory.create());
 
-    PartitionAttributesData parData = bean.listPartitionAttributes();
+    fixedPartitionedRegion = getCache_tmp().createRegion(FIXED_PR_NAME, attributesFactory.create());
+    assertThat(fixedPartitionedRegion).isNotNull();
 
-    assertPartitionData(regAttrs, parData);
+    RegionMXBean regionMXBean = service.getLocalRegionMBean(FIXED_PR_PATH);
+    RegionAttributes regionAttributes = fixedPartitionedRegion.getAttributes();
 
-    FixedPartitionAttributesData[] fixedPrData = bean.listFixedPartitionAttributes();
+    PartitionAttributesData partitionAttributesData = regionMXBean.listPartitionAttributes();
+    verifyPartitionData(regionAttributes, partitionAttributesData);
 
-    assertNotNull(fixedPrData);
+    FixedPartitionAttributesData[] fixedPartitionAttributesData =
+        regionMXBean.listFixedPartitionAttributes();
+    assertThat(fixedPartitionAttributesData).isNotNull();
+    assertThat(fixedPartitionAttributesData).hasSize(3);
 
-    assertEquals(3, fixedPrData.length);
-    for (int i = 0; i < fixedPrData.length; i++) {
-      LogWriterUtils.getLogWriter()
-          .info("<ExpectedString> Fixed PR Data is " + fixedPrData[i] + "</ExpectedString> ");
+    for (int i = 0; i < fixedPartitionAttributesData.length; i++) {
+      // LogWriterUtils.getLogWriter().info("<ExpectedString> Fixed PR Data is " +
+      // fixedPartitionAttributesData[i] + "</ExpectedString> ");
     }
   }
 
-  /**
-   * Verifies the Fixed Partition Region for partition related attributes
-   * 
-   * @param vm
-   */
-  protected void validateRemoteFixedPartitionRegion(final VM vm) throws Exception {
-    SerializableRunnable verifyFixedRegion = new SerializableRunnable("Verify Partition region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        Set<DistributedMember> otherMemberSet =
-            cache.getDistributionManager().getOtherNormalDistributionManagerIds();
-
-        for (DistributedMember member : otherMemberSet) {
-          RegionMXBean bean = null;
-          try {
-            bean = MBeanUtil.getRegionMbeanProxy(member, FIXED_PR_PATH);
-          } catch (Exception e) {
-            InternalDistributedSystem.getLoggerI18n()
-                .fine("Undesired Result , RegionMBean Should not be null");
-          }
-          PartitionAttributesData data = bean.listPartitionAttributes();
-          assertNotNull(data);
-          FixedPartitionAttributesData[] fixedPrData = bean.listFixedPartitionAttributes();
-          assertNotNull(fixedPrData);
-          assertEquals(3, fixedPrData.length);
-          for (int i = 0; i < fixedPrData.length; i++) {
-            LogWriterUtils.getLogWriter().info(
-                "<ExpectedString> Remote PR Data is " + fixedPrData[i] + "</ExpectedString> ");
-          }
-        }
-
+  // /**
+  // * Invoked in manager VM
+  // */
+  // private void verifyRemoteFixedPartitionRegion(final VM vm) throws Exception {
+  // vm.invoke("Verify Partition region", () -> {
+  // Set<DistributedMember> otherMemberSet =
+  // getDistributionManager_tmp().getOtherNormalDistributionManagerIds();
+  //
+  // for (DistributedMember member : otherMemberSet) {
+  // RegionMXBean regionMXBean = awaitRegionMXBeanProxy(member, FIXED_PR_PATH);
+  //
+  // PartitionAttributesData partitionAttributesData = regionMXBean.listPartitionAttributes();
+  // assertNotNull(partitionAttributesData);
+  //
+  // FixedPartitionAttributesData[] fixedPartitionAttributesData =
+  // regionMXBean.listFixedPartitionAttributes();
+  // assertNotNull(fixedPartitionAttributesData);
+  // assertEquals(3, fixedPartitionAttributesData.length);
+  //
+  // for (int i = 0; i < fixedPartitionAttributesData.length; i++) {
+  // //LogWriterUtils.getLogWriter().info("<ExpectedString> Remote PR Data is " +
+  // fixedPartitionAttributesData[i] + "</ExpectedString> ");
+  // }
+  // }
+  // });
+  // }
+
+  private void addMemberNotificationListener(final VM managerVM, final int expectedMembers) {
+    managerVM.invoke("addMemberNotificationListener", () -> {
+      Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
+      assertThat(otherMemberSet).hasSize(expectedMembers);
+
+      SystemManagementService service = getSystemManagementService_tmp();
+
+      List<Notification> notifications = new ArrayList<>();
+      MEMBER_NOTIFICATIONS_REF.set(notifications);
+
+      for (DistributedMember member : otherMemberSet) {
+        MemberNotificationListener listener = new MemberNotificationListener(notifications);
+        ObjectName objectName = service.getMemberMBeanName(member);
+        awaitMemberMXBeanProxy(objectName);
+
+        ManagementFactory.getPlatformMBeanServer().addNotificationListener(objectName, listener,
+            null, null);
       }
-
-    };
-    vm.invoke(verifyFixedRegion);
-  }
-
-  /**
-   * Add a Notification listener to MemberMBean
-   * 
-   * @param vm
-   */
-  protected void addMemberListener(final VM vm) {
-    SerializableRunnable addMemberListener = new SerializableRunnable("addMemberListener") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-
-        SystemManagementService service = (SystemManagementService) getManagementService();
-
-        Set<DistributedMember> otherMemberSet =
-            cache.getDistributionManager().getOtherNormalDistributionManagerIds();
-
-        for (DistributedMember member : otherMemberSet) {
-
-          MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-
-          RegionNotif regionCreate = new RegionNotif();
-
-          ObjectName memberMBeanName;
-          try {
-            memberMBeanName = service.getMemberMBeanName(member);
-            Set<ObjectName> names = service.queryMBeanNames(member);
-            if (names != null) {
-              for (ObjectName name : names) {
-                LogWriterUtils.getLogWriter()
-                    .info("<ExpectedString> ObjectNames arr" + name + "</ExpectedString> ");
-              }
-            }
-            waitForProxy(memberMBeanName, MemberMXBean.class);
-            mbeanServer.addNotificationListener(memberMBeanName, regionCreate, null, null);
-          } catch (NullPointerException e) {
-            Assert.fail("FAILED WITH EXCEPION", e);
-          } catch (InstanceNotFoundException e) {
-            Assert.fail("FAILED WITH EXCEPION", e);
-          } catch (Exception e) {
-            Assert.fail("FAILED WITH EXCEPION", e);
-          }
-
-        }
-
-      }
-    };
-    vm.invoke(addMemberListener);
-
+    });
   }
 
   /**
    * Add a Notification listener to DistributedSystemMBean which should gather all the notifications
    * which are propagated through all individual MemberMBeans Hence Region created/destroyed should
    * be visible to this listener
-   * 
-   * @param vm
    */
-  protected void addDistrListener(final VM vm) {
-    SerializableRunnable addDistrListener = new SerializableRunnable("addDistrListener") {
-      public void run() {
-        MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-
-        DistrNotif regionCreate = new DistrNotif();
-
-        ObjectName systemMBeanName;
-        try {
-          systemMBeanName = MBeanJMXAdapter.getDistributedSystemName();
-          mbeanServer.addNotificationListener(systemMBeanName, regionCreate, null, null);
-
-        } catch (NullPointerException e) {
-          Assert.fail("FAILED WITH EXCEPION", e);
-        } catch (InstanceNotFoundException e) {
-          Assert.fail("FAILED WITH EXCEPION", e);
+  private void addSystemNotificationListener(final VM managerVM) {
+    managerVM.invoke("addSystemNotificationListener", () -> {
+      awaitDistributedSystemMXBean();
+
+      List<Notification> notifications = new ArrayList<>();
+      SYSTEM_NOTIFICATIONS_REF.set(notifications);
+
+      DistributedSystemNotificationListener listener =
+          new DistributedSystemNotificationListener(notifications);
+      ObjectName objectName = MBeanJMXAdapter.getDistributedSystemName();
+      ManagementFactory.getPlatformMBeanServer().addNotificationListener(objectName, listener, null,
+          null);
+    });
+  }
 
+  private void verifyMemberNotifications(final VM managerVM, final String regionName,
+      final int expectedMembers) {
+    managerVM.invoke("verifyMemberNotifications", () -> {
+      assertThat(MEMBER_NOTIFICATIONS_REF.get()).isNotNull();
+      assertThat(MEMBER_NOTIFICATIONS_REF.get()).hasSize(expectedMembers * 2);
+
+      int regionCreatedCount = 0;
+      int regionDestroyedCount = 0;
+      for (Notification notification : MEMBER_NOTIFICATIONS_REF.get()) {
+        if (JMXNotificationType.REGION_CREATED.equals(notification.getType())) {
+          regionCreatedCount++;
+          assertThat(notification.getMessage()).contains(regionName);
+        } else if (JMXNotificationType.REGION_CLOSED.equals(notification.getType())) {
+          regionDestroyedCount++;
+          assertThat(notification.getMessage()).contains(regionName);
+        } else {
+          fail("Unexpected notification type: " + notification.getType());
         }
-
       }
-    };
-    vm.invoke(addDistrListener);
 
+      assertThat(regionCreatedCount).isEqualTo(expectedMembers);
+      assertThat(regionDestroyedCount).isEqualTo(expectedMembers);
+    });
   }
 
-  public void ensureProxyCleanup(final VM vm) {
-
-    SerializableRunnable ensureProxyCleanup = new SerializableRunnable("Ensure Proxy cleanup") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        Set<DistributedMember> otherMemberSet =
-            cache.getDistributionManager().getOtherNormalDistributionManagerIds();
-
-        final SystemManagementService service = (SystemManagementService) getManagementService();
-
-        for (final DistributedMember member : otherMemberSet) {
-          RegionMXBean bean = null;
-          try {
-
-            Wait.waitForCriterion(new WaitCriterion() {
-
-              RegionMXBean bean = null;
-
-              public String description() {
-                return "Waiting for the proxy to get deleted at managing node";
-              }
-
-              public boolean done() {
-                ObjectName objectName = service.getRegionMBeanName(member, REGION_PATH);
-                bean = service.getMBeanProxy(objectName, RegionMXBean.class);
-                boolean done = (bean == null);
-                return done;
-              }
-
-            }, MAX_WAIT, 500, true);
-
-          } catch (Exception e) {
-            fail("could not remove proxies in required time");
-
-          }
-          assertNull(bean);
-
+  // <[javax.management.Notification[source=10.118.33.232(17632)<v1>-32770][type=gemfire.distributedsystem.cache.region.created][message=Region
+  // Created With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=10.118.33.232(17633)<v2>-32771][type=gemfire.distributedsystem.cache.region.created][message=Region
+  // Created With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=10.118.33.232(17634)<v3>-32772][type=gemfire.distributedsystem.cache.region.created][message=Region
+  // Created With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=10.118.33.232(17632)<v1>-32770][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=10.118.33.232(17633)<v2>-32771][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=10.118.33.232(17634)<v3>-32772][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION]]>
+
+  private void verifySystemNotifications(final VM managerVM, final String regionName,
+      final int expectedMembers) {
+    managerVM.invoke("verifySystemNotifications", () -> {
+      assertThat(SYSTEM_NOTIFICATIONS_REF.get()).isNotNull();
+      assertThat(SYSTEM_NOTIFICATIONS_REF.get()).hasSize(expectedMembers + 2); // 2 for the manager
+
+
+      int regionCreatedCount = 0;
+      int regionDestroyedCount = 0;
+      for (Notification notification : SYSTEM_NOTIFICATIONS_REF.get()) {
+        if (JMXNotificationType.REGION_CREATED.equals(notification.getType())) {
+          regionCreatedCount++;
+          assertThat(notification.getMessage()).contains(regionName);
+        } else if (JMXNotificationType.REGION_CLOSED.equals(notification.getType())) {
+          regionDestroyedCount++;
+          assertThat(notification.getMessage()).contains(regionName);
+        } else {
+          fail("Unexpected notification type: " + notification.getType());
         }
-
       }
-    };
-    vm.invoke(ensureProxyCleanup);
-  }
-
-  /**
-   * Verifies a Remote Distributed Region
-   * 
-   * @param vm
-   */
-  protected void verifyRemoteDistributedRegion(final VM vm, final int expectedMembers)
-      throws Exception {
-    SerializableRunnable verifyRegion = new SerializableRunnable("Verify Distributed region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        Set<DistributedMember> otherMemberSet =
-            cache.getDistributionManager().getOtherNormalDistributionManagerIds();
-
-        for (DistributedMember member : otherMemberSet) {
-          RegionMXBean bean = null;
-          try {
-            bean = MBeanUtil.getRegionMbeanProxy(member, REGION_PATH);
-          } catch (Exception e) {
-            InternalDistributedSystem.getLoggerI18n()
-                .fine("Undesired Result , RegionMBean Should not be null" + e);
-
-          }
-          assertNotNull(bean);
-
-          RegionAttributesData data = bean.listRegionAttributes();
-          assertNotNull(data);
-          MembershipAttributesData membershipData = bean.listMembershipAttributes();
-          EvictionAttributesData evictionData = bean.listEvictionAttributes();
-          assertNotNull(membershipData);
-          assertNotNull(evictionData);
-          LogWriterUtils.getLogWriter().info("<ExpectedString> Membership Data is "
-              + membershipData.toString() + "</ExpectedString> ");
-          LogWriterUtils.getLogWriter().info("<ExpectedString> Eviction Data is "
-              + membershipData.toString() + "</ExpectedString> ");
-
-        }
-        DistributedRegionMXBean bean = null;
-        try {
-          bean = MBeanUtil.getDistributedRegionMbean(REGION_PATH, expectedMembers);
-        } catch (Exception e) {
-          InternalDistributedSystem.getLoggerI18n()
-              .fine("Undesired Result , DistributedRegionMXBean Should not be null" + e);
-        }
-
-        assertNotNull(bean);
-        assertEquals(REGION_PATH, bean.getFullPath());
 
+      assertThat(regionCreatedCount).isEqualTo(1); // just the manager
+      assertThat(regionDestroyedCount).isEqualTo(expectedMembers + 1); // all 3 members + manager
+    });
+  }
 
+  // <[javax.management.Notification[source=192.168.1.72(18496)<v27>-32770][type=gemfire.distributedsystem.cache.region.created][message=Region
+  // Created With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=192.168.1.72(18497)<v28>-32771][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=192.168.1.72(18498)<v29>-32772][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=192.168.1.72(18499)<v30>-32773][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION],
+  // javax.management.Notification[source=192.168.1.72(18496)<v27>-32770][type=gemfire.distributedsystem.cache.region.closed][message=Region
+  // Destroyed/Closed With Name /MANAGEMENT_TEST_REGION]]>
+
+  private void verifyProxyCleanup(final VM managerVM) {
+    managerVM.invoke("verifyProxyCleanup", () -> {
+      SystemManagementService service = getSystemManagementService_tmp();
+
+      Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
+      for (final DistributedMember member : otherMemberSet) {
+        String alias = "Waiting for the proxy to get deleted at managing node";
+        await(alias).until(
+            () -> assertThat(service.getMBeanProxy(service.getRegionMBeanName(member, REGION_PATH),
+                RegionMXBean.class)).isNull());
       }
-    };
-    vm.invoke(verifyRegion);
+    });
   }
 
+  private void verifyRemoteDistributedRegion(final VM managerVM, final int expectedMembers)
+      throws Exception {
+    managerVM.invoke("verifyRemoteDistributedRegion", () -> {
+      Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
+      assertThat(otherMemberSet).hasSize(expectedMembers);
 
-  protected void validateDistributedMBean(final VM vm, final int expectedMembers) {
-    SerializableRunnable verifyRegion = new SerializableRunnable("Verify Distributed region") {
-      public void run() {
-        DistributedRegionMXBean bean = null;
-        DistributedSystemMXBean sysMBean = null;
-        final ManagementService service = getManagementService();
-
-        if (expectedMembers == 0) {
-          try {
-            Wait.waitForCriterion(new WaitCriterion() {
-
-              RegionMXBean bean = null;
-
-              public String description() {
-                return "Waiting for the proxy to get deleted at managing node";
-              }
-
-              public boolean done() {
-                DistributedRegionMXBean bean = service.getDistributedRegionMXBean(REGION_PATH);
-                boolean done = (bean == null);
-                return done;
-              }
+      for (DistributedMember member : otherMemberSet) {
+        RegionMXBean regionMXBean = awaitRegionMXBeanProxy(member, REGION_PATH);
 
-            }, MAX_WAIT, 500, true);
+        RegionAttributesData regionAttributesData = regionMXBean.listRegionAttributes();
+        assertThat(regionAttributesData).isNotNull();
 
-          } catch (Exception e) {
-            fail("could not remove Aggregate Bean in required time");
+        MembershipAttributesData membershipAttributesData = regionMXBean.listMembershipAttributes();
+        assertThat(membershipAttributesData).isNotNull();
 
-          }
-          return;
-        }
-
-        try {
-          bean = MBeanUtil.getDistributedRegionMbean(REGION_PATH, expectedMembers);
-          sysMBean = service.getDistributedSystemMXBean();
-        } catch (Exception e) {
-          InternalDistributedSystem.getLoggerI18n()
-              .fine("Undesired Result , DistributedRegionMXBean Should not be null" + e);
-        }
+        EvictionAttributesData evictionAttributesData = regionMXBean.listEvictionAttributes();
+        assertThat(evictionAttributesData).isNotNull();
+      }
 
-        assertNotNull(bean);
-        assertEquals(REGION_PATH, bean.getFullPath());
-        assertEquals(expectedMembers, bean.getMemberCount());
-        assertEquals(expectedMembers, bean.getMembers().length);
+      DistributedRegionMXBean distributedRegionMXBean =
+          awaitDistributedRegionMXBean(REGION_PATH, expectedMembers);
 
-        // Check Stats related Data
-        // Add Mock testing
-        LogWriterUtils.getLogWriter().info("<ExpectedString> CacheListenerCallsAvgLatency is "
-            + bean.getCacheListenerCallsAvgLatency() + "</ExpectedString> ");
-        LogWriterUtils.getLogWriter().info("<ExpectedString> CacheWriterCallsAvgLatency is "
-            + bean.getCacheWriterCallsAvgLatency() + "</ExpectedString> ");
-        LogWriterUtils.getLogWriter().info(
-            "<ExpectedString> CreatesRate is " + bean.getCreatesRate() + "</ExpectedString> ");
+      assertThat(distributedRegionMXBean).isNotNull();
+      assertThat(distributedRegionMXBean.getFullPath()).isEqualTo(REGION_PATH);
+    });
+  }
 
+  private void verifyDistributedMBean(final VM managerVM, final int expectedMembers) {
+    managerVM.invoke("verifyDistributedMBean", () -> {
+      if (expectedMembers == 0) {
+        ManagementService service = getManagementService_tmp();
+        String alias = "Waiting for the proxy to get deleted at managing node";
+        await(alias)
+            .until(() -> assertThat(service.getDistributedRegionMXBean(REGION_PATH)).isNull());
+        return;
       }
-    };
-    // Test DistributedRegionMXBean
 
-    vm.invoke(verifyRegion);
+      DistributedRegionMXBean distributedRegionMXBean =
+          awaitDistributedRegionMXBean(REGION_PATH, expectedMembers);
+
+      assertThat(distributedRegionMXBean.getFullPath()).isEqualTo(REGION_PATH);
+      assertThat(distributedRegionMXBean.getMemberCount()).isEqualTo(expectedMembers);
+      assertThat(distributedRegionMXBean.getMembers()).hasSize(expectedMembers);
+
+      // Check Stats related Data
+      // LogWriterUtils.getLogWriter().info("<ExpectedString> CacheListenerCallsAvgLatency is " +
+      // distributedRegionMXBean.getCacheListenerCallsAvgLatency() + "</ExpectedString> ");
+      // LogWriterUtils.getLogWriter().info("<ExpectedString> CacheWriterCallsAvgLatency is " +
+      // distributedRegionMXBean.getCacheWriterCallsAvgLatency() + "</ExpectedString> ");
+      // LogWriterUtils.getLogWriter().info("<ExpectedString> CreatesRate is " +
+      // distributedRegionMXBean.getCreatesRate() + "</ExpectedString> ");
+    });
   }
 
-  /**
-   * Verifies a Remote Partition Region
-   * 
-   * @param vm
-   */
-  protected void validateRemotePartitionRegion(final VM vm) throws Exception {
-    SerializableRunnable verifyRegion = new SerializableRunnable("Verify Partition region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        Set<DistributedMember> otherMemberSet =
-            cache.getDistributionManager().getOtherNormalDistributionManagerIds();
-
-        for (DistributedMember member : otherMemberSet) {
-          RegionMXBean bean = null;
-          try {
-            bean = MBeanUtil.getRegionMbeanProxy(member, PARTITIONED_REGION_PATH);
-          } catch (Exception e) {
-            InternalDistributedSystem.getLoggerI18n()
-                .fine("Undesired Result , RegionMBean Should not be null");
-          }
-          PartitionAttributesData data = bean.listPartitionAttributes();
-          assertNotNull(data);
-        }
-
-        ManagementService service = getManagementService();
-        DistributedRegionMXBean bean = service.getDistributedRegionMXBean(PARTITIONED_REGION_PATH);
-        assertEquals(3, bean.getMembers().length);
+  private void verifyRemotePartitionRegion(final VM managerVM) throws Exception {
+    managerVM.invoke("verifyRemotePartitionRegion", () -> {
+      Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
 
+      for (DistributedMember member : otherMemberSet) {
+        RegionMXBean regionMXBean = awaitRegionMXBeanProxy(member, PARTITIONED_REGION_PATH);
+        PartitionAttributesData partitionAttributesData = regionMXBean.listPartitionAttributes();
+        assertThat(partitionAttributesData).isNotNull();
       }
 
-    };
-    vm.invoke(verifyRegion);
+      ManagementService service = getManagementService_tmp();
+      DistributedRegionMXBean distributedRegionMXBean =
+          service.getDistributedRegionMXBean(PARTITIONED_REGION_PATH);
+      assertThat(distributedRegionMXBean.getMembers()).hasSize(3);
+    });
   }
 
+  private void verifyReplicateRegionAfterCreate(final VM memberVM) {
+    memberVM.invoke("verifyReplicateRegionAfterCreate", () -> {
+      Cache cache = getCache_tmp();
 
+      String memberId =
+          MBeanJMXAdapter.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
+      ObjectName objectName = ObjectName.getInstance("GemFire:type=Member,member=" + memberId);
 
-  /**
-   * Creates a Distributed Region
-   * 
-   * @param vm
-   */
-  protected void validateReplicateRegionAfterCreate(final VM vm) {
-    SerializableRunnable checkDistributedRegion =
-        new SerializableRunnable("Check Distributed region") {
-          public void run() {
-
-            GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-            SystemManagementService service = (SystemManagementService) getManagementService();
-
-            MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
-            RegionNotif test = new RegionNotif();
-
-            String memberId = MBeanJMXAdapter
-                .getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
-
-            ObjectName memberMBeanName;
-            try {
-              memberMBeanName = ObjectName.getInstance("GemFire:type=Member,member=" + memberId);
-              mbeanServer.addNotificationListener(memberMBeanName, test, null, null);
-            } catch (MalformedObjectNameException e) {
-
-              Assert.fail("FAILED WITH EXCEPION", e);
-            } catch (NullPointerException e) {
-              Assert.fail("FAILED WITH EXCEPION", e);
-
-            } catch (InstanceNotFoundException e) {
-              Assert.fail("FAILED WITH EXCEPION", e);
+      // List<Notification> notifications = new ArrayList<>();
+      // MEMBER_NOTIFICATIONS_REF.set(notifications);
+      //
+      // MemberNotificationListener listener = new MemberNotificationListener(notifications);
+      // ManagementFactory.getPlatformMBeanServer().addNotificationListener(objectName, listener,
+      // null, null);
 
-            }
+      SystemManagementService service = getSystemManagementService_tmp();
+      RegionMXBean regionMXBean = service.getLocalRegionMBean(REGION_PATH);
+      assertThat(regionMXBean).isNotNull();
 
-            assertNotNull(service.getLocalRegionMBean(REGION_PATH));
+      Region region = cache.getRegion(REGION_PATH);
+      RegionAttributes regionAttributes = region.getAttributes();
 
-            RegionMXBean bean = service.getLocalRegionMBean(REGION_PATH);
-            Region region = cache.getRegion(REGION_PATH);
+      RegionAttributesData regionAttributesData = regionMXBean.listRegionAttributes();
+      verifyRegionAttributes(regionAttributes, regionAttributesData);
 
-            RegionAttributes regAttrs = region.getAttributes();
+      MembershipAttributesData membershipData = regionMXBean.listMembershipAttributes();
+      assertThat(membershipData).isNotNull();
 
-            RegionAttributesData data = bean.listRegionAttributes();
-
-            assertRegionAttributes(regAttrs, data);
-            MembershipAttributesData membershipData = bean.listMembershipAttributes();
-            EvictionAttributesData evictionData = bean.listEvictionAttributes();
-            assertNotNull(membershipData);
-            assertNotNull(evictionData);
-            LogWriterUtils.getLogWriter().info("<ExpectedString> Membership Data is "
-                + membershipData.toString() + "</ExpectedString> ");
-            LogWriterUtils.getLogWriter().info("<ExpectedString> Eviction Data is "
-                + membershipData.toString() + "</ExpectedString> ");
-          }
-        };
-    vm.invoke(checkDistributedRegion);
+      EvictionAttributesData evictionData = regionMXBean.listEvictionAttributes();
+      assertThat(evictionData).isNotNull();
+    });
   }
 
-  /**
-   * Creates a partition Region
-   * 
-   * @param vm
-   */
-  protected void validatePartitionRegionAfterCreate(final VM vm) {
-    SerializableRunnable createParRegion = new SerializableRunnable("Create Partitioned region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        SystemManagementService service = (SystemManagementService) getManagementService();
-        assertNotNull(service.getLocalRegionMBean(PARTITIONED_REGION_PATH));
-        RegionMXBean bean = service.getLocalRegionMBean(PARTITIONED_REGION_PATH);
-        Region partitionedRegion = cache.getRegion(PARTITIONED_REGION_PATH);
-        RegionAttributes regAttrs = partitionedRegion.getAttributes();
-        RegionAttributesData data = bean.listRegionAttributes();
-        PartitionAttributesData parData = bean.listPartitionAttributes();
-        assertPartitionData(regAttrs, parData);
+  private void verifyPartitionRegionAfterCreate(final VM memberVM) {
+    memberVM.invoke("verifyPartitionRegionAfterCreate", () -> {
+      Region region = getCache_tmp().getRegion(PARTITIONED_REGION_PATH);
 
-      }
-    };
-    vm.invoke(createParRegion);
-  }
+      SystemManagementService service = getSystemManagementService_tmp();
+      RegionMXBean regionMXBean = service.getLocalRegionMBean(PARTITIONED_REGION_PATH);
 
-  /**
-   * closes a Distributed Region
-   * 
-   * @param vm
-   */
-  protected void validateReplicatedRegionAfterClose(final VM vm) {
-    SerializableRunnable closeRegion = new SerializableRunnable("Close Distributed region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        SystemManagementService service = (SystemManagementService) getManagementService();
-        RegionMXBean bean = null;
-        try {
-          bean = service.getLocalRegionMBean(REGION_PATH);
-        } catch (ManagementException mgtEx) {
-          LogWriterUtils.getLogWriter().info("<ExpectedString> Expected Exception  "
-              + mgtEx.getLocalizedMessage() + "</ExpectedString> ");
-        }
-        assertNull(bean);
-        ObjectName regionObjectName = service
-            .getRegionMBeanName(cache.getDistributedSystem().getDistributedMember(), REGION_PATH);
-        assertNull(service.getLocalManager().getManagementResourceRepo()
-            .getEntryFromLocalMonitoringRegion(regionObjectName));
-      }
-    };
-    vm.invoke(closeRegion);
+      verifyPartitionData(region.getAttributes(), regionMXBean.listPartitionAttributes());
+    });
   }
 
-  /**
-   * close a partition Region
-   * 
-   * @param vm
-   */
-  protected void validatePartitionRegionAfterClose(final VM vm) {
-    SerializableRunnable closeParRegion = new SerializableRunnable("Close Partition region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        ManagementService service = getManagementService();
-        LogWriterUtils.getLogWriter().info("Closing Par Region");
-        RegionMXBean bean = null;
-        try {
-          bean = service.getLocalRegionMBean(PARTITIONED_REGION_PATH);
-        } catch (ManagementException mgtEx) {
-          LogWriterUtils.getLogWriter().info("<ExpectedString> Expected Exception  "
-              + mgtEx.getLocalizedMessage() + "</ExpectedString> ");
-        }
-        assertNull(bean);
-      }
-    };
-    vm.invoke(closeParRegion);
+  private void verifyReplicatedRegionAfterClose(final VM memberVM) {
+    memberVM.invoke("verifyReplicatedRegionAfterClose", () -> {
+      SystemManagementService service = getSystemManagementService_tmp();
+      RegionMXBean regionMXBean = service.getLocalRegionMBean(REGION_PATH);
+      assertThat(regionMXBean).isNull();
+
+      ObjectName objectName = service.getRegionMBeanName(
+          getCache_tmp().getDistributedSystem().getDistributedMember(), REGION_PATH);
+      assertThat(service.getLocalManager().getManagementResourceRepo()
+          .getEntryFromLocalMonitoringRegion(objectName)).isNull();
+    });
   }
 
-  /**
-   * Closes Fixed Partition region
-   * 
-   * @param vm
-   */
-  protected void closeFixedPartitionRegion(final VM vm) {
-    SerializableRunnable closeParRegion = new SerializableRunnable("Close Fixed Partition region") {
-      public void run() {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        ManagementService service = getManagementService();
-        LogWriterUtils.getLogWriter().info("Closing Fixed Par Region");
-        Region region = cache.getRegion(FIXED_PR_PATH);
-        region.close();
-        RegionMXBean bean = null;
-        try {
-          bean = service.getLocalRegionMBean(FIXED_PR_PATH);
-        } catch (ManagementException mgtEx) {
-          LogWriterUtils.getLogWriter().info("<ExpectedString> Expected Exception  "
-              + mgtEx.getLocalizedMessage() + "</ExpectedString> ");
-        }
-        assertNull(bean);
-      }
-    };
-    vm.invoke(closeParRegion);
+  private void verifyPartitionRegionAfterClose(final VM memberVM) {
+    memberVM.invoke("verifyPartitionRegionAfterClose", () -> {
+      ManagementService service = getManagementService_tmp();
+      RegionMXBean regionMXBean = service.getLocalRegionMBean(PARTITIONED_REGION_PATH);
+      assertThat(regionMXBean).isNull();
+    });
   }
 
   /**
-   * Asserts and verifies all the partition related data
-   * 
-   * @param regAttrs
-   * @param partitionAttributesData
+   * Invoked in member VMs
    */
+  private void verifyPartitionData(final RegionAttributes expectedRegionAttributes,
+      final PartitionAttributesData partitionAttributesData) {
+    PartitionAttributes expectedPartitionAttributes =
+        expectedRegionAttributes.getPartitionAttributes();
 
-  protected static void assertPartitionData(RegionAttributes regAttrs,
-      PartitionAttributesData partitionAttributesData) {
-    PartitionAttributesData data = partitionAttributesData;
+    assertThat(partitionAttributesData.getRedundantCopies())
+        .isEqualTo(expectedPartitionAttributes.getRedundantCopies());
 
-    PartitionAttributes partAttrs = regAttrs.getPartitionAttributes();
+    assertThat(partitionAttributesData.getTotalMaxMemory())
+        .isEqualTo(expectedPartitionAttributes.getTotalMaxMemory());
 
-    int redundantCopies = partAttrs.getRedundantCopies();
-    assertEquals(redundantCopies, data.getRedundantCopies());
-    long totalMaxMemory = partAttrs.getTotalMaxMemory();
-    assertEquals(totalMaxMemory, data.getTotalMaxMemory());
     // Total number of buckets for whole region
-    int totalNumBuckets = partAttrs.getTotalNumBuckets();
-    assertEquals(totalNumBuckets, data.getTotalNumBuckets());
+    assertThat(partitionAttributesData.getTotalNumBuckets())
+        .isEqualTo(expectedPartitionAttributes.getTotalNumBuckets());
 
-    int localMaxMemory = partAttrs.getLocalMaxMemory();
-    assertEquals(localMaxMemory, data.getLocalMaxMemory());
+    assertThat(partitionAttributesData.getLocalMaxMemory())
+        .isEqualTo(expectedPartitionAttributes.getLocalMaxMemory());
 
-    String colocatedWith = partAttrs.getColocatedWith();
-    assertEquals(colocatedWith, data.getColocatedWith());
+    assertThat(partitionAttributesData.getColocatedWith())
+        .isEqualTo(expectedPartitionAttributes.getColocatedWith());
 
     String partitionResolver = null;
-    if (partAttrs.getPartitionResolver() != null) {
-      partitionResolver = partAttrs.getPartitionResolver().getName();
+    if (expectedPartitionAttributes.getPartitionResolver() != null) { // TODO: these conditionals
+                                                                      // should be deterministic
+      partitionResolver = expectedPartitionAttributes.getPartitionResolver().getName();
     }
+    assertThat(partitionAttributesData.getPartitionResolver()).isEqualTo(partitionResolver);
 
-    assertEquals(partitionResolver, data.getPartitionResolver());
+    assertThat(partitionAttributesData.getRecoveryDelay())
+        .isEqualTo(expectedPartitionAttributes.getRecoveryDelay());
 
-    long recoveryDelay = partAttrs.getRecoveryDelay();
-    assertEquals(recoveryDelay, data.getRecoveryDelay());
+    assertThat(partitionAttributesData.getStartupRecoveryDelay())
+        .isEqualTo(expectedPartitionAttributes.getStartupRecoveryDelay());
 
-    long startupRecoveryDelay = partAttrs.getStartupRecoveryDelay();
-    assertEquals(startupRecoveryDelay, data.getStartupRecoveryDelay());
+    if (expectedPartitionAttributes.getPartitionListeners() != null) {
+      for (int i = 0; i < expectedPartitionAttributes.getPartitionListeners().length; i++) {
+        // assertEquals((expectedPartitionAttributes.getPartitionListeners())[i].getClass().getCanonicalName(),
+        // partitionAttributesData.getPartitionListeners()[i]);
+        assertThat(partitionAttributesData.getPartitionListeners()[i]).isEqualTo(
+            expectedPartitionAttributes.getPartitionListeners()[i].getClass().getCanonicalName());
 
-    if (partAttrs.getPartitionListeners() != null) {
-      for (int i = 0; i < partAttrs.getPartitionListeners().length; i++) {
-        assertEquals((partAttrs.getPartitionListeners())[i].getClass().getCanonicalName(),
-            data.getPartitionListeners()[i]);
       }
-
     }
-
   }
 
   /**
-   * Checks all Region Attributes
-   * 
-   * @param regAttrs
-   * @param data
+   * Invoked in member VMs
    */
-  protected static void assertRegionAttributes(RegionAttributes regAttrs,
-      RegionAttributesData data) {
-
+  private void verifyRegionAttributes(final RegionAttributes regionAttributes,
+      final RegionAttributesData regionAttributesData) {
     String compressorClassName = null;
-    if (regAttrs.getCompressor() != null) {
-      compressorClassName = regAttrs.getCompressor().getClass().getCanonicalName();
+    if (regionAttributes.getCompressor() != null) { // TODO: these conditionals should be
+                                                    // deterministic
+      compressorClassName = regionAttributes.getCompressor().getClass().getCanonicalName();
     }
-    assertEquals(compressorClassName, data.getCompressorClassName());
+    assertThat(regionAttributesData.getCompressorClassName()).isEqualTo(compressorClassName);
+
     String cacheLoaderClassName = null;
-    if (regAttrs.getCacheLoader() != null) {
-      cacheLoaderClassName = regAttrs.getCacheLoader().getClass().getCanonicalName();
+    if (regionAttributes.getCacheLoader() != null) {
+      cacheLoaderClassName = regionAttributes.getCacheLoader().getClass().getCanonicalName();
     }
-    assertEquals(cacheLoaderClassName, data.getCacheLoaderClassName());
+    assertThat(regionAttributesData.getCacheLoaderClassName()).isEqualTo(cacheLoaderClassName);
+
     String cacheWriteClassName = null;
-    if (regAttrs.getCacheWriter() != null) {
-      cacheWriteClassName = regAttrs.getCacheWriter().getClass().getCanonicalName();
+    if (regionAttributes.getCacheWriter() != null) {
+      cacheWriteClassName = regionAttributes.getCacheWriter().getClass().getCanonicalName();
     }
-    assertEquals(cacheWriteClassName, data.getCacheWriterClassName());
+    assertThat(regionAttributesData.getCacheWriterClassName()).isEqualTo(cacheWriteClassName);
+
     String keyConstraintClassName = null;
-    if (regAttrs.getKeyConstraint() != null) {
-      keyConstraintClassName = regAttrs.getKeyConstraint().getName();
+    if (regionAttributes.getKeyConstraint() != null) {
+      keyConstraintClassName = regionAttributes.getKeyConstraint().getName();
     }
-    assertEquals(keyConstraintClassName, data.getKeyConstraintClassName());
+    assertThat(regionAttributesData.getKeyConstraintClassName()).isEqualTo(keyConstraintClassName);
+
     String valueContstaintClassName = null;
-    if (regAttrs.getValueConstraint() != null) {
-      valueContstaintClassName = regAttrs.getValueConstraint().getName();
+    if (regionAttributes.getValueConstraint() != null) {
+      valueContstaintClassName = regionAttributes.getValueConstraint().getName();
     }
-    assertEquals(valueContstaintClassName, data.getValueConstraintClassName());
-    CacheListener[] listeners = regAttrs.getCacheListeners();
-
+    assertThat(regionAttributesData.getValueConstraintClassName())
+        .isEqualTo(valueContstaintClassName);
 
+    CacheListener[] listeners = regionAttributes.getCacheListeners();
     if (listeners != null) {
-      String[] value = data.getCacheListeners();
+      String[] value = regionAttributesData.getCacheListeners();
       for (int i = 0; i < listeners.length; i++) {
-        assertEquals(value[i], listeners[i].getClass().getName());
+        assertThat(listeners[i].getClass().getName()).isEqualTo(value[i]);
       }
-
     }
 
+    assertThat(regionAttributesData.getRegionTimeToLive())
+        .isEqualTo(regionAttributes.getRegionTimeToLive().getTimeout());
 
+    assertThat(regionAttributesData.getRegionIdleTimeout())
+        .isEqualTo(regionAttributes.getRegionIdleTimeout().getTimeout());
 
-    int regionTimeToLive = regAttrs.getRegionTimeToLive().getTimeout();
-
-    assertEquals(regionTimeToLive, data.getRegionTimeToLive());
-
-    int regionIdleTimeout = regAttrs.getRegionIdleTimeout().getTimeout();
-
-    assertEquals(regionIdleTimeout, data.getRegionIdleTimeout());
+    assertThat(regionAttributesData.getEntryTimeToLive())
+        .isEqualTo(regionAttributes.getEntryTimeToLive().getTimeout());
 
-    int entryTimeToLive = regAttrs.getEntryTimeToLive().getTimeout();
+    assertThat(regionAttributesData.getEntryIdleTimeout())
+        .isEqualTo(regionAttributes.getEntryIdleTimeout().getTimeout());
 
-    assertEquals(entryTimeToLive, data.getEntryTimeToLive());
-
-    int entryIdleTimeout = regAttrs.getEntryIdleTimeout().getTimeout();
-
-    assertEquals(entryIdleTimeout, data.getEntryIdleTimeout());
     String customEntryTimeToLive = null;
-    Object o1 = regAttrs.getCustomEntryTimeToLive();
+    Object o1 = regionAttributes.getCustomEntryTimeToLive();
     if (o1 != null) {
       customEntryTimeToLive = o1.toString();
     }
-    assertEquals(customEntryTimeToLive, data.getCustomEntryTimeToLive());
+    assertThat(regionAttributesData.getCustomEntryTimeToLive()).isEqualTo(customEntryTimeToLive);
 
     String customEntryIdleTimeout = null;
-    Object o2 = regAttrs.getCustomEntryIdleTimeout();
+    Object o2 = regionAttributes.getCustomEntryIdleTimeout();
     if (o2 != null) {
       customEntryIdleTimeout = o2.toString();
     }
-    assertEquals(customEntryIdleTimeout, data.getCustomEntryIdleTimeout());
+    assertThat(regionAttributesData.getCustomEntryIdleTimeout()).isEqualTo(customEntryIdleTimeout);
 
-    boolean ignoreJTA = regAttrs.getIgnoreJTA();
-    assertEquals(ignoreJTA, data.isIgnoreJTA());
+    assertThat(regionAttributesData.isIgnoreJTA()).isEqualTo(regionAttributes.getIgnoreJTA());
 
-    String dataPolicy = regAttrs.getDataPolicy().toString();
-    assertEquals(dataPolicy, data.getDataPolicy());
+    assertThat(regionAttributesData.getDataPolicy())
+        .isEqualTo(regionAttributes.getDataPolicy().toString());
 
-    String scope = regAttrs.getScope().toString();
-    assertEquals(scope, data.getScope());
+    assertThat(regionAttributesData.getScope()).isEqualTo(regionAttributes.getScope().toString());
 
-    int initialCapacity = regAttrs.getInitialCapacity();
-    assertEquals(initialCapacity, data.getInitialCapacity());
-    float loadFactor = regAttrs.getLoadFactor();
-    assertEquals(loadFactor, data.getLoadFactor(), 0);
+    assertThat(regionAttributesData.getInitialCapacity())
+        .isEqualTo(regionAttributes.getInitialCapacity());
 
-    boolean lockGrantor = regAttrs.isLockGrantor();
-    assertEquals(lockGrantor, data.isLockGrantor());
+    assertThat(regionAttributesData.getLoadFactor()).isEqualTo(regionAttributes.getLoadFactor());
 
-    boolean multicastEnabled = regAttrs.getMulticastEnabled();
-    assertEquals(multicastEnabled, data.isMulticastEnabled());
+    assertThat(regionAttributesData.isLockGrantor()).isEqualTo(regionAttributes.isLockGrantor());
 
-    int concurrencyLevel = regAttrs.getConcurrencyLevel();
-    assertEquals(concurrencyLevel, data.getConcurrencyLevel());
+    assertThat(regionAttributesData.isMulticastEnabled())
+        .isEqualTo(regionAttributes.getMulticastEnabled());
 
-    boolean indexMaintenanceSynchronous = regAttrs.getIndexMaintenanceSynchronous();
-    assertEquals(indexMaintenanceSynchronous, data.isIndexMaintenanceSynchronous());
+    assertThat(regionAttributesData.getConcurrencyLevel())
+        .isEqualTo(regionAttributes.getConcurrencyLevel());
 
-    boolean statisticsEnabled = regAttrs.getStatisticsEnabled();
+    assertThat(regionAttributesData.isIndexMaintenanceSynchronous())
+        .isEqualTo(regionAttributes.getIndexMaintenanceSynchronous());
 
-    assertEquals(statisticsEnabled, data.isStatisticsEnabled());
+    assertThat(regionAttributesData.isStatisticsEnabled())
+        .isEqualTo(regionAttributes.getStatisticsEnabled());
 
-    boolean subsciptionConflationEnabled = regAttrs.getEnableSubscriptionConflation();
-    assertEquals(subsciptionConflationEnabled, data.isSubscriptionConflationEnabled());
+    assertThat(regionAttributesData.isSubscriptionConflationEnabled())
+        .isEqualTo(regionAttributes.getEnableSubscriptionConflation());
 
-    boolean asyncConflationEnabled = regAttrs.getEnableAsyncConflation();
-    assertEquals(asyncConflationEnabled, data.isAsyncConflationEnabled());
+    assertThat(regionAttributesData.isAsyncConflationEnabled())
+        .isEqualTo(regionAttributes.getEnableAsyncConflation());
 
-    String poolName = regAttrs.getPoolName();
-    assertEquals(poolName, data.getPoolName());
+    assertThat(regionAttributesData.getPoolName()).isEqualTo(regionAttributes.getPoolName());
 
-    boolean isCloningEnabled = regAttrs.getCloningEnabled();
-    assertEquals(isCloningEnabled, data.isCloningEnabled());
+    assertThat(regionAttributesData.isCloningEnabled())
+        .isEqualTo(regionAttributes.getCloningEnabled());
 
-    String diskStoreName = regAttrs.getDiskStoreName();
-    assertEquals(diskStoreName, data.getDiskStoreName());
+    assertThat(regionAttributesData.getDiskStoreName())
+        .isEqualTo(regionAttributes.getDiskStoreName());
 
     String interestPolicy = null;
-    if (regAttrs.getSubscriptionAttributes() != null) {
-      interestPolicy = regAttrs.getSubscriptionAttributes().getInterestPolicy().toString();
+    if (regionAttributes.getSubscriptionAttributes() != null) {
+      interestPolicy = regionAttributes.getSubscriptionAttributes().getInterestPolicy().toString();
     }
-    assertEquals(interestPolicy, data.getInterestPolicy());
-    boolean diskSynchronus = regAttrs.isDiskSynchronous();
-    assertEquals(diskSynchronus, data.isDiskSynchronous());
+    assertThat(regionAttributesData.getInterestPolicy()).isEqualTo(interestPolicy);
+
+    assertThat(regionAttributesData.isDiskSynchronous())
+        .isEqualTo(regionAttributes.isDiskSynchronous());
   }
 
-  /**
-   * Verifies Region related Statistics
-   */
-  public void verifyStatistics() {
+  private void verifyRemoteFixedPartitionRegion(final VM managerVM) throws Exception {
+    managerVM.invoke("Verify Partition region", () -> {
+      Set<DistributedMember> otherMemberSet = getOtherNormalMembers_tmp();
+
+      for (DistributedMember member : otherMemberSet) {
+        RegionMXBean bean = awaitRegionMXBeanProxy(member, FIXED_PR_PATH);
+
+        PartitionAttributesData data = bean.listPartitionAttributes();
+        assertThat(data).isNotNull();
+
+        FixedPartitionAttributesData[] fixedPrData = bean.listFixedPartitionAttributes();
+        assertThat(fixedPrData).isNotNull();
+        assertThat(fixedPrData).hasSize(3);
+
+        for (int i = 0; i < fixedPrData.length; i++) {
+          // LogWriterUtils.getLogWriter().info("<ExpectedString> Remote PR Data is " +
+          // fixedPrData[i] + "</ExpectedString> ");
+        }
+      }
+    });
+  }
+
+  private void createDistributedRegion_tmp(final VM vm, final String regionName) {
+    vm.invoke(() -> createDistributedRegion_tmp(regionName));
+  }
+
+  private void createDistributedRegion_tmp(final String regionName) {
+    getCache_tmp().createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
+  }
+
+  private void createPartitionRegion_tmp(final VM vm, final String partitionRegionName) {
+    vm.invoke("Create Partitioned region", () -> {
+      SystemManagementService service = getSystemManagementService_tmp();
+      RegionFactory regionFactory =
+          getCache_tmp().createRegionFactory(RegionShortcut.PARTITION_REDUNDANT);
+      regionFactory.create(partitionRegionName);
+    });
+  }
+
+  private void createLocalRegion_tmp(final VM vm, final String localRegionName) {
+    vm.invoke("Create Local region", () -> {
+      SystemManagementService service = getSystemManagementService_tmp();
+      RegionFactory regionFactory = getCache_tmp().createRegionFactory(RegionShortcut.LOCAL);
+      regionFactory.create(localRegionName);
+    });
+  }
 
+  private void createSubRegion_tmp(final VM vm, final String parentRegionPath,
+      final String subregionName) {
+    vm.invoke("Create Sub region", () -> {
+      SystemManagementService service = getSystemManagementService_tmp();
+      Region region = getCache_tmp().getRegion(parentRegionPath);
+      region.createSubregion(subregionName, region.getAttributes());
+    });
   }
 
+  private String getDistributedMemberId_tmp(final VM vm) {
+    return vm.invoke("getMemberId",
+        () -> getCache_tmp().getDistributedSystem().getDistributedMember().getId());
+  }
+
+  private DistributedMember getDistributedMember_tmp(final VM anyVM) {
+    return anyVM.invoke("getDistributedMember_tmp",
+        () -> getCache_tmp().getDistributedSystem().getDistributedMember());
+  }
+
+  private SystemManagementService getSystemManagementService_tmp() {
+    return (SystemManagementService) getManagementService_tmp();
+  }
+
+  private DM getDistributionManager_tmp() {
+    return ((GemFireCacheImpl) getCache_tmp()).getDistributionManager();
+  }
+
+  private DistributedMember getDistributedMember_tmp() {
+    return getCache_tmp().getDistributedSystem().getDistributedMember();
+  }
+
+  private Set<DistributedMember> getOtherNormalMembers_tmp() {
+    Set<DistributedMember> allMembers =
+        new HashSet<>(getDistributionManager_tmp().getNormalDistributionManagerIds());
+    allMembers.remove(getDistributedMember_tmp());
+    return allMembers;
+  }
+
+  private void awaitMemberCount(final int expectedCount) {
+    DistributedSystemMXBean distributedSystemMXBean = awaitDistributedSystemMXBean();
+    await()
+        .until(() -> assertThat(distributedSystemMXBean.getMemberCount()).isEqualTo(expectedCount));
+  }
+
+  private DistributedRegionMXBean awaitDistributedRegionMXBean(final String name) {
+    SystemManagementService service = getSystemManagementService_tmp();
+
+    await().until(() -> assertThat(service.getDistributedRegionMXBean(name)).isNotNull());
+
+    return service.getDistributedRegionMXBean(name);
+  }
+
+  private DistributedRegionMXBean awaitDistributedRegionMXBean(final String name,
+      final int memberCount) {
+    SystemManagementService service = getSystemManagementService_tmp();
+
+    await().until(() -> assertThat(service.getDistributedRegionMXBean(name)).isNotNull());
+    await().until(() -> assertThat(service.getDistributedRegionMXBean(name).getMemberCount())
+        .isEqualTo(memberCount));
+
+    return service.getDistributedRegionMXBean(name);
+  }
+
+  private RegionMXBean awaitRegionMXBeanProxy(final DistributedMember member, final String name) {
+    SystemManagementService service = getSystemManagementService_tmp();
+    ObjectName objectName = service.getRegionMBeanName(member, name);
+    String alias = "awaiting RegionMXBean proxy for " + member;
+
+    await(alias)
+        .until(() -> assertThat(service.getMBeanProxy(objectName, RegionMXBean.class)).isNotNull());
+
+    return service.getMBeanProxy(objectName, RegionMXBean.class);
+  }
+
+  private RegionMXBean awaitRegionMXBeanProxy(final ObjectName objectName) {
+    SystemManagementService service = getSystemManagementService_tmp();
+
+    await()
+        .until(() -> assertThat(service.getMBeanProxy(objectName, RegionMXBean.class)).isNotNull());
+
+    return service.getMBeanProxy(objectName, RegionMXBean.class);
+  }
+
+  private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
+    SystemManagementService service = getSystemManagementService_tmp();
+    ObjectName objectName = service.getMemberMBeanName(member);
+    String alias = "awaiting MemberMXBean proxy for " + member;
+
+    await(alias)
+        .until(() -> assertThat(service.getMBeanProxy(objectName, MemberMXBean.class)).isNotNull());
+
+    return service.getMBeanProxy(objectName, MemberMXBean.class);
+  }
+
+  private MemberMXBean awaitMemberMXBeanProxy(final ObjectName objectName) {
+    SystemManagementService service = getSystemManagementService_tmp();
+    await()
+        .until(() -> assertThat(service.getMBeanProxy(objectName, MemberMXBean.class)).isNotNull());
+    return service.getMBeanProxy(objectName, MemberMXBean.cla

<TRUNCATED>

Mime
View raw message