Author: akazakov
Date: 2010-08-28 04:34:57 -0400 (Sat, 28 Aug 2010)
New Revision: 24538
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/AlternativeStereotype.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/DuplicatedAlternativeStereotype.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6523 beans.xml validation
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-08-28
05:57:56 UTC (rev 24537)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-08-28
08:34:57 UTC (rev 24538)
@@ -2208,6 +2208,7 @@
}
continue;
} else {
+ // TODO we should check Decorators/Interceptors as well as Alternatives
(classes/stereotypes)!
IClassBean classBean = getClassBean(type);
if(classBean==null || !classBean.isAlternative()) {
addError(illegalTypeErrorMessage,
CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML,
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml 2010-08-28
08:34:57 UTC (rev 24538)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans>
+ <alternatives>
+ <class>org.jboss.jsr299.tck.tests.policy.broken.not.policy.Cat</class>
+
+ <class>
+ org.jboss.jsr299.tck.tests.policy.broken.incorrect.name.NonExistingClass
+ </class>
+
+ <stereotype>
+ <!-- Some comment -->
+ org.jboss.jsr299.tck.tests.policy.broken.not.policy.stereotype.NotExistingStereotype
+ </stereotype>
+
+ <stereotype>org.jboss.jsr299.tck.tests.policy.broken.not.policy.stereotype.Mock</stereotype>
+
+ <stereotype>org.jboss.jsr299.tck.tests.jbt.validation.beansxml.AlternativeStereotype</stereotype>
+
+ <class>org.jboss.jsr299.tck.tests.policy.broken.same.type.twice.Dog</class>
+ <class>org.jboss.jsr299.tck.tests.policy.broken.same.type.twice.Cat</class>
+ <class>
+ org.jboss.jsr299.tck.tests.policy.broken.same.type.twice.Cat
+ <!-- Some comment -->
+ </class>
+
+ <stereotype>org.jboss.jsr299.tck.tests.jbt.validation.beansxml.DuplicatedAlternativeStereotype</stereotype>
+ <stereotype>org.jboss.jsr299.tck.tests.jbt.validation.beansxml.DuplicatedAlternativeStereotype</stereotype>
+
+ </alternatives>
+
+ <decorators>
+ <class>com.acme.NonExistantDecoratorClass</class>
+ <class>org.jboss.jsr299.tck.tests.decorators.resolution.BarDecorator</class>
+
+ <class>org.jboss.jsr299.tck.tests.decorators.definition.broken.enabledDecoratorIsNotDecorator.TimestampLogger</class>
+
+
<class>org.jboss.jsr299.tck.tests.decorators.definition.broken.decoratorListedTwiceInBeansXml.PresentDecorator</decorator>
+
<class>org.jboss.jsr299.tck.tests.decorators.definition.broken.decoratorListedTwiceInBeansXml.PresentDecorator</decorator>
+ </decorators>
+
+ <interceptors>
+ <class>com.acme.Foo</class>
+ <class>org.jboss.jsr299.tck.tests.jbt.validation.interceptors.CatInterceptor</class>
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.broken.nonInterceptorClassInBeansXml.Foo</class>
+
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.broken.sameClassListedTwiceInBeansXml.FordInterceptor</class>
+ <class>org.jboss.jsr299.tck.tests.interceptors.definition.broken.sameClassListedTwiceInBeansXml.FordInterceptor</class>
+ </interceptors>
+
+</beans>
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/AlternativeStereotype.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/AlternativeStereotype.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/AlternativeStereotype.java 2010-08-28
08:34:57 UTC (rev 24538)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.beansxml;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Alternative;
+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
+@Alternative
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface AlternativeStereotype {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/AlternativeStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/DuplicatedAlternativeStereotype.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/DuplicatedAlternativeStereotype.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/DuplicatedAlternativeStereotype.java 2010-08-28
08:34:57 UTC (rev 24538)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.beansxml;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Alternative;
+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
+@Alternative
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface DuplicatedAlternativeStereotype {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/beansxml/DuplicatedAlternativeStereotype.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/ValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-08-28
05:57:56 UTC (rev 24537)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-08-28
08:34:57 UTC (rev 24538)
@@ -1471,7 +1471,9 @@
* and treats it as a deployment problem.
*/
public void testNoAlternativeClassWithSpecifiedName() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME,
4);
+ assertMarkerIsNotCreated(file,
CDIValidationMessages.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME, 19);
}
/**
@@ -1480,7 +1482,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testIllegalAlternativeClassWithSpecifiedName() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_ALTERNATIVE_BEAN_CLASS, 7);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_ALTERNATIVE_BEAN_CLASS,
19);
}
/**
@@ -1490,7 +1494,9 @@
* problem and treats it as a deployment problem.
*/
public void testNoAlternativeAnnotationWithSpecifiedName() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME,
12);
+ assertMarkerIsNotCreated(file,
CDIValidationMessages.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME, 17);
}
/**
@@ -1499,7 +1505,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testIllegalAlternativeAnnotationWithSpecifiedName() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_ALTERNATIVE_ANNOTATION, 15);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_ALTERNATIVE_ANNOTATION,
17);
}
/**
@@ -1508,7 +1516,9 @@
* treats it as a deployment problem.
*/
public void testSameAlternativeClassListedTwice() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_ALTERNATIVE_TYPE, 20, 22);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_ALTERNATIVE_TYPE, 19);
}
/**
@@ -1517,7 +1527,9 @@
* treats it as a deployment problem.
*/
public void testSameAlternativeAnnotationListedTwice() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_ALTERNATIVE_TYPE, 26, 27);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_ALTERNATIVE_TYPE, 17);
}
/**
@@ -1526,7 +1538,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testNonExistantDecoratorClassInBeansXmlNotOK() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
32);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
33);
}
/**
@@ -1535,7 +1549,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testEnabledDecoratorNotADecorator() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS, 35);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS,
33);
}
/**
@@ -1544,7 +1560,9 @@
* treats it as a deployment problem.
*/
public void testDecoratorListedTwiceInBeansXmlNotOK() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS, 37, 38);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS, 33);
}
/**
@@ -1553,7 +1571,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testNonExistantClassInBeansXmlNotOk() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME, 42);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME,
43);
}
/**
@@ -1562,7 +1582,9 @@
* the container automatically detects the problem and treats it as a deployment
problem.
*/
public void testNonInterceptorClassInBeansXmlNotOk() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS, 44);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS, 43);
}
/**
@@ -1571,7 +1593,9 @@
* a deployment problem.
*/
public void testSameInterceptorClassListedTwiceInBeansXmlNotOk() throws Exception {
- //TODO
+ IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS, 46,
47);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS, 43);
}
/**