Object ns1 = handlerContainer.getComponentInstance("NSHandlerOne");
assertTrue(ns1 instanceof NSHandlerOne);
Object ns2 = handlerContainer.getComponentInstance("NSHandlerTwo");
assertTrue(ns2 instanceof NSHandlerTwo);
NSHandlerTwo nstwo = (NSHandlerTwo)ns2;
//now we have a handle to the nshandler2, we can query what it 'saw', and ensure
//that the interceptors are functioning as expected.
List<String> log = nstwo.getLog();
//TestBeanC has the interceptor configured, and is injected to OtherBeanA & OtherBeanB
//which then uses the injected bean during their init method call, to invoke a method
checkInterceptorLog(new String[] {
"PRECALL:TestBeanC:methodToInvoke:[RED]:",
"POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
"PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
"POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:"
}, log);
//invoking GREEN is hardwired to cause an exception response, we do this
//from here to ensure the exception occurs and is visible as expected
RuntimeException re=null;
try{
testBeanC.methodToInvoke("GREEN");
}catch(RuntimeException e){
re=e;
}
assertNotNull("invocation of Green did not cause an exception as expected",re);
//Exception responses should be intercepted too, test for the POSTCALLWITHEXCEPTION log entry.
log = nstwo.getLog();
checkInterceptorLog(new String[] {
"PRECALL:TestBeanC:methodToInvoke:[RED]:",
"POSTCALL[true]:TestBeanC:methodToInvoke:[RED]:",
"PRECALL:TestBeanC:methodToInvoke:[BLUE]:",
"POSTCALL[false]:TestBeanC:methodToInvoke:[BLUE]:",