org.xwiki.test
Class AbstractComponentTestCase

java.lang.Object
  extended by org.xwiki.test.AbstractMockingTestCase
      extended by org.xwiki.test.AbstractComponentTestCase

public abstract class AbstractComponentTestCase
extends AbstractMockingTestCase

Tests which needs to have XWiki Components set up should extend this class which makes the Component Manager available. Use this class for JUnit 4.x tests. XWiki 2.2M1 also introduced AbstractMockingComponentTestCase which provides automatic mocking for injected component dependencies and which is thus better when writing pure unit tests, isolated from the rest.


Constructor Summary
AbstractComponentTestCase()
           
 
Method Summary
 EmbeddableComponentManager getComponentManager()
           
 MockConfigurationSource getConfigurationSource()
           
 void registerComponent(Class<?> componentClass)
           
protected  void registerComponents()
          Register custom/mock components
 void setUp()
          Tests that require fine-grained initializations can override this method and not call super.
 void tearDown()
          Clean up test states.
 
Methods inherited from class org.xwiki.test.AbstractMockingTestCase
getMockery, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent, registerMockComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractComponentTestCase

public AbstractComponentTestCase()
Method Detail

setUp

public void setUp()
           throws Exception
Tests that require fine-grained initializations can override this method and not call super.

Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Clean up test states.

Throws:
Exception

registerComponents

protected void registerComponents()
                           throws Exception
Register custom/mock components

Throws:
Exception

getComponentManager

public EmbeddableComponentManager getComponentManager()
                                               throws Exception
Specified by:
getComponentManager in class AbstractMockingTestCase
Returns:
a configured Component Manager (which uses the plexus.xml file in the test resources directory) which can then be put in the XWiki Context for testing.
Throws:
Exception

getConfigurationSource

public MockConfigurationSource getConfigurationSource()
Returns:
a modifiable mock configuration source

registerComponent

public void registerComponent(Class<?> componentClass)
                       throws Exception
Throws:
Exception
Since:
3.2M3


Copyright © 2004-2012 XWiki. All Rights Reserved.