-
Bug
-
Resolution: Fixed
-
Neutral
-
None
-
None
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(); }
- is superseded by
-
MAGNOLIA-5173 Deprecate/rewrite MgnlTestCase and subclasses - Testing framework issues
- Closed