caching java config

This commit is contained in:
DOHA
2015-12-06 13:01:52 +02:00
parent de70a8595c
commit f54c2fcae4
6 changed files with 48 additions and 21 deletions
@@ -1,11 +1,11 @@
package org.baeldung.caching.test;
import org.baeldung.caching.config.CachingConfig;
import org.baeldung.caching.example.Customer;
import org.baeldung.caching.example.CustomerDataService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@Component
public class SpringCachingBehaviorTest {
@@ -13,12 +13,16 @@ public class SpringCachingBehaviorTest {
@Test
public void testCaching() {
@SuppressWarnings("resource")
final ApplicationContext context = new ClassPathXmlApplicationContext("config.xml");
final
// final ApplicationContext context = new ClassPathXmlApplicationContext("config.xml");
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(CachingConfig.class);
context.refresh();
final CustomerDataService service = context.getBean(CustomerDataService.class);
final Customer cust = new Customer("Tom", "67-2, Downing Street, NY");
service.getAddress1(cust);
service.getAddress1(cust);
service.getAddress(cust);
service.getAddress(cust);
// fail("Unable to instantiate the CustomerDataService");
}