Search in sources :

Example 1 with DynamicPropertyRegistry

use of org.springframework.test.context.DynamicPropertyRegistry in project spring-framework by bluecrow1986.

the class DynamicPropertiesContextCustomizer method buildDynamicPropertiesMap.

private Map<String, Supplier<Object>> buildDynamicPropertiesMap() {
    Map<String, Supplier<Object>> map = new LinkedHashMap<>();
    DynamicPropertyRegistry dynamicPropertyRegistry = (name, valueSupplier) -> {
        Assert.hasText(name, "'name' must not be null or blank");
        Assert.notNull(valueSupplier, "'valueSupplier' must not be null");
        map.put(name, valueSupplier);
    };
    this.methods.forEach(method -> {
        ReflectionUtils.makeAccessible(method);
        ReflectionUtils.invokeMethod(method, null, dynamicPropertyRegistry);
    });
    return Collections.unmodifiableMap(map);
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) DynamicPropertySource(org.springframework.test.context.DynamicPropertySource) Set(java.util.Set) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) MergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration) ReflectionUtils(org.springframework.util.ReflectionUtils) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Method(java.lang.reflect.Method) Collections(java.util.Collections) Assert(org.springframework.util.Assert) Supplier(java.util.function.Supplier) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with DynamicPropertyRegistry

use of org.springframework.test.context.DynamicPropertyRegistry in project spring-framework by spring-projects.

the class DynamicPropertiesContextCustomizer method buildDynamicPropertiesMap.

private Map<String, Supplier<Object>> buildDynamicPropertiesMap() {
    Map<String, Supplier<Object>> map = new LinkedHashMap<>();
    DynamicPropertyRegistry dynamicPropertyRegistry = (name, valueSupplier) -> {
        Assert.hasText(name, "'name' must not be null or blank");
        Assert.notNull(valueSupplier, "'valueSupplier' must not be null");
        map.put(name, valueSupplier);
    };
    this.methods.forEach(method -> {
        ReflectionUtils.makeAccessible(method);
        ReflectionUtils.invokeMethod(method, null, dynamicPropertyRegistry);
    });
    return Collections.unmodifiableMap(map);
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) DynamicPropertySource(org.springframework.test.context.DynamicPropertySource) Set(java.util.Set) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) MergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration) ReflectionUtils(org.springframework.util.ReflectionUtils) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Method(java.lang.reflect.Method) Collections(java.util.Collections) Assert(org.springframework.util.Assert) Supplier(java.util.function.Supplier) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with DynamicPropertyRegistry

use of org.springframework.test.context.DynamicPropertyRegistry in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.

the class DynamicPropertiesContextCustomizer method buildDynamicPropertiesMap.

private Map<String, Supplier<Object>> buildDynamicPropertiesMap() {
    Map<String, Supplier<Object>> map = new LinkedHashMap<>();
    DynamicPropertyRegistry dynamicPropertyRegistry = (name, valueSupplier) -> {
        Assert.hasText(name, "'name' must not be null or blank");
        Assert.notNull(valueSupplier, "'valueSupplier' must not be null");
        map.put(name, valueSupplier);
    };
    this.methods.forEach(method -> {
        ReflectionUtils.makeAccessible(method);
        ReflectionUtils.invokeMethod(method, null, dynamicPropertyRegistry);
    });
    return Collections.unmodifiableMap(map);
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) DynamicPropertySource(org.springframework.test.context.DynamicPropertySource) Set(java.util.Set) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) MergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration) ReflectionUtils(org.springframework.util.ReflectionUtils) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Method(java.lang.reflect.Method) Collections(java.util.Collections) Assert(org.springframework.util.Assert) Supplier(java.util.function.Supplier) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with DynamicPropertyRegistry

use of org.springframework.test.context.DynamicPropertyRegistry in project spring-framework-debug by Joker-5.

the class DynamicPropertiesContextCustomizer method buildDynamicPropertiesMap.

private Map<String, Supplier<Object>> buildDynamicPropertiesMap() {
    Map<String, Supplier<Object>> map = new LinkedHashMap<>();
    DynamicPropertyRegistry dynamicPropertyRegistry = (name, valueSupplier) -> {
        Assert.hasText(name, "'name' must not be null or blank");
        Assert.notNull(valueSupplier, "'valueSupplier' must not be null");
        map.put(name, valueSupplier);
    };
    this.methods.forEach(method -> {
        ReflectionUtils.makeAccessible(method);
        ReflectionUtils.invokeMethod(method, null, dynamicPropertyRegistry);
    });
    return Collections.unmodifiableMap(map);
}
Also used : ContextCustomizer(org.springframework.test.context.ContextCustomizer) DynamicPropertySource(org.springframework.test.context.DynamicPropertySource) Set(java.util.Set) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) Supplier(java.util.function.Supplier) LinkedHashMap(java.util.LinkedHashMap) MergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration) ReflectionUtils(org.springframework.util.ReflectionUtils) Modifier(java.lang.reflect.Modifier) Map(java.util.Map) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Method(java.lang.reflect.Method) Collections(java.util.Collections) Assert(org.springframework.util.Assert) Supplier(java.util.function.Supplier) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Method (java.lang.reflect.Method)4 Modifier (java.lang.reflect.Modifier)4 Collections (java.util.Collections)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Set (java.util.Set)4 Supplier (java.util.function.Supplier)4 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4 MutablePropertySources (org.springframework.core.env.MutablePropertySources)4 ContextCustomizer (org.springframework.test.context.ContextCustomizer)4 DynamicPropertyRegistry (org.springframework.test.context.DynamicPropertyRegistry)4 DynamicPropertySource (org.springframework.test.context.DynamicPropertySource)4 MergedContextConfiguration (org.springframework.test.context.MergedContextConfiguration)4 Assert (org.springframework.util.Assert)4 ReflectionUtils (org.springframework.util.ReflectionUtils)4