@Test
public void testDeprecatedKeys_throwsExceptionWhenDeprecatedKeyIsUsed() {

  HadoopConfigurationProperty<String> gcsProxyAddress =
      new HadoopConfigurationProperty<>(
          GCS_CONFIG_PREFIX + PROXY_ADDRESS_SUFFIX.getKey(),
          "proxy-address",
          "fs.gs.proxy.deprecated.address");
  HadoopConfigurationProperty<Integer> gcsProxyUsername =
      new HadoopConfigurationProperty<>(
          GCS_CONFIG_PREFIX + PROXY_USERNAME_SUFFIX.getKey(),
          1234,
          "fs.gs.proxy.deprecated.user");
  HadoopConfigurationProperty<String> gcsProxyPassword =
      new HadoopConfigurationProperty<>(
          GCS_CONFIG_PREFIX + PROXY_PASSWORD_SUFFIX.getKey(),
          "proxy-pass",
          "fs.gs.proxy.deprecated.pass");
  Configuration config = new Configuration();
  config.set(gcsProxyAddress.getKey(), gcsProxyAddress.getDefault());
  config.setInt(gcsProxyUsername.getKey(), gcsProxyUsername.getDefault());
  config.set("fs.gs.proxy.deprecated.pass", gcsProxyPassword.getDefault());
  // Verify that we can read password from config when used key is deprecated.
  String userPass = gcsProxyPassword.getPassword(config);
  assertThat(userPass).isEqualTo("proxy-pass");
  GoogleCloudStorageOptions.Builder optionsBuilder =
      GoogleHadoopFileSystemConfiguration.getGcsOptionsBuilder(config);
  // Building configuration using deprecated key (in eg. proxy password) should fail.
  assertThrows(IllegalArgumentException.class, optionsBuilder::build);
}