Verify meta @TestPropertySource overrides meta-meta declaration
This commit introduces tests which verify that properties configured via @TestPropertySource used as a meta-annotation override those configured via @TestPropertySource used as a meta-meta-annotation. See gh-23320
This commit is contained in:
parent
1954861844
commit
a37eaf75c4
|
|
@ -35,7 +35,7 @@ public class LocalInlinedPropertyAndMetaInlinedPropertyTests extends AbstractRep
|
|||
@Test
|
||||
public void test() {
|
||||
assertEnvironmentValue("key1", "local");
|
||||
assertEnvironmentValue("meta", "inlined");
|
||||
assertEnvironmentValue("enigma", "meta");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
@MetaComposedTestProperty
|
||||
public class LocalInlinedPropertyAndMetaMetaInlinedPropertyTests extends AbstractRepeatableTestPropertySourceTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertEnvironmentValue("key1", "local");
|
||||
assertEnvironmentValue("enigma", "meta meta");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -28,13 +28,13 @@ import org.springframework.test.context.TestPropertySource;
|
|||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
@TestPropertySource(properties = "meta = local override")
|
||||
@TestPropertySource(properties = "enigma = local override")
|
||||
@MetaInlinedTestProperty
|
||||
public class LocalInlinedPropertyOverridesMetaInlinedPropertyTests extends AbstractRepeatableTestPropertySourceTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertEnvironmentValue("meta", "local override");
|
||||
assertEnvironmentValue("enigma", "local override");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 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;
|
||||
import org.springframework.test.context.env.repeatable.MetaComposedTestProperty.MetaMetaInlinedTestProperty;
|
||||
|
||||
/**
|
||||
* Composed annotation that declares a property via
|
||||
* {@link TestPropertySource @TestPropertySource} used as a meta-meta-annotation.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@MetaMetaInlinedTestProperty
|
||||
@interface MetaComposedTestProperty {
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@TestPropertySource(properties = "enigma = meta meta")
|
||||
@interface MetaMetaInlinedTestProperty {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 Sam Brannen
|
||||
* @since 5.2
|
||||
*/
|
||||
@MetaInlinedTestProperty
|
||||
@MetaComposedTestProperty
|
||||
public class MetaInlinedPropertyOverridesMetaMetaInlinedPropertyTests extends AbstractRepeatableTestPropertySourceTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertEnvironmentValue("enigma", "meta");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -32,6 +32,6 @@ import org.springframework.test.context.TestPropertySource;
|
|||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@TestPropertySource(properties = "meta = inlined")
|
||||
@TestPropertySource(properties = "enigma = meta")
|
||||
@interface MetaInlinedTestProperty {
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue