Author: akazakov
Date: 2010-12-15 13:28:01 -0500 (Wed, 15 Dec 2010)
New Revision: 27521
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingOk.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingWTypeTarget.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeFBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMFBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeOk.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeTMFBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWTypeTarget.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java
Log:
https://issues.jboss.org/browse/JBIDE-7897 https://issues.jboss.org/browse/JBIDE-7895
https://issues.jboss.org/browse/JBIDE-7894
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -11,7 +11,7 @@
package org.jboss.tools.cdi.internal.core.validation;
-import java.util.HashSet;
+import java.text.MessageFormat;
import java.util.Set;
import org.eclipse.core.resources.IResource;
@@ -25,6 +25,7 @@
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IScope;
import org.jboss.tools.cdi.core.IStereotype;
+import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.preferences.CDIPreferences;
/**
@@ -34,6 +35,25 @@
*/
public class AnnotationValidationDelegate extends CDICoreValidationDelegate {
+ static final String TARGET_METHOD = "METHOD";
+ static final String TARGET_FIELD = "FIELD";
+ static final String TARGET_PARAMETER = "PARAMETER";
+ static final String TARGET_TYPE = "TYPE";
+
+ static final String[] TMF = {TARGET_METHOD, TARGET_FIELD, TARGET_TYPE};
+ static final String[] MF = {TARGET_METHOD, TARGET_FIELD};
+ static final String[][] STEREOTYPE_GENERAL_TARGET_VARAINTS = {TMF, MF,
+ {TARGET_TYPE}, {TARGET_METHOD}, {TARGET_FIELD}};
+ static final String[][] QUALIFIER_GENERAL_TARGET_VARIANTS = {{TARGET_METHOD,
TARGET_FIELD, TARGET_PARAMETER, TARGET_TYPE},
+ {TARGET_FIELD, TARGET_PARAMETER}};
+ static final String[][] SCOPE_GENERAL_TARGET_VARIANTS = {TMF};
+ static final String[][] STEREOTYPE_TMF_VARIANTS = {TMF};
+ static final String[][] STEREOTYPE_MF_VARIANTS = {MF};
+ static final String[][] STEREOTYPE_M_VARIANTS = {{TARGET_METHOD}};
+ static final String[][] STEREOTYPE_F_VARIANTS = {{TARGET_FIELD}};
+
+ static final String[][] TYPE_VARIANTS = {{TARGET_TYPE}};
+
public AnnotationValidationDelegate(CDICoreValidator validator) {
super(validator);
}
@@ -43,15 +63,51 @@
* Stereotype annotation type should be annotated with @Target with correct targets
[JSR-299 §2.7.1]
* Stereotype annotation type should be annotated with @Retention(RUNTIME)
*/
- String[][] variants = {{TARGET_METHOD, TARGET_FIELD, TARGET_TYPE},
- {TARGET_METHOD, TARGET_FIELD},
- {TARGET_TYPE}, {TARGET_METHOD}, {TARGET_FIELD}};
- validateTargetAnnotation(stereotype, variants,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
+ validateTargetAnnotation(stereotype, STEREOTYPE_GENERAL_TARGET_VARAINTS,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
/*
* Stereotype annotation type should be annotated with @Retention(RUNTIME)
*/
validateRetentionAnnotation(stereotype,
CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
+
+ /*
+ * 2.7.1.5. Stereotypes with additional stereotypes
+ * - Stereotypes declared @Target(TYPE) may not be applied to stereotypes declared
@Target({TYPE, METHOD, FIELD}),
+ * @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}).
+ */
+ Set<IStereotypeDeclaration> stereotypes =
stereotype.getStereotypeDeclarations();
+ for (IStereotypeDeclaration stereotypeDeclaration : stereotypes) {
+ IStereotype superStereotype = stereotypeDeclaration.getStereotype();
+ if(superStereotype!=null) {
+ Boolean result = CDIUtil.checkTargetAnnotation(superStereotype, TYPE_VARIANTS);
+ if(result!=null && result) {
+ IAnnotationDeclaration target =
stereotype.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(target!=null) {
+ result = CDIUtil.checkTargetAnnotation(target, STEREOTYPE_TMF_VARIANTS);
+ String stName = stereotype.getSourceType().getElementName();
+ String superStName = superStereotype.getSourceType().getElementName();
+ if(result) {
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{superStName, stName}, stereotypeDeclaration, resource);
+ continue;
+ }
+ result = CDIUtil.checkTargetAnnotation(target, STEREOTYPE_M_VARIANTS);
+ if(result) {
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{superStName, stName}, stereotypeDeclaration, resource);
+ continue;
+ }
+ result = CDIUtil.checkTargetAnnotation(target, STEREOTYPE_F_VARIANTS);
+ if(result) {
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{superStName, stName}, stereotypeDeclaration, resource);
+ continue;
+ }
+ result = CDIUtil.checkTargetAnnotation(target, STEREOTYPE_MF_VARIANTS);
+ if(result) {
+ validator.addError(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, new
String[]{superStName, stName}, stereotypeDeclaration, resource);
+ }
+ }
+ }
+ }
+ }
}
/**
@@ -80,8 +136,7 @@
/*
* Scope annotation type should be annotated with @Target({TYPE, METHOD, FIELD})
*/
- String[][] variants = {{TARGET_TYPE, TARGET_METHOD, TARGET_FIELD}};
- validateTargetAnnotation(scope, variants,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE, resource);
+ validateTargetAnnotation(scope, SCOPE_GENERAL_TARGET_VARIANTS,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE, resource);
/*
* Scope annotation type should be annotated with @Retention(RUNTIME)
@@ -113,43 +168,12 @@
}
}
- Set<String> getTargetAnnotationValues(IAnnotationDeclaration target) throws
JavaModelException {
- Set<String> result = new HashSet<String>();
- IMemberValuePair[] ps = target.getDeclaration().getMemberValuePairs();
- for (IMemberValuePair p: ps) {
- if(!"value".equals(p.getMemberName())) continue;
- Object o = p.getValue();
- if(o instanceof Object[]) {
- Object[] os = (Object[])o;
- for (Object q: os) {
- String s = q.toString();
- int i = s.lastIndexOf('.');
- if(i >= 0) s = s.substring(i + 1);
- result.add(s);
- }
- } else if(o != null) {
- String s = o.toString();
- int i = s.lastIndexOf('.');
- if(i >= 0) s = s.substring(i + 1);
- result.add(s);
- }
- }
- return result;
- }
-
- static String TARGET_METHOD = "METHOD";
- static String TARGET_FIELD = "FIELD";
- static String TARGET_PARAMETER = "PARAMETER";
- static String TARGET_TYPE = "TYPE";
-
public void validateQualifierAnnotationTypeAnnotations(IQualifier qualifier, IResource
resource) throws JavaModelException {
/*
* Qualifier annotation type should be annotated with @Target({METHOD, FIELD,
PARAMETER, TYPE}) or @Target({"FIELD", "PARAMETER"})
* Qualifier annotation type should be annotated with @Retention(RUNTIME)
*/
- String[][] variants = {{TARGET_METHOD, TARGET_FIELD, TARGET_PARAMETER, TARGET_TYPE},
- {TARGET_FIELD, TARGET_PARAMETER}};
- validateTargetAnnotation(qualifier, variants,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE, resource);
+ validateTargetAnnotation(qualifier, QUALIFIER_GENERAL_TARGET_VARIANTS,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE, resource);
/*
* Qualifier annotation type should be annotated with @Retention(RUNTIME)
@@ -159,30 +183,10 @@
private void validateTargetAnnotation(ICDIAnnotation annotationType, String[][]
variants, String message, IResource resource) throws JavaModelException {
IAnnotationDeclaration target =
annotationType.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
- if(target == null) {
+ if(target==null) {
validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(annotationType.getSourceType().getNameRange()),
resource);
- } else {
- Set<String> vs = getTargetAnnotationValues(target);
- boolean ok = false;
- for (int i = 0; i < variants.length; i++) {
- if(vs.size() == variants[i].length) {
- boolean ok2 = true;
- String[] values = variants[i];
- for (String s: values) {
- if(!vs.contains(s)) {
- ok2 = false;
- break;
- }
- }
- if(ok2) {
- ok = true;
- break;
- }
- }
- }
- if(!ok) {
- validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, target,
resource);
- }
+ } else if(!CDIUtil.checkTargetAnnotation(target, variants)) {
+ validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, target,
resource);
}
}
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -2057,6 +2057,7 @@
// validate sources only
return;
}
+ addLinkedStereotypes(stereotype.getResource().getFullPath().toOSString(), stereotype);
List<IAnnotationDeclaration> as = stereotype.getAnnotationDeclarations();
// 1. non-empty name
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -59,6 +59,12 @@
public static String MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE;
public static String MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE;
public static String MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE;
+ public static String ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF;
+ public static String ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M;
+ public static String ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F;
+ public static String ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF;
+ public static String ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE;
+ public static String ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE;
public static String MULTIPLE_SCOPE_TYPE_ANNOTATIONS;
public static String MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_BEAN_CLASS;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-15
18:28:01 UTC (rev 27521)
@@ -243,4 +243,19 @@
the class with the specified name is not an interceptor class, the container
automatically detects the problem and treats it as
a deployment problem.
- If the same class is listed twice under the <interceptors> element, the container
automatically detects the problem and treats it as
- a deployment problem.
\ No newline at end of file
+ a deployment problem.
+
+
+Other errors.
+
+
+2.7.1.5. Stereotypes with additional stereotypes
+- Stereotypes declared @Target(TYPE) may not be applied to stereotypes declared
@Target({TYPE, METHOD, FIELD}),
+ @Target(METHOD), @Target(FIELD) or @Target({METHOD, FIELD}).
+
+9.1.1. Interceptor binding types with additional interceptor bindings
+- Interceptor binding types declared @Target(TYPE) may not be applied to interceptor
binding types declared
+ @Target({TYPE, METHOD}).
+
+9.1.2. Interceptor bindings for stereotypes
+- If a stereotype declares interceptor bindings, it must be defined as @Target(TYPE).
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-15
18:28:01 UTC (rev 27521)
@@ -38,6 +38,12 @@
MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE=Stereotype annotation type must be
annotated with @Retention(RUNTIME) [JSR-299 �2.7.1]
MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE=Scope annotation type must be annotated with
@Target('{'TYPE, METHOD, FIELD'}') [JSR-299 �2.4.2]
MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE=Scope annotation type must be annotated with
@Retention(RUNTIME) [JSR-299 �2.4.2]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF=Stereotype {0} is declared @Target(TYPE) and may
not be applied to stereotype {1} which is declared @Target('{TYPE, METHOD,
FIELD}') [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target(METHOD) [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target(FIELD) [JSR-299 �2.7.1.5]
+ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF=Stereotype {0} is declared @Target(TYPE) may not be
applied to stereotype {1} which is declared @Target('{METHOD, FIELD}') [JSR-299
�2.7.1.5]
+ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE=Interceptor binding type {0} is declared
@Target(TYPE) and may not be applied to interceptor binding type {1} which is declared
@Target('{TYPE, METHOD}') [JSR-299 �9.1.1]
+ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE=Stereotype {0} must be defined
as @Target(TYPE) since it declares interceptor bindings ({1}) [JSR-299 �9.1.2]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS=Bean class or producer method or field specifies multiple
scope type annotations [JSR-299 �2.4.3]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_BEAN_CLASS=Bean class specifies multiple scope type
annotations [JSR-299 �2.4.3]
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Inherited
+@InterceptorBindingWTypeTarget
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+public @interface InterceptorBindingBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingOk.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingOk.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingOk.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Inherited
+@InterceptorBindingWTypeTarget
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface InterceptorBindingOk {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingOk.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingWTypeTarget.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingWTypeTarget.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingWTypeTarget.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Inherited
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface InterceptorBindingWTypeTarget {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/InterceptorBindingWTypeTarget.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeFBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeFBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeFBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@StereotypeWTypeTarget
+@Target({ FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeFBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeFBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+@Stereotype
+@StereotypeWTypeTarget
+@Target({METHOD})
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeMBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMFBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMFBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMFBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@StereotypeWTypeTarget
+@Target({ METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeMFBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeMFBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeOk.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeOk.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeOk.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,20 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@StereotypeWTypeTarget
+@InterceptorBindingWTypeTarget
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeOk {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeOk.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeTMFBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeTMFBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeTMFBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@StereotypeWTypeTarget
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeTMFBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeTMFBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWTypeTarget.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWTypeTarget.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWTypeTarget.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,18 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeWTypeTarget {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWTypeTarget.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.target;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@InterceptorBindingWTypeTarget
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface StereotypeWithInterceptorBindingBroken {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java 2010-12-15
17:59:31 UTC (rev 27520)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java 2010-12-15
18:28:01 UTC (rev 27521)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.core.test.tck.validation;
+import java.text.MessageFormat;
+
import org.eclipse.core.resources.IFile;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;
@@ -70,4 +72,52 @@
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/annotations/scope/broken/FooScoped_WrongTarget.java");
assertMarkerIsCreated(file,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE.substring(0, 52) +
".*", 30);
}
+
+ public void testStereotypesWithAdditionalStereotypesWithTMFTarget() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeTMFBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF,
"StereotypeWTypeTarget", "StereotypeTMFBroken"), 15);
+ }
+
+ public void testStereotypesWithAdditionalStereotypesWithMTarget() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeMBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M,
"StereotypeWTypeTarget", "StereotypeMBroken"), 13);
+ }
+
+ public void testStereotypesWithAdditionalStereotypesWithFTarget() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeFBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F,
"StereotypeWTypeTarget", "StereotypeFBroken"), 13);
+ }
+
+ public void testStereotypesWithAdditionalStereotypesWithMFTarget() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeMFBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF,
"StereotypeWTypeTarget", "StereotypeMFBroken"), 14);
+ }
+
+ public void testStereotypesWithAdditionalStereotypesOk() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeOk.java");
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_TMF,
"StereotypeWTypeTarget", "StereotypeOk"), 13);
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_M,
"StereotypeWTypeTarget", "StereotypeOk"), 13);
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_F,
"StereotypeWTypeTarget", "StereotypeOk"), 13);
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF,
"StereotypeWTypeTarget", "StereotypeOk"), 13);
+ }
+
+ public void testInterceptorBindingWithAdditionalInterceptorBindings() throws Exception
{
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/InterceptorBindingBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE,
"InterceptorBindingWTypeTarget", "InterceptorBindingBroken"), 16);
+ }
+
+ public void testInterceptorBindingWithAdditionalInterceptorBindingsOk() throws Exception
{
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/InterceptorBindingOk.java");
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE,
"InterceptorBindingWTypeTarget", "InterceptorBindingOk"), 15);
+ }
+
+ public void testInterceptorBindingsForStereotypes() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeWithInterceptorBindingBroken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeWithInterceptorBindingBroken",
"InterceptorBindingWTypeTarget"), 15);
+ }
+
+ public void testInterceptorBindingsForStereotypesOk() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/target/StereotypeOk.java");
+ assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE,
"StereotypeOk", "InterceptorBindingWTypeTarget"), 14);
+ }
}
\ No newline at end of file