Details
Description
public interface IService<O extends Object> {
boolean test(final O value);
}
public interface IExtendService<S extends Serializable> extends IService<S> {
boolean another(final S value);
}
public class ServiceImpl implements IExtendService<Serializable> {
public boolean test(final Serializable value)
public boolean another(final Serializable value) { return false; }
}
@Decorator
public abstract class ServiceDecorator<S extends Serializable> implements
IExtendService<S> {
@Inject
@Delegate
@Any
private IExtendService<S> delegate;
public static boolean called = false;
public boolean test(final S value)
}
@RunWith(BlockJUnit4ClassRunner.class)
public class ServiceTest extends
org.apache.myfaces.extensions.cdi.test.junit4.AbstractCdiAwareTest {
@Inject
IExtendService<Serializable> service;
@Test
public void test() {
Assert.assertNotNull("Inject service is null", this.service);
Assert.assertFalse("Value should be false before calling service",ServiceDecorator.called);
this.service.test(new Serializable() {
});
Assert.assertTrue("Value should be true before calling service",
ServiceDecorator.called);
}
}
When running the JUnit test, i've got next exception :
java.lang.RuntimeException: org.apache.webbeans.exception.inject.DeploymentException: org.apache.webbeans.exception.WebBeansConfigurationException: Decorator : org.apache.webbeans.component.creation.DecoratorBeanBuilder@1329346 generic delegate attribute must be same with decorated type : IService<S>
I've attached a maven projet to reproduce the error.