Author: akazakov
Date: 2010-12-02 08:28:22 -0500 (Thu, 02 Dec 2010)
New Revision: 27092
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotyped.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Cod.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Sole.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
Log:
https://jira.jboss.org/browse/JBIDE-6575 Added 5.3.1. Ambiguous EL names validation
rules.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -306,7 +306,7 @@
*/
public static IAnnotationDeclaration getQualifiedSpecializesDeclaration(IBean bean,
String qualifierTypeName) {
IBean specializedBean = bean.getSpecializedBean();
- return specializedBean!=null?getQualifierDeclaration(bean, qualifierTypeName):null;
+ return specializedBean!=null?getQualifierDeclaration(specializedBean,
qualifierTypeName):null;
}
/**
@@ -316,10 +316,13 @@
* @return
*/
public static IAnnotationDeclaration getQualifiedStereotypeDeclaration(IStereotyped
stereotyped, String qualifierTypeName) {
- Set<IStereotypeDeclaration> declarations =
stereotyped.getStereotypeDeclarations();
- for (IStereotypeDeclaration declaration : declarations) {
- if (qualifierTypeName.equals(declaration.getType().getFullyQualifiedName())
- || getQualifiedStereotypeDeclaration(declaration.getStereotype(), qualifierTypeName)
!= null) {
+ IAnnotationDeclaration qualifierDeclaration =
stereotyped.getAnnotation(qualifierTypeName);
+ if (qualifierDeclaration != null) {
+ return qualifierDeclaration;
+ }
+ Set<IStereotypeDeclaration> stereotypeDeclarations =
stereotyped.getStereotypeDeclarations();
+ for (IStereotypeDeclaration declaration : stereotypeDeclarations) {
+ if (getQualifiedStereotypeDeclaration(declaration.getStereotype(), qualifierTypeName)
!= null) {
return declaration;
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotyped.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotyped.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotyped.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -17,7 +17,7 @@
*
* @author Alexey Kazakov
*/
-public interface IStereotyped {
+public interface IStereotyped extends IAnnotated {
/**
* Obtains the stereotype declarations of the element (bean class or
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -41,6 +41,7 @@
defaultPreferences.put(CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.AMBIGUOUS_EL_NAMES, CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.UNPROXYABLE_BEAN_TYPE, CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.INJECTED_DECORATOR, CDIPreferences.WARNING);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -39,6 +39,12 @@
// - interceptor or decorator has a name (2.5.3 non-portable)
public static final String INTERCEPTOR_HAS_NAME =
INSTANCE.createSeverityOption("interceptorHasName"); //$NON-NLS-1$
public static final String DECORATOR_HAS_NAME =
INSTANCE.createSeverityOption("decoratorHasName"); //$NON-NLS-1$
+// 5.3.1. Ambiguous EL names
+// - All unresolvable ambiguous EL names are detected by the container when the
application is initialized. Suppose two beans are both available for injection in a
certain war, and either:
+// • the two beans have the same EL name and the name is not resolvable, or
+// • the EL name of one bean is of the form x.y, where y is a valid bean EL name, and
x is the EL name of the other bean,
+// the container automatically detects the problem and treats it as a deployment
problem.
+ public static final String AMBIGUOUS_EL_NAMES =
INSTANCE.createSeverityOption("ambiguousElNames"); //$NON-NLS-1$
//Type group
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -12,11 +12,13 @@
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -39,8 +41,10 @@
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeParameter;
+import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
@@ -212,12 +216,35 @@
if (ValidationUtil.checkFileExtensionForJavaAndXml(currentFile)) {
resources.add(currentFile.getFullPath());
+ Set<String> newElNamesOfChangedFile =
getELNamesByResource(currentFile.getFullPath());
+ for (String newElName : newElNamesOfChangedFile) {
+ // Collect resources that had EL names (in previous validation session) declared in
this changed resource.
+ Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(newElName, true);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
+ }
+ }
+ // Get old EL names which were linked with this resource in previous validation
session.
+ Set<String> oldElNamesOfChangedFile =
validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), true);
+ if(oldElNamesOfChangedFile!=null) {
+ for (String name : oldElNamesOfChangedFile) {
+ Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(name, true);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
+ }
+ // Save old (from previous validation session) EL names. We need to validate all
the resources which use this old EL name in case the name has been changed.
+ validationContext.addVariableNameForELValidation(name);
+ }
+ }
+
// Get all the paths of related resources for given file. These
// links were saved in previous validation process.
Set<String> oldReletedResources =
getValidationContext().getVariableNamesByCoreResource(currentFile.getFullPath(), false);
if (oldReletedResources != null) {
for (String resourcePath : oldReletedResources) {
- resources.add(Path.fromOSString(resourcePath));
+ if(resourcePath.startsWith("/")) {
+ resources.add(Path.fromOSString(resourcePath));
+ }
}
}
}
@@ -401,11 +428,6 @@
if(bean.getBeanClass().isReadOnly()) {
return;
}
- // Collect all relations between the bean and other CDI elements.
- String name = bean.getName();
- if (name != null) {
- getValidationContext().addVariableNameForELValidation(name);
- }
String beanPath = bean.getResource().getFullPath().toOSString();
Set<IScopeDeclaration> scopeDeclarations = bean.getScopeDeclarations();
for (IScopeDeclaration scopeDeclaration : scopeDeclarations) {
@@ -460,8 +482,93 @@
}
validateSpecializingBean(bean);
+
+ validateBeanName(bean);
}
+ /**
+ * Validates a bean EL name.
+ *
+ * @param bean
+ */
+ private void validateBeanName(IBean bean) {
+ String name = bean.getName();
+ if(name!=null && !name.startsWith("/")) {
+ // Collect all relations between the bean and other CDI elements.
+ getValidationContext().addVariableNameForELValidation(name);
+ getValidationContext().addLinkedCoreResource(name, bean.getSourcePath(), true);
+ /*
+ * 5.3.1. Ambiguous EL names
+ * - All unresolvable ambiguous EL names are detected by the container when the
application is initialized.
+ * Suppose two beans are both available for injection in a certain war, and
either:
+ * • the two beans have the same EL name and the name is not resolvable, or
+ */
+ Set<IBean> beans = cdiProject.getBeans(name, true);
+ if(beans.size()>1 && beans.contains(bean)) {
+ ITextSourceReference reference = bean.getNameLocation();
+ if(reference==null) {
+ reference = CDIUtil.getNamedDeclaration(bean);
+ }
+ StringBuffer sb = new StringBuffer(bean.getSimpleJavaName());
+ for (IBean iBean : beans) {
+ if(bean!=iBean) {
+ sb.append(", ").append(iBean.getSimpleJavaName());
+ }
+ }
+ addError(MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME,
sb.toString()), CDIPreferences.AMBIGUOUS_EL_NAMES, reference, bean.getResource());
+ } else {
+ /*
+ * • the EL name of one bean is of the form x.y, where y is a valid bean EL name,
and x is the EL name of the other bean,
+ * the container automatically detects the problem and treats it as a
deployment problem.
+ */
+ if(name.indexOf('.')>0) {
+ StringTokenizer st = new StringTokenizer(name, ".", false);
+ StringBuffer xName = new StringBuffer();
+ while(st.hasMoreTokens()) {
+ if(xName.length()>0) {
+ xName.append('.');
+ }
+ xName.append(st.nextToken());
+ if(st.hasMoreTokens()) {
+ String xNameAsString = xName.toString();
+ Set<IBean> xBeans = cdiProject.getBeans(xNameAsString, true);
+ if(!xBeans.isEmpty()) {
+ String yName = name.substring(xNameAsString.length()+1);
+ IStatus status = JavaConventions.validateJavaTypeName(yName,
CompilerOptions.VERSION_1_6, CompilerOptions.VERSION_1_6);
+ if (status.getSeverity() != IStatus.ERROR) {
+ ITextSourceReference reference = bean.getNameLocation();
+ if(reference==null) {
+ reference = CDIUtil.getNamedDeclaration(bean);
+ }
+ addError(MessageFormat.format(CDIValidationMessages.UNRESOLVABLE_EL_NAME, name,
yName, xNameAsString, xBeans.iterator().next().getSimpleJavaName()),
CDIPreferences.AMBIGUOUS_EL_NAMES, reference, bean.getResource());
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Returns set of EL names which are declared in the resource
+ */
+ private Set<String> getELNamesByResource(IPath resourcePath) {
+ Set<IBean> beans = cdiProject.getBeans(resourcePath);
+ if(beans.isEmpty()) {
+ return Collections.emptySet();
+ }
+ Set<String> result = new HashSet<String>();
+ for (IBean bean : beans) {
+ String name = bean.getName();
+ if(name!=null) {
+ result.add(name);
+ }
+ }
+ return result;
+ }
+
private IType getTypeOfInjection(IInjectionPoint injection) {
IParametedType parametedType = injection.getType();
return parametedType==null?null:parametedType.getType();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -34,6 +34,8 @@
public static String UNPROXYABLE_BEAN_TYPE_WITH_FM;
public static String DECORATOR_RESOLVES_TO_FINAL_CLASS;
public static String DECORATOR_RESOLVES_TO_FINAL_METHOD;
+ public static String DUPLCICATE_EL_NAME;
+ public static String UNRESOLVABLE_EL_NAME;
public static String ILLEGAL_TYPE_IN_TYPED_DECLARATION;
public static String ILLEGAL_TYPE_IN_TYPED_DECLARATION_IN_BEAN_CLASS;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-12-02
13:28:22 UTC (rev 27092)
@@ -194,6 +194,12 @@
with a non-primitive return type or a producer field with a non-primitive type, the
container automatically detects the problem
and treats it as a deployment problem.
+5.3.1. Ambiguous EL names
+- All unresolvable ambiguous EL names are detected by the container when the application
is initialized. Suppose two beans are both available for injection in a certain war, and
either:
+ • the two beans have the same EL name and the name is not resolvable, or
+ • the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is
the EL name of the other bean,
+ the container automatically detects the problem and treats it as a deployment
problem.
+
5.4.1. Unproxyable bean types
- If an injection point whose declared type cannot be proxied by the container resolves
to a bean with a normal scope,
the container automatically detects the problem and treats it as a deployment problem:
@@ -236,16 +242,8 @@
- If the same class is listed twice under the <interceptors> element, the container
automatically detects the problem and treats it as
a deployment problem.
-
-
Unimplemented:
5.1.3. Inconsistent specialization
- Suppose an enabled bean X specializes a second bean Y. If there is another enabled bean
that specializes Y we say that inconsistent
- specialization exists. The container automatically detects inconsistent specialization
and treats it as a deployment problem.
-
-5.3.1. Ambiguous EL names
-- All unresolvable ambiguous EL names are detected by the container when the application
is initialized. Suppose two beans are both available for injection in a certain war, and
either:
- • the two beans have the same EL name and the name is not resolvable, or
- • the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is
the EL name of the other bean,
- the container automatically detects the problem and treats it as a deployment
problem.
\ No newline at end of file
+ specialization exists. The container automatically detects inconsistent specialization
and treats it as a deployment problem.
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-12-02
13:28:22 UTC (rev 27092)
@@ -3,6 +3,8 @@
PARAM_INJECTION_DECLARES_EMPTY_NAME=Injection point other than injected field must not
declare a @Named annotation that does not specify the value member [JSR-299 �3.11]
INTERCEPTOR_HAS_NAME=Interceptor has a name [JSR-299 �2.5.3]
DECORATOR_HAS_NAME=Decorator has a name [JSR-299 �2.5.3]
+DUPLCICATE_EL_NAME=A few beans ({0}) have the same EL name and the name is not resolvable
[JSR-299 �5.3.1]
+UNRESOLVABLE_EL_NAME=The EL name "{0}" is of the form x.y, where y
("{1}") is a valid bean EL name, and x ("{2}") is the EL name of the
other bean {3} [JSR-299 �5.3.1]
UNSATISFIED_INJECTION_POINTS=No bean is eligible for injection to the injection point
AMBIGUOUS_INJECTION_POINTS=Multiple beans are eligible for injection to the injection
point
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -36,6 +36,7 @@
{CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_paramInjectionDeclaresEmptyName_label},
{CDIPreferences.INTERCEPTOR_HAS_NAME,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorHasName_label},
{CDIPreferences.DECORATOR_HAS_NAME,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_decoratorHasName_label},
+ {CDIPreferences.AMBIGUOUS_EL_NAMES,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_ambiguousElNames_label},
},
CDICorePlugin.PLUGIN_ID
);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -39,6 +39,7 @@
public static String
CDIValidatorConfigurationBlock_pb_paramInjectionDeclaresEmptyName_label;
public static String CDIValidatorConfigurationBlock_pb_interceptorHasName_label;
public static String CDIValidatorConfigurationBlock_pb_decoratorHasName_label;
+ public static String CDIValidatorConfigurationBlock_pb_ambiguousElNames_label;
// Section Type
public static String CDIValidatorConfigurationBlock_section_type;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2010-12-02
13:28:22 UTC (rev 27092)
@@ -28,6 +28,7 @@
CDIValidatorConfigurationBlock_pb_paramInjectionDeclaresEmptyName_label=Empty name at
parameter injection:
CDIValidatorConfigurationBlock_pb_interceptorHasName_label=Interceptor declares name:
CDIValidatorConfigurationBlock_pb_decoratorHasName_label=Decorator declares name:
+CDIValidatorConfigurationBlock_pb_ambiguousElNames_label=Ambiguous EL names:
##Section Type
CDIValidatorConfigurationBlock_section_type=Type
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Cod.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Cod.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Cod.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -18,7 +18,7 @@
import javax.inject.Named;
-@Named("whitefish")
+@Named("whitefishJBTDup") // Original tck name was "whitefish".
modified for JBT tests to "whitefishJBTDup"
class Cod
{
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Sole.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Sole.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/byname/duplicateNameResolution/Sole.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -18,7 +18,7 @@
import javax.inject.Named;
-@Named("whitefish")
+@Named("whitefishJBTDup") // Original tck name was "whitefish".
modified for JBT tests to "whitefishJBTDup"
class Sole
{
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2010-12-02
13:19:54 UTC (rev 27091)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2010-12-02
13:28:22 UTC (rev 27092)
@@ -135,6 +135,32 @@
}
/**
+ * 5.3.1. Ambiguous EL names
+ * - All unresolvable ambiguous EL names are detected by the container when the
application is initialized.
+ * Suppose two beans are both available for injection in a certain war, and either:
+ * • the two beans have the same EL name and the name is not resolvable, or
+ *
+ * @throws Exception
+ */
+ public void testDuplicateNamedBeans() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicateNameResolution/Cod.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Cod, Sole"),
21);
+ file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicateNameResolution/Sole.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.DUPLCICATE_EL_NAME, "Sole, Cod"),
21);
+ }
+
+ /**
+ * • the EL name of one bean is of the form x.y, where y is a valid bean EL name, and
x is the EL name of the other bean,
+ * the container automatically detects the problem and treats it as a deployment
problem.
+ *
+ * @throws Exception
+ */
+ public void testDuplicateBeanNamePrefix() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/byname/duplicatePrefixResolution/ExampleWebsite_Broken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.UNRESOLVABLE_EL_NAME, "example.com",
"com", "example", "Example"), 22);
+ }
+
+ /**
* 8.3 - Decorator resolution
* - If a decorator matches a managed bean, and the managed bean class is declared
final, the container automatically detects
* the problem and treats it as a deployment problem.