@Test
public void defineInProxy() throws NoSuchMethodException
{

    final Properties config = new Properties();
    config.setProperty(DefiningClassService.class.getName(), ClassLoaderProxyService.class.getName());
    final WebBeansContext context = new WebBeansContext(emptyMap(), config);
    final NormalScopeProxyFactory factory = new NormalScopeProxyFactory(context);
    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
    final Class<MyBean> proxyClass = factory.createProxyClass(contextClassLoader, MyBean.class);
    assertNotEquals(contextClassLoader, proxyClass.getClassLoader());
    final ClassLoader proxyLoader = context.getService(DefiningClassService.class).getProxyClassLoader(proxyClass);
    assertEquals(proxyLoader, proxyClass.getClassLoader());
    proxyClass.getMethod("ok", String.class); // this line would fail if not here, no assert needed
}