org.xwiki.test
Class TestComponentManager

java.lang.Object
  extended by org.xwiki.component.embed.EmbeddableComponentManager
      extended by org.xwiki.test.TestComponentManager
All Implemented Interfaces:
org.xwiki.component.manager.ComponentManager, org.xwiki.component.phase.Disposable
Direct Known Subclasses:
ComponentManagerRule, MockitoComponentManager

public class TestComponentManager
extends EmbeddableComponentManager

Initialize a Component Manager and uses the AllComponents and ComponentList annotations to decide what components to discover and register.

Also offers helper APIs to register components and in-memory configuration sources.

Since:
5.1RC1
Version:
$Id: 9619d3baf5bae4540c098f24c1f29de57cda3dc3 $

Field Summary
protected  org.xwiki.test.internal.ComponentRegistrator componentRegistrator
          Used to register components.
 
Constructor Summary
TestComponentManager()
           
 
Method Summary
 void initializeTest(Object testClassInstance)
          Initialize the test component manager by registering components based on the presence of AllComponents and ComponentList annotations.
 void registerComponent(Class<?> testClass)
          Register components associated to the provided class.
 void registerComponent(Type roleType, Object instance)
          Registers a component (with a default role hint).
 void registerComponent(Type roleType, String roleHint, Object instance)
          Registers a component.
 org.xwiki.configuration.internal.MemoryConfigurationSource registerMemoryConfigurationSource()
          Register in-memory data source for the default and "xwikiproperties" configuration sources.
 void shutdownTest()
          Cleans up the test component manager by disposing components registered in it.
 
Methods inherited from class org.xwiki.component.embed.EmbeddableComponentManager
createLogger, dispose, getComponentDescriptor, getComponentDescriptorList, getComponentDescriptorList, getComponentEventManager, getComponentInstance, getInstance, getInstance, getInstanceList, getInstanceMap, getParent, hasComponent, hasComponent, initialize, registerComponent, registerComponent, release, setComponentEventManager, setParent, unregisterComponent, unregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

componentRegistrator

protected org.xwiki.test.internal.ComponentRegistrator componentRegistrator
Used to register components.

Constructor Detail

TestComponentManager

public TestComponentManager()
Method Detail

registerMemoryConfigurationSource

public org.xwiki.configuration.internal.MemoryConfigurationSource registerMemoryConfigurationSource()
                                                                                             throws Exception
Register in-memory data source for the default and "xwikiproperties" configuration sources.

Returns:
the in-memory configuration source used for both default and "xwikiproperties" component hints
Throws:
Exception - in case the registration fails

registerComponent

public void registerComponent(Type roleType,
                              String roleHint,
                              Object instance)
                       throws Exception
Registers a component.

Parameters:
roleType - the type of the component role to register
roleHint - the role hint of the component to register
instance - the instance to register
Throws:
Exception - in case of an error during registration

registerComponent

public void registerComponent(Type roleType,
                              Object instance)
                       throws Exception
Registers a component (with a default role hint).

Parameters:
roleType - the type of the component role to register
instance - the instance to register
Throws:
Exception - in case of an error during registration

registerComponent

public void registerComponent(Class<?> testClass)
                       throws Exception
Register components associated to the provided class.

Parameters:
testClass - the class containing the annotations
Throws:
Exception - in case of an error during registration
Since:
5.2M1

initializeTest

public void initializeTest(Object testClassInstance)
                    throws Exception
Initialize the test component manager by registering components based on the presence of AllComponents and ComponentList annotations. Also calls methods annotated with BeforeComponent.

Parameters:
testClassInstance - the test instance on which the annotations are present
Throws:
Exception - if an error happens during initialization

shutdownTest

public void shutdownTest()
                  throws Exception
Cleans up the test component manager by disposing components registered in it.

Throws:
Exception - if an error happens during clean up


Copyright © 2004–2014 XWiki. All rights reserved.