Class TestComponentManagerContainer


  • public class TestComponentManagerContainer
    extends Object
    A container for a Test Component Manager that can be configured with one of more components.
    • Constructor Detail

      • TestComponentManagerContainer

        public TestComponentManagerContainer​(String configPaths,
                                             Properties props)
                                      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