Author: scabanovich
Date: 2010-09-10 10:06:15 -0400 (Fri, 10 Sep 2010)
New Revision: 24869
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/SelectedAlternativeTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/BeansXmlValidationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7044
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml 2010-09-10
13:56:27 UTC (rev 24868)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/tck/WebContent/WEB-INF/beans.xml 2010-09-10
14:06:15 UTC (rev 24869)
@@ -26,6 +26,8 @@
<stereotype>org.jboss.jsr299.tck.tests.jbt.validation.beansxml.DuplicatedAlternativeStereotype</stereotype>
<stereotype>org.jboss.jsr299.tck.tests.jbt.validation.beansxml.DuplicatedAlternativeStereotype</stereotype>
+ <class>org.jboss.jsr299.tck.tests.policy.EnabledSheepProducer</class>
+ <stereotype>org.jboss.jsr299.tck.tests.policy.EnabledPolicyStereotype</stereotype>
</alternatives>
<decorators>
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-09-10
13:56:27 UTC (rev 24868)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-09-10
14:06:15 UTC (rev 24869)
@@ -34,6 +34,7 @@
import org.jboss.tools.cdi.core.test.tck.QualifierWithMembersTest;
import org.jboss.tools.cdi.core.test.tck.ResolutionByTypeTest;
import org.jboss.tools.cdi.core.test.tck.ScopeDefinitionTest;
+import org.jboss.tools.cdi.core.test.tck.SelectedAlternativeTest;
import org.jboss.tools.cdi.core.test.tck.StereotypeDefinitionTest;
import org.jboss.tools.cdi.core.test.tck.StereotypeInheritenceTest;
import org.jboss.tools.cdi.core.test.tck.validation.AnnotationsValidationTest;
@@ -83,6 +84,7 @@
suite.addTestSuite(BeansXmlValidationTest.class);
suite.addTestSuite(AnnotationsValidationTest.class);
suite.addTestSuite(CoreValidationTest.class);
+ suite.addTestSuite(SelectedAlternativeTest.class);
suiteAll.addTestSuite(BeansXMLTest.class);
suiteAll.addTestSuite(DependentProjectTest.class);
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/SelectedAlternativeTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/SelectedAlternativeTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/SelectedAlternativeTest.java 2010-09-10
14:06:15 UTC (rev 24869)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.test.tck;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IProducer;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class SelectedAlternativeTest extends TCKTest {
+
+ /**
+ * 5.1.1. Declaring selected alternatives for a bean archive
+ * By default, a bean archive has no selected alternatives. An alternative must be
explicitly declared using the
+ * <alternatives> element of the beans.xml file of the bean archive. The
<alternatives> element contains a list of bean
+ * classes and stereotypes. An alternative is selected for the bean archive if either:
+ *
+ * • the alternative is a managed bean or session bean and the bean class of the bean
is listed,
+ */
+ public void testSelectedAlternativeManagedBean() {
+ IClassBean bean =
getClassBean("JavaSource/org/jboss/jsr299/tck/tests/policy/broken/same/type/twice/Cat.java");
+ assertTrue(bean.isSelectedAlternative());
+ }
+
+ /**
+ * • any @Alternative stereotype of the alternative is listed.
+ */
+ public void testSelectedAlternativeStereotype() {
+ IClassBean bean =
getClassBean("JavaSource/org/jboss/jsr299/tck/tests/policy/Bird.java");
+ assertTrue(bean.isSelectedAlternative());
+ }
+
+ /**
+ * • the alternative is a producer method, field or resource, and the bean class that
declares the method or field is listed
+ */
+ public void testSelectedAlternativeProducer() {
+ Set<IBean> beans = cdiProject.getBeans(new
Path("/tck/JavaSource/org/jboss/jsr299/tck/tests/policy/EnabledSheepProducer.java"));
+ int producerCount = 0;
+ for (IBean bean: beans) {
+ if(bean instanceof IProducer) {
+ producerCount++;
+ assertTrue(bean.isSelectedAlternative());
+ }
+ }
+ assertEquals(2, producerCount);
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/SelectedAlternativeTest.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/validation/BeansXmlValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/BeansXmlValidationTest.java 2010-09-10
13:56:27 UTC (rev 24868)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/BeansXmlValidationTest.java 2010-09-10
14:06:15 UTC (rev 24869)
@@ -18,7 +18,14 @@
* @author Alexey Kazakov
*/
public class BeansXmlValidationTest extends ValidationTest {
+ static int BAR_DECORATOR_LINE = 35; //
<class>org.jboss.jsr299.tck.tests.decorators.resolution.BarDecorator</class>
+ static int FOO_LINE = 44; // <class>com.acme.Foo</class>
+ static int CAT_INTERCEPTOR_LINE = FOO_LINE + 1; //
<class>org.jboss.jsr299.tck.tests.jbt.validation.interceptors.CatInterceptor</class>
+ static int NON_INTERCEPTOR_LINE = CAT_INTERCEPTOR_LINE + 1; //
<class>org.jboss.jsr299.tck.tests.interceptors.definition.broken.nonInterceptorClassInBeansXml.Foo</class>
+ static int FORD_INTERCEPTOR_1_LINE = CAT_INTERCEPTOR_LINE + 3; //
<class>org.jboss.jsr299.tck.tests.interceptors.definition.broken.sameClassListedTwiceInBeansXml.FordInterceptor</class>
+ static int FORD_INTERCEPTOR_2_LINE = FORD_INTERCEPTOR_1_LINE + 1; //
+
/**
* 5.1.1. Declaring selected alternatives for a bean archive
* - Each child <class> element must specify the name of an alternative bean
class. If there is no class with the specified
@@ -84,8 +91,8 @@
*/
public void testNonExistantDecoratorClassInBeansXmlNotOK() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
32);
- assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
33);
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
34);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_DECORATOR_BEAN_CLASS_NAME,
BAR_DECORATOR_LINE);
}
/**
@@ -95,8 +102,8 @@
*/
public void testEnabledDecoratorNotADecorator() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS, 35);
- assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS,
33);
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS, 37);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_DECORATOR_BEAN_CLASS,
BAR_DECORATOR_LINE);
}
/**
@@ -106,8 +113,8 @@
*/
public void testDecoratorListedTwiceInBeansXmlNotOK() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS, 37, 38);
- assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS, 33);
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS, 39, 40);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_DECORATOR_CLASS,
BAR_DECORATOR_LINE);
}
/**
@@ -117,8 +124,8 @@
*/
public void testNonExistantClassInBeansXmlNotOk() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME, 42);
- assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME,
43);
+ assertMarkerIsCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME,
FOO_LINE);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.UNKNOWN_INTERCEPTOR_CLASS_NAME,
CAT_INTERCEPTOR_LINE);
}
/**
@@ -128,8 +135,8 @@
*/
public void testNonInterceptorClassInBeansXmlNotOk() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS, 44);
- assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS, 43);
+ assertMarkerIsCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS,
NON_INTERCEPTOR_LINE);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.ILLEGAL_INTERCEPTOR_CLASS,
CAT_INTERCEPTOR_LINE);
}
/**
@@ -139,7 +146,7 @@
*/
public void testSameInterceptorClassListedTwiceInBeansXmlNotOk() throws Exception {
IFile file = tckProject.getFile("WebContent/WEB-INF/beans.xml");
- assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS, 46,
47);
- assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS, 43);
+ assertMarkerIsCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS,
FORD_INTERCEPTOR_1_LINE, FORD_INTERCEPTOR_2_LINE);
+ assertMarkerIsNotCreated(file, CDIValidationMessages.DUPLICATE_INTERCEPTOR_CLASS,
CAT_INTERCEPTOR_LINE);
}
}
\ No newline at end of file