Class LoadableComponent<T extends LoadableComponent<T>>

  • Type Parameters:
    T - The type to be returned (normally the subclass' type)
    Direct Known Subclasses:
    SlowLoadableComponent

    public abstract class LoadableComponent<T extends LoadableComponent<T>>
    extends java.lang.Object
    Represents any abstraction of something that can be loaded. This may be an entire web page, or simply a component within that page (such as a login box or menu) or even a service. The expected usage is:
     new HypotheticalComponent().get();
     

    After the get() method is called, the component will be loaded and ready for use. This is verified using Assert.assertTrue so expect to catch an Error rather than an Exception when errors occur. *

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      T get()
      Ensure that the component is currently loaded.
      protected abstract void isLoaded()
      Determine whether or not the component is loaded.
      protected abstract void load()
      When this method returns, the component modeled by the subclass should be fully loaded.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LoadableComponent

        public LoadableComponent()
    • Method Detail

      • get

        public T get()
        Ensure that the component is currently loaded.
        Returns:
        The component.
        Throws:
        java.lang.Error - when the component cannot be loaded.
      • load

        protected abstract void load()
        When this method returns, the component modeled by the subclass should be fully loaded. This subclass is expected to navigate to an appropriate page should this be necessary.
      • isLoaded

        protected abstract void isLoaded()
                                  throws java.lang.Error
        Determine whether or not the component is loaded. When the component is loaded, this method will return, but when it is not loaded, an Error should be thrown. This also allows for complex checking and error reporting when loading a page, which in turn supports better error reporting when a page fails to load.

        This behaviour makes it readily visible when a page has not been loaded successfully, and because an error and not an exception is thrown tests should fail as expected. By using Error, we also allow the use of junit's "Assert.assert*" methods

        Throws:
        java.lang.Error - when the page is not loaded.