Class UIUnitTest

java.lang.Object
com.vaadin.testbench.uiunittest.AbstractUIUnitTest
com.vaadin.testbench.uiunittest.UIUnitTest

public abstract class UIUnitTest extends AbstractUIUnitTest
Base class for unit testing complex Vaadin Components and UIs with vanilla Vaadin applications without specific support for CDI or Spring servlet.
  • Field Details

  • Constructor Details

    • UIUnitTest

      public UIUnitTest()
  • Method Details

    • mockVaadin

      public com.vaadin.ui.UI mockVaadin() throws com.vaadin.server.ServiceException
      Description copied from class: AbstractUIUnitTest
      Create mocked Vaadin environment with blank UI without Atmosphere support. This is enough for common use cases testing standalone server side components. Session is locked. UI and VaadinSession thread locals are set.
      Specified by:
      mockVaadin in class AbstractUIUnitTest
      Returns:
      Plank mock UI instance
      Throws:
      com.vaadin.server.ServiceException
      See Also:
    • mockVaadin

      public void mockVaadin(com.vaadin.ui.UI ui) throws com.vaadin.server.ServiceException
      Description copied from class: AbstractUIUnitTest
      Create mocked Vaadin environment with given UI without Atmosphere support. This is makes possible to test more complex UI logic. Session is locked. UI and VaadinSession thread locals are set.
      Specified by:
      mockVaadin in class AbstractUIUnitTest
      Parameters:
      ui - UI instance
      Throws:
      com.vaadin.server.ServiceException
      See Also:
    • tearDown

      public void tearDown()
      Description copied from class: AbstractUIUnitTest
      Do clean-up of the mocked Vaadin created with mockVaadin methods. This may be necessary especially if custom UI have side effects.
      Specified by:
      tearDown in class AbstractUIUnitTest
      See Also:
    • getService

      protected MockVaadinService getService() throws com.vaadin.server.ServiceException
      Get the mock VaadinService or create a new one if it doesn't exist.
      Returns:
      the MockVaadinService
      Throws:
      com.vaadin.server.ServiceException
    • getSession

      protected MockHttpSession getSession()
      Get the mock HTTP session or create a new one if it doesn't exist.

      This can be called before calling mockVaadin() to customize the session, for example to set attributes.

      Returns:
      the MockHttpSession
    • getVaadinSession

      protected MockVaadinSession getVaadinSession() throws com.vaadin.server.ServiceException
      Get the mock VaadinSession or create a new one if it doesn't exist.

      This can be called before calling mockVaadin() to customize the session, for example to set attributes.

      Returns:
      the MockVaadinSession
      Throws:
      com.vaadin.server.ServiceException
    • getVaadinRequest

      protected com.vaadin.server.VaadinServletRequest getVaadinRequest() throws com.vaadin.server.ServiceException
      Create a VaadinServletRequest for the mocked HTTP session and service.

      This can be used as utility to create a VaadinRequest for testing methods that need it.

      Throws:
      com.vaadin.server.ServiceException