Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-1895

Allow individual tests to provide fixture code that is called before components are initialized

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 11.10
    • Fix Version/s: 12.2
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      When we have components that implement Initializable, we may need to write tests that provide different fixtures for the code inside the initialize() method. So far we had a @BeforeComponent but that's common to all tests and doesn't allow varying the fixture per test.

      The proposal here is to introduce the following:

        @BeforeComponent("normalizeFromRootServletContextAndServletMapping")
          public void beforeNormalizeFromRootServletContextAndServletMapping()
          {
              when(this.servletContext.getServletRegistration("action").getMappings())
                  .thenReturn(Arrays.asList("/*", "/bin/*", "/wiki/*", "/testbin/*"));
          }
      
          @Test
          public void normalizeFromRootServletContextAndServletMapping()
          {
              when(this.servletContext.getContextPath()).thenReturn("/");
      
              HttpServletRequest req = createMockRequest();
              when(req.getServletPath()).thenReturn("/");
      
              assertEquals("/one/two", this.normalizer.normalize(this.testURL).serialize());
          }
      

        Attachments

          Activity

            People

            • Assignee:
              vmassol Vincent Massol
              Reporter:
              vmassol Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: