@Test
public void invokedAsynchronouslyOnProxyTarget() {
StaticApplicationContext context = new StaticApplicationContext();
context.registerBeanDefinition("postProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
TestBean tb = new TestBean();
ProxyFactory pf = new ProxyFactory(ITestBean.class,
(MethodInterceptor) invocation -> invocation.getMethod().invoke(tb, invocation.getArguments()));
context.registerBean("target", ITestBean.class, () -> (ITestBean) pf.getProxy());
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
Thread mainThread = Thread.currentThread();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertNotSame(mainThread, asyncThread);
context.close();
}