Package com.vaadin.testbench.uiunittest
Class UIUnitTest
java.lang.Object
com.vaadin.testbench.uiunittest.AbstractUIUnitTest
com.vaadin.testbench.uiunittest.UIUnitTest
Base class for unit testing complex Vaadin Components and UIs with vanilla
Vaadin applications without specific support for CDI or Spring servlet.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.testbench.uiunittest.AbstractUIUnitTest
AbstractUIUnitTest.QueryResult<T extends com.vaadin.server.ClientConnector> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MockVaadinServiceGet the mock VaadinService or create a new one if it doesn't exist.protected MockHttpSessionGet the mock HTTP session or create a new one if it doesn't exist.protected com.vaadin.server.VaadinServletRequestCreate a VaadinServletRequest for the mocked HTTP session and service.protected MockVaadinSessionGet the mock VaadinSession or create a new one if it doesn't exist.com.vaadin.ui.UICreate mocked Vaadin environment with blank UI without Atmosphere support.voidmockVaadin(com.vaadin.ui.UI ui) Create mocked Vaadin environment with given UI without Atmosphere support.voidtearDown()Do clean-up of the mocked Vaadin created with mockVaadin methods.
-
Field Details
-
mockId
-
-
Constructor Details
-
UIUnitTest
public UIUnitTest()
-
-
Method Details
-
mockVaadin
public com.vaadin.ui.UI mockVaadin() throws com.vaadin.server.ServiceExceptionDescription copied from class:AbstractUIUnitTestCreate 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:
mockVaadinin classAbstractUIUnitTest- 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:AbstractUIUnitTestCreate 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:
mockVaadinin classAbstractUIUnitTest- Parameters:
ui- UI instance- Throws:
com.vaadin.server.ServiceException- See Also:
-
tearDown
public void tearDown()Description copied from class:AbstractUIUnitTestDo clean-up of the mocked Vaadin created with mockVaadin methods. This may be necessary especially if custom UI have side effects.- Specified by:
tearDownin classAbstractUIUnitTest- See Also:
-
getService
Get the mock VaadinService or create a new one if it doesn't exist.- Returns:
- the MockVaadinService
- Throws:
com.vaadin.server.ServiceException
-
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
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.ServiceExceptionCreate 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
-