Code: Select all
myapp.prop = oldValue
< /code>
Die entsprechende Eigenschaftsklasse: < /p>
@ConfigMapping(prefix = "myapp")
public interface MyPropertiesMapping {
String prop();
}
Code: Select all
@QuarkusTest
class ConfigTest {
@ConfigProperty(name = "myapp.prop")
String property;
@Inject
MyPropertiesMapping myProperites;
@BeforeAll
static void changeProperty() {
System.setProperty("myapp.prop", "newValue");
}
@AfterAll
static void clearProperty() {
System.clearProperty("myapp.prop");
}
@Test
void testConfigProperty() {
Assertions.assertEquals("newValue", property);
}
@Test
void testConfigMapping() {
Assertions.assertEquals("oldValue", myProperites.prop());
}