Upgrade to spring-javaformat 0.0.11
This commit is contained in:
@@ -48,13 +48,11 @@ public class ChatService {
|
||||
@org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class,
|
||||
decoders = JacksonEncoderDecoder.class)
|
||||
public Message onMessage(Message message) throws IOException {
|
||||
this.logger.info("Author {} sent message {}", message.getAuthor(),
|
||||
message.getMessage());
|
||||
this.logger.info("Author {} sent message {}", message.getAuthor(), message.getMessage());
|
||||
return message;
|
||||
}
|
||||
|
||||
public static class JacksonEncoderDecoder
|
||||
implements Encoder<Message, String>, Decoder<String, Message> {
|
||||
public static class JacksonEncoderDecoder implements Encoder<Message, String>, Decoder<String, Message> {
|
||||
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
|
||||
@@ -48,11 +48,10 @@ public class SampleAtmosphereApplication {
|
||||
public ServletRegistrationBean atmosphereServlet() {
|
||||
// Dispatcher servlet is mapped to '/home' to allow the AtmosphereServlet
|
||||
// to be mapped to '/chat'
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(
|
||||
new AtmosphereServlet(), "/chat/*");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(new AtmosphereServlet(), "/chat/*");
|
||||
registration.addInitParameter("org.atmosphere.cpr.packages", "sample");
|
||||
registration.addInitParameter("org.atmosphere.interceptor.HeartbeatInterceptor"
|
||||
+ ".clientHeartbeatFrequencyInSeconds", "10");
|
||||
registration.addInitParameter(
|
||||
"org.atmosphere.interceptor.HeartbeatInterceptor" + ".clientHeartbeatFrequencyInSeconds", "10");
|
||||
registration.setLoadOnStartup(0);
|
||||
// Need to occur before the EmbeddedAtmosphereInitializer
|
||||
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
|
||||
@@ -46,8 +46,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = SampleAtmosphereApplication.class,
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@SpringBootTest(classes = SampleAtmosphereApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SampleAtmosphereApplicationTests {
|
||||
|
||||
@@ -58,18 +57,15 @@ public class SampleAtmosphereApplicationTests {
|
||||
|
||||
@Test
|
||||
public void chatEndpoint() throws Exception {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(
|
||||
ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class)
|
||||
.properties("websocket.uri:ws://localhost:" + this.port
|
||||
+ "/chat/websocket")
|
||||
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;
|
||||
AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload;
|
||||
context.close();
|
||||
assertThat(count).isEqualTo(0L);
|
||||
assertThat(messagePayloadReference.get())
|
||||
.contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
|
||||
assertThat(messagePayloadReference.get()).contains("{\"message\":\"test\",\"author\":\"test\",\"time\":");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -95,8 +91,7 @@ public class SampleAtmosphereApplicationTests {
|
||||
|
||||
@Bean
|
||||
public WebSocketConnectionManager wsConnectionManager() {
|
||||
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(),
|
||||
handler(), this.webSocketUri);
|
||||
WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), handler(), this.webSocketUri);
|
||||
manager.setAutoStartup(true);
|
||||
return manager;
|
||||
}
|
||||
@@ -111,17 +106,13 @@ public class SampleAtmosphereApplicationTests {
|
||||
return new TextWebSocketHandler() {
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session)
|
||||
throws Exception {
|
||||
session.sendMessage(new TextMessage(
|
||||
"{\"author\":\"test\",\"message\":\"test\"}"));
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
session.sendMessage(new TextMessage("{\"author\":\"test\",\"message\":\"test\"}"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTextMessage(WebSocketSession session,
|
||||
TextMessage message) throws Exception {
|
||||
logger.info("Received: " + message + " ("
|
||||
+ ClientConfiguration.this.latch.getCount() + ")");
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||
logger.info("Received: " + message + " (" + ClientConfiguration.this.latch.getCount() + ")");
|
||||
session.close();
|
||||
ClientConfiguration.this.messagePayload.set(message.getPayload());
|
||||
ClientConfiguration.this.latch.countDown();
|
||||
|
||||
Reference in New Issue
Block a user