Details
-
Improvement
-
Resolution: Fixed
-
Major
-
4.3
-
None
Description
See also XCOMMONS-317
Usage example:
@ComponentList({ DefaultExtensionLicenseManager.class }) public class DefaultExtensionLicenseManagerTest { @Rule public final ComponentManagerRule componentManager = new ComponentManagerRule(); ... @Before public void setUp() throws Exception { this.licenseManager = this.componentManager.getInstance(ExtensionLicenseManager.class); } ...
Another example (using the new @BeforeComponent annotation):
@ComponentList({ DefaultExtensionManagerConfiguration.class, DefaultLoggerManager.class, DefaultObservationManager.class }) public class DefaultExtensionManagerConfigurationTest { @Rule public final MockitoComponentManagerRule componentManager = new MockitoComponentManagerRule(); private ExtensionManagerConfiguration configuration; private MemoryConfigurationSource source; @BeforeComponent public void registerComponents() throws Exception { // Register a Mocked Environment since we need to provide one. this.componentManager.registerMockComponent(Environment.class); // Register some in-memory Configuration Source for the test this.source = this.componentManager.registerMemoryConfigurationSource(); } @Before public void setUp() throws Exception { this.configuration = this.componentManager.getInstance(ExtensionManagerConfiguration.class); } ...
@BeforeComponent is used by ComponentManagerRule and methods annotated with it are called before other components are registered (ie before processing of @AllComponents and @ComponentList annotations).
MockitoComponentManagerRule extends ComponentManagerRule and just adds some helper methods to register a mock component.
Attachments
Issue Links
- relates to
-
XCOMMONS-319 Move all JMock-related classes to a jmock package in the Commons Test module
- Closed
-
XCOMMONS-320 Introduce a MockitoComponentMockingRule to replace AbstractMockingComponentTestCase
- Closed