Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-2046

CDI Injection in methods should only inject @Inject parameters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.1.11.Final
    • Runtime Enricher SPI
    • None
    • Hide

      Run attached testcase. It is build with maven and assumes there is an empty wildfly running on ports 8080 (http) and 9990 (mgmt).

      It can fail because it receives an incorrect bean or (if it received the correct bean) because it detects that two instances of TestData were created (ie, one was created by CDIInjectionEnricher).
      It will log the stacktrace of every <init> call for TestData (the bean) to stderr, which will probably end up in the serverlog.

      Show
      Run attached testcase. It is build with maven and assumes there is an empty wildfly running on ports 8080 (http) and 9990 (mgmt). It can fail because it receives an incorrect bean or (if it received the correct bean) because it detects that two instances of TestData were created (ie, one was created by CDIInjectionEnricher). It will log the stacktrace of every <init> call for TestData (the bean) to stderr, which will probably end up in the serverlog.

      The CDIInjectionEnricher should only inject method parameters annotated with @Inject, as is the spec and as it does with instance variables.

      The current implementation, which treats every method parameter as an injection point, conflicts with custom test enrichers. If my project is a beanarchive with bean-discovery-mode=all then every class is counted as a bean.

      If I have a testmethod where a custom enricher supplies one of the parameters the CDIInjectionEnricher also provides that parameter but by calling it's default parameter and not setting any other configuration, resulting in faulty testdata.

      Even worse, because the ordering of TestEnrichers as used in LocalTestExecutor#enrichArguments is not defined, sometimes the bean provided by the custom enricher will be used, and sometimes the one provided by CDIInjectionEnricher, leading to a testcase that will only fail sometimes.

              Unassigned Unassigned
              sven.haster Sven Haster (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: