org.xwiki.test
Class ComponentManagerRule

java.lang.Object
  extended by org.xwiki.component.embed.EmbeddableComponentManager
      extended by org.xwiki.test.ComponentManagerRule
All Implemented Interfaces:
org.junit.rules.MethodRule, org.xwiki.component.manager.ComponentManager
Direct Known Subclasses:
MockitoComponentManagerRule

public class ComponentManagerRule
extends EmbeddableComponentManager
implements org.junit.rules.MethodRule

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.

Note: We need to implement the deprecated MethodRule for the time being for the following reason: https://github.com/KentBeck/junit/issues/351

Since:
4.3.1
Version:
$Id: 6713c82aa33b02ab4aae4a2d9c85b81aec68f290 $

Constructor Summary
ComponentManagerRule()
           
 
Method Summary
 org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)
           
 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.
 
Methods inherited from class org.xwiki.component.embed.EmbeddableComponentManager
createLogger, 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
 

Constructor Detail

ComponentManagerRule

public ComponentManagerRule()
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

apply

public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
                                               org.junit.runners.model.FrameworkMethod method,
                                               Object target)
Specified by:
apply in interface org.junit.rules.MethodRule


Copyright © 2004-2013 XWiki. All Rights Reserved.