MapVersionCache implements MapVersionCacheMBean { private MapVersionCache(String name) { this.name = name; } private  MapVersionCache(String name); static MapVersionCache getInstance(String name); static MapVersionCache getInstance(); @Override MAPApplicationContextVersion getMAPApplicationContextVersion(String globalTitleDigits); void setMAPApplicationContextVersion(String globalTitleDigits, MAPApplicationContextVersion version); @Override void forceMAPApplicationContextVersion(String globalTitleDigits, MAPApplicationContextVersion version); @Override FastMap<String, MapVersionNeg> getMAPApplicationContextVersionCache(); @Override void forceClear();  }
@Test(groups = { "cassandra" }) public void testMapVersionCache() throws Exception { MapVersionCache cache = MapVersionCache.getInstance("Test"); MAPApplicationContextVersion v = cache.getMAPApplicationContextVersion("111"); assertNull(v); cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version3); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version3); cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version2); cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version2); for (int i1 = 0; i1 < MapVersionNeg.mapV2RetestUpCount - 2; i1++) { cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version2); } cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version3); cache.setMAPApplicationContextVersion("111", MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("111"); assertEquals(v, MAPApplicationContextVersion.version2); v = cache.getMAPApplicationContextVersion("222"); assertNull(v); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version3); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version1); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); for (int i1 = 0; i1 < MapVersionNeg.mapV1RetestUpCount - 1; i1++) { v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version1); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); } cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version3); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version1); v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version1); cache.setMAPApplicationContextVersion("222", MAPApplicationContextVersion.version3); v = cache.getMAPApplicationContextVersion("222"); assertEquals(v, MAPApplicationContextVersion.version3); }