Source:
public void testInstanceListing(String availabilityFlag, Frequency frequency, TimeZone timeZone, Date start, Date end) throws Exception { EmbeddedCluster firstCluster = EmbeddedCluster.newCluster("TestFeedListing", false); FileSystem fs = firstCluster.getFileSystem(); ConfigurationStore.get().publish(EntityType.CLUSTER, firstCluster.getCluster()); EmbeddedCluster secondCluster = EmbeddedCluster.newCluster("TestFeedInstanceListing", false); ConfigurationStore.get().publish(EntityType.CLUSTER, secondCluster.getCluster()); try { Feed feed = getFeed(availabilityFlag, frequency, timeZone); Cluster cluster = new Cluster(); cluster.setName("TestFeedInstanceListing"); feed.getClusters().getClusters().add(cluster); Validity validity = new Validity(); cluster.setValidity(validity); validity.setStart(new Date(System.currentTimeMillis() - (1000L * 24 * 3600000))); validity.setEnd(new Date(System.currentTimeMillis() - (1000L * 21 * 3600000))); Locations locations = new Locations(); Location dataLocation = new Location(); dataLocation.setPath("/TestFeedInstanceListing/data/${YEAR}/${MONTH}/${DAY}" + (frequency.getTimeUnit() == Frequency.TimeUnit.hours ? "/${HOUR}" : "") + "/MORE"); dataLocation.setType(LocationType.DATA); locations.getLocations().add(dataLocation); cluster.setLocations(locations); List<FeedInstanceStatus> expected = prepareData(fs, feed, start, end); FeedInstanceResult actual = FeedHelper.getFeedInstanceListing(feed, start, end); Assert.assertEquals(actual.getInstances().length, expected.size()); } finally { ConfigurationStore.get().remove(EntityType.CLUSTER, firstCluster.getCluster().getName()); ConfigurationStore.get().remove(EntityType.CLUSTER, secondCluster.getCluster().getName()); } }

Target:
public void testInstanceListing(String availabilityFlag, Frequency frequency, TimeZone timeZone, Date start, Date end) throws Exception { EmbeddedCluster firstCluster = EmbeddedCluster.newCluster(TEST_FEED_LISTING, false); FileSystem fs = firstCluster.getFileSystem(); ConfigurationStore.get().publish(EntityType.CLUSTER, firstCluster.getCluster()); EmbeddedCluster secondCluster = EmbeddedCluster.newCluster(TEST_FEED_INSTANCE_LISTING, false); ConfigurationStore.get().publish(EntityType.CLUSTER, secondCluster.getCluster()); try { Feed feed = getFeed(availabilityFlag, frequency, timeZone); Cluster cluster = new Cluster(); cluster.setName(TEST_FEED_INSTANCE_LISTING); feed.getClusters().getClusters().add(cluster); Validity validity = new Validity(); cluster.setValidity(validity); validity.setStart(new Date(System.currentTimeMillis() - (1000L * 24 * 3600000))); validity.setEnd(new Date(System.currentTimeMillis() - (1000L * 21 * 3600000))); Locations locations = new Locations(); Location dataLocation = new Location(); dataLocation.setPath("/TestFeedInstanceListing/data/${YEAR}/${MONTH}/${DAY}" + (frequency.getTimeUnit() == Frequency.TimeUnit.hours ? "/${HOUR}" : "") + "/MORE"); dataLocation.setType(LocationType.DATA); locations.getLocations().add(dataLocation); cluster.setLocations(locations); List<FeedInstanceStatus> expected = prepareData(fs, feed, start, end); FeedInstanceResult actual = FeedHelper.getFeedInstanceListing(feed, start, end); Assert.assertEquals(actual.getInstances().length, expected.size()); } finally { ConfigurationStore.get().remove(EntityType.CLUSTER, firstCluster.getCluster().getName()); ConfigurationStore.get().remove(EntityType.CLUSTER, secondCluster.getCluster().getName()); } }