use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class CustomContainerWebSocketsApplicationTests method reverseEndpoint.
@Test
public void reverseEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class).properties("websocket.uri:ws://localhost:" + PORT + "/ws/reverse").run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload;
context.close();
assertThat(count).isEqualTo(0);
assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class SampleAtmosphereApplicationTests method chatEndpoint.
@Test
public void chatEndpoint() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class).properties("websocket.uri:ws://localhost:" + this.port + "/chat/websocket").run("--spring.main.web_environment=false");
long count = context.getBean(ClientConfiguration.class).latch.getCount();
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload;
context.close();
assertThat(count).isEqualTo(0L);
assertThat(messagePayloadReference.get()).contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class SampleSessionRedisApplicationTests method sessionExpiry.
@Test
public void sessionExpiry() throws Exception {
String port = null;
try {
ConfigurableApplicationContext context = new SpringApplicationBuilder().sources(SampleSessionRedisApplication.class).properties("server.port:0").initializers(new ServerPortInfoApplicationContextInitializer()).run();
port = context.getEnvironment().getProperty("local.server.port");
} catch (RuntimeException ex) {
if (!redisServerRunning(ex)) {
return;
}
throw ex;
}
URI uri = URI.create("http://localhost:" + port + "/");
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.getForEntity(uri, String.class);
String uuid1 = response.getBody();
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("Cookie", response.getHeaders().getFirst("Set-Cookie"));
RequestEntity<Void> request = new RequestEntity<>(requestHeaders, HttpMethod.GET, uri);
String uuid2 = restTemplate.exchange(request, String.class).getBody();
assertThat(uuid1).isEqualTo(uuid2);
Thread.sleep(5000);
String uuid3 = restTemplate.exchange(request, String.class).getBody();
assertThat(uuid2).isNotEqualTo(uuid3);
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class SampleElasticsearchApplicationTests method testDefaultSettings.
@Test
public void testDefaultSettings() throws Exception {
new SpringApplicationBuilder(SampleElasticsearchApplication.class).run();
String output = this.outputCapture.toString();
assertThat(output).contains("firstName='Alice', lastName='Smith'");
}
use of org.springframework.boot.builder.SpringApplicationBuilder in project spring-boot by spring-projects.
the class ShutdownParentEndpointTests method shutdownParent.
@Test
public void shutdownParent() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).child(Config.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();
}
Aggregations