Weld SVN: r4030 - core/trunk/impl/src/main/java/org/jboss/weld/xml.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 04:20:21 -0400 (Wed, 14 Oct 2009)
New Revision: 4030
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
Log:
TODO - move validation over to Validator
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-10-14 08:19:08 UTC (rev 4029)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-10-14 08:20:21 UTC (rev 4030)
@@ -270,6 +270,8 @@
return list;
}
+
+ //TODO - move validation to Validator
private static List<Class<?>> processInterceptorElement(ResourceLoader resourceLoader, XmlElement element)
{
List<Class<?>> list = new ArrayList<Class<?>>();
15 years
Weld SVN: r4029 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/nonInterceptorClassInBeansXml.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 04:19:08 -0400 (Wed, 14 Oct 2009)
New Revision: 4029
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/nonInterceptorClassInBeansXml/NonInterceptorClassInBeansXmlTest.java
Log:
Fixing and enabling tests.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/nonInterceptorClassInBeansXml/NonInterceptorClassInBeansXmlTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/nonInterceptorClassInBeansXml/NonInterceptorClassInBeansXmlTest.java 2009-10-14 08:16:59 UTC (rev 4028)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/nonInterceptorClassInBeansXml/NonInterceptorClassInBeansXmlTest.java 2009-10-14 08:19:08 UTC (rev 4029)
@@ -15,7 +15,7 @@
@BeansXml("beans.xml")
public class NonInterceptorClassInBeansXmlTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.4", id = "cab")
public void testNonInterceptorClassInBeansXmlNotOk()
{
15 years
Weld SVN: r4028 - in cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests: interceptors/definition and 2 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 04:16:59 -0400 (Wed, 14 Oct 2009)
New Revision: 4028
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/Transactional.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/FordInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Deadly.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Fast.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/FastAndDeadlyMissile.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/MultipleInterceptorBindingsTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Slow.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/SlowMissile.java
Log:
Fixing and enabling tests.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -398,7 +398,7 @@
assert InteriorDecorator.isDestroyed();
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "6.4.1", id = "aa")
public void testDependentScopedInterceptorsAreDependentObjectsOfBean()
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -166,7 +166,7 @@
assert interceptors.get(1).getInterceptorBindingTypes().contains(transactionalBinding);
}
- @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
+ @Test(expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
@SpecAssertion(section = "11.3.12", id = "b")
})
@@ -179,7 +179,7 @@
getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, transactionalBinding, transactionalBinding);
}
- @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
+ @Test(expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
@SpecAssertion(section = "11.3.12", id = "c")
})
@@ -189,7 +189,7 @@
getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE);
}
- @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
+ @Test(expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
@SpecAssertion(section = "11.3.12", id = "d")
})
@@ -229,7 +229,7 @@
assert !MissileInterceptor.intercepted;
}
- @Test (groups = "ri-broken")
+ @Test
@SpecAssertion(section = "7.2", id = "ia")
public void testProducerMethodsAreIntercepted()
{
@@ -277,7 +277,7 @@
assert NetworkLogger.intercepted;
}
- @Test (groups = "ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section = "9.1.1", id = "a"),
@SpecAssertion(section = "9.1.1", id = "b")
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/FordInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/FordInterceptor.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/FordInterceptor.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -2,7 +2,9 @@
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
+import javax.interceptor.Interceptor;
+@Interceptor @Transactional
class FordInterceptor
{
@AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/Transactional.java (from rev 4022, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidLifecycleInterceptor/Transactional.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/Transactional.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/Transactional.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.broken.sameClassListedTwiceInBeansXml;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@InterceptorBinding
+@interface Transactional
+{
+
+}
\ No newline at end of file
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Deadly.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Deadly.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Deadly.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -11,12 +11,13 @@
import java.lang.annotation.Target;
import javax.inject.Qualifier;
+import javax.interceptor.InterceptorBinding;
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Target( { TYPE, METHOD})
@Retention(RUNTIME)
@Documented
-@Qualifier
-@interface Deadly
+@InterceptorBinding
+public @interface Deadly
{
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Fast.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Fast.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Fast.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -11,12 +11,13 @@
import java.lang.annotation.Target;
import javax.inject.Qualifier;
+import javax.interceptor.InterceptorBinding;
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Target( { TYPE, METHOD})
@Retention(RUNTIME)
@Documented
-@Qualifier
-@interface Fast
+@InterceptorBinding
+public @interface Fast
{
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/FastAndDeadlyMissile.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/FastAndDeadlyMissile.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/FastAndDeadlyMissile.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -1,8 +1,6 @@
package org.jboss.jsr299.tck.tests.interceptors.definition.multipleBindings;
-import javax.interceptor.Interceptors;
-(a)Interceptors(MissileInterceptor.class)
@Fast @Deadly
class FastAndDeadlyMissile implements Missile
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/MultipleInterceptorBindingsTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/MultipleInterceptorBindingsTest.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/MultipleInterceptorBindingsTest.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -15,7 +15,7 @@
@BeansXml("beans.xml")
public class MultipleInterceptorBindingsTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section = "9.5.1", id = "a"),
@SpecAssertion(section = "9.5", id = "ca")
@@ -24,21 +24,19 @@
{
MissileInterceptor.intercepted = false;
- Missile missile = getInstanceByType(Missile.class,
- new AnnotationLiteral<Fast>() {}, new AnnotationLiteral<Deadly>() {});
+ Missile missile = getInstanceByType(FastAndDeadlyMissile.class);
missile.fire();
assert MissileInterceptor.intercepted;
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.5.1", id = "b")
public void testInterceptorNotAppliedToBeanWithSomeBindings()
{
MissileInterceptor.intercepted = false;
- Missile missile = getInstanceByType(Missile.class,
- new AnnotationLiteral<Slow>() {}, new AnnotationLiteral<Deadly>() {});
+ Missile missile = getInstanceByType(SlowMissile.class);
missile.fire();
assert !MissileInterceptor.intercepted;
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Slow.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Slow.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/Slow.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -1,22 +1,21 @@
package org.jboss.jsr299.tck.tests.interceptors.definition.multipleBindings;
+import java.lang.annotation.Documented;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
-import javax.inject.Qualifier;
+import javax.interceptor.InterceptorBinding;
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Target( { TYPE, METHOD})
@Retention(RUNTIME)
@Documented
-@Qualifier
-@interface Slow
+@InterceptorBinding
+public @interface Slow
{
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/SlowMissile.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/SlowMissile.java 2009-10-14 07:26:33 UTC (rev 4027)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/multipleBindings/SlowMissile.java 2009-10-14 08:16:59 UTC (rev 4028)
@@ -1,8 +1,6 @@
package org.jboss.jsr299.tck.tests.interceptors.definition.multipleBindings;
-import javax.interceptor.Interceptors;
-(a)Interceptors(MissileInterceptor.class)
@Slow @Deadly
class SlowMissile implements Missile
{
15 years
Weld SVN: r4027 - in core/trunk/impl/src/main/java/org/jboss/weld: bean and 5 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 03:26:33 -0400 (Wed, 14 Oct 2009)
New Revision: 4027
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java
core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
Log:
Fixing some interceptor functionality - structural validation, deployment error reporting.
Modified: core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -1055,6 +1055,17 @@
*/
public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
{
+ if (interceptorBindings.length == 0)
+ throw new IllegalArgumentException("Interceptor bindings list cannot be empty");
+ Set<Class<?>> uniqueInterceptorBindings = new HashSet<Class<?>>();
+ for (Annotation interceptorBinding: interceptorBindings)
+ {
+ if (uniqueInterceptorBindings.contains(interceptorBinding.annotationType()))
+ throw new IllegalArgumentException("Duplicate interceptor binding type: " + interceptorBinding.annotationType());
+ if (!isInterceptorBindingType(interceptorBinding.annotationType()))
+ throw new IllegalArgumentException("Trying to resolve interceptors with non-binding type: " + interceptorBinding.annotationType());
+ uniqueInterceptorBindings.add(interceptorBinding.annotationType());
+ }
return new ArrayList<Interceptor<?>>(interceptorResolver.resolve(ResolvableFactory.of(type,interceptorBindings)));
}
@@ -1280,7 +1291,7 @@
{
if (getServices().get(MetaAnnotationStore.class).getInterceptorBindingModel(bindingType).isValid())
{
- return getServices().get(MetaAnnotationStore.class).getInterceptorBindingModel(bindingType).getInheritedInterceptionBindingTypes();
+ return getServices().get(MetaAnnotationStore.class).getInterceptorBindingModel(bindingType).getMetaAnnotations();
}
else
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -42,6 +42,7 @@
import org.jboss.interceptor.model.InterceptionModelBuilder;
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.DefinitionException;
+import org.jboss.weld.DeploymentException;
import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.context.SerializableContextualInstance;
@@ -405,31 +406,40 @@
return foundInterceptionBindingTypes;
}
+
+
protected void initInterceptors()
{
if (manager.getBoundInterceptorsRegistry().getInterceptionModel(getType()) == null)
{
InterceptionModelBuilder<Class<?>, SerializableContextual<Interceptor<?>, ?>> builder = InterceptionModelBuilder.newBuilderFor(getType(), (Class) SerializableContextual.class);
-
Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(manager, getAnnotatedItem().getAnnotations());
for (Class<? extends Annotation> annotation : getStereotypes())
{
classBindingAnnotations.addAll(flattenInterceptorBindings(manager, manager.getStereotypeDefinition(annotation)));
}
-
- Annotation[] classBindingAnnotationsArray = classBindingAnnotations.toArray(new Annotation[0]);
- builder.interceptPostConstruct().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_CONSTRUCT, classBindingAnnotationsArray)));
- builder.interceptPreDestroy().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_DESTROY, classBindingAnnotationsArray)));
- builder.interceptPrePassivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_PASSIVATE, classBindingAnnotationsArray)));
- builder.interceptPostActivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_ACTIVATE, classBindingAnnotationsArray)));
-
+ if (classBindingAnnotations.size() > 0)
+ {
+ if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
+ throw new DeploymentException("Conflicting interceptor bindings found on " + getType());
+ Annotation[] classBindingAnnotationsArray = classBindingAnnotations.toArray(new Annotation[0]);
+ builder.interceptPostConstruct().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_CONSTRUCT, classBindingAnnotationsArray)));
+ builder.interceptPreDestroy().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_DESTROY, classBindingAnnotationsArray)));
+ builder.interceptPrePassivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.PRE_PASSIVATE, classBindingAnnotationsArray)));
+ builder.interceptPostActivate().with(toSerializableContextualArray(manager.resolveInterceptors(InterceptionType.POST_ACTIVATE, classBindingAnnotationsArray)));
+ }
List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
for (WeldMethod<?, ?> method : businessMethods)
{
- List<Annotation> methodBindingAnnotations = new ArrayList<Annotation>(classBindingAnnotations);
+ Set<Annotation> methodBindingAnnotations = new HashSet<Annotation>(classBindingAnnotations);
methodBindingAnnotations.addAll(flattenInterceptorBindings(manager, method.getAnnotations()));
- List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
- builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+ if (methodBindingAnnotations.size() > 0)
+ {
+ if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
+ throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
+ List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
+ builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+ }
}
manager.getBoundInterceptorsRegistry().registerInterceptionModel(getType(), builder.build());
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -19,6 +19,7 @@
import java.lang.annotation.Annotation;
import java.util.Set;
+import java.util.HashSet;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
@@ -28,6 +29,8 @@
import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.DeploymentException;
+import org.jboss.weld.util.Beans;
import org.jboss.weld.introspector.WeldClass;
/**
@@ -43,7 +46,20 @@
{
super(type, new StringBuilder().append(Interceptor.class.getSimpleName()).append(BEAN_ID_SEPARATOR).append(type.getName()).toString(), manager);
this.interceptorClassMetadata = InterceptorClassMetadataRegistry.getRegistry().getInterceptorClassMetadata(type.getJavaClass());
- this.interceptorBindingTypes = flattenInterceptorBindings(manager, getAnnotatedItem().getAnnotations());
+ this.interceptorBindingTypes = new HashSet<Annotation>();
+ interceptorBindingTypes.addAll(flattenInterceptorBindings(manager, getAnnotatedItem().getAnnotations()));
+ for (Class<? extends Annotation> annotation : getStereotypes())
+ {
+ interceptorBindingTypes.addAll(flattenInterceptorBindings(manager, manager.getStereotypeDefinition(annotation)));
+ }
+ if (this.interceptorBindingTypes.size() == 0)
+ {
+ throw new DeploymentException("An interceptor must have at least one binding, but " + type.getName() + " has none");
+ }
+ if (Beans.findInterceptorBindingConflicts(manager, interceptorBindingTypes))
+ {
+ throw new DeploymentException("Conflicting interceptor bindings found on " + getType());
+ }
}
public static <T> InterceptorImpl<T> of(WeldClass<T> type, BeanManagerImpl manager)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -17,6 +17,8 @@
package org.jboss.weld.bean.interceptor;
+import java.lang.reflect.Constructor;
+
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
@@ -24,6 +26,7 @@
import org.jboss.interceptor.proxy.DirectClassInterceptionHandler;
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.DeploymentException;
+import org.jboss.weld.util.Reflections;
/**
* @author Marius Bogoevici
@@ -44,7 +47,9 @@
try
{
// this is not a managed instance - assume no-argument constructor exists
- Object interceptorInstance = clazz.newInstance();
+ Constructor constructor = clazz.getDeclaredConstructor();
+ Reflections.ensureAccessible(constructor);
+ Object interceptorInstance = constructor.newInstance();
// inject
manager.createInjectionTarget(manager.createAnnotatedType(clazz)).inject(interceptorInstance, creationalContext);
return new DirectClassInterceptionHandler(interceptorInstance, clazz);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -23,6 +23,7 @@
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
+import javax.interceptor.Interceptor;
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.bean.AbstractClassBean;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -25,6 +25,7 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.Container;
+import org.jboss.weld.DeploymentException;
import org.jboss.weld.bootstrap.events.ProcessAnnotatedTypeImpl;
import org.jboss.weld.ejb.EjbDescriptors;
import org.jboss.weld.ejb.InternalEjbDescriptor;
@@ -98,10 +99,12 @@
boolean managedBeanOrDecorator = !getEnvironment().getEjbDescriptors().contains(clazz.getJavaClass()) && isTypeManagedBeanOrDecorator(clazz);
if (managedBeanOrDecorator && clazz.isAnnotationPresent(Decorator.class))
{
+ validateDecorator(clazz);
createDecorator(clazz);
}
else if (managedBeanOrDecorator && clazz.isAnnotationPresent(Interceptor.class))
{
+ validateInterceptor(clazz);
createInterceptor(clazz);
}
else if (managedBeanOrDecorator && !clazz.isAbstract())
@@ -116,4 +119,20 @@
return this;
}
+ private void validateInterceptor(WeldClass<?> clazz)
+ {
+ if (clazz.isAnnotationPresent(Decorator.class))
+ {
+ throw new DeploymentException("Class " + clazz.getName() + " has both @Interceptor and @Decorator annotations");
+ }
+ }
+
+ private void validateDecorator(WeldClass<?> clazz)
+ {
+ if (clazz.isAnnotationPresent(Interceptor.class))
+ {
+ throw new DeploymentException("Class " + clazz.getName() + " has both @Interceptor and @Decorator annotations");
+ }
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -75,11 +75,16 @@
public boolean isEqual(Annotation instance, Annotation other)
{
+ return isEqual(instance, other, false);
+ }
+
+ public boolean isEqual(Annotation instance, Annotation other, boolean includeNonBindingTypes)
+ {
if (instance.annotationType().equals(getRawType()) && other.annotationType().equals(getRawType()))
{
for (WeldMethod<?, ?> annotatedMethod : getAnnotatedAnnotation().getMembers())
{
- if (!nonBindingTypes.contains(annotatedMethod))
+ if (includeNonBindingTypes || !nonBindingTypes.contains(annotatedMethod))
{
try
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -232,8 +232,6 @@
{
int modifiers = ((WeldMember) annotatedMethod).getJavaMember().getModifiers();
boolean businessMethod = !annotatedMethod.isStatic()
- && (Modifier.isPublic(modifiers)
- || Modifier.isProtected(modifiers))
&& !annotatedMethod.isAnnotationPresent(Inject.class);
if (businessMethod)
@@ -479,6 +477,27 @@
}
return true;
}
+
+ public static boolean findInterceptorBindingConflicts(BeanManagerImpl manager, Set<Annotation> bindings)
+ {
+ Map<Class<? extends Annotation>, Annotation> foundAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation binding: bindings)
+ {
+ if (foundAnnotations.containsKey(binding.annotationType()))
+ {
+ InterceptorBindingModel<?> bindingType = manager.getServices().get(MetaAnnotationStore.class).getInterceptorBindingModel(binding.annotationType());
+ if (!bindingType.isEqual(binding, foundAnnotations.get(binding.annotationType()), false))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ foundAnnotations.put(binding.annotationType(), binding);
+ }
+ }
+ return false;
+ }
/**
@@ -719,5 +738,5 @@
{
return annotatedItem.isAnnotationPresent(Decorator.class);
}
-
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-10-14 07:19:49 UTC (rev 4026)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2009-10-14 07:26:33 UTC (rev 4027)
@@ -28,6 +28,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.interceptor.Interceptor;
import org.jboss.weld.DeploymentException;
import org.jboss.weld.resources.spi.ResourceLoader;
@@ -203,7 +204,7 @@
else if (interceptorsElements.size() == 1)
{
enabledInterceptorClasses = new ArrayList<Class<?>>();
- enabledInterceptorClasses.addAll(processElement(resourceLoader, interceptorsElements.get(0)));
+ enabledInterceptorClasses.addAll(processInterceptorElement(resourceLoader, interceptorsElements.get(0)));
}
}
@@ -268,5 +269,39 @@
}
return list;
}
+
+ private static List<Class<?>> processInterceptorElement(ResourceLoader resourceLoader, XmlElement element)
+ {
+ List<Class<?>> list = new ArrayList<Class<?>>();
+ for (Node child : new NodeListIterable(element.getElement().getChildNodes()))
+ {
+ String className = processNode(child);
+ if (className != null)
+ {
+ try
+ {
+ Class<?> clazz = resourceLoader.classForName(className);
+ if (!clazz.isAnnotationPresent(Interceptor.class))
+ {
+ throw new DeploymentException("Class " + clazz.getName() + " is enabled as an interceptor," +
+ " but it does not have the appropriate annotation");
+ }
+ else if (list.contains(clazz))
+ {
+ throw new DeploymentException("Class " + clazz.getName() + " is listed twice as an enabled interceptor");
+ }
+ else
+ {
+ list.add(clazz);
+ }
+ }
+ catch (ResourceLoadingException e)
+ {
+ throw new DeploymentException("Cannot load class " + className + " defined in " + element.getFile().toString());
+ }
+ }
+ }
+ return list;
+ }
}
15 years
Weld SVN: r4026 - in cdi-tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorWithNoBinding and 5 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 03:19:49 -0400 (Wed, 14 Oct 2009)
New Revision: 4026
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Secure.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorCanNotBeDecorator/InterceptorCanNotBeDecoratorTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorWithNoBinding/InterceptorWithNoBindingTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/FooStereotype.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/InvalidInterceptorBindingAnnotationsTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/SameClassListedTwiceInBeansXmlTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorNotListedInBeansXml/Transactional.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/AnotherInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/FirstInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Foo.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/InterceptorOrderTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/SecondInterceptor.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml
Log:
Corrections to make the tests compliant with the specification. Enabling tests.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorCanNotBeDecorator/InterceptorCanNotBeDecoratorTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorCanNotBeDecorator/InterceptorCanNotBeDecoratorTest.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorCanNotBeDecorator/InterceptorCanNotBeDecoratorTest.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -15,7 +15,7 @@
@BeansXml("beans.xml")
public class InterceptorCanNotBeDecoratorTest extends AbstractJSR299Test
{
- @Test(groups = { "ri-broken" })
+ @Test
@SpecAssertion(section = "3.1", id = "f0")
public void testInterceptorCanNotAlsoBeDecorator() throws Exception
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorWithNoBinding/InterceptorWithNoBindingTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorWithNoBinding/InterceptorWithNoBindingTest.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/interceptorWithNoBinding/InterceptorWithNoBindingTest.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -17,10 +17,10 @@
@SpecVersion(spec="cdi", version="PFD2")
public class InterceptorWithNoBindingTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.2", id = "c")
public void testInterceptorWithNoBindingNotOk()
{
-
+ assert false;
}
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/FooStereotype.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/FooStereotype.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/FooStereotype.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -12,11 +12,11 @@
import javax.enterprise.inject.stereotype.Stereotype;
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Target( { TYPE, METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@FooBinding("abc")
-@Stereotype
+public @Stereotype
@interface FooStereotype
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/InvalidInterceptorBindingAnnotationsTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/InvalidInterceptorBindingAnnotationsTest.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/invalidBindingAnnotations/InvalidInterceptorBindingAnnotationsTest.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -1,6 +1,7 @@
package org.jboss.jsr299.tck.tests.interceptors.definition.broken.invalidBindingAnnotations;
import org.jboss.jsr299.tck.DeploymentError;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
@@ -12,9 +13,9 @@
@ExpectedDeploymentException(DeploymentError.class)
@SpecVersion(spec="cdi", version="PFD2")
@BeansXml("beans.xml")
-public class InvalidInterceptorBindingAnnotationsTest
+public class InvalidInterceptorBindingAnnotationsTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.5.2", id = "d")
public void testInterceptorBindingsWithConflictingAnnotationMembersNotOk()
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/SameClassListedTwiceInBeansXmlTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/SameClassListedTwiceInBeansXmlTest.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/broken/sameClassListedTwiceInBeansXml/SameClassListedTwiceInBeansXmlTest.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -15,7 +15,7 @@
@BeansXml("beans.xml")
public class SameClassListedTwiceInBeansXmlTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.4", id = "cb")
public void testSameInterceptorClassListedTwiceInBeansXmlNotOk()
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorNotListedInBeansXml/Transactional.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorNotListedInBeansXml/Transactional.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorNotListedInBeansXml/Transactional.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -12,7 +12,7 @@
import javax.interceptor.InterceptorBinding;
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Target( { TYPE, METHOD })
@Retention(RUNTIME)
@Documented
@InterceptorBinding
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/AnotherInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/AnotherInterceptor.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/AnotherInterceptor.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -4,7 +4,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-@Interceptor
class AnotherInterceptor
{
public static boolean first = false;
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/FirstInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/FirstInterceptor.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/FirstInterceptor.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -4,7 +4,7 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-@Interceptor
+@Interceptor @Secure
public class FirstInterceptor
{
public static boolean calledFirst = false;
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Foo.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Foo.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Foo.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -2,7 +2,7 @@
import javax.interceptor.Interceptors;
-(a)Interceptors({FirstInterceptor.class, SecondInterceptor.class})
+@Secure
class Foo
{
public void bar() {}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/InterceptorOrderTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/InterceptorOrderTest.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/InterceptorOrderTest.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -13,7 +13,7 @@
@BeansXml("beans.xml")
public class InterceptorOrderTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section = "9.4", id = "b"),
@SpecAssertion(section = "9.5", id = "ea")
@@ -29,7 +29,7 @@
assert SecondInterceptor.calledFirst;
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.4", id = "f")
public void testInterceptorsDeclaredUsingInterceptorsCalledBeforeInterceptorBinding()
{
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/SecondInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/SecondInterceptor.java 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/SecondInterceptor.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -4,7 +4,7 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-@Interceptor
+@Interceptor @Secure
public class SecondInterceptor
{
public static boolean calledFirst = false;
Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Secure.java (from rev 4022, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Transactional.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Secure.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorOrder/Secure.java 2009-10-14 07:19:49 UTC (rev 4026)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition.interceptorOrder;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+@Target( { TYPE, METHOD})
+@Retention(RUNTIME)
+@Documented
+@InterceptorBinding
+@interface Secure
+{
+
+}
\ No newline at end of file
Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml 2009-10-14 05:37:42 UTC (rev 4025)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml 2009-10-14 07:19:49 UTC (rev 4026)
@@ -1,7 +1,4 @@
<beans>
- <interceptors>
- <class>org.jboss.jsr299.tck.tests.interceptors.definition.interceptorCalledBeforeDecorator.TransactionInterceptor</class>
- </interceptors>
<decorators>
<class>org.jboss.jsr299.tck.tests.interceptors.definition.interceptorCalledBeforeDecorator.FooDecorator</class>
</decorators>
15 years
Weld SVN: r4025 - in cdi-tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator and 1 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-14 01:37:42 -0400 (Wed, 14 Oct 2009)
New Revision: 4025
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MissileInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/TransactionInterceptor.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/dependent/beans.xml
Log:
Corrections to make the tests compliant with the specification (i.e. @Interceptor-annotated beans *must* specify bindings, interceptors must be declared, etc). Enabling tests.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-10-14 03:28:06 UTC (rev 4024)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2009-10-14 05:37:42 UTC (rev 4025)
@@ -411,7 +411,7 @@
AccountTransaction trans = bean.create(ctx);
trans.execute();
- assert TransactionalInterceptor.intercepted = true;
+ assert TransactionalInterceptor.intercepted;
bean.destroy(trans, ctx);
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MissileInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MissileInterceptor.java 2009-10-14 03:28:06 UTC (rev 4024)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/MissileInterceptor.java 2009-10-14 05:37:42 UTC (rev 4025)
@@ -2,10 +2,11 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
+import javax.interceptor.AroundInvoke;
-@Interceptor
class MissileInterceptor
{
+ @AroundInvoke
public Object intercept(InvocationContext context) throws Exception
{
return context.proceed();
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/TransactionInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/TransactionInterceptor.java 2009-10-14 03:28:06 UTC (rev 4024)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/TransactionInterceptor.java 2009-10-14 05:37:42 UTC (rev 4025)
@@ -4,7 +4,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-@Interceptor
public class TransactionInterceptor
{
@AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/dependent/beans.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/dependent/beans.xml 2009-10-14 03:28:06 UTC (rev 4024)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/dependent/beans.xml 2009-10-14 05:37:42 UTC (rev 4025)
@@ -1,6 +1,8 @@
<beans>
<decorators>
- <decorator>org.jboss.jsr299.tck.tests.context.dependent.InteriorDecorator</decorator>
+ <class>org.jboss.jsr299.tck.tests.context.dependent.InteriorDecorator</class>
</decorators>
-
+ <interceptors>
+ <class>org.jboss.jsr299.tck.tests.context.dependent.TransactionalInterceptor</class>
+ </interceptors>
</beans>
15 years
Weld SVN: r4024 - in cdi-tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/interceptors/definition and 1 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-13 23:28:06 -0400 (Tue, 13 Oct 2009)
New Revision: 4024
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NotEnabledAtomicInterceptor.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/AtomicInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/FileLogger.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/MissileInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NetworkLogger.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/SecureTransaction.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/beans.xml
Log:
Fixing InterceptorDefinitionTest and enabling tests.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -42,6 +42,7 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.stereotype.Stereotype;
import javax.inject.Qualifier;
@@ -142,7 +143,7 @@
assert !getCurrentManager().isStereotype(Transactional.class);
}
- @Test(groups = {"ri-broken", "rewrite"})
+ @Test(groups="rewrite")
// WBRI-59
// Should also check a custom interceptor binding type
@SpecAssertion(section = "11.3.13", id = "ad")
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/AtomicInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/AtomicInterceptor.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/AtomicInterceptor.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -11,6 +11,7 @@
@AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
{
+ intercepted = true;
return ctx.proceed();
}
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/FileLogger.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/FileLogger.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/FileLogger.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -7,8 +7,11 @@
@Logged @Interceptor
class FileLogger
{
+ public static boolean intercepted = false;
+
@AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
{
+ intercepted = true;
return ctx.proceed();
}
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -20,15 +20,14 @@
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
-import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.ArrayList;
import javax.enterprise.inject.AnnotationLiteral;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
@@ -37,6 +36,8 @@
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+
import org.testng.annotations.Test;
/**
@@ -44,23 +45,24 @@
* their execution.
*
* @author David Allen
- *
+ * @author Marius Bogoevici
*/
@Artifact
-@SpecVersion(spec="cdi", version="PFD2")
+@SpecVersion(spec = "cdi", version = "PFD2")
+@BeansXml("beans.xml")
public class InterceptorDefinitionTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "11.1.2", id = "a")
+ @SpecAssertion(section = "11.1.2", id = "a")
})
// WBRI-59
public void testInterceptorsImplementInterceptorInterface()
{
boolean interfaceFound = false;
- for (Type type : getInterfacesImplemented(getBeans(TransactionalInterceptor.class).iterator().next().getClass()))
+ for (Type type : getInterfacesImplemented(getTransactionalInterceptor().getClass()))
{
- if (type.equals(Interceptor.class))
+ if (type instanceof ParameterizedTypeImpl && ((ParameterizedTypeImpl)type).getRawType().equals(Interceptor.class))
{
interfaceFound = true;
break;
@@ -68,35 +70,28 @@
}
assert interfaceFound;
}
-
- private Set<Type> getInterfacesImplemented(Class<?> clazz)
- {
- Set<Type> interfaces = new HashSet<Type>();
- interfaces.addAll(new HierarchyDiscovery(clazz).getFlattenedTypes());
- return interfaces;
- }
-
- @Test(groups = "ri-broken")
+
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "11.1.2", id = "b")
+ @SpecAssertion(section = "11.1.2", id = "b")
})
// WBRI-59
public void testInterceptorBindingTypes()
{
- Interceptor<?> interceptorBean = (Interceptor<?>) getBeans(TransactionalInterceptor.class).iterator().next();
+ Interceptor<?> interceptorBean = getTransactionalInterceptor();
assert interceptorBean.getInterceptorBindingTypes().size() == 1;
- assert interceptorBean.getInterceptorBindingTypes().contains(Transactional.class);
+ assert interceptorBean.getInterceptorBindingTypes().contains(new AnnotationLiteral<Transactional>(){});
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "11.1.2", id = "c"),
- @SpecAssertion(section = "11.1.2", id = "e")
+ @SpecAssertion(section = "11.1.2", id = "c"),
+ @SpecAssertion(section = "11.1.2", id = "e")
})
// WBRI-59
public void testInterceptionType()
{
- Interceptor<?> interceptorBean = (Interceptor<?>) getBeans(TransactionalInterceptor.class).iterator().next();
+ Interceptor<?> interceptorBean = getTransactionalInterceptor();
assert interceptorBean.intercepts(InterceptionType.AROUND_INVOKE);
assert !interceptorBean.intercepts(InterceptionType.POST_ACTIVATE);
assert !interceptorBean.intercepts(InterceptionType.POST_CONSTRUCT);
@@ -104,24 +99,61 @@
assert !interceptorBean.intercepts(InterceptionType.PRE_PASSIVATE);
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "11.1.2", id = "f")
// WBRI-59
public void testInstanceOfInterceptorForEveryEnabledInterceptor()
{
- assert !getBeans(TransactionalInterceptor.class).isEmpty();
- assert !getBeans(SecureInterceptor.class).isEmpty();
+ List<AnnotationLiteral<?>> annotationLiterals = Arrays.<AnnotationLiteral<?>>asList(
+ new AnnotationLiteral<Transactional>(){},
+ new AnnotationLiteral<Secure>(){},
+ new AnnotationLiteral<MissileBinding>(){},
+ new AnnotationLiteral<Logged>(){});
+
+ List<Class<?>> interceptorClasses = new ArrayList<Class<?>>(Arrays.<Class<?>>asList(
+ AtomicInterceptor.class,
+ MissileInterceptor.class,
+ SecureInterceptor.class,
+ TransactionalInterceptor.class,
+ NetworkLogger.class,
+ FileLogger.class,
+ NotEnabledAtomicInterceptor.class
+ ));
+
+ for (AnnotationLiteral<?> annotationLiteral: annotationLiterals)
+ {
+ List<Interceptor<?>> interceptors = getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, annotationLiteral);
+ for (Interceptor<?> interceptor: interceptors)
+ {
+ interceptorClasses.remove(interceptor.getBeanClass());
+ }
+ }
+
+ List<Interceptor<?>> interceptors = getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE,
+ new AnnotationLiteral<Atomic>(){},
+ new AnnotationLiteral<MissileBinding>(){});
+ for (Interceptor<?> interceptor : interceptors)
+ {
+ interceptorClasses.remove(interceptor.getBeanClass());
+ }
+
+ assert interceptorClasses.size() == 1;
+ assert interceptorClasses.get(0).equals(NotEnabledAtomicInterceptor.class);
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "11.3.12", id = "a")
+ @SpecAssertion(section = "11.3.12", id = "a")
})
// WBRI-59
public void testResolveInterceptorsReturnsOrderedList()
{
- Annotation transactionalBinding = new AnnotationLiteral<Transactional>() {};
- Annotation secureBinding = new AnnotationLiteral<Secure>() {};
+ Annotation transactionalBinding = new AnnotationLiteral<Transactional>()
+ {
+ };
+ Annotation secureBinding = new AnnotationLiteral<Secure>()
+ {
+ };
List<Interceptor<?>> interceptors = getCurrentManager().resolveInterceptors(
InterceptionType.AROUND_INVOKE,
transactionalBinding,
@@ -129,126 +161,158 @@
);
assert interceptors.size() == 2;
assert interceptors.get(0).getInterceptorBindingTypes().size() == 1;
- assert interceptors.get(0).getInterceptorBindingTypes().contains(transactionalBinding);
+ assert interceptors.get(0).getInterceptorBindingTypes().contains(secureBinding);
assert interceptors.get(1).getInterceptorBindingTypes().size() == 1;
- assert interceptors.get(1).getInterceptorBindingTypes().contains(secureBinding);
+ assert interceptors.get(1).getInterceptorBindingTypes().contains(transactionalBinding);
}
-
- @Test(groups = "ri-broken")
+
+ @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
- @SpecAssertion(section = "11.3.12", id = "b")
+ @SpecAssertion(section = "11.3.12", id = "b")
})
// WBRI-59
public void testSameBindingTypesToResolveInterceptorsFails()
{
- Annotation transactionalBinding = new AnnotationLiteral<Transactional>() {};
+ Annotation transactionalBinding = new AnnotationLiteral<Transactional>()
+ {
+ };
getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, transactionalBinding, transactionalBinding);
}
-
- @Test(groups = "ri-broken")
+
+ @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
- @SpecAssertion(section = "11.3.12", id = "c")
+ @SpecAssertion(section = "11.3.12", id = "c")
})
// WBRI-59
public void testNoBindingTypesToResolveInterceptorsFails()
{
getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE);
}
-
- @Test(groups = "ri-broken")
+
+ @Test(groups = "ri-broken", expectedExceptions = {IllegalArgumentException.class})
@SpecAssertions({
- @SpecAssertion(section = "11.3.12", id = "d")
+ @SpecAssertion(section = "11.3.12", id = "d")
})
// WBRI-59
public void testNonBindingTypeToResolveInterceptorsFails()
{
- Annotation nonBinding = new AnnotationLiteral<NonBindingType>() {};
+ Annotation nonBinding = new AnnotationLiteral<NonBindingType>()
+ {
+ };
getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, nonBinding);
}
-
- @Test(groups = "ri-broken")
+
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "7.2", id = "a"),
- @SpecAssertion(section = "9.2", id = "a"),
- @SpecAssertion(section = "12.3", id = "kb")
+ @SpecAssertion(section = "7.2", id = "a"),
+ @SpecAssertion(section = "9.2", id = "a"),
+ @SpecAssertion(section = "12.3", id = "kb")
})
public void testManagedBeanIsIntercepted()
{
MissileInterceptor.intercepted = false;
-
+
Missile missile = getInstanceByType(Missile.class);
missile.fire();
-
+
assert MissileInterceptor.intercepted;
}
-
+
@Test
@SpecAssertion(section = "7.2", id = "a1")
public void testInitializerMethodsNotIntercepted()
{
MissileInterceptor.intercepted = false;
-
+
getInstanceByType(Missile.class);
-
+
assert !MissileInterceptor.intercepted;
}
-
- @Test(groups = "ri-broken")
+
+ @Test (groups = "ri-broken")
@SpecAssertion(section = "7.2", id = "ia")
public void testProducerMethodsAreIntercepted()
{
MissileInterceptor.intercepted = false;
-
+
getInstanceByType(Wheat.class);
-
+
assert MissileInterceptor.intercepted;
}
-
- @Test(groups = "ri-broken")
+
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "9.1", id = "a"),
- @SpecAssertion(section = "9.1", id = "b"),
- @SpecAssertion(section = "9.1", id = "c"),
- @SpecAssertion(section = "9.3", id = "a")
+ @SpecAssertion(section = "9.1", id = "a"),
+ @SpecAssertion(section = "9.1", id = "b"),
+ @SpecAssertion(section = "9.1", id = "c"),
+ @SpecAssertion(section = "9.3", id = "a")
})
public void testInterceptorBindingAnnotation()
- {
- Interceptor<?> interceptorBean = (Interceptor<?>) getBeans(FileLogger.class).iterator().next();
+ {
+ Interceptor<?> interceptorBean = getLoggedInterceptors().iterator().next();
assert interceptorBean.getInterceptorBindingTypes().size() == 1;
- assert interceptorBean.getInterceptorBindingTypes().contains(Logged.class);
+ assert interceptorBean.getInterceptorBindingTypes().contains(new AnnotationLiteral<Logged>(){});
- Target target = ((AnnotatedElement) interceptorBean.getInterceptorBindingTypes().iterator().next()).getAnnotation(Target.class);
+ Target target = (interceptorBean.getInterceptorBindingTypes().iterator().next()).annotationType().getAnnotation(Target.class);
List<ElementType> elements = Arrays.asList(target.value());
assert elements.contains(ElementType.TYPE);
- assert elements.contains(ElementType.METHOD);
+ assert elements.contains(ElementType.METHOD);
}
-
- @Test(groups = "ri-broken")
+
+ @Test
@SpecAssertions({
- @SpecAssertion(section = "9.1.2", id = "a"),
- @SpecAssertion(section = "9.1.2", id = "b"),
- @SpecAssertion(section = "2.7.1.2", id = "b")
+ @SpecAssertion(section = "9.1.2", id = "a"),
+ @SpecAssertion(section = "9.1.2", id = "b"),
+ @SpecAssertion(section = "2.7.1.2", id = "b")
})
public void testStereotypeInterceptorBindings()
- {
- Bean<SecureTransaction> bean = getBeans(SecureTransaction.class).iterator().next();
- assert bean.getQualifiers().contains(Logged.class);
+ {
+ FileLogger.intercepted = false;
+ NetworkLogger.intercepted = false;
+
+ SecureTransaction secureTransaction = getInstanceByType(SecureTransaction.class);
+ secureTransaction.transact();
+
+ assert FileLogger.intercepted;
+ assert NetworkLogger.intercepted;
}
-
- @Test(groups = "ri-broken")
+
+ @Test (groups = "ri-broken")
@SpecAssertions({
- @SpecAssertion(section = "9.1.1", id = "a"),
- @SpecAssertion(section = "9.1.1", id = "b")
+ @SpecAssertion(section = "9.1.1", id = "a"),
+ @SpecAssertion(section = "9.1.1", id = "b")
})
public void testInterceptorBindingsCanDeclareOtherInterceptorBindings()
{
AtomicInterceptor.intercepted = false;
MissileInterceptor.intercepted = false;
-
+
AtomicFoo foo = getInstanceByType(AtomicFoo.class);
foo.doAction();
-
+
assert AtomicInterceptor.intercepted;
assert MissileInterceptor.intercepted;
}
+
+ private Interceptor<?> getTransactionalInterceptor()
+ {
+ return getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, new AnnotationLiteral<Transactional>()
+ {
+ }).iterator().next();
+ }
+
+ private List<Interceptor<?>> getLoggedInterceptors()
+ {
+ return getCurrentManager().resolveInterceptors(InterceptionType.AROUND_INVOKE, new AnnotationLiteral<Logged>()
+ {
+ });
+ }
+
+ private Set<Type> getInterfacesImplemented(Class<?> clazz)
+ {
+ Set<Type> interfaces = new HashSet<Type>();
+ interfaces.addAll(new HierarchyDiscovery(clazz).getFlattenedTypes());
+ return interfaces;
+ }
+
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/MissileInterceptor.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/MissileInterceptor.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/MissileInterceptor.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -4,7 +4,7 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-@Interceptor
+@Interceptor @MissileBinding
class MissileInterceptor
{
public static boolean intercepted = false;
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NetworkLogger.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NetworkLogger.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NetworkLogger.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -7,8 +7,11 @@
@Logged @Interceptor
class NetworkLogger
{
+ public static boolean intercepted = false;
+
@AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
{
+ intercepted = true;
return ctx.proceed();
}
}
Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NotEnabledAtomicInterceptor.java (from rev 4022, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/AtomicInterceptor.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NotEnabledAtomicInterceptor.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/NotEnabledAtomicInterceptor.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Atomic @Interceptor
+class NotEnabledAtomicInterceptor
+{
+ public static boolean intercepted = false;
+
+ @AroundInvoke public Object alwaysReturnThis(InvocationContext ctx) throws Exception
+ {
+ intercepted = true;
+ return ctx.proceed();
+ }
+}
\ No newline at end of file
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/SecureTransaction.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/SecureTransaction.java 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/SecureTransaction.java 2009-10-14 03:28:06 UTC (rev 4024)
@@ -3,5 +3,5 @@
@Loggable
class SecureTransaction
{
-
+ public void transact() {}
}
Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/beans.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/beans.xml 2009-10-13 23:26:59 UTC (rev 4023)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/beans.xml 2009-10-14 03:28:06 UTC (rev 4024)
@@ -4,5 +4,7 @@
<class>org.jboss.jsr299.tck.tests.interceptors.definition.MissileInterceptor</class>
<class>org.jboss.jsr299.tck.tests.interceptors.definition.SecureInterceptor</class>
<class>org.jboss.jsr299.tck.tests.interceptors.definition.TransactionalInterceptor</class>
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.FileLogger</class>
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.NetworkLogger</class>
</interceptors>
</beans>
15 years
Weld SVN: r4023 - in cdi-tck/trunk/impl/src/main: resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator and 1 other directory.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-13 19:26:59 -0400 (Tue, 13 Oct 2009)
New Revision: 4023
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/InterceptorCalledBeforeDecoratorTest.java
cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml
Log:
Fix test and enable.
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/InterceptorCalledBeforeDecoratorTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/InterceptorCalledBeforeDecoratorTest.java 2009-10-13 20:56:13 UTC (rev 4022)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/InterceptorCalledBeforeDecoratorTest.java 2009-10-13 23:26:59 UTC (rev 4023)
@@ -4,13 +4,16 @@
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+
import org.testng.annotations.Test;
@Artifact
@SpecVersion(spec="cdi", version="PFD2")
+@BeansXml("beans.xml")
public class InterceptorCalledBeforeDecoratorTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "9.4", id = "g")
public void testInterceptorCalledBeforeDecorator()
{
@@ -21,5 +24,6 @@
foo.bar();
assert Foo.interceptorCalledFirst;
+ assert !Foo.decoratorCalledFirst;
}
}
Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml 2009-10-13 20:56:13 UTC (rev 4022)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/interceptors/definition/interceptorCalledBeforeDecorator/beans.xml 2009-10-13 23:26:59 UTC (rev 4023)
@@ -2,4 +2,7 @@
<interceptors>
<class>org.jboss.jsr299.tck.tests.interceptors.definition.interceptorCalledBeforeDecorator.TransactionInterceptor</class>
</interceptors>
+ <decorators>
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.interceptorCalledBeforeDecorator.FooDecorator</class>
+ </decorators>
</beans>
15 years
Weld SVN: r4022 - core/tags/1.0.0-CR1/jboss-as.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-10-13 16:56:13 -0400 (Tue, 13 Oct 2009)
New Revision: 4022
Modified:
core/tags/1.0.0-CR1/jboss-as/build.properties
core/tags/1.0.0-CR1/jboss-as/build.xml
Log:
update to released versions
Modified: core/tags/1.0.0-CR1/jboss-as/build.properties
===================================================================
--- core/tags/1.0.0-CR1/jboss-as/build.properties 2009-10-13 17:15:21 UTC (rev 4021)
+++ core/tags/1.0.0-CR1/jboss-as/build.properties 2009-10-13 20:56:13 UTC (rev 4022)
@@ -7,8 +7,8 @@
# maximum number of TCK tests to deploy before restarting JBoss AS
# jboss.deployments.restart = 25
-weld-deployer.version=5.2.0-SNAPSHOT
-weld.version=1.0.0-SNAPSHOT
+weld-deployer.version=5.2.0-Beta3
+weld.version=1.0.0-CR1
jboss-ejb3.version=1.0.0
javassist.version=3.11.0.GA
validation.version=1.0.CR3
Modified: core/tags/1.0.0-CR1/jboss-as/build.xml
===================================================================
--- core/tags/1.0.0-CR1/jboss-as/build.xml 2009-10-13 17:15:21 UTC (rev 4021)
+++ core/tags/1.0.0-CR1/jboss-as/build.xml 2009-10-13 20:56:13 UTC (rev 4022)
@@ -22,6 +22,7 @@
<fail unless="jboss.home" message="Please pass in -Djboss.home=..." />
<delete dir="${jboss.home}/server/default/deployers/weld.deployer" failonerror="false" />
+ <delete dir="${jboss.home}/server/default/deployers/webbeans.deployer" failonerror="false" />
<delete dir="target" failonerror="false" />
<artifact:dependencies filesetId="weld.deployer.fileset" versionsId="weld.deployer.versions">
15 years
Weld SVN: r4021 - in core/trunk: bom and 8 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-10-13 13:15:21 -0400 (Tue, 13 Oct 2009)
New Revision: 4021
Modified:
core/trunk/bom/pom.xml
core/trunk/impl/pom.xml
core/trunk/inject-tck-runner/pom.xml
core/trunk/jboss-tck-runner/pom.xml
core/trunk/logging/pom.xml
core/trunk/osgi-bundle/pom.xml
core/trunk/parent/pom.xml
core/trunk/pom.xml
core/trunk/porting-package/pom.xml
core/trunk/tests/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/bom/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -3,7 +3,7 @@
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-bom</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>org.jboss.weld</groupId>
@@ -155,9 +155,9 @@
<!-- SCM and distribution management -->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/core/tags/1.0.0-CR1/bom</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/core/tags/1.0.0-CR1/bom</developerConnection>
- <url>scm:svn:https://svn.jboss.org/repos/weld/core/tags/1.0.0-CR1/core/bom</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/core/trunk/bom</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/core/trunk/bom</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Weld/core/bom</url>
</scm>
</project>
Modified: core/trunk/impl/pom.xml
===================================================================
--- core/trunk/impl/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/impl/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/inject-tck-runner/pom.xml
===================================================================
--- core/trunk/inject-tck-runner/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/inject-tck-runner/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/jboss-tck-runner/pom.xml
===================================================================
--- core/trunk/jboss-tck-runner/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/jboss-tck-runner/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/logging/pom.xml
===================================================================
--- core/trunk/logging/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/logging/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/osgi-bundle/pom.xml
===================================================================
--- core/trunk/osgi-bundle/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/osgi-bundle/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -16,7 +16,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/parent/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -7,7 +7,7 @@
<parent>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-bom</artifactId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../bom</relativePath>
</parent>
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -3,7 +3,7 @@
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-build-aggregator</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>org.jboss.weld</groupId>
@@ -18,9 +18,9 @@
<!-- SCM and distribution management -->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/core/tags/1.0.0-CR1</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/core/tags/1.0.0-CR1</developerConnection>
- <url>scm:svn:https://svn.jboss.org/repos/weld/core/tags/1.0.0-CR1</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/weld/core/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/weld/core/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Weld</url>
</scm>
<profiles>
Modified: core/trunk/porting-package/pom.xml
===================================================================
--- core/trunk/porting-package/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/porting-package/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: core/trunk/tests/pom.xml
===================================================================
--- core/trunk/tests/pom.xml 2009-10-13 17:15:01 UTC (rev 4020)
+++ core/trunk/tests/pom.xml 2009-10-13 17:15:21 UTC (rev 4021)
@@ -2,7 +2,7 @@
<parent>
<artifactId>weld-core-parent</artifactId>
<groupId>org.jboss.weld</groupId>
- <version>1.0.0-CR1</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
15 years