Example usage for org.springframework.context ConfigurableApplicationContext close

List of usage examples for org.springframework.context ConfigurableApplicationContext close

Introduction

In this page you can find the example usage for org.springframework.context ConfigurableApplicationContext close.

Prototype

@Override
void close();

Source Link

Document

Close this application context, releasing all resources and locks that the implementation might hold.

Usage

From source file:sample.atmosphere.SampleAtmosphereApplicationTests.java

@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, equalTo(0L));/* w w  w  .j av  a  2  s  . c o  m*/
    assertThat(messagePayloadReference.get(),
            containsString("{\"message\":\"test\",\"author\":\"test\",\"time\":"));
}

From source file:samples.websocket.jetty93.echo.CustomContainerWebSocketsApplicationTests.java

@Test
public void echoEndpoint() throws Exception {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class)
                    .properties("websocket.uri:ws://localhost:" + PORT + "/ws/echo/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(0);/*w  w  w . j ava2 s. co m*/
    assertThat(messagePayloadReference.get()).isEqualTo("Did you say \"Hello world!\"?");
}

From source file:samples.websocket.jetty93.echo.CustomContainerWebSocketsApplicationTests.java

@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);/*www.  j  a va  2 s. co m*/
    assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
}

From source file:samples.websocket.jetty93.SampleWebSocketsApplicationTests.java

@Test
public void echoEndpoint() throws Exception {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class)
                    .properties("websocket.uri:ws://localhost:" + this.port + "/echo/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(0);//from w w w  .  j a  v a 2s  .com
    assertThat(messagePayloadReference.get()).isEqualTo("Did you say \"Hello world!\"?");
}

From source file:samples.websocket.jetty93.SampleWebSocketsApplicationTests.java

@Test
public void reverseEndpoint() throws Exception {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class)
                    .properties("websocket.uri:ws://localhost:" + this.port + "/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);/*  w  w  w.ja  va  2 s  .c o  m*/
    assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
}