Interceptor interceptorBean = beanManager.resolveInterceptors(InterceptionType.AROUND_INVOKE, new AnnotationLiteral<RuntimeExceptions>() {}).iterator().next();
Bean bean = beanManager.resolve(beanManager.getBeans(RuntimeExceptionBindingTypeBean.class));
CreationalContext creationalContext = beanManager.createCreationalContext(bean);
// we cannot use the container to create the proxy as it already proxies the internal instance
RuntimeExceptionBindingTypeBean target = new RuntimeExceptionBindingTypeBean();
RuntimeExceptionsInterceptor interceptor = (RuntimeExceptionsInterceptor) interceptorBean.create(creationalContext);
Method[] interceptedMethods = {RuntimeExceptionBindingTypeBean.class.getMethod("business")};
Map<Method, List<Interceptor<?>>> interceptors = new HashMap<Method, List<Interceptor<?>>>();
interceptors.put(interceptedMethods[0], Arrays.<Interceptor<?>> asList(interceptorBean));
Map instances = new HashMap();
instances.put(interceptorBean, interceptor);
InterceptorHandler interceptorHandler
= new DefaultInterceptorHandler<RuntimeExceptionBindingTypeBean>(target, target, interceptors, instances, null);
InterceptorDecoratorProxyFactory factory = new InterceptorDecoratorProxyFactory(getWebBeansContext());
Class<RuntimeExceptionBindingTypeBean> proxyClass
= factory.createProxyClass(bean, Thread.currentThread().getContextClassLoader(), RuntimeExceptionBindingTypeBean.class, interceptedMethods, null);
RuntimeExceptionBindingTypeBean instance = factory.createProxyInstance(proxyClass, target, interceptorHandler);
int result = instance.business();
Assert.assertEquals(42, result);
Assert.assertEquals(1, interceptor.invoked);
shutDownContainer();