org.sakaiproject.component.cover
Class TestComponentManagerContainer

java.lang.Object
  extended by org.sakaiproject.component.cover.TestComponentManagerContainer

public class TestComponentManagerContainer
extends Object

A container for a Test Component Manager that can be configured with one of more components.


Constructor Summary
TestComponentManagerContainer(String configPaths)
          create a component manager based on a list of component.xml
 
Method Summary
protected  String generateSiteId()
          Convenience method to create a somewhat unique site id for testing.
 ComponentManager getComponentManager()
          get the current component manager
 Object getService(String beanId)
          Convenience method to get a service bean from the Sakai component manager.
static Object getServiceProxy(Class clazz, InvocationHandler handler)
          Returns a dynamic proxy for a service interface.
 void loadComponent(org.springframework.context.ConfigurableApplicationContext ac, List<org.springframework.core.io.Resource> config, ClassLoader loader)
          Load the application context using a single classloader
static void setSakaiHome(String sakaiHome)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestComponentManagerContainer

public TestComponentManagerContainer(String configPaths)
                              throws IOException
create a component manager based on a list of component.xml

Parameters:
configPaths - a ';' seperated list of xml bean config files
Throws:
IOException
Method Detail

loadComponent

public void loadComponent(org.springframework.context.ConfigurableApplicationContext ac,
                          List<org.springframework.core.io.Resource> config,
                          ClassLoader loader)
Load the application context using a single classloader

Parameters:
ac - The spring application context
config - a list of configurations represented as List of resources
loader - the classloader to use

getComponentManager

public ComponentManager getComponentManager()
get the current component manager

Returns:

generateSiteId

protected String generateSiteId()
Convenience method to create a somewhat unique site id for testing. Useful in tests that need to create a site to run tests upon.

Returns:
A string suitable for using as a site id.

getServiceProxy

public static final Object getServiceProxy(Class clazz,
                                           InvocationHandler handler)
Returns a dynamic proxy for a service interface. Useful for testing with customized service implementations without needing to write custom stubs.

Parameters:
clazz - The service interface class
handler - The invocation handler that defines how the dynamic proxy should behave
Returns:
The dynamic proxy to use as a collaborator

setSakaiHome

public static void setSakaiHome(String sakaiHome)

getService

public Object getService(String beanId)
Convenience method to get a service bean from the Sakai component manager.

Parameters:
beanId - The id of the service
Returns:
The service, or null if the ID is not registered


Copyright © 2003-2012 The Sakai Foundation. All Rights Reserved.