Class MockCompMgr

  • All Implemented Interfaces:
    ComponentManager

    public class MockCompMgr
    extends Object
    implements ComponentManager
    This is a totally fake component manager which is just going to pretend to try to find services, maybe later this could try to use the sakai mock stuff but for now it is just here to stop the CM from firing up during unit tests
    • Field Detail

      • components

        public ConcurrentHashMap<String,​Object> components
        Not really needed but this allows us to at least put fake ones into this CM for tests if we like
    • Constructor Detail

      • MockCompMgr

        public MockCompMgr​(boolean loadMocks)
        Startup the CM as a mock system for unit tests
    • Method Detail

      • close

        public void close()
        Description copied from interface: ComponentManager
        Close the component manager, shutting down any created singletons.
        Specified by:
        close in interface ComponentManager
      • hasBeenClosed

        public boolean hasBeenClosed()
        Description copied from interface: ComponentManager
        Check if the ComponentManager has already been or is in the processing of being closed.
        Specified by:
        hasBeenClosed in interface ComponentManager
        Returns:
        true if closed, false if not.
      • contains

        public boolean contains​(Class iface)
        Description copied from interface: ComponentManager
        Check if this interface Class has a registered component.
        Specified by:
        contains in interface ComponentManager
        Parameters:
        iface - The interface Class.
        Returns:
        true if this interface Class has a registered component, false if not.
      • contains

        public boolean contains​(String ifaceName)
        Description copied from interface: ComponentManager
        Check if this interface Class name has a registered component.
        Specified by:
        contains in interface ComponentManager
        Parameters:
        ifaceName - The fully qualified interface Class name.
        Returns:
        true if this interface has a registered component, false if not.
      • get

        public <T> T get​(Class<T> iface)
        Description copied from interface: ComponentManager
        Find a component that is registered to provide this interface.
        Specified by:
        get in interface ComponentManager
        Parameters:
        iface - The interface Class.
        Returns:
        a component instance, or null if not found.
      • get

        public Object get​(String ifaceName)
        Description copied from interface: ComponentManager
        Find a component that is registered to provide this interface.
        Specified by:
        get in interface ComponentManager
        Parameters:
        ifaceName - The fully qualified interface Class name.
        Returns:
        a component instance, or null if not found.
      • getRegisteredInterfaces

        public Set<String> getRegisteredInterfaces()
        Description copied from interface: ComponentManager
        Get all interfaces registered in the component manager.
        Specified by:
        getRegisteredInterfaces in interface ComponentManager
        Returns:
        A Set (String class name) of all interfaces registered in the component manager.
      • loadComponent

        public void loadComponent​(Class iface,
                                  Object component)
        Description copied from interface: ComponentManager
        Load a singleton already created component for this interface class as a singleton.
        Specified by:
        loadComponent in interface ComponentManager
        Parameters:
        iface - The interface class.
        component - The alread created component.
      • loadComponent

        public void loadComponent​(String ifaceName,
                                  Object component)
        Description copied from interface: ComponentManager
        Load a singleton already created component for this interface class as a singleton.
        Specified by:
        loadComponent in interface ComponentManager
        Parameters:
        ifaceName - The fully qualified interface Class name.
        component - The alread created component.