Author: akazakov
Date: 2010-06-09 11:31:30 -0400 (Wed, 09 Jun 2010)
New Revision: 22703
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseQualifierDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
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/EnterpriseQualifierDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseQualifierDefinitionTest.java 2010-06-09
14:11:21 UTC (rev 22702)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/EnterpriseQualifierDefinitionTest.java 2010-06-09
15:31:30 UTC (rev 22703)
@@ -29,7 +29,7 @@
* @throws CoreException
*/
public void testQualifierDeclaredInheritedIsInherited() throws CoreException {
- IQualifierDeclaration hairy =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Hairy");
+ IQualifierDeclaration hairy =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Hairy");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.BorderCollieLocal");
Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
// assertEquals("Wrong number of beans.", 1, beans.size());
@@ -45,7 +45,7 @@
* @throws JavaModelException
*/
public void testQualifierNotDeclaredInheritedIsNotInherited() throws JavaModelException
{
- IQualifierDeclaration skinny =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/SkinnyHairlessCat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Skinny");
+ IQualifierDeclaration skinny =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/SkinnyHairlessCat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Skinny");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.TameSkinnyHairlessCatLocal");
Set<IBean> beans = cdiProject.getBeans(true, type, skinny);
assertTrue("Wrong number of beans.", beans.isEmpty());
@@ -56,7 +56,7 @@
* @throws CoreException
*/
public void testQualifierDeclaredInheritedIsIndirectlyInherited() throws CoreException
{
- IQualifierDeclaration hairy =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Hairy");
+ IQualifierDeclaration hairy =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Hairy");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.EnglishBorderCollieLocal");
Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
assertEquals("Wrong number of beans.", 1, beans.size());
@@ -72,7 +72,7 @@
* @throws JavaModelException
*/
public void testQualifierNotDeclaredInheritedIsNotIndirectlyInherited() throws
JavaModelException {
- IQualifierDeclaration skinny =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/SkinnyHairlessCat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Skinny");
+ IQualifierDeclaration skinny =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/enterprise/SkinnyHairlessCat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.Skinny");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.enterprise.FamousCatLocal");
Set<IBean> beans = cdiProject.getBeans(true, type, skinny);
assertTrue("Wrong number of beans.", beans.isEmpty());
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-06-09
14:11:21 UTC (rev 22702)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-06-09
15:31:30 UTC (rev 22703)
@@ -80,7 +80,7 @@
* @throws CoreException
*/
public void testQualifiersDeclaredInJava() throws CoreException {
- IQualifierDeclaration synchronous =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Synchronous");
+ IQualifierDeclaration synchronous =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cat.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Synchronous");
Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.definition.qualifier.Cat",
"org.jboss.jsr299.tck.tests.definition.qualifier.Synchronous");
assertEquals("Wrong number of beans with
org.jboss.jsr299.tck.tests.definition.qualifier.Cat type and
org.jboss.jsr299.tck.tests.definition.qualifier.Synchronous qualifier.", 1,
beans.size());
IBean bean = beans.iterator().next();
@@ -98,8 +98,8 @@
* @throws JavaModelException
*/
public void testMultipleQualifiers() throws JavaModelException {
- IQualifierDeclaration chunky =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Chunky");
- IQualifierDeclaration whitefish =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Whitefish");
+ IQualifierDeclaration chunky =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Chunky");
+ IQualifierDeclaration whitefish =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Whitefish");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.Cod");
Set<IBean> beans = cdiProject.getBeans(true, type, chunky, whitefish);
assertEquals("Wrong number of beans.", 1, beans.size());
@@ -144,7 +144,7 @@
* @throws CoreException
*/
public void testQualifierDeclaredInheritedIsInherited() throws CoreException {
- IQualifierDeclaration hairy =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ IQualifierDeclaration hairy =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.BorderCollie");
Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
assertFalse("Wrong number of beans.", beans.isEmpty());
@@ -176,7 +176,7 @@
* @throws CoreException
*/
public void testQualifierDeclaredInheritedIsBlockedByIntermediateClass() throws
CoreException {
- IQualifierDeclaration hairy =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/ClippedBorderCollie.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ IQualifierDeclaration hairy =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/ClippedBorderCollie.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.ClippedBorderCollie");
Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
assertEquals("Wrong number of beans.", 1, beans.size());
@@ -192,7 +192,7 @@
* @throws CoreException
*/
public void testQualifierDeclaredInheritedIsIndirectlyInherited() throws CoreException
{
- IQualifierDeclaration hairy =
getQualifierDeclarationFromBeanClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
+ IQualifierDeclaration hairy =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/LongHairedDog.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Hairy");
IParametedType type =
getType("org.jboss.jsr299.tck.tests.definition.qualifier.EnglishBorderCollie");
Set<IBean> beans = cdiProject.getBeans(true, type, hairy);
assertEquals("Wrong number of beans.", 1, beans.size());
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
14:11:21 UTC (rev 22702)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-09
15:31:30 UTC (rev 22703)
@@ -123,8 +123,8 @@
* @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");
+ IQualifierDeclaration expensiveQualifier =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/RoundWhitefish.java",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Expensive");
+ IQualifierDeclaration whitefishQualifier =
getQualifierDeclarationFromClass("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"});
@@ -171,5 +171,79 @@
assertContainsBeanTypeSignatures(false, bean,
"QFlightlessBird<QAustralian;>;");
}
- // TODO continue implementing the tests
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * c) Check producer method.
+ *
+ * @throws CoreException
+ */
+ public void testBeanTypesOnProducerMethod() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanType(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Parrot",
"java.lang.Object");
+
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
+
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * h) Check generic producer field.
+ *
+ * @throws CoreException
+ */
+ public void testGenericBeanTypesOnProducerField() throws CoreException {
+ IType type =
EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.PetShop");
+ IParametedType parametedType =
cdiProject.getNature().getTypeFactory().getParametedType(type,
"QCat<QEuropean;>;");
+ IQualifierDeclaration qualifier =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/PetShop.java",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tame");
+ assertNotNull("Can't find the qualifier.", qualifier);
+ Set<IBean> beans = cdiProject.getBeans(true, parametedType, new
IQualifierDeclaration[]{qualifier});
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ IBean bean = beans.iterator().next();
+
+ assertContainsBeanType(false, bean, "java.lang.Object");
+ assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypeSignatures(false, bean, "QCat<QEuropean;>;");
+
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.DomesticCat",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tame");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
+
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * g) Check generic producer method.
+ *
+ * @throws CoreException
+ */
+ public void testGenericBeanTypesOnProducerMethod() throws CoreException {
+ IType type =
EclipseJavaUtil.findType(EclipseUtil.getJavaProject(cdiProject.getNature().getProject()),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.PetShop");
+ IParametedType parametedType =
cdiProject.getNature().getTypeFactory().getParametedType(type,
"QCat<QAfrican;>;");
+ IQualifierDeclaration qualifier =
getQualifierDeclarationFromClass("JavaSource/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/PetShop.java",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Wild");
+ assertNotNull("Can't find the qualifier.", qualifier);
+ Set<IBean> beans = cdiProject.getBeans(true, parametedType, new
IQualifierDeclaration[]{qualifier});
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ IBean bean = beans.iterator().next();
+
+ assertContainsBeanType(false, bean, "java.lang.Object");
+ assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Cat");
+ assertContainsBeanTypeSignatures(false, bean, "QCat<QAfrican;>;");
+
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Lion",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Wild");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
+
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * d) Check producer field.
+ *
+ * @throws CoreException
+ */
+ public void testBeanTypesOnProducerField() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ assertContainsBeanType(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Dove",
"java.lang.Object");
+
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ }
}
\ 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
14:11:21 UTC (rev 22702)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-09
15:31:30 UTC (rev 22703)
@@ -135,19 +135,21 @@
return null;
}
- protected IQualifierDeclaration getQualifierDeclarationFromBeanClass(String
beanClassFilePath, String annotationTypeName) throws JavaModelException {
- IFile file = tckProject.getFile(beanClassFilePath);
+ protected IQualifierDeclaration getQualifierDeclarationFromClass(String beanFilePath,
String annotationTypeName) throws JavaModelException {
+ IFile file = tckProject.getFile(beanFilePath);
Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
- IBean bean = beans.iterator().next();
- Set<IQualifierDeclaration> declarations = bean.getQualifierDeclarations();
- IParametedType type = getType(annotationTypeName);
- for (IQualifierDeclaration declaration : declarations) {
- IAnnotation annotation = declaration.getDeclaration();
- if(type.getType().getElementName().equals(annotation.getElementName())) {
- return declaration;
+ assertFalse("Can't find any bean in " + beanFilePath, beans.isEmpty());
+ for (IBean bean : beans) {
+ Set<IQualifierDeclaration> declarations = bean.getQualifierDeclarations();
+ IParametedType type = getType(annotationTypeName);
+ for (IQualifierDeclaration declaration : declarations) {
+ IAnnotation annotation = declaration.getDeclaration();
+ if(type.getType().getElementName().equals(annotation.getElementName())) {
+ return declaration;
+ }
}
}
- fail("Can't find " + annotationTypeName + " qualifier in " +
beanClassFilePath + " bean.");
+ fail("Can't find " + annotationTypeName + " qualifier in " +
beanFilePath);
return null;
}