Package com.foreach.across.test.support
Class AbstractViewElementTemplateTest
java.lang.Object
com.foreach.across.test.support.AbstractViewElementTemplateTest
@DirtiesContext
@WebAppConfiguration("classpath:")
@SpringJUnitConfig(classes=Config.class)
public abstract class AbstractViewElementTemplateTest
extends Object
Base integration test class for testing
ViewElement
rendering using Thymeleaf. This bootstraps an AcrossContext
with web support and the WebTestModule
enabled.
Will generate the output by running through the entire view resolving/Thymeleaf template stack and allows xml assertion to be used on the generated result, thus ignoring whitespace and attribute ordering.
See the renderAndExpect(Object, java.lang.String)
method.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<String>
Override this method to define the named entities that can be referenced in the xml.void
initMvc()
render
(ViewElement viewElement) render
(ViewElement viewElement, RenderViewElementController.Callback callback) void
renderAndExpect
(Object viewElement, RenderViewElementController.Callback callback, String expectedContent) Renders a singleViewElement
by dispatching it to the render controller.void
renderAndExpect
(Object viewElement, String expectedContent) Renders a singleViewElement
by dispatching it to the render controller.protected void
Set the callback method to be called before rendering the view element.protected void
setTemplate
(String template) Set a custom Thymeleaf template that should be used for rendering.
-
Field Details
-
CUSTOM_TEMPLATE
Constants pointing to a custom template in across test library, along with the expected output if the template is being used.- See Also:
-
CUSTOM_TEMPLATE_OUTPUT
- See Also:
-
-
Constructor Details
-
AbstractViewElementTemplateTest
public AbstractViewElementTemplateTest()
-
-
Method Details
-
initMvc
@BeforeEach public void initMvc() -
setCallback
Set the callback method to be called before rendering the view element. If set this way, the callback will be used for every test method. See
renderAndExpect(Object, RenderViewElementController.Callback, String)
to execute a callback a single time only.Set to
null
to remove the callback.- Parameters:
callback
- to be executed before rendering
-
setTemplate
Set a custom Thymeleaf template that should be used for rendering.- Parameters:
template
- to use
-
renderAndExpect
Renders a singleViewElement
by dispatching it to the render controller. Verifies the generated content by using xml comparison.- Parameters:
viewElement
- element to renderexpectedContent
- xml body that should be generated
-
renderAndExpect
public void renderAndExpect(Object viewElement, RenderViewElementController.Callback callback, String expectedContent) Renders a singleViewElement
by dispatching it to the render controller. Verifies the generated content by using xml comparison.- Parameters:
viewElement
- element to rendercallback
- to be executed before renderingexpectedContent
- xml body that should be generated
-
render
- Returns:
- output that was rendered
-
render
- Returns:
- output that was rendered
-
allowedXmlEntities
Override this method to define the named entities that can be referenced in the xml.
-