Class TestPropertyValues

    • Method Detail

      • applyTo

        public void applyTo​(org.springframework.context.ConfigurableApplicationContext context)
        Add the properties from the underlying map to the environment owned by an ApplicationContext.
        Parameters:
        context - the context with an environment to modify
      • applyTo

        public void applyTo​(org.springframework.core.env.ConfigurableEnvironment environment)
        Add the properties from the underlying map to the environment. The default property source used is MapPropertySource.
        Parameters:
        environment - the environment that needs to be modified
      • applyTo

        public void applyTo​(org.springframework.core.env.ConfigurableEnvironment environment,
                            TestPropertyValues.Type type)
        Add the properties from the underlying map to the environment using the specified property source type.
        Parameters:
        environment - the environment that needs to be modified
        type - the type of PropertySource to be added. See TestPropertyValues.Type
      • applyTo

        public void applyTo​(org.springframework.core.env.ConfigurableEnvironment environment,
                            TestPropertyValues.Type type,
                            String name)
        Add the properties from the underlying map to the environment using the specified property source type and name.
        Parameters:
        environment - the environment that needs to be modified
        type - the type of PropertySource to be added. See TestPropertyValues.Type
        name - the name for the property source
      • applyToSystemProperties

        public <T> T applyToSystemProperties​(Callable<T> call)
        Add the properties to the system properties for the duration of the call, restoring previous values when the call completes.
        Type Parameters:
        T - the result type
        Parameters:
        call - the call to make
        Returns:
        the result of the call
      • of

        public static TestPropertyValues of​(String... pairs)
        Return a new TestPropertyValues with the underlying map populated with the given property pairs. Name-value pairs can be specified with colon (":") or equals ("=") separators.
        Parameters:
        pairs - the name-value pairs for properties that need to be added to the environment
        Returns:
        the new instance
      • of

        public static TestPropertyValues of​(Iterable<String> pairs)
        Return a new TestPropertyValues with the underlying map populated with the given property pairs. Name-value pairs can be specified with colon (":") or equals ("=") separators.
        Parameters:
        pairs - the name-value pairs for properties that need to be added to the environment
        Returns:
        the new instance
      • of

        public static TestPropertyValues of​(Stream<String> pairs)
        Return a new TestPropertyValues with the underlying map populated with the given property pairs. Name-value pairs can be specified with colon (":") or equals ("=") separators.
        Parameters:
        pairs - the name-value pairs for properties that need to be added to the environment
        Returns:
        the new instance