26 changed files with 943 additions and 129 deletions
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context; |
||||
|
||||
import java.lang.annotation.Documented; |
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Inherited; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* {@code @TestPropertySources} is a container for one or more |
||||
* {@link TestPropertySource @TestPropertySource} declarations. |
||||
* |
||||
* <p>Note, however, that use of the {@code @TestPropertySources} container is |
||||
* completely optional since {@code @TestPropertySource} is a |
||||
* {@linkplain java.lang.annotation.Repeatable repeatable} annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
@Inherited |
||||
public @interface TestPropertySources { |
||||
|
||||
/** |
||||
* An array of one or more {@link TestPropertySource @TestPropertySource} |
||||
* declarations. |
||||
*/ |
||||
TestPropertySource[] value(); |
||||
|
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env; |
||||
|
||||
import org.junit.platform.runner.JUnitPlatform; |
||||
import org.junit.platform.suite.api.IncludeClassNamePatterns; |
||||
import org.junit.platform.suite.api.IncludeEngines; |
||||
import org.junit.platform.suite.api.SelectPackages; |
||||
import org.junit.platform.suite.api.UseTechnicalNames; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Test suite for tests that involve {@link TestPropertySource @TestPropertySource}. |
||||
* |
||||
* <p>Note that tests included in this suite will be executed at least twice if |
||||
* run from an automated build process, test runner, etc. that is not configured |
||||
* to exclude tests based on a {@code "*TestSuite.class"} pattern match. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@RunWith(JUnitPlatform.class) |
||||
@IncludeEngines("junit-vintage") |
||||
@SelectPackages("org.springframework.test.context.env") |
||||
@IncludeClassNamePatterns(".*Tests$") |
||||
@UseTechnicalNames |
||||
public class TestPropertySourceTestSuite { |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Abstract base class which declares an inlined property via |
||||
* {@link TestPropertySource @TestPropertySource}. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "key1 = parent") |
||||
abstract class AbstractClassWithTestProperty extends AbstractRepeatableTestPropertySourceTests { |
||||
} |
||||
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.runner.RunWith; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.core.env.Environment; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import org.springframework.test.context.TestPropertySource; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Abstract base class for integration tests involving |
||||
* {@link TestPropertySource @TestPropertySource} as a repeatable annotation. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@RunWith(SpringRunner.class) |
||||
@ContextConfiguration |
||||
abstract class AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Autowired |
||||
Environment env; |
||||
|
||||
|
||||
protected void assertEnvironmentValue(String key, String expected) { |
||||
assertThat(env.getProperty(key)).as("Value of key [" + key + "].").isEqualTo(expected); |
||||
} |
||||
|
||||
|
||||
@Configuration |
||||
static class Config { |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource |
||||
@TestPropertySource("local.properties") |
||||
public class DefaultPropertiesFileDetectionRepeatedTestPropertySourceTests |
||||
extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("default.value", "default file"); |
||||
assertEnvironmentValue("key1", "local file"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* <p>Same as {@link ReversedExplicitPropertiesFilesRepeatedTestPropertySourceTests}, |
||||
* but with the order of the properties files reversed. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource("first.properties") |
||||
@TestPropertySource("second.properties") |
||||
public class ExplicitPropertiesFilesRepeatedTestPropertySourceTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("alpha", "omega"); |
||||
assertEnvironmentValue("first", "1111"); |
||||
assertEnvironmentValue("second", "2222"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "key2 = local") |
||||
public class LocalInlinedPropertyAndInheritedInlinedPropertyTests extends AbstractClassWithTestProperty { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("key1", "parent"); |
||||
assertEnvironmentValue("key2", "local"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "key1 = local") |
||||
@MetaInlinedTestProperty |
||||
public class LocalInlinedPropertyAndMetaInlinedPropertyTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("key1", "local"); |
||||
assertEnvironmentValue("meta", "inlined"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
import org.springframework.test.context.env.repeatable.LocalInlinedPropertyOverridesInheritedAndMetaInlinedPropertiesTests.Key1InlinedTestProperty; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "key1 = local") |
||||
@Key1InlinedTestProperty |
||||
public class LocalInlinedPropertyOverridesInheritedAndMetaInlinedPropertiesTests extends AbstractClassWithTestProperty { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("key1", "local"); |
||||
} |
||||
|
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@TestPropertySource(properties = "key1 = meta") |
||||
@interface Key1InlinedTestProperty { |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "key1 = local value") |
||||
@TestPropertySource(properties = "second = local override") |
||||
public class LocalInlinedPropertyOverridesInheritedInlinedPropertyTests extends RepeatedTestPropertySourceTests { |
||||
|
||||
@Test |
||||
@Override |
||||
public void test() { |
||||
assertEnvironmentValue("key1", "local value"); |
||||
assertEnvironmentValue("second", "local override"); |
||||
assertEnvironmentValue("first", "repeated override"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "meta = local override") |
||||
@MetaInlinedTestProperty |
||||
public class LocalInlinedPropertyOverridesMetaInlinedPropertyTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("meta", "local override"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
import org.springframework.test.context.env.repeatable.LocalPropertiesFileAndMetaPropertiesFileTests.MetaFileTestProperty; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* <p>Verify a property value is defined both in the properties file which is declared |
||||
* via {@link MetaFileTestProperty @MetaFileTestProperty} and in the properties file |
||||
* which is declared locally via {@code @TestPropertySource}. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource("local.properties") |
||||
@MetaFileTestProperty |
||||
public class LocalPropertiesFileAndMetaPropertiesFileTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("key1", "local file"); |
||||
assertEnvironmentValue("key2", "meta file"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Composed annotation that declares a properties file via |
||||
* {@link TestPropertySource @TestPropertySource}. |
||||
*/ |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@TestPropertySource("meta.properties") |
||||
@interface MetaFileTestProperty { |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Composed annotation that declares a {@code meta} inlined property via |
||||
* {@link TestPropertySource @TestPropertySource}. |
||||
* |
||||
* @author Anatoliy Korovin |
||||
* @since 5.2 |
||||
*/ |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@TestPropertySource(properties = "meta = inlined") |
||||
@interface MetaInlinedTestProperty { |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Integration tests for {@link TestPropertySource @TestPropertySource} as a |
||||
* repeatable annotation. |
||||
* |
||||
* <p>Tests multiple local {@link TestPropertySource} declarations. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource(properties = "first = repeated") |
||||
@TestPropertySource(properties = "second = repeated") |
||||
@TestPropertySource(properties = "first = repeated override") |
||||
public class RepeatedTestPropertySourceTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("first", "repeated override"); |
||||
assertEnvironmentValue("second", "repeated"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright 2002-2019 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.test.context.env.repeatable; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import org.springframework.test.context.TestPropertySource; |
||||
|
||||
/** |
||||
* Same as {@link ExplicitPropertiesFilesRepeatedTestPropertySourceTests}, but |
||||
* with the order of the properties files reversed. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 5.2 |
||||
*/ |
||||
@TestPropertySource("second.properties") |
||||
@TestPropertySource("first.properties") |
||||
public class ReversedExplicitPropertiesFilesRepeatedTestPropertySourceTests extends AbstractRepeatableTestPropertySourceTests { |
||||
|
||||
@Test |
||||
public void test() { |
||||
assertEnvironmentValue("alpha", "beta"); |
||||
assertEnvironmentValue("first", "1111"); |
||||
assertEnvironmentValue("second", "1111"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
default.value = default file |
||||
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
alpha = beta |
||||
first = 1111 |
||||
second = 1111 |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
key1 = local file |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
key2 = meta file |
||||
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
alpha = omega |
||||
second = 2222 |
||||
Loading…
Reference in new issue