Author: akazakov
Date: 2010-04-07 08:18:07 -0400 (Wed, 07 Apr 2010)
New Revision: 21300
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/StereotypeDefinitionTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5808 Added new CDI tests for Stereotypes.
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java 2010-04-07
11:58:05 UTC (rev 21299)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreTestSetup.java 2010-04-07
12:18:07 UTC (rev 21300)
@@ -14,6 +14,7 @@
import junit.framework.Test;
import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.internal.core.JavaModelManager;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ResourcesUtils;
@@ -31,6 +32,7 @@
@Override
protected void setUp() throws Exception {
+ JavaModelManager.getIndexManager().disable();
tckProject = TCKTest.importPreparedProject("/");
}
@@ -41,5 +43,6 @@
tckProject.delete(true, true, null);
JobUtils.waitForIdle();
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ JavaModelManager.getIndexManager().enable();
}
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/StereotypeDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/StereotypeDefinitionTest.java 2010-04-07
11:58:05 UTC (rev 21299)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/StereotypeDefinitionTest.java 2010-04-07
12:18:07 UTC (rev 21300)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
+import org.jboss.tools.common.text.ITextSourceReference;
/**
* @author Alexey Kazakov
@@ -40,4 +41,152 @@
.size());
assertLocationEquals(declarations, 835, 17);
}
+
+ /**
+ * section 2.7.1.1 aa) section 2.4.4 b)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeWithoutScopeType() throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.Reindeer");
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
"javax.enterprise.context.Dependent",
+ bean.getScope().getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 2.7 c) section 2.7.1 b)
+ *
+ * @throws JavaModelException
+ */
+ public void testOneStereotypeAllowed() throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.LongHairedDog");
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.RequestScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 2.7.2 e)
+ * section 2.7 d)
+ */
+ public void testMultipleStereotypesAllowed() {
+ Set<IBean> beans = cdiProject.getBeans(true,
"org.jboss.jsr299.tck.tests.definition.stereotype.HighlandCow",
"org.jboss.jsr299.tck.tests.definition.stereotype.Tame");
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ assertNull("The bean should not have any EL name.", bean.getName());
+ assertContainsQualifierType(bean,
"org.jboss.jsr299.tck.tests.definition.stereotype.Tame");
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.RequestScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ Set<? extends ITextSourceReference> declarations =
bean.getQualifierDeclarations(false);
+ assertEquals("Wrong number of qualifier declarations", 1,
declarations.size());
+ assertLocationEquals(declarations, 877, 5);
+
+ declarations = bean.getStereotypeDeclarations();
+ assertEquals("Wrong number of stereotype declarations", 2,
declarations.size());
+ assertLocationEquals(declarations, 835, 23);
+ assertLocationEquals(declarations, 859, 17);
+ }
+
+ /**
+ * section 2.7.2 e) section 2.4.4 e)
+ *
+ * @throws JavaModelException
+ */
+ public void testExplicitScopeOverridesMergedScopesFromMultipleStereotype()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.Springbok");
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.RequestScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 ab)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeDeclaredInheritedIsInherited()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.BorderCollie");
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.RequestScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 aba)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeNotDeclaredInheritedIsNotInherited()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.ShetlandPony");
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
"javax.enterprise.context.Dependent",
+ bean.getScope().getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 ah)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeDeclaredInheritedIsIndirectlyInherited()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.EnglishBorderCollie");
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.RequestScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 aha)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeNotDeclaredInheritedIsNotIndirectlyInherited()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.MiniatureClydesdale");
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
"javax.enterprise.context.Dependent",
+ bean.getScope().getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 hhh)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeScopeIsOverriddenByInheritedScope()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.Chihuahua");
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.SessionScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
+
+ /**
+ * section 4.1 hhi)
+ *
+ * @throws JavaModelException
+ */
+ public void testStereotypeScopeIsOverriddenByIndirectlyInheritedScope()
+ throws JavaModelException {
+ Set<IBean> beans =
getBeans("org.jboss.jsr299.tck.tests.definition.stereotype.MexicanChihuahua");
+ IBean bean = beans.iterator().next();
+ assertEquals("Wrong scope type",
+ "javax.enterprise.context.SessionScoped", bean.getScope()
+ .getSourceType().getFullyQualifiedName());
+ }
}
\ No newline at end of file