@BeforeMethod(alwaysRun = true)
  public void setUp() throws Exception {
    List<String> propsToRemove =
        ImmutableList.of(
            "imageDescriptionRegex", "imageNameRegex", "inboundPorts", "hardwareId", "minRam");

    // Don't let any defaults from brooklyn.properties (except credentials) interfere with test
    brooklynProperties = BrooklynProperties.Factory.newDefault();
    for (String propToRemove : propsToRemove) {
      for (String propVariant :
          ImmutableList.of(
              propToRemove, CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, propToRemove))) {
        brooklynProperties.remove("brooklyn.locations.jclouds." + PROVIDER + "." + propVariant);
        brooklynProperties.remove("brooklyn.locations." + propVariant);
        brooklynProperties.remove("brooklyn.jclouds." + PROVIDER + "." + propVariant);
        brooklynProperties.remove("brooklyn.jclouds." + propVariant);
      }
    }

    // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can
    // cause "stdin: is not a tty")
    brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");

    ctx = new LocalManagementContext(brooklynProperties);
    app = ApplicationBuilder.newManagedApp(TestApplication.class, ctx);
  }
  protected static void stripBrooklynProperties(BrooklynProperties props) {
    // remove all location properties except for identity and credential
    // (so key, scripts, etc settings don't interfere with tests)
    for (String key : ImmutableSet.copyOf(props.asMapWithStringKeys().keySet())) {
      if (key.startsWith(BROOKLYN_PROPERTIES_PREFIX)
          && !(key.endsWith("identity") || key.endsWith("credential"))) {
        props.remove(key);
      }
      if (key.startsWith(BROOKLYN_PROPERTIES_LEGACY_PREFIX)
          && !(key.endsWith("identity") || key.endsWith("credential"))) {
        props.remove(key);
      }

      // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can
      // cause "stdin: is not a tty")
      if (key.startsWith("brooklyn.ssh")) {
        props.remove(key);
      }
    }
  }
 @Override
 public Object remove(Object key) {
   return delegate.remove(key);
 }