org.springframework.test.context

Interface ContextLoader

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      ApplicationContext loadContext(java.lang.String... locations)
      Loads a new context based on the supplied locations, configures the context, and finally returns the context in fully refreshed state.
      java.lang.String[] processLocations(java.lang.Class<?> clazz, java.lang.String... locations)
      Processes application context resource locations for a specified class.
    • Method Detail

      • processLocations

        java.lang.String[] processLocations(java.lang.Class<?> clazz,
                                            java.lang.String... locations)
        Processes application context resource locations for a specified class.

        Concrete implementations may choose to modify the supplied locations, generate new locations, or simply return the supplied locations unchanged.

        Parameters:
        clazz - the class with which the locations are associated: used to determine how to process the supplied locations
        locations - the unmodified locations to use for loading the application context (can be null or empty)
        Returns:
        an array of application context resource locations
      • loadContext

        ApplicationContext loadContext(java.lang.String... locations)
                                throws java.lang.Exception
        Loads a new context based on the supplied locations, configures the context, and finally returns the context in fully refreshed state.

        Configuration locations are generally considered to be classpath resources by default.

        Concrete implementations should register annotation configuration processors with bean factories of application contexts loaded by this ContextLoader. Beans will therefore automatically be candidates for annotation-based dependency injection using @Autowired, @Resource, and @Inject.

        Any ApplicationContext loaded by a ContextLoader must register a JVM shutdown hook for itself. Unless the context gets closed early, all context instances will be automatically closed on JVM shutdown. This allows for freeing external resources held by beans within the context, e.g. temporary files.

        Parameters:
        locations - the resource locations to use to load the application context
        Returns:
        a new application context
        Throws:
        java.lang.Exception - if context loading failed