Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.CDIVersion;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.ICDIAnnotation;
Expand Down Expand Up @@ -1844,12 +1845,15 @@ private void validateInjectionPoint(CDIValidationContext context, IInjectionPoin
addProblem(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS, CDIPreferences.UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS, reference, injection.getResource(), AMBIGUOUS_INJECTION_POINTS_ID);
} else if(beans.size()==1) {
IBean bean = beans.iterator().next();
if(cdiProject.getVersion() == CDIVersion.CDI_1_0) {
/*
* CDI 1.0 specification, it is omitted since CDI 1.1:
* 5.2.4. Primitive types and null values
* - injection point of primitive type resolves to a bean that may have null values, such as a producer method with a non-primitive return type or a producer field with a non-primitive type
*/
if(bean.isNullable() && injection.getType()!=null && injection.getType().isPrimitive()) {
addProblem(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
if(bean.isNullable() && injection.getType()!=null && injection.getType().isPrimitive()) {
addProblem(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
}
}
/*
* 5.1.4. Inter-module injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@SuppressWarnings("unused")
class GameBroken {
@Inject @PrimitiveTestQualifer private int numberBroken;
@Inject @PrimitiveTestQualifer private int numberBroken; //It is not broken since 1.1

@Inject @PrimitiveTestQualifer private Integer number2;
@Inject @TestQualifer private int number3;
Expand All @@ -16,7 +16,7 @@ public void setNumber() {
}

@Inject
public void setNumber2(@PrimitiveTestQualifer int numberBroken,
public void setNumber2(@PrimitiveTestQualifer int numberBroken, //It is not broken since 1.1
@PrimitiveTestQualifer Integer number2,
@TestQualifer int number3,
@TestQualifer Integer number4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
******************************************************************************/
package org.jboss.tools.cdi.core.test.tck11.validation;

import org.eclipse.core.resources.IFile;
import org.jboss.tools.cdi.core.test.tck.ITCKProjectNameProvider;
import org.jboss.tools.cdi.core.test.tck.validation.AYTDeploymentProblemsValidationTests;
import org.jboss.tools.cdi.core.test.tck11.TCK11ProjectNameProvider;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;

/**
* @author Alexey Kazakov
Expand All @@ -23,4 +25,27 @@ public class AYTDeploymentProblemsValidationCDI11Tests extends AYTDeploymentProb
public ITCKProjectNameProvider getProjectNameProvider() {
return new TCK11ProjectNameProvider();
}

/**
* The defined in CDI 1.0 '5.2.4. Primitive types and null values'
* prohibition for an injection point of primitive type to be resolved to
* a bean that may have null values is removed from CDI 1.1 (container lets
* an injection point to have default value when resolved bean returns null
* value).
*
* removed from CDI 1.1.
*/
@Override
public void testPrimitiveInjectionPointResolvedToNonPrimitiveProducerMethod() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add @OverRide to the method

IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GameBroken.java");
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 19);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@

package org.jboss.tools.cdi.core.test.tck11.validation;

import org.eclipse.core.resources.IFile;
import org.jboss.tools.cdi.core.test.tck.ITCKProjectNameProvider;
import org.jboss.tools.cdi.core.test.tck.validation.DeploymentProblemsValidationTests;
import org.jboss.tools.cdi.core.test.tck11.TCK11ProjectNameProvider;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationMessages;

/**
* @author Alexey Kazakov
Expand All @@ -24,4 +26,27 @@ public class DeploymentProblemsValidationCDI11Tests extends DeploymentProblemsVa
public ITCKProjectNameProvider getProjectNameProvider() {
return new TCK11ProjectNameProvider();
}

/**
* The defined in CDI 1.0 '5.2.4. Primitive types and null values'
* prohibition for an injection point of primitive type to be resolved to
* a bean that may have null values is removed from CDI 1.1 (container lets
* an injection point to have default value when resolved bean returns null
* value).
*
* removed from CDI 1.1.
*/
@Override
public void testPrimitiveInjectionPointResolvedToNonPrimitiveProducerMethod() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add @OverRide to the method

IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/inject/GameBroken.java");
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 7);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 19);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 9);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 10);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 11);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 20);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 21);
getAnnotationTest().assertAnnotationIsNotCreated(file, CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN, 22);
}

}