MockitoComponentMockingRule instead@Deprecated public abstract class AbstractMockingComponentTestCase<T> extends AbstractMockingTestCase
AbstractComponentTestCase test class. To use this class, annotate your test class with
with MockingRequirement, passing the implementation class you're testing.
Then in your test code, do a lookup of your component under test and you'll get a component instance which has all
its injected dependencies mocked automatically. For example:
@MockingRequirement(MyComponentImplementation.class)
public class MyComponentTest extends AbstractMockingComponentTestCase<MyComponent>
{
@Test
public void someTest() throws Exception
{
MyComponent myComponent = getMockedComponent();
...
}
Note that by default there are no component registered against the component manager except those mocked
automatically by the @MockingRequirement annotation. This has 2 advantages:
ComponentList annotation and if you really really
need to register all components (it takes time) then use AllComponents.mockery| Constructor and Description |
|---|
AbstractMockingComponentTestCase()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
MockingComponentManager |
getComponentManager()
Deprecated.
|
T |
getMockedComponent()
Deprecated.
|
T |
getMockedComponent(Class mockedComponentClass)
Deprecated.
|
org.slf4j.Logger |
getMockLogger()
Deprecated.
|
org.slf4j.Logger |
getMockLogger(Class<?> mockedComponentClass)
Deprecated.
|
void |
setUp()
Deprecated.
|
getMockery, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponentpublic AbstractMockingComponentTestCase()
public T getMockedComponent() throws org.xwiki.component.manager.ComponentLookupException
MockingRequirement annotationorg.xwiki.component.manager.ComponentLookupExceptionpublic T getMockedComponent(Class mockedComponentClass) throws org.xwiki.component.manager.ComponentLookupException
mockedComponentClass - the class of the mocked component to returnMockingRequirement annotation that is of the passed class typeorg.xwiki.component.manager.ComponentLookupExceptionpublic org.slf4j.Logger getMockLogger(Class<?> mockedComponentClass) throws Exception
Exceptionpublic org.slf4j.Logger getMockLogger()
throws Exception
Exceptionpublic MockingComponentManager getComponentManager() throws Exception
getComponentManager in class AbstractMockingTestCaseExceptionCopyright © 2004–2014 XWiki. All rights reserved.