Author: akazakov
Date: 2010-06-09 10:11:21 -0400 (Wed, 09 Jun 2010)
New Revision: 22702
Modified:
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/TCKTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6418 https://jira.jboss.org/browse/JBIDE-5808
Modified:
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 2010-06-09
13:20:16 UTC (rev 22701)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-09
14:11:21 UTC (rev 22702)
@@ -145,5 +145,31 @@
assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary",
"java.lang.Object");
}
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * e) Check generic managed bean.
+ *
+ * @throws CoreException
+ */
+ public void testGenericBeanTypesOnManagedBean() throws CoreException {
+ IType type =
EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Emu");
+ IParametedType parametedType =
cdiProject.getNature().getTypeFactory().getParametedType(type,
"QFlightlessBird<QAustralian;>;");
+ Set<IBean> beans = cdiProject.getBeans(true, parametedType, new
IQualifierDeclaration[0]);
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ IBean bean = beans.iterator().next();
+
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Emu");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+
+ type =
EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Emu");
+ parametedType = cdiProject.getNature().getTypeFactory().getParametedType(type,
"QFlightlessBird<QEuropean;>;");
+ beans = cdiProject.getBeans(true, parametedType, new IQualifierDeclaration[0]);
+ assertEquals("Wrong number of the beans", 0, beans.size());
+
+ assertContainsBeanType(false, bean, "java.lang.Object");
+ assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.FlightlessBird");
+ assertContainsBeanTypeSignatures(false, bean,
"QFlightlessBird<QAustralian;>;");
+ }
+
// TODO continue implementing the tests
}
\ 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-09
13:20:16 UTC (rev 22701)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-09
14:11:21 UTC (rev 22702)
@@ -246,6 +246,30 @@
}
}
+ protected void assertContainsBeanTypeSignatures(IBean bean, String... typeSignatures) {
+ assertContainsBeanTypeSignatures(true, bean, typeSignatures);
+ }
+
+ protected void assertContainsBeanTypeSignatures(boolean checkTheNumberOfTypes, IBean
bean, String... typeSignatures) {
+ if(checkTheNumberOfTypes) {
+ assertEquals("Wrong number of types.", typeSignatures.length,
bean.getLegalTypes().size());
+ }
+ for (String typeSignature : typeSignatures) {
+ Set<IParametedType> types = bean.getLegalTypes();
+ StringBuffer allTypes = new StringBuffer("[");
+ boolean found = false;
+ for (IParametedType type : types) {
+ allTypes.append(" ").append(type.getSignature()).append(";");
+ if (typeSignature.equals(type.getSignature())) {
+ found = true;
+ break;
+ }
+ }
+ allTypes.append("]");
+ assertTrue(bean.getResource().getFullPath() + " bean " + allTypes.toString()
+ " should have " + typeSignature + " type signature.", found);
+ }
+ }
+
public static void assertContainsBeanClasses(Set<IBean> beans, String...
beanClassNames) throws CoreException {
assertContainsBeanClasses(true, beans, beanClassNames);
}