Class SpringTestHelper


  • public class SpringTestHelper
    extends BaseTestHelper
    A facility that provides some common tasks for testing, such as creating a Spring context and manipulating files.
    Since:
    3.2-ALPHA-18
    Author:
    Fabrizio Giudici
    • Constructor Summary

      Constructors 
      Constructor Description
      SpringTestHelper​(java.lang.Object test)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.context.ApplicationContext createSpringContext​(java.lang.String... configurationFiles)
      Creates a Spring context configured with the given files.
      org.springframework.context.ApplicationContext createSpringContext​(java.util.function.Consumer<? super org.springframework.context.support.GenericApplicationContext> modifier, java.lang.String... configurationFiles)
      Creates a Spring context configured with the given files.
      org.springframework.context.ApplicationContext createSpringContext​(java.util.Map<java.lang.String,​java.lang.Object> properties, java.lang.String... configurationFiles)
      Creates a Spring context configured with the given files.
      org.springframework.context.ApplicationContext createSpringContext​(java.util.Map<java.lang.String,​java.lang.Object> properties, java.util.function.Consumer<? super org.springframework.context.support.GenericApplicationContext> modifier, java.lang.String... configurationFiles)
      Creates a Spring context configured with the given files.
      • Methods inherited from class java.lang.Object

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

      • SpringTestHelper

        public SpringTestHelper​(@Nonnull
                                java.lang.Object test)
    • Method Detail

      • createSpringContext

        @Nonnull
        public org.springframework.context.ApplicationContext createSpringContext​(@Nonnull
                                                                                  java.lang.String... configurationFiles)
        Creates a Spring context configured with the given files. A further configuration file is appended, named test-class-simple-name/TestBeans.xml.
        Parameters:
        configurationFiles - the configuration files
        Returns:
        the Spring ApplicationContext
      • createSpringContext

        @Nonnull
        public org.springframework.context.ApplicationContext createSpringContext​(@Nonnull
                                                                                  java.util.Map<java.lang.String,​java.lang.Object> properties,
                                                                                  @Nonnull
                                                                                  java.lang.String... configurationFiles)
        Creates a Spring context configured with the given files. A further configuration file is appended, named test-class-simple-name/TestBeans.xml.
        Parameters:
        properties - the properties
        configurationFiles - the configuration files
        Returns:
        the Spring ApplicationContext
      • createSpringContext

        @Nonnull
        public org.springframework.context.ApplicationContext createSpringContext​(@Nonnull
                                                                                  java.util.function.Consumer<? super org.springframework.context.support.GenericApplicationContext> modifier,
                                                                                  @Nonnull
                                                                                  java.lang.String... configurationFiles)
        Creates a Spring context configured with the given files. A further configuration file is appended, named test-class-simple-name/TestBeans.xml.
        Parameters:
        configurationFiles - the configuration files
        modifier - a processor to modify the contents of the context
        Returns:
        the Spring ApplicationContext
      • createSpringContext

        @Nonnull
        public org.springframework.context.ApplicationContext createSpringContext​(@Nonnull
                                                                                  java.util.Map<java.lang.String,​java.lang.Object> properties,
                                                                                  @Nonnull
                                                                                  java.util.function.Consumer<? super org.springframework.context.support.GenericApplicationContext> modifier,
                                                                                  @Nonnull
                                                                                  java.lang.String... configurationFiles)
        Creates a Spring context configured with the given files. A further configuration file is appended, named test-class-simple-name/TestBeans.xml.
        Parameters:
        properties - the properties
        modifier - a processor to modify the contents of the context
        configurationFiles - the configuration files
        Returns:
        the Spring ApplicationContext