Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-760

TestControl module creates Applicationscoped beans more than once for single test

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 1.0.3
    • None
    • CdiControl
    • None

    Description

      I have a test that is @RunWith(CdiTestRunner.class), is @Injecting an
      @ApplicationScopedBean1 which itself @Injects another @ApplicationScopedBean2 and then I have another @Inject directly in the test class which also @Injects the @ApplicationScopedBean2.

      The CDI implementation used is Weld-SE

      ApplicationScopedBean2 contains a cache.

      What's happeneing is, that ApplicationScopedBean2 gets created twice, once for ApplicationScopedBean1 and once for the test class.

      So when I then call ApplicationScopedBean2.invalidateMyCache() in the test and then ask ApplicationScopedBean1.getSomethingFromYourApplicationScopedBean2sCache, then because its two different beans I still get some cached values. Of course all calls are done within the same test method!

      Deployed on a server the whole thing works as expected, only one bean of type ApplicationScopedBean2 is being created.

      But the whole purpose of having DeltaSpike is to be able to test stuff exactly as it would be on the server, right?

      So I'm not sure, if this is a Bug, a known limitation (couldn't find anything about that) or a configuration problem with my test setup.

      Attachments

        Activity

          People

            struberg Mark Struberg
            bes82 Björn Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: