@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) + "-")); } }
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("house-config.xml"); House house = (House) context.getBean("house"); System.out.println(house.getPrice()); }
public static void main(String[] args) { // 创建Spring容器 ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml"); // 获取Spring容器中的所有Bean实例的名 System.out.println("--------------" + java.util.Arrays.toString(ctx.getBeanDefinitionNames())); }