Search in sources :

Example 1 with SpringApplicationBuilder

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

the class SampleCouchbaseApplicationTests method testDefaultSettings.

@Test
public void testDefaultSettings() throws Exception {
    try {
        new SpringApplicationBuilder(SampleCouchbaseApplication.class).run("--server.port=0");
    } catch (RuntimeException ex) {
        if (serverNotRunning(ex)) {
            return;
        }
    }
    String output = this.outputCapture.toString();
    assertThat(output).contains("firstName='Alice', lastName='Smith'");
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Test(org.junit.Test)

Example 2 with SpringApplicationBuilder

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

the class ResourceServerTokenServicesConfigurationTests method asymmetricJwt.

@Test
public void asymmetricJwt() {
    EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY);
    this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment).web(WebApplicationType.NONE).run();
    DefaultTokenServices services = this.context.getBean(DefaultTokenServices.class);
    assertThat(services).isNotNull();
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) DefaultTokenServices(org.springframework.security.oauth2.provider.token.DefaultTokenServices) Test(org.junit.Test)

Example 3 with SpringApplicationBuilder

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

the class ResourceServerTokenServicesConfigurationTests method useRemoteTokenServices.

@Test
public void useRemoteTokenServices() {
    EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.tokenInfoUri:http://example.com", "security.oauth2.resource.clientId=acme");
    this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment).web(WebApplicationType.NONE).run();
    RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
    assertThat(services).isNotNull();
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) RemoteTokenServices(org.springframework.security.oauth2.provider.token.RemoteTokenServices) Test(org.junit.Test)

Example 4 with SpringApplicationBuilder

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

the class ShutdownParentEndpointTests method shutdownChild.

@Test
public void shutdownChild() throws Exception {
    this.context = new SpringApplicationBuilder(Config.class).child(Empty.class).web(WebApplicationType.NONE).run();
    CountDownLatch latch = this.context.getBean(Config.class).latch;
    assertThat((String) getEndpointBean().invoke().get("message")).startsWith("Shutting down");
    assertThat(this.context.isActive()).isTrue();
    assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 5 with SpringApplicationBuilder

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

the class LoggingApplicationListenerIntegrationTests method loggingPerformedDuringChildApplicationStartIsNotLost.

@Test
public void loggingPerformedDuringChildApplicationStartIsNotLost() {
    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(this.outputCapture.toString()).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.Test)

Aggregations

SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)188 Test (org.junit.Test)90 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)66 ApplicationContext (org.springframework.context.ApplicationContext)37 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)26 InputDestination (org.springframework.cloud.stream.binder.test.InputDestination)26 Test (org.junit.jupiter.api.Test)25 OutputDestination (org.springframework.cloud.stream.binder.test.OutputDestination)24 Environment (org.springframework.cloud.config.environment.Environment)19 Before (org.junit.Before)9 SpringApplication (org.springframework.boot.SpringApplication)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 LinkedHashMap (java.util.LinkedHashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Git (org.eclipse.jgit.api.Git)4 MessageHeaders (org.springframework.messaging.MessageHeaders)4 ConsulClient (com.ecwid.consul.v1.ConsulClient)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3