Search in sources :

Example 56 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project pinpoint by naver.

the class BasicStarter method start.

public void start(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    builder.sources(sources);
    builder.web(WebApplicationType.SERVLET);
    builder.bannerMode(Banner.Mode.OFF);
    builder.listeners(new ProfileResolveListener());
    builder.listeners(new EnvironmentLoggingListener());
    builder.listeners(new ExternalEnvironmentListener(externalPropertySourceName, externalConfigurationKey));
    builder.listeners(new PinpointSpringBanner());
    SpringApplication springApplication = builder.build();
    springApplication.run(args);
}
Also used : ExternalEnvironmentListener(com.navercorp.pinpoint.common.server.env.ExternalEnvironmentListener) SpringApplication(org.springframework.boot.SpringApplication) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) EnvironmentLoggingListener(com.navercorp.pinpoint.common.server.env.EnvironmentLoggingListener) ProfileResolveListener(com.navercorp.pinpoint.common.server.env.ProfileResolveListener) PinpointSpringBanner(com.navercorp.pinpoint.common.server.banner.PinpointSpringBanner)

Example 57 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.

the class SpringApplicationAdminJmxAutoConfigurationTests method registerWithSimpleWebApp.

@Test
void registerWithSimpleWebApp() throws Exception {
    try (ConfigurableApplicationContext context = new SpringApplicationBuilder().sources(ServletWebServerFactoryAutoConfiguration.class, DispatcherServletAutoConfiguration.class, MultipleMBeanExportersConfiguration.class, SpringApplicationAdminJmxAutoConfiguration.class).run("--" + ENABLE_ADMIN_PROP, "--server.port=0")) {
        assertThat(context).isInstanceOf(ServletWebServerApplicationContext.class);
        assertThat(this.server.getAttribute(createDefaultObjectName(), "EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
        int expected = ((ServletWebServerApplicationContext) context).getWebServer().getPort();
        String actual = getProperty(createDefaultObjectName(), "local.server.port");
        assertThat(actual).isEqualTo(String.valueOf(expected));
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ServletWebServerFactoryAutoConfiguration(org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) DispatcherServletAutoConfiguration(org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration) Test(org.junit.jupiter.api.Test)

Example 58 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.

the class LoggingApplicationListenerIntegrationTests method loggingSystemRegisteredInTheContext.

@Test
void loggingSystemRegisteredInTheContext() {
    try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class).web(WebApplicationType.NONE).run()) {
        SampleService service = context.getBean(SampleService.class);
        assertThat(service.loggingSystem).isNotNull();
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Test(org.junit.jupiter.api.Test)

Example 59 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.

the class LoggingApplicationListenerIntegrationTests method loggingPerformedDuringChildApplicationStartIsNotLost.

@Test
void loggingPerformedDuringChildApplicationStartIsNotLost(CapturedOutput output) {
    new SpringApplicationBuilder(Config.class).web(WebApplicationType.NONE).child(Config.class).web(WebApplicationType.NONE).listeners(new ApplicationListener<ApplicationStartingEvent>() {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public void onApplicationEvent(ApplicationStartingEvent event) {
            this.logger.info("Child application starting");
        }
    }).run();
    assertThat(output).contains("Child application starting");
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) ApplicationListener(org.springframework.context.ApplicationListener) ApplicationStartingEvent(org.springframework.boot.context.event.ApplicationStartingEvent) Logger(org.slf4j.Logger) Test(org.junit.jupiter.api.Test)

Example 60 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.

the class SpringApplicationTests method defaultPropertiesShouldBeMerged.

@Test
void defaultPropertiesShouldBeMerged() {
    MockEnvironment environment = new MockEnvironment();
    environment.getPropertySources().addFirst(new MapPropertySource(DefaultPropertiesPropertySource.NAME, Collections.singletonMap("bar", "foo")));
    SpringApplication application = new SpringApplicationBuilder(ExampleConfig.class).environment(environment).properties("baz=bing").web(WebApplicationType.NONE).build();
    this.context = application.run();
    assertThat(getEnvironment().getProperty("bar")).isEqualTo("foo");
    assertThat(getEnvironment().getProperty("baz")).isEqualTo("bing");
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) MapPropertySource(org.springframework.core.env.MapPropertySource) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)319 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)170 Test (org.junit.Test)156 OutputDestination (org.springframework.cloud.stream.binder.test.OutputDestination)105 InputDestination (org.springframework.cloud.stream.binder.test.InputDestination)100 Test (org.junit.jupiter.api.Test)82 ApplicationContext (org.springframework.context.ApplicationContext)55 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)26 Environment (org.springframework.cloud.config.environment.Environment)19 Before (org.junit.Before)8 SpringApplication (org.springframework.boot.SpringApplication)8 Map (java.util.Map)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 ConsulClient (com.ecwid.consul.v1.ConsulClient)6 Message (org.springframework.messaging.Message)6 MessageHeaders (org.springframework.messaging.MessageHeaders)6 GenericMessage (org.springframework.messaging.support.GenericMessage)6 ArrayList (java.util.ArrayList)5 LinkedHashMap (java.util.LinkedHashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5