Author: akazakov
Date: 2012-08-16 19:40:33 -0400 (Thu, 16 Aug 2012)
New Revision: 43080
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AYTDeploymentProblemsValidationTests.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/CDICoreAllTests.java
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/DefenitionErrorsValidationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationTest.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAnnotationTest.java
Log:
https://issues.jboss.org/browse/JBIDE-10611 As-you-type CDI 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 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -728,12 +728,23 @@
*/
Collection<IBean> beans = context.getCdiProject().getBeans(name, true);
if(beans.size()>1 && beans.contains(bean)) {
+ // We need to sort bean element names to make sure we report the same problem message
for the same bean name for every validation process.
+ IBean[] sortedBeans = beans.toArray(new IBean[beans.size()]);
+ for (int i = sortedBeans.length - 1; i >= 0; i--) {
+ for (int j = 0; j < i; j++) {
+ if (sortedBeans[j].getElementName().compareTo(sortedBeans[j + 1].getElementName())
> 0) {
+ IBean t = sortedBeans[j];
+ sortedBeans[j] = sortedBeans[j+1];
+ sortedBeans[j+1] = t;
+ }
+ }
+ }
ITextSourceReference reference = bean.getNameLocation(true);
Set<String> names = new HashSet<String>();
String bName = bean.getElementName();
names.add(bName);
StringBuffer sb = new StringBuffer(bName);
- for (IBean iBean : beans) {
+ for (IBean iBean : sortedBeans) {
if(!isAsYouTypeValidation()) {
getValidationContext().addLinkedCoreResource(SHORT_ID, name, iBean.getSourcePath(),
true);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -56,6 +56,7 @@
import org.jboss.tools.cdi.core.test.tck.lookup.UnsatisfiedDependencyTest;
import org.jboss.tools.cdi.core.test.tck.validation.AYTAnnotationValidationTest;
import org.jboss.tools.cdi.core.test.tck.validation.AYTDefenitionErrorsValidationTest;
+import
org.jboss.tools.cdi.core.test.tck.validation.AYTDeploymentProblemsValidationTests;
import org.jboss.tools.cdi.core.test.tck.validation.AnnotationsValidationTest;
import org.jboss.tools.cdi.core.test.tck.validation.BeansXmlValidationTest;
import org.jboss.tools.cdi.core.test.tck.validation.BuilderOrderValidationTest;
@@ -135,7 +136,7 @@
// As-you-type validation tests
suite.addTestSuite(AYTDefenitionErrorsValidationTest.class);
-// suite.addTestSuite(DeploymentProblemsValidationTests.class);
+ suite.addTestSuite(AYTDeploymentProblemsValidationTests.class);
// suite.addTestSuite(BeansXmlValidationTest.class);
suite.addTestSuite(AYTAnnotationValidationTest.class);
// suite.addTestSuite(CoreValidationTest.class);
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AYTDeploymentProblemsValidationTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AYTDeploymentProblemsValidationTests.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AYTDeploymentProblemsValidationTests.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.test.tck.validation;
+
+import org.jboss.tools.tests.IAnnotationTest;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class AYTDeploymentProblemsValidationTests extends
DeploymentProblemsValidationTests {
+
+ private CDIAnnotationTest annotationTest = new CDIAnnotationTest();
+
+ @Override
+ protected IAnnotationTest getAnnotationTest() {
+ return annotationTest;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AYTDeploymentProblemsValidationTests.java
___________________________________________________________________
Added: 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 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/AnnotationsValidationTest.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -15,8 +15,6 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;
-import org.jboss.tools.tests.AbstractResourceMarkerTest;
-import org.jboss.tools.tests.IAnnotationTest;
/**
* Wrong targets in CDI annotation types.
@@ -25,12 +23,6 @@
*/
public class AnnotationsValidationTest extends ValidationTest {
- private IAnnotationTest annotationTest = new AbstractResourceMarkerTest();
-
- protected IAnnotationTest getAnnotationTest() {
- return annotationTest;
- }
-
public void testQualifierWithMissingTarget() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/annotations/qualifier/broken/Hairy_MissingTarget.java");
getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE.substring(0, 56) +
".*", 36);
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DefenitionErrorsValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DefenitionErrorsValidationTest.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DefenitionErrorsValidationTest.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -18,19 +18,12 @@
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;
import org.jboss.tools.tests.AbstractResourceMarkerTest;
-import org.jboss.tools.tests.IAnnotationTest;
/**
* @author Alexey Kazakov
*/
public class DefenitionErrorsValidationTest extends ValidationTest {
- private IAnnotationTest annotationTest = new AbstractResourceMarkerTest();
-
- protected IAnnotationTest getAnnotationTest() {
- return annotationTest;
- }
-
/**
* 2.2.2. Restricting the bean types of a bean
* - bean class or producer method or field specifies a @Typed annotation,
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -21,7 +21,6 @@
import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;
-import org.jboss.tools.tests.AbstractResourceMarkerTest;
/**
* @author Alexey Kazakov
@@ -37,9 +36,9 @@
*/
public void testInconsistentSpecialization() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/inconsistent/Maid.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.INCONSISTENT_SPECIALIZATION, "Maid,
Manager", "Employee"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.INCONSISTENT_SPECIALIZATION, "Maid,
Manager", "Employee"), 21);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/inheritance/specialization/simple/broken/inconsistent/Manager.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.INCONSISTENT_SPECIALIZATION, "Manager,
Maid", "Employee"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.INCONSISTENT_SPECIALIZATION, "Manager,
Maid", "Employee"), 21);
}
/**
@@ -50,15 +49,15 @@
*/
public void testAmbiguousDependency() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/broken/ambiguous/Farm_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 25);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 25);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/decorators/definition/inject/delegateField/TimestampLogger.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 34);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 34);
}
public void testAmbiguousDependencyWithNamed() throws Exception {
String path =
"JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java";
IFile file = tckProject.getFile(path);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 9, 25, 26);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 9, 25, 26);
IInjectionPointField p = getInjectionPointField(path, "s5");
Collection<IBean> bs = cdiProject.getBeans(false, p);
@@ -88,17 +87,17 @@
*/
public void testUnsatisfiedDependency() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/broken/unsatisfied/Bean_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 25);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 25);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/decorators/definition/inject/delegateField/TimestampLogger.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 34);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 34);
}
public void testUnsatisfiedDependencyWithNamed() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 22, 23, 19, 20);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 22, 23, 19, 20);
int[] lines = {10, 11, 13, 14, 16, 17};
for (int i: lines) {
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, i);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, i);
}
}
@@ -110,8 +109,8 @@
*/
public void testAmbiguousDependencyForInstance() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/InjectionInstance.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 8);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 11);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 8);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 11);
}
/**
@@ -122,8 +121,8 @@
*/
public void testUnsatisfiedDependencyForInstance() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/InjectionInstance.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 9);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 12);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 9);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 12);
}
/**
@@ -133,9 +132,9 @@
*/
public void testBeansWithDefaultCounstructor() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/defaultconstructors/CurrentProject.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 12);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 12);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 15);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 12);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNSATISFIED_INJECTION_POINTS, 12);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, 15);
}
/**
@@ -146,13 +145,13 @@
*/
public void testPrimitiveInjectionPointResolvedToNonPrimitiveProducerMethod() throws
Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GameBroken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7, 19);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
+ getAnnotationTest().assertAnnotationIsCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7, 19);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
}
/**
@@ -165,15 +164,15 @@
*/
public void testInjectionPointWithArrayType() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/unproxyable/InjectionPointBean_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType[]", "ArrayProducer.produce()"), 6);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType", "TestType"), 7);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType[]", "ArrayProducer.produce2()"), 8);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType[]", "ArrayProducer.produce()"), 6);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType", "TestType"), 7);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
"TestType[]", "ArrayProducer.produce2()"), 8);
}
public void testNormalBeanWithArrayType() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/unproxyable/ArrayProducer.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE_2,
"TestType[]", "ArrayProducer.produce()"), 8);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE_2,
"TestType[]", "ArrayProducer.produce2()"), 8);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE_2,
"TestType[]", "ArrayProducer.produce()"), 8);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE_2,
"TestType[]", "ArrayProducer.produce2()"), 8);
}
/**
@@ -186,18 +185,18 @@
*/
public void testInjectionPointWithUnproxyableTypeWhichResolvesToNormalScopedBean()
throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/unproxyable/Number_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"int", "NumberProducer.produce()"), 9);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"long", "NumberProducer.foo"), 13);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"Short", "NumberProducer.foo2"), 17);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"boolean", "NumberProducer.foo3"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"int", "NumberProducer.produce()"), 9);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"long", "NumberProducer.foo"), 13);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"Short", "NumberProducer.foo2"), 17);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
"boolean", "NumberProducer.foo3"), 21);
}
public void testNormalScopedBeanWithUnproxyableType() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/unproxyable/NumberProducer.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"int", "NumberProducer.produce()"), 9);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"long", "NumberProducer.foo"), 16);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"Short", "NumberProducer.foo2"), 21);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"boolean", "NumberProducer.foo3"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"int", "NumberProducer.produce()"), 9);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"long", "NumberProducer.foo"), 16);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"Short", "NumberProducer.foo2"), 21);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE_2,
"boolean", "NumberProducer.foo3"), 21);
}
/**
@@ -210,8 +209,8 @@
*/
public void testClassWithPrivateConstructor() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/privateConstructor/InjectionPointBean.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
"Unproxyable_Broken", "Unproxyable_Broken"), 23);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC.substring(0, 0), 25);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
"Unproxyable_Broken", "Unproxyable_Broken"), 23);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC.substring(0, 0), 25);
}
/**
@@ -220,7 +219,7 @@
*/
public void testClassWithDefaultConstructor() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/unproxyable/Number_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
"BeanWithDefaultConsturctor", "BeanWithDefaultConsturctor"), 24);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
"BeanWithDefaultConsturctor", "BeanWithDefaultConsturctor"), 24);
}
/**
@@ -233,19 +232,19 @@
*/
public void testInjectionPointWhichResolvesToNormalScopedFinalBean() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalClass/FishFarm.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
"Tuna_Broken", "Tuna_Broken"), 24);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE.substring(0, 0) + ".*", 26);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
"Tuna_Broken", "Tuna_Broken"), 24);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE.substring(0, 0) + ".*", 26);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalClass/Opportunity.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
"String", "Opportunity.t"), 26);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
"String", "Opportunity.t"), 26);
}
public void testNormalScopedFinalBean() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalClass/Tuna_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE_2,
"Tuna_Broken", "Tuna_Broken"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE_2,
"Tuna_Broken", "Tuna_Broken"), 21);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalClass/Opportunity.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE_2,
"String", "Opportunity.t"), 32);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE_2,
"String", "Opportunity.t"), 32);
}
/**
@@ -258,11 +257,11 @@
*/
public void testClassWithFinalMethodCannotBeProxied() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalMethod/FishFarm.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM,
"Tuna_Broken", "Tuna_Broken"), 23);
- AbstractResourceMarkerTest.assertMarkerIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM.substring(0, 0) + ".*",
25);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM,
"Tuna_Broken", "Tuna_Broken"), 23);
+ getAnnotationTest().assertAnnotationIsNotCreated(file,
CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM.substring(0, 0) + ".*",
25);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/clientProxy/unproxyable/finalMethod/Tuna_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM_2,
"Tuna_Broken", "Tuna_Broken"), 21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM_2,
"Tuna_Broken", "Tuna_Broken"), 21);
}
@@ -276,14 +275,14 @@
*/
public void testDuplicateNamedBeans() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicateNameResolution/Cod.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Cod, Sole"),
21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Cod, Sole"),
21);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicateNameResolution/Sole.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Sole, Cod"),
21);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Sole, Cod"),
21);
file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/lookup/duplicateName/TestNamed.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo4.*"), 40, 49);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo5.*"), 43);
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo6.*"), 46);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo4.*"), 40, 49);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo5.*"), 43);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
"TestNamed.foo6.*"), 46);
}
/**
@@ -294,7 +293,7 @@
*/
public void testDuplicateBeanNamePrefix() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicatePrefixResolution/ExampleWebsite_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNRESOLVABLE_EL_NAME, "example.com",
"com", "example", "Example"), 22);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNRESOLVABLE_EL_NAME, "example.com",
"com", "example", "Example"), 22);
}
/**
@@ -306,7 +305,7 @@
*/
public void testAppliesToFinalManagedBeanClass() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanClass/TimestampLogger.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_CLASS,
"MockLogger"), 31);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_CLASS,
"MockLogger"), 31);
}
/**
@@ -318,7 +317,7 @@
*/
public void testAppliesToFinalMethodOnManagedBeanClass() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_METHOD,
"MockLogger", "log(String string)"), 31);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_METHOD,
"MockLogger", "log(String string)"), 31);
}
/**
@@ -330,6 +329,6 @@
*/
public void testSimpleWebBeanWithNonSerializableImplementationClassFails() throws
Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/context/passivating/broken/nonPassivationCapableManagedBeanHasPassivatingScope/Hamina_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
"Hamina_Broken", "SessionScoped"), 22);
+ getAnnotationTest().assertAnnotationIsCreated(file,
MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
"Hamina_Broken", "SessionScoped"), 22);
}
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationTest.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/ValidationTest.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -16,12 +16,20 @@
import org.jboss.tools.cdi.internal.core.validation.CDICoreValidator;
import org.jboss.tools.common.validation.IValidator;
import org.jboss.tools.common.validation.ValidationContext;
+import org.jboss.tools.tests.AbstractResourceMarkerTest;
+import org.jboss.tools.tests.IAnnotationTest;
/**
* @author Alexey Kazakov
*/
public class ValidationTest extends TCKTest {
+ private IAnnotationTest annotationTest = new AbstractResourceMarkerTest();
+
+ protected IAnnotationTest getAnnotationTest() {
+ return annotationTest;
+ }
+
protected CDICoreValidator getCDIValidator() {
ValidationContext context = new ValidationContext(tckProject);
List<IValidator> validators = context.getValidators();
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -40,6 +40,7 @@
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.util.EclipseUIUtil;
import org.jboss.tools.common.validation.java.TempJavaProblemAnnotation;
@@ -165,12 +166,17 @@
private void validate(Set<? extends IAsYouTypeValidator> validators,
Collection<IRegion> dirtyRegions, IValidationContext helper, IReporter reporter) {
count++;
- for (IAsYouTypeValidator validator : validators) {
- IProject rootProject = rootProjects.get(validator);
- IValidatingProjectSet projectBrunch =
context.getValidatingProjectTree(validator).getBrunches().get(rootProject);
- if(projectBrunch!=null) {
- validator.validate(this, rootProject, dirtyRegions, helper, reporter, context,
projectBrunch.getRootContext(), file);
+ try {
+ for (IAsYouTypeValidator validator : validators) {
+ IProject rootProject = rootProjects.get(validator);
+ IValidatingProjectSet projectBrunch =
context.getValidatingProjectTree(validator).getBrunches().get(rootProject);
+ if(projectBrunch!=null) {
+ validator.validate(this, rootProject, dirtyRegions, helper, reporter, context,
projectBrunch.getRootContext(), file);
+ }
}
+ } catch(Exception e) {
+ // We need to catch exceptions and wrap them in KBValidationException to let JUnit
tests catch validation exceptions reported to eclipse log.
+ CommonPlugin.getDefault().logError(new JBTValidationException(e.getMessage(), e));
}
}
Modified:
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAnnotationTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAnnotationTest.java 2012-08-16
22:45:09 UTC (rev 43079)
+++
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/validation/AbstractAnnotationTest.java 2012-08-16
23:40:33 UTC (rev 43080)
@@ -195,7 +195,8 @@
assertEquals("The number of markers doesn't equal to the number of AYT
messages for " + resource + ".\r\nThe full list of the markers and
messages:\r\n" + markersSB + "\r\n" + messagesSB, allMarkers.length,
messages.size());
for (IMessage message : messages) {
- assertTrue("Can't find message: [text=\"" + message.getText() +
"\"; line=\"" + message.getLineNumber() + "\";
start=\"" + message.getOffset() + "\"; end=\"" +
message.getOffset() + message.getLength() + "\"; type=\"] for " +
resource + ".\r\nThe full list of the markers and messages:\r\n" + markersSB +
"\r\n" + messagesSB, contains(allMarkers, message));
+ int end = message.getOffset() + message.getLength();
+ assertTrue("Can't find message: [text=\"" + message.getText() +
"\"; line=\"" + message.getLineNumber() + "\";
start=\"" + message.getOffset() + "\"; end=\"" + end +
"\"; type=\"] for " + resource + ".\r\nThe full list of the
markers and messages:\r\n" + markersSB + "\r\n" + messagesSB,
contains(allMarkers, message));
}
} catch (BadLocationException e) {
throw new CoreException(new Status(IStatus.ERROR, BaseTestPlugin.PLUGIN_ID,
e.getMessage(), e));