Author: akazakov
Date: 2010-06-08 14:44:28 -0400 (Tue, 08 Jun 2010)
New Revision: 22641
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.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/BeanDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-08
16:41:16 UTC (rev 22640)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanDefinitionTest.java 2010-06-08
18:44:28 UTC (rev 22641)
@@ -125,14 +125,12 @@
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.bean.Tarantula");
assertEquals("There should be the only bean with
org.jboss.jsr299.tck.tests.definition.bean.Tarantula type", 1, beans.size());
IBean bean = beans.iterator().next();
- Set<IParametedType> types = bean.getLegalTypes();
- assertEquals("Wrong number of legal types were found for
org.jboss.jsr299.tck.tests.definition.bean.Tarantula bean.", 6, types.size());
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Tarantula");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Spider");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Animal");
- assertContainsBeanType(bean, "java.lang.Object");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.DeadlySpider");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.DeadlyAnimal");
+ assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Tarantula",
+ "org.jboss.jsr299.tck.tests.definition.bean.Spider",
+ "org.jboss.jsr299.tck.tests.definition.bean.Animal",
+ "java.lang.Object",
+ "org.jboss.jsr299.tck.tests.definition.bean.DeadlySpider",
+ "org.jboss.jsr299.tck.tests.definition.bean.DeadlyAnimal");
Set<ITypeDeclaration> declarations = bean.getAllTypeDeclarations();
assertEquals("There should be three type declarations in
org.jboss.jsr299.tck.tests.definition.bean.Tarantula bean.", declarations.size(),
3);
@@ -150,12 +148,10 @@
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope");
assertEquals("There should be the only bean with
org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope type", 1, beans.size());
IBean bean = beans.iterator().next();
- Set<IParametedType> types = bean.getLegalTypes();
- assertEquals("Wrong number of legal types were found for
org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope bean.", 4,
types.size());
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.AbstractAntelope");
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.Animal");
- assertContainsBeanType(bean, "java.lang.Object");
+ assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope",
+ "org.jboss.jsr299.tck.tests.definition.bean.AbstractAntelope",
+ "org.jboss.jsr299.tck.tests.definition.bean.Animal",
+ "java.lang.Object");
Set<ITypeDeclaration> declarations = bean.getAllTypeDeclarations();
assertEquals("There should be three type declarations in
org.jboss.jsr299.tck.tests.definition.bean.FriendlyAntelope bean.",
declarations.size(), 2);
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-08
16:41:16 UTC (rev 22640)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/BeanSpecializationTest.java 2010-06-08
18:44:28 UTC (rev 22641)
@@ -30,7 +30,7 @@
Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.LazyFarmer",
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
+ assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Farmer");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.simple.Lazy",
@@ -48,7 +48,7 @@
Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.LazyFarmerLocal",
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner");
assertEquals("Wrong number of beans.", 1, beans.size());
IBean bean = beans.iterator().next();
- assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
+ assertContainsBeanType(false, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.FarmerLocal");
assertContainsQualifierType(true, bean,
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Landowner",
"org.jboss.jsr299.tck.tests.inheritance.specialization.enterprise.Lazy",
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-08
16:41:16 UTC (rev 22640)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ResolutionByTypeTest.java 2010-06-08
18:44:28 UTC (rev 22641)
@@ -37,7 +37,7 @@
public void testDefaultBindingTypeAssumed() throws CoreException {
Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
assertEquals("Wrong number of the beans", 1, beans.size());
- assertContainsBeanType(beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
+ assertContainsBeanType(false, beans.iterator().next(),
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Tuna");
}
/**
@@ -130,5 +130,20 @@
assertContainsBeanClasses(beans, new
String[]{"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.RoundWhitefish",
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Halibut"});
}
+ /**
+ * Section 2.2.2 - Restricting the bean types of a bean
+ * a) Check managed bean.
+ *
+ * @throws CoreException
+ */
+ public void testBeanTypesOnManagedBean() throws CoreException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary");
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ beans =
getBeans("org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Bird");
+ assertEquals("Wrong number of the beans", 0, beans.size());
+ assertContainsBeanType(bean,
"org.jboss.jsr299.tck.tests.lookup.typesafe.resolution.Canary",
"java.lang.Object");
+ }
+
// 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-08
16:41:16 UTC (rev 22640)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-06-08
18:44:28 UTC (rev 22641)
@@ -222,17 +222,28 @@
fail(message.toString());
}
- protected void assertContainsBeanType(IBean bean, String typeName) {
- Set<IParametedType> types = bean.getLegalTypes();
- StringBuffer allTypes = new StringBuffer("[");
- for (IParametedType type : types) {
- allTypes.append("
").append(type.getType().getFullyQualifiedName()).append(";");
- if (typeName.equals(type.getType().getFullyQualifiedName())) {
- return;
+ protected void assertContainsBeanType(IBean bean, String... typeNames) {
+ assertContainsBeanType(true, bean, typeNames);
+ }
+
+ protected void assertContainsBeanType(boolean checkTheNumberOfTypes, IBean bean,
String... typeNames) {
+ if(checkTheNumberOfTypes) {
+ assertEquals("Wrong number of types.", typeNames.length,
bean.getLegalTypes().size());
+ }
+ for (String typeName : typeNames) {
+ Set<IParametedType> types = bean.getLegalTypes();
+ StringBuffer allTypes = new StringBuffer("[");
+ boolean found = false;
+ for (IParametedType type : types) {
+ allTypes.append("
").append(type.getType().getFullyQualifiedName()).append(";");
+ if (typeName.equals(type.getType().getFullyQualifiedName())) {
+ found = true;
+ break;
+ }
}
+ allTypes.append("]");
+ assertTrue(bean.getResource().getFullPath() + " bean " + allTypes.toString()
+ " should have " + typeName + " type.", found);
}
- allTypes.append("]");
- fail(bean.getResource().getFullPath() + " bean " + allTypes.toString() +
" should have " + typeName + " type.");
}
public static void assertContainsBeanClasses(Set<IBean> beans, String...
beanClassNames) throws CoreException {