@Test
public void testEnableCaching() {

  String networkCacheDefault = Security.getProperty(
      SLSRunner.NETWORK_CACHE_TTL);
  String networkNegativeCacheDefault =
      Security.getProperty(SLSRunner.NETWORK_NEGATIVE_CACHE_TTL);
  try {
    Configuration conf = new Configuration(false);
    // check when dns caching is disabled
    conf.setBoolean(SLSConfiguration.DNS_CACHING_ENABLED, false);
    SLSRunner.enableDNSCaching(conf);
    assertEquals(networkCacheDefault,
        Security.getProperty(SLSRunner.NETWORK_CACHE_TTL));
    assertEquals(networkNegativeCacheDefault,
        Security.getProperty(SLSRunner.NETWORK_NEGATIVE_CACHE_TTL));
    // check when dns caching is enabled
    conf.setBoolean(SLSConfiguration.DNS_CACHING_ENABLED, true);
    SLSRunner.enableDNSCaching(conf);
    assertEquals("-1",
        Security.getProperty(SLSRunner.NETWORK_CACHE_TTL));
    assertEquals("-1",
        Security.getProperty(SLSRunner.NETWORK_NEGATIVE_CACHE_TTL));
  } finally {
    // set security settings back to default
    Security.setProperty(SLSRunner.NETWORK_CACHE_TTL,
        String.valueOf(networkCacheDefault));
    Security.setProperty(SLSRunner.NETWORK_NEGATIVE_CACHE_TTL,
        String.valueOf(networkNegativeCacheDefault));
  }
}