[jbosstools-commits] JBoss Tools SVN: r22482 - in trunk/cdi: tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jun 2 10:58:32 EDT 2010


Author: akazakov
Date: 2010-06-02 10:58:31 -0400 (Wed, 02 Jun 2010)
New Revision: 22482

Added:
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
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/messages.properties
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.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-5808

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-06-02 14:36:05 UTC (rev 22481)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java	2010-06-02 14:58:31 UTC (rev 22482)
@@ -35,8 +35,10 @@
 	public static String PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT;
 	public static String INJECTION_TYPE_IS_VARIABLE;
 	public static String STEREOTYPE_IS_ANNOTATED_TYPED;
-	public static String MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER;
-	public static String MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER;
+	public static String MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER;
+	public static String MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER;
+	public static String MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER;
+	public static String MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER;
 
 	public static String MULTIPLE_SCOPE_TYPE_ANNOTATIONS;
 	public static String MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE;

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-06-02 14:36:05 UTC (rev 22481)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties	2010-06-02 14:58:31 UTC (rev 22482)
@@ -14,8 +14,10 @@
 PRODUCER_FIELD_TYPE_DOES_NOT_MATCH_JAVA_EE_OBJECT=Matching object in the Java EE component environment is not of the same type as the producer field declaration
 INJECTION_TYPE_IS_VARIABLE=Injection point type is a type variable
 STEREOTYPE_IS_ANNOTATED_TYPED=Stereotype is annotated @Typed
-MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER=Array-valued or annotation-valued member of a qualifier type is not annotated @Nonbinding
-MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER=Array-valued or annotation-valued member of an interceptor binding type is not annotated @Nonbinding
+MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER=Annotation-valued member of a qualifier type is not annotated @Nonbinding
+MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER=Array-valued member of a qualifier type is not annotated @Nonbinding
+MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER=Annotation-valued member of an interceptor binding type is not annotated @Nonbinding
+MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER=Array-valued member of an interceptor binding type is not annotated @Nonbinding
 
 MULTIPLE_SCOPE_TYPE_ANNOTATIONS=Bean class or producer method or field specifies multiple scope type annotations
 MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE=Bean does not explicitly declare a scope when there is no default scope

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java	2010-06-02 14:36:05 UTC (rev 22481)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSuite.java	2010-06-02 14:58:31 UTC (rev 22482)
@@ -14,6 +14,7 @@
 import junit.framework.TestSuite;
 
 import org.jboss.tools.cdi.core.test.tck.BeanDefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.BeanSpecializationTest;
 import org.jboss.tools.cdi.core.test.tck.DefaultNamedTest;
 import org.jboss.tools.cdi.core.test.tck.EnterpriseQualifierDefinitionTest;
 import org.jboss.tools.cdi.core.test.tck.EnterpriseScopeDefinitionTest;
@@ -22,8 +23,8 @@
 import org.jboss.tools.cdi.core.test.tck.NameDefinitionTest;
 import org.jboss.tools.cdi.core.test.tck.ProducerMethodDefinitionTest;
 import org.jboss.tools.cdi.core.test.tck.QualifierDefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.ResolutionByTypeTest;
 import org.jboss.tools.cdi.core.test.tck.ScopeDefinitionTest;
-import org.jboss.tools.cdi.core.test.tck.BeanSpecializationTest;
 import org.jboss.tools.cdi.core.test.tck.StereotypeDefinitionTest;
 import org.jboss.tools.cdi.core.test.tck.StereotypeInheritenceTest;
 import org.jboss.tools.cdi.core.test.tck.ValidationTest;
@@ -48,6 +49,7 @@
 		suite.addTestSuite(ProducerMethodDefinitionTest.class);
 		suite.addTestSuite(InjectionPointTest.class);
 		suite.addTestSuite(BeanSpecializationTest.class);
+		suite.addTestSuite(ResolutionByTypeTest.class);
 		suite.addTestSuite(ValidationTest.class);
 		return suite;
 	}

Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java	2010-06-02 14:58:31 UTC (rev 22482)
@@ -0,0 +1,38 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 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;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IParametedType;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ResolutionByTypeTest extends TCKTest {
+
+	/**
+	 * Section 5.2 - Typesafe resolution
+	 *   ld) Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated @javax.enterprise.util.NonBinding.
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testResolveByTypeWithNonBindingMembers() throws CoreException {
+		IQualifierDeclaration expensiveQualifier = getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/RoundWhitefish.java", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Expensive");
+		IQualifierDeclaration whitefishQualifier = getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/RoundWhitefish.java", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Whitefish");
+		IParametedType type = getType("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Animal");
+		Set<IBean> beans = cdiProject.getBeans(true, type, new IQualifierDeclaration[]{expensiveQualifier, whitefishQualifier});
+		assertContainsBeanClasses(beans, new String[]{"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.RoundWhitefish", "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Halibut"});
+	}
+}
\ 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/ResolutionByTypeTest.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/TCKTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java	2010-06-02 14:36:05 UTC (rev 22481)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java	2010-06-02 14:58:31 UTC (rev 22482)
@@ -228,6 +228,37 @@
 		fail(bean.getResource().getFullPath() + " bean " + allTypes.toString() + " should have " + typeName + " type.");
 	}
 
+	public static void assertContainsBeanClasses(Set<IBean> beans, String... beanClassNames) throws CoreException {
+		assertContainsBeanClasses(true, beans, beanClassNames);
+	}
+
+	public static void assertContainsBeanClasses(boolean checkTheNumberOfBeans, Set<IBean> beans, String... beanClassNames) throws CoreException {
+		if(checkTheNumberOfBeans) {
+			assertEquals("Wrong number of beans.", beanClassNames.length, beans.size());
+		}
+		StringBuffer sb = new StringBuffer("[");
+		for (String beanClassName : beanClassNames) {
+			sb.append(beanClassName).append("; ");
+		}
+		sb.append("]");
+		for (String beanClassName : beanClassNames) {
+			assertTrue("Didn't found " + beanClassName + " among " + sb.toString(), containsBeanClass(beans, beanClassName));
+		}
+	}
+
+	public static void assertContainsBeanClass(Set<IBean> beans, String beanClassName) throws CoreException {
+		assertTrue("Didn't find " + beanClassName, containsBeanClass(beans, beanClassName));
+	}
+
+	private static boolean containsBeanClass(Set<IBean> beans, String beanClassName) throws CoreException {
+		for (IBean bean : beans) {
+			if(beanClassName.equals(bean.getBeanClass().getFullyQualifiedName())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	public static void assertContainsQualifier(IBean bean, IQualifierDeclaration declaration) throws CoreException {
 		String typeName = declaration.getQualifier().getSourceType().getFullyQualifiedName();
 		Set<IQualifier> qualifiers = bean.getQualifiers();

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-06-02 14:36:05 UTC (rev 22481)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java	2010-06-02 14:58:31 UTC (rev 22482)
@@ -897,6 +897,28 @@
 	}
 
 	/**
+	 * 5.2.5. Qualifier annotations with members
+	 *  - annotation-valued member of a qualifier type is not annotated @Nonbinding (Non-Portable behavior)
+	 * 
+	 * @throws Exception
+	 */
+	public void testAnnotationMemberWithoutNonBinding() throws Exception {
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Expensive_Broken.java");
+		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER, 35);
+	}
+
+	/**
+	 * 5.2.5. Qualifier annotations with members
+	 *  - array-valued member of a qualifier type is not annotated @Nonbinding (Non-Portable behavior)
+	 * 
+	 * @throws Exception
+	 */
+	public void testArrayMemberWithoutNonBinding() throws Exception {
+		IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/binding/members/array/Expensive_Broken.java");
+		AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER, 34);
+	}
+
+	/**
 	 * 10.4.2. Declaring an observer method
 	 *  - method has more than one parameter annotated @Observes
 	 *  



More information about the jbosstools-commits mailing list