Search in sources :

Example 11 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 12 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 13 with SpringApplicationBuilder

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

the class SpringApplicationAdminJmxAutoConfigurationTests method registerWithSimpleWebApp.

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

Example 14 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project camel by apache.

the class Configuration method shouldOnlyCollectRoutesOnce.

@Test
public void shouldOnlyCollectRoutesOnce() {
    GenericApplicationContext parent = new GenericApplicationContext();
    parent.refresh();
    ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
    ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
    RoutesCollector collector = context.getBean(RoutesCollector.class);
    //no changes should happen here
    collector.onApplicationEvent(refreshEvent);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) RoutesCollector(org.apache.camel.spring.boot.RoutesCollector) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) ContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent) Test(org.junit.Test)

Example 15 with SpringApplicationBuilder

use of org.springframework.boot.builder.SpringApplicationBuilder in project libresonic by Libresonic.

the class Application method main.

public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    doConfigure(builder).run(args);
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder)

Aggregations

SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)36 Test (org.junit.Test)32 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 DefaultTokenServices (org.springframework.security.oauth2.provider.token.DefaultTokenServices)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 URI (java.net.URI)1 RoutesCollector (org.apache.camel.spring.boot.RoutesCollector)1 Logger (org.slf4j.Logger)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)1 Banner (org.springframework.boot.Banner)1 SpringApplication (org.springframework.boot.SpringApplication)1 JmxAutoConfiguration (org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration)1 ParentContextApplicationContextInitializer (org.springframework.boot.builder.ParentContextApplicationContextInitializer)1 ApplicationStartingEvent (org.springframework.boot.context.event.ApplicationStartingEvent)1 ServerPortInfoApplicationContextInitializer (org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer)1 AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ApplicationListener (org.springframework.context.ApplicationListener)1