Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-44577 Blogs: decouple from Message Boards API, introduce Comments API
  3. LPS-48247

Comments API: modularize Spring configuration, circular reference affects functional tests

    Details

      Description

      LPS-46460 (Comments API) caused LPS-48168 (Selenium functional tests broken).

      The root cause was this line:

      https://github.com/liferay/liferay-portal/blob/0e8020f778b35fad94d204894898f01b843a2d0b/portal-impl/src/META-INF/util-spring.xml#L1019

      This line is effectively trying to make a bean declared at util-spring.xml (MBCommentManager) use another bean declared at portal-spring.xml (MBMessageLocalService).

      This is not allowed, as it results in a module-level circular dependency between util-spring and portal-spring. It's usual and valid for beans in portal-spring to inject beans from util-spring, but the other way around has never been done before and is not valid.

      The broken Selenium tests make this much more evident. When applying the Spring wiring, Liferay's BaseTestCase restricts itself to only two Spring configuration files:

      [META-INF/management-spring.xml, META-INF/util-spring.xml]

      It doesn't include portal-spring.xml, therefore MBMessageLocalService isn't present, hence the bug. Which makes sense, as Selenium tests are black-box client tests running against an external Portal and wouldn't be expected to invoke local services.

      This bug can be solved, and the Comments API become more modular, by moving all Comments-related bean declarations from util-spring.xml to a Spring configuration file of their own (comment-spring.xml). This is a well-established trend for several modules like workflow-spring.xml and mobile-device-spring.xml; gets Spring wiring working for functional tests, integration tests and the runtime Portal; and eliminates the need for any changes at Java source code level. (Reverting the modifications made for LPS-48168 to pass and returning the Java code back to its original state from LPS-46460.)

      As a bonus, we introduce a test (InitUtilTest) to do exactly the same as the Selenium base test class (com.liferay.portalweb.portal.BaseTestCase), but at the integration test level: run the Spring wiring with the same reduced set of configurations (management-spring.xml, util-spring.xml) that will be later used by the Selenium functional tests.

      Now a programmer that changes util-spring.xml in an invalid way will see this test break when running the Portal integration tests from the command line or local Jenkins, and have a chance to fix the problem before sending a pull request. This will prevent QA functional tests from breaking for the same reason in the future.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brian.chan Brian Chan
              Reporter:
              andre.oliveira André Ricardo Barreto de Oliveira
              Recent user:
              Shuyang Zhou
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 22 weeks ago

                  Packages

                  Version Package
                  7.0.0 M1