Change getEnvironment() to return null by default
Update the `SpringBootContextLoader.getEnvironment()` method so that it returns `null` rather than a new `StandardEnvironment`. Closes gh-29405
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -61,7 +62,7 @@ class SpringBootTestWithActiveProfilesAndEnvironmentPropertyTests {
|
||||
|
||||
@Override
|
||||
protected ConfigurableEnvironment getEnvironment() {
|
||||
ConfigurableEnvironment environment = super.getEnvironment();
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
MutablePropertySources sources = environment.getPropertySources();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("spring.profiles.active", "local");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,7 +64,7 @@ class SpringBootTestWithActiveProfilesAndSystemEnvironmentPropertyTests {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ConfigurableEnvironment getEnvironment() {
|
||||
ConfigurableEnvironment environment = super.getEnvironment();
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
MutablePropertySources sources = environment.getPropertySources();
|
||||
PropertySource<?> source = sources.get(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
|
||||
Map<String, Object> map = new LinkedHashMap<>((Map<String, Object>) source.getSource());
|
||||
|
||||
Reference in New Issue
Block a user