@Override
    public Map<String, Object> load(String configKey) {
        if (targetUri == null) {
            return null;
        }

        // Check for new file every so often
        int currentTimeSecs = Time.currentTimeSecs();
        if (lastReturnedValue != null && ((currentTimeSecs - lastReturnedTime) < artifactoryPollTimeSecs)) {
            LOG.debug("currentTimeSecs: {}; lastReturnedTime {}; artifactoryPollTimeSecs: {}. Returning our last map.",
                      currentTimeSecs, lastReturnedTime, artifactoryPollTimeSecs);
            return (Map<String, Object>) lastReturnedValue.get(configKey);
        }

        try {
            Map<String, Object> raw = loadFromUri(targetUri);
            if (raw != null) {
                return (Map<String, Object>) raw.get(configKey);
            }
        } catch (Exception e) {
            LOG.error("Failed to load from uri {}", targetUri);
        }
        return null;
    }
@Test
    public void testArtifactUpdate() {
        // This is a test where we are configured to point right at an artifact dir
        Config conf = new Config();
        conf.put(DaemonConfig.SCHEDULER_CONFIG_LOADER_URI,
                 ARTIFACTORY_HTTP_SCHEME_PREFIX + "bogushost.yahoo.com:9999/location/of/test/dir");
        conf.put(Config.STORM_LOCAL_DIR, tmpDirPath.toString());

        try (SimulatedTime ignored = new SimulatedTime()) {
            ArtifactoryConfigLoaderMock loaderMock = new ArtifactoryConfigLoaderMock(conf);

            loaderMock.setData("Anything", "/location/of/test/dir",
                               "{\"children\" : [ { \"uri\" : \"/20160621204337.yaml\", \"folder\" : false }]}");
            loaderMock.setData(null, null, "{ \"" + DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS + "\": {one: 1, two: 2, three: 3}}");
            Map<String, Object> ret = loaderMock.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);

            assertNotNull(ret, "Unexpectedly returned null");
            assertEquals(1, ret.get("one"));
            assertEquals(2, ret.get("two"));
            assertEquals(3, ret.get("three"));
            assertNull(ret.get("four"), "Unexpectedly contained \"four\"");

            // Now let's load w/o setting up gets, and we should still get valid map back
            ArtifactoryConfigLoaderMock tc2 = new ArtifactoryConfigLoaderMock(conf);
            Map<String, Object> ret2 = tc2.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
            assertNotNull(ret2, "Unexpectedly returned null");
            assertEquals(1, ret2.get("one"));
            assertEquals(2, ret2.get("two"));
            assertEquals(3, ret2.get("three"));
            assertNull(ret2.get("four"), "Unexpectedly did not return null");

            // Now let's update it, but not advance time.  Should get old map again.
            loaderMock.setData("Anything", "/location/of/test/dir",
                               "{\"children\" : [ { \"uri\" : \"/20160621204999.yaml\", \"folder\" : false }]}");
            loaderMock
                .setData(null, null, "{ \"" + DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS + "\": {one: 1, two: 2, three: 3, four : 4}}");
            ret = loaderMock.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
            assertNotNull(ret, "Unexpectedly returned null");
            assertEquals(1, ret.get("one"));
            assertEquals(2, ret.get("two"));
            assertEquals(3, ret.get("three"));
            assertNull(ret.get("four"), "Unexpectedly did not return null, not enough time passed!");

            // Re-load from cached' file.
            ret2 = tc2.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
            assertNotNull(ret2, "Unexpectedly returned null");
            assertEquals(1, ret2.get("one"));
            assertEquals(2, ret2.get("two"));
            assertEquals(3, ret2.get("three"));
            assertNull(ret2.get("four"), "Unexpectedly did not return null, last cached result should not have \"four\"");

            // Now, let's advance time.
            Time.advanceTime(11 * 60 * 1000);

            ret = loaderMock.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
            assertNotNull(ret, "Unexpectedly returned null");
            assertEquals(1, ret.get("one"));
            assertEquals(2, ret.get("two"));
            assertEquals(3, ret.get("three"));
            assertEquals(4, ret.get("four"));

            // Re-load from cached' file.
            ret2 = tc2.load(DaemonConfig.MULTITENANT_SCHEDULER_USER_POOLS);
            assertNotNull(ret2, "Unexpectedly returned null");
            assertEquals(1, ret2.get("one"));
            assertEquals(2, ret2.get("two"));
            assertEquals(3, ret2.get("three"));
            assertEquals(4, ret2.get("four"));
        }
    }