Details
-
Improvement
-
Resolution: Fixed
-
Major
-
11.10
-
None
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()); }