Bean<?> bean = getBeanManager().getBeans(OutputProvider.class, new AnnotationLiteral<Default>()
{
}).iterator().next();
Object instance = getBeanManager().getReference(bean, OutputProvider.class, getBeanManager().createCreationalContext(bean));
OutputProvider outputProvider = (OutputProvider) instance;
Assert.assertTrue(outputProvider != null);
String result = outputProvider.getOutput();
System.out.println(result);
// Verify that the Decorators were called in order, and in a stack, including the Abstract Decorator 3
Assert.assertTrue(result.equalsIgnoreCase("Decorator1\nDecorator2\nDecorator3\nOutputProvider\n"));
String hijackedStack = outputProvider.trace();
// Verify that the a method change in Decorator2 from trace->otherMethod results in the right stack
Assert.assertEquals("Decorator1/trace,Decorator2/trace,delegate/otherMethod", hijackedStack);
}