@Test public void test() { final TestSvc test = (TestSvc) context.getBean("testSvc"); // *AssignCache assignments are not very dynamic by their very nature. // Take care to invalidate the caches before each of the *AssignCache tests test.invalidateL2AssignIndia(System.currentTimeMillis()); // Set the first cached datum final String orig = test.getL2AssignGolf(999L, RandomStringUtils.randomAlphabetic(4) + "-"); // Make sure the value is definitely in there for (int ix = 0; ix < 3; ix++) { assertEquals( orig, test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(4 + ix) + "-")); } // Force the update to happen. final String renew = test.getL2AssignHotel( System.currentTimeMillis(), RandomStringUtils.randomAlphanumeric(8) + "-"); assertFalse(orig.equals(renew)); // Make sure the NEW value is definitely in there for (int ix = 0; ix < 3; ix++) { assertEquals( renew, test.getL2AssignGolf(1000L + ix, RandomStringUtils.randomAlphanumeric(8 + ix) + "-")); } }