@Override
 protected LocalManagementContext createNewManagementContext(
     File mementoDir, HighAvailabilityMode haMode) {
   BrooklynProperties properties = BrooklynProperties.Factory.newDefault();
   properties.put(
       BrooklynServerConfig.BROOKLYN_CATALOG_URL,
       "classpath://brooklyn/entity/rebind/rebind-catalog-item-test-catalog.xml");
   return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
       .properties(properties)
       .forLive(useLiveManagementContext())
       .haMode(haMode)
       .emptyCatalog(useEmptyCatalog())
       .buildUnstarted();
 }
 @Override
 protected LocalManagementContext createOrigManagementContext() {
   BrooklynProperties properties = BrooklynProperties.Factory.newDefault();
   properties.put(
       BrooklynServerConfig.BROOKLYN_CATALOG_URL,
       "classpath://brooklyn/entity/rebind/rebind-catalog-item-test-catalog.xml");
   properties.put(
       BrooklynServerConfig.CATALOG_LOAD_MODE,
       org.apache.brooklyn.core.catalog.CatalogLoadMode.LOAD_BROOKLYN_CATALOG_URL);
   return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
       .properties(properties)
       .persistPeriodMillis(getPersistPeriodMillis())
       .forLive(useLiveManagementContext())
       .buildStarted();
 }
  private void doTestAddAndRebindAndDeleteLocation(boolean suppressPeriodicCheckpointing)
      throws Exception {
    String symbolicName = "sample_location";
    String yaml =
        Joiner.on("\n")
            .join(
                "brooklyn.catalog:",
                "  items:",
                "  - id: " + symbolicName,
                "    version: " + TEST_VERSION,
                "    itemType: location",
                "    item:",
                "      type: " + LocalhostMachineProvisioningLocation.class.getName(),
                "      brooklyn.config:",
                "        cfg1: 111",
                "        cfg2: 222");
    CatalogLocationItemDto item =
        CatalogItemBuilder.newLocation(symbolicName, TEST_VERSION)
            .displayName(symbolicName)
            .plan(yaml)
            .build();
    origManagementContext.getCatalog().addItem(item);
    assertEquals(item.getCatalogItemType(), CatalogItemType.LOCATION);
    if (!suppressPeriodicCheckpointing) {
      rebindAndAssertCatalogsAreEqual();
    } else {
      LocalManagementContext nmc =
          RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
              .forLive(useLiveManagementContext())
              .emptyCatalog(useEmptyCatalog())
              .persistPeriod(Duration.PRACTICALLY_FOREVER)
              .buildUnstarted();
      rebind(RebindOptions.create().newManagementContext(nmc));
    }

    deleteItem(newManagementContext, item.getSymbolicName(), item.getVersion());

    switchOriginalToNewManagementContext();
    rebindAndAssertCatalogsAreEqual();
  }