MetaStbCache { public MetaStb getMetaStb(String deviceId) { return getMetaStb(deviceId, false); }  MetaStb getMetaStb(String deviceId); MetaStb getMetaStb(String deviceId, boolean refresh); Collection<MetaStb> getMetaStbs(String[] deviceIds); Collection<MetaStb> getMetaStbs(String[] deviceIds, boolean refresh); MetaStbCacheEntry putMetaStb(MetaStb stb); MetaStbCacheEntry putMetaStb(String deviceId, MetaStb stb); long getCacheTime(); void setCacheTime(long cacheTime); static final long DEFAULT_CACHE_TIME; }
@Test public void testGetMetaStb() throws InterruptedException { final MockDawgHouseClient client = new MockDawgHouseClient(); MetaStbCache cache = new MetaStbCache(); DawgShowConfiguration config = new DawgShowConfiguration(); config.put(DawgShowConfiguration.DAWG_HOUSE_URL, "http: Wiring.autowire(cache, config); Assert.assertNotNull(cache.getDawgHouseClient()); cache = new MetaStbCache() { protected DawgHouseClient getDawgHouseClient() { return client; } }; cache.setCacheTime(500); Assert.assertEquals(500, cache.getCacheTime()); MetaStb stb1 = cache.getMetaStb(TestUtils.ID); MetaStb stb2 = cache.getMetaStb(TestUtils.ID); Thread.sleep(1000); MetaStb stb3 = cache.getMetaStb(TestUtils.ID); Assert.assertEquals(stb1.getId(), TestUtils.ID); Assert.assertEquals(stb1.getName(), TestUtils.NAME); Assert.assertTrue(stb1 == stb2); Assert.assertFalse(stb2 == stb3); Assert.assertEquals(stb3.getId(), TestUtils.ID); Assert.assertEquals(stb3.getName(), TestUtils.NAME); }