Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-5170

LegacyComponentsConfigurer can't work (in tests) when modules declare components in <properties>

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Neutral
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.2, 5.1
    • Component/s: testing
    • Labels:
      None
    • Magnolia Release:
      5.0.2, 5.1

      Description

      info.magnolia.objectfactory.configuration.LegacyComponentsConfigurer#addComponent registers a component twice - as a component, and as a type mapping.
      Consequently, info.magnolia.test.mock.AbstractComponentProvider#configure calls registerImplementation twice (one from the loop of configuration.getComponents() and once from the loop of configuration.getTypeMapping()). The second call fails.

      I experienced this while testing a ModuleVersionHandler, where the imaging module was involved (at the time of writing, the imaging module still has a component declared in <properties>.

      Workarounds:

      • Remove the <property> (replace it by the appropriate <component> or <type-mapping>)
      • Add ComponentsTestUtil.setImplementation(SystemContext.class, MockContext.class); in the test's setUp (no idea why this "works")

      Some more "interesting" observations that may or may not be related, but are probably due to other bugs in MgnlTestCase, RepositoryTestCase etc:

      • In my test, only the 2nd test method would fail, from the setUp, due to the imaging component being registered twice. Consequently, the tearDown would also fail, claiming a SystemContext impl isn't registered (which is what led me to the 2nd workaround)
      • When adding the following in my test class, both test methods would fail the same way, which leads me to believe there are other bugs in the setup/teardown of our abstract test classes.
            @Override
            @Before
            public void setUp() throws Exception {
                SystemProperty.clear();
                ComponentsTestUtil.clear();
                super.setUp();
            }
        

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gjoseph Magnolia International
              Reporter:
              gjoseph Magnolia International
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response: