Hi, I am trying to write a simple junit test that loads up one of my annotation based components/beans but I am not being successful when trying to use the AnnotationConfigWebApplicationContext class to do this.
In my test class, I am instantiating a new AnnotationConfigWebApplicationContext, calling refresh() in my @Before method (it tells me to do this) and within my test, I am calling:
I do not get any values in array beanNamesForType nor am I able to find the bean I am looking for by Type or literal name (I even tried specifying a Qualifier)Code:public class HighriseClientTest { HighriseClient client; AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext(); @Before public void setup() { annotationConfigWebApplicationContext.refresh(); } @Test public void testGetPeople() throws Exception { String[] beanNamesForType = annotationConfigWebApplicationContext.getBeanNamesForType(HighriseClient.class); client = annotationConfigWebApplicationContext.getBean(HighriseClient.class); List<Contact> people = client.getPeople(); assertNotNull(people); } }
Any help would be greatly appreciated.


Reply With Quote
