List of usage examples for org.springframework.context ConfigurableApplicationContext getBean
Object getBean(String name) throws BeansException;
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();/*from w ww. j a v a 2 s. c o m*/ assertThat(count).isEqualTo(0); 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();// w ww. j ava 2s. c o m assertThat(count).isEqualTo(0); assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH"); }