[weld-dev] Is an interceptor with @Target(METHOD, CONSTRUCTOR, TYPE) a problem?
Marcin ZajÄ…czkowski
mszpak at wp.pl
Sat Jul 17 17:36:07 EDT 2010
Hi,
I'm trying to write mocked unit tests for my interceptor using
mechanisms given by AbstractWeldTest and jboss-test-harness package.
My test class extends AbstractWeldTest, had Artifact and WebBeans
(pointing to beans.xml with my interceptor defined) annotations.
My interceptor seems normal for me:
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@InterceptorBinding
public @interface Perf4jProfiled {
}
When I run a very simple test, I've got:
23:06:53.505 [main] DEBUG org.jboss.weld.Reflection - WELD-000602
interface net.sf.perf4cdi.api.Perf4jProfiled is not declared
@Target(TYPE, METHOD) or @Target(TYPE)
org.jboss.weld.exceptions.DeploymentException: WELD-000069 An
interceptor must have at least one binding, but
net.sf.perf4cdi.Perf4jProfiledInterceptor has none
at org.jboss.weld.bean.InterceptorImpl.<init>(InterceptorImpl.java:71)
at org.jboss.weld.bean.InterceptorImpl.of(InterceptorImpl.java:55)
at
org.jboss.weld.bootstrap.AbstractBeanDeployer.createInterceptor(AbstractBeanDeployer.java:255)
at org.jboss.weld.bootstrap.BeanDeployer.createBeans(BeanDeployer.java:106)
at
org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:151)
at
org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:377)
at
org.jboss.weld.mock.MockServletLifecycle.beginApplication(MockServletLifecycle.java:121)
at org.jboss.weld.mock.TestContainer.startContainer(TestContainer.java:85)
at
org.jboss.weld.test.harness.AbstractStandaloneContainersImpl.deploy(AbstractStandaloneContainersImpl.java:40)
at org.jboss.testharness.AbstractTest.deployArtifact(AbstractTest.java:103)
at org.jboss.testharness.AbstractTest.beforeClass(AbstractTest.java:206)
at
org.jboss.weld.test.AbstractWeldTest.beforeClass(AbstractWeldTest.java:57)
When I remove CONSTRUCTOR it works better (there is another problem, but
not related I have to debug it).
I would like to ask if this is a limitation of CDI that an interceptor
cannot be put on constructor?
Regards
Marcin
More information about the weld-dev
mailing list