Search in sources :

Example 1 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.

the class ServerPropertiesTests method testServerHeader.

@Test
public void testServerHeader() throws Exception {
    RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
    binder.bind(new MutablePropertyValues(Collections.singletonMap("server.server-header", "Custom Server")));
    assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server");
}
Also used : RelaxedDataBinder(org.springframework.boot.bind.RelaxedDataBinder) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 2 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.

the class ServerPropertiesTests method testServletPathAsPrefix.

@Test
public void testServletPathAsPrefix() throws Exception {
    RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
    binder.bind(new MutablePropertyValues(Collections.singletonMap("server.servlet.path", "/foo")));
    assertThat(binder.getBindingResult().hasErrors()).isFalse();
    assertThat(this.properties.getServlet().getServletMapping()).isEqualTo("/foo/*");
    assertThat(this.properties.getServlet().getServletPrefix()).isEqualTo("/foo");
}
Also used : RelaxedDataBinder(org.springframework.boot.bind.RelaxedDataBinder) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 3 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.

the class ServerPropertiesTests method testSlashOfContextPathIsDefaultValue.

@Test
public void testSlashOfContextPathIsDefaultValue() {
    new RelaxedDataBinder(this.properties, "server").bind(new MutablePropertyValues(Collections.singletonMap("server.servlet.contextPath", "/")));
    assertThat(this.properties.getServlet().getContextPath()).isEqualTo("");
}
Also used : RelaxedDataBinder(org.springframework.boot.bind.RelaxedDataBinder) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) Test(org.junit.Test)

Example 4 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.

the class EndpointMBeanExporterTests method testRegistrationWithDifferentDomain.

@Test
public void testRegistrationWithDifferentDomain() throws Exception {
    this.context = new GenericApplicationContext();
    this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class, null, new MutablePropertyValues(Collections.singletonMap("domain", "test-domain"))));
    this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class));
    this.context.refresh();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer().getMBeanInfo(getObjectName("test-domain", "endpoint1", false, this.context))).isNotNull();
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) MBeanExporter(org.springframework.jmx.export.MBeanExporter) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Test(org.junit.Test)

Example 5 with MutablePropertyValues

use of org.springframework.beans.MutablePropertyValues in project spring-boot by spring-projects.

the class EndpointMBeanExporterTests method testSkipRegistrationOfDisabledEndpoint.

@Test
public void testSkipRegistrationOfDisabledEndpoint() throws Exception {
    this.context = new GenericApplicationContext();
    this.context.registerBeanDefinition("endpointMbeanExporter", new RootBeanDefinition(EndpointMBeanExporter.class));
    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.add("enabled", Boolean.FALSE);
    this.context.registerBeanDefinition("endpoint1", new RootBeanDefinition(TestEndpoint.class, null, mpv));
    this.context.refresh();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer().isRegistered(getObjectName("endpoint1", this.context))).isFalse();
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) MutablePropertyValues(org.springframework.beans.MutablePropertyValues) MBeanExporter(org.springframework.jmx.export.MBeanExporter) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Test(org.junit.Test)

Aggregations

MutablePropertyValues (org.springframework.beans.MutablePropertyValues)383 Test (org.junit.jupiter.api.Test)216 TestBean (org.springframework.beans.testfixture.beans.TestBean)96 Test (org.junit.Test)92 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)91 DerivedTestBean (org.springframework.beans.testfixture.beans.DerivedTestBean)77 IndexedTestBean (org.springframework.beans.testfixture.beans.IndexedTestBean)73 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)68 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)54 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)33 PropertyValue (org.springframework.beans.PropertyValue)31 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)27 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)26 PropertyEditorSupport (java.beans.PropertyEditorSupport)23 NestedTestBean (org.springframework.beans.testfixture.beans.NestedTestBean)21 BeanWrapper (org.springframework.beans.BeanWrapper)17 ITestBean (org.springframework.tests.sample.beans.ITestBean)15 TestBean (org.springframework.tests.sample.beans.TestBean)15 HashMap (java.util.HashMap)14 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)14