[jbosstools-commits] JBoss Tools SVN: r22833 - in trunk/cdi: tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jun 16 08:32:26 EDT 2010


Author: akazakov
Date: 2010-06-16 08:32:25 -0400 (Wed, 16 Jun 2010)
New Revision: 22833

Added:
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.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/AssignabilityOfRawAndParameterizedTypesTest.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.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6474
https://jira.jboss.org/browse/JBIDE-5808
New JUnit tests for CDI bean resolution.

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-06-16 12:23:13 UTC (rev 22832)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java	2010-06-16 12:32:25 UTC (rev 22833)
@@ -107,19 +107,19 @@
 	 */
 	public IValidatingProjectSet getValidatingProjects(IProject project) {
 		IValidationContext rootContext = null;
-		IProject war = null; // TODO get war ?
-		if (war != null && war.isAccessible()) {
-			IKbProject kbProject = KbProjectFactory.getKbProject(war, false);
-			if (kbProject != null) {
-				rootContext = kbProject.getValidationContext();
-			} else {
-				KbProject.checkKBBuilderInstalled(war);
-				CDICoreNature cdiProject = CDICorePlugin.getCDI(project, false);
-				if (cdiProject != null) {
-					rootContext = null; // cdiProject.getDelegate().getValidationContext();
-				}
-			}
-		}
+//		IProject war = null; // TODO get war ?
+//		if (war != null && war.isAccessible()) {
+//			IKbProject kbProject = KbProjectFactory.getKbProject(war, false);
+//			if (kbProject != null) {
+//				rootContext = kbProject.getValidationContext();
+//			} else {
+//				KbProject.checkKBBuilderInstalled(war);
+//				CDICoreNature cdiProject = CDICorePlugin.getCDI(project, false);
+//				if (cdiProject != null) {
+//					rootContext = null; // cdiProject.getDelegate().getValidationContext();
+//				}
+//			}
+//		}
 		if (rootContext == null) {
 			CDICoreNature cdiProject = CDICorePlugin.getCDI(project, false);
 			if (cdiProject != null) {

Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java	2010-06-16 12:32:25 UTC (rev 22833)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.jbt.resolution;
+
+import javax.inject.Inject;
+
+import org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Result;
+
+public class AssignabilityOfRawAndParameterizedTypes<T1 extends Exception, T2 extends Exception> {
+
+	private @Inject Result<? extends Throwable, ? super Exception> injection;
+	
+	private @Inject Result<? extends Exception, ? super Exception> injection2;
+
+	private @Inject Result<Exception, Exception> injection3;
+
+	private @Inject Result<T1, T2> injection4;
+}


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.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/AssignabilityOfRawAndParameterizedTypesTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java	2010-06-16 12:23:13 UTC (rev 22832)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/AssignabilityOfRawAndParameterizedTypesTest.java	2010-06-16 12:32:25 UTC (rev 22833)
@@ -13,7 +13,13 @@
 import java.util.Set;
 
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
 import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IParametedType;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
 
 /**
  * @author Alexey Kazakov
@@ -31,5 +37,91 @@
 		assertEquals("Wrong number of the beans", 4, beans.size());
 	}
 
-	// TODO continue implementing tests.
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   ba) Check the required type parameter and the bean type parameter are actual types with identical raw type
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithActualTypes() throws CoreException {
+		IType type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.MapProducer");
+		IParametedType parametedType = cdiProject.getNature().getTypeFactory().getParametedType(type, "QMap<QInteger;>;");
+		Set<IBean> beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
+		assertEquals("Wrong number of the beans", 2, beans.size());
+
+		type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()), "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.IntegerHashMap");
+		parametedType = cdiProject.getNature().getTypeFactory().getParametedType(type, "QHashMap<QInteger;>;");
+		beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
+		assertFalse("Wrong number of the beans", beans.isEmpty());
+		assertContainsBeanClass(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.IntegerHashMap");
+	}
+
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   c) Check the required type parameter is a wildcard, the bean type parameter is an actual type and the actual type is assignable to the upper bound of the wildcard and assignable from the lower bound of the wildcard
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithWildcards() throws CoreException {
+		IInjectionPointField injection = getInjectionPointField("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/parameterized/InjectedBean.java", "map");
+		Set<IBean> beans = cdiProject.getBeans(true, injection);
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		assertContainsBeanClass(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.IntegerHashMap");
+	}
+
+//	public void testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithWildcardsAtInjectionPoint() throws CoreException {
+//		// The same as testAssignabilityOfParameterizedTypeWithActualTypesToParameterizedTypeWithWildcards()
+//	}
+
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   da) Check the required type parameter is a wildcard, the bean type parameter is a type variable and the upper bound of the type variable is assignable to the upper bound of the wildcard and assignable from the lower bound of the wildcard
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeWithWildcards() throws CoreException {
+		IInjectionPointField injection = getInjectionPointField("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java", "injection");
+		Set<IBean> beans = cdiProject.getBeans(true, injection);
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Result", "java.lang.Object");
+	}
+
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   db) Check the required type parameter is a wildcard, the bean type parameter is a type variable and the upper bound of the type variable is assignable from the upper bound of the wildcard and assignable from the lower bound of the wildcard
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeWithWildcards2() throws CoreException {
+		IInjectionPointField injection = getInjectionPointField("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java", "injection2");
+		Set<IBean> beans = cdiProject.getBeans(true, injection);
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Result", "java.lang.Object");
+	}
+
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   e) Check the required type parameter is an actual type, the bean type parameter is a type variable and the actual type is assignable to the upper bound of the type variable
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeWithActualTypes() throws CoreException {
+		IInjectionPointField injection = getInjectionPointField("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java", "injection3");
+		Set<IBean> beans = cdiProject.getBeans(true, injection);
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Result", "java.lang.Object");
+	}
+
+	/**
+	 * Section 5.2.3 - Assignability of raw and parameterized types
+	 *   f) Check the required type parameter and the bean type parameter are both type variables and the upper bound of the required type parameter is assignable to the upper bound of the bean type parameter.
+	 *   
+	 * @throws CoreException 
+	 */
+	public void testAssignabilityOfParameterizedTypeWithTypeVariablesToParameterizedTypeTypeVariable() throws CoreException {
+		IInjectionPointField injection = getInjectionPointField("JavaSource/org/jboss/jsr299/tck/tests/jbt/resolution/AssignabilityOfRawAndParameterizedTypes.java", "injection4");
+		Set<IBean> beans = cdiProject.getBeans(true, injection);
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		assertContainsBeanClasses(beans, "org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.parameterized.Result", "java.lang.Object");
+	}
 }
\ No newline at end of file

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-16 12:23:13 UTC (rev 22832)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java	2010-06-16 12:32:25 UTC (rev 22833)
@@ -24,6 +24,8 @@
 import org.jboss.tools.cdi.core.IBean;
 import org.jboss.tools.cdi.core.ICDIProject;
 import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointField;
 import org.jboss.tools.cdi.core.IParametedType;
 import org.jboss.tools.cdi.core.IQualifier;
 import org.jboss.tools.cdi.core.IQualifierDeclaration;
@@ -283,6 +285,23 @@
 		}
 	}
 
+	protected IInjectionPointField getInjectionPointField(String beanClassFilePath, String fieldName) {
+		IFile file = tckProject.getFile(beanClassFilePath);
+		Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+		assertEquals("Wrong number of the beans", 1, beans.size());
+		Set<IInjectionPoint> injections = beans.iterator().next().getInjectionPoints();
+		for (IInjectionPoint injectionPoint : injections) {
+			if(injectionPoint instanceof IInjectionPointField) {
+				IInjectionPointField field = (IInjectionPointField)injectionPoint;
+				if(fieldName.equals(field.getField().getElementName())) {
+					return field;
+				}
+			}
+		}
+		fail("Can't find \"" + fieldName + "\" injection point filed in " + beanClassFilePath);
+		return null;
+	}
+
 	public static void assertContainsBeanClasses(Set<IBean> beans, String... beanClassNames) throws CoreException {
 		assertContainsBeanClasses(true, beans, beanClassNames);
 	}

Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java	2010-06-16 12:23:13 UTC (rev 22832)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/wizard/NewCDIWizardTest.java	2010-06-16 12:32:25 UTC (rev 22833)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 20010 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,



More information about the jbosstools-commits mailing list