Use AssertJ in spring-boot-samples
See gh-5083
This commit is contained in:
@@ -24,7 +24,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import samples.websocket.tomcat.client.GreetingService;
|
||||
import samples.websocket.tomcat.client.SimpleClientWebSocketHandler;
|
||||
import samples.websocket.tomcat.client.SimpleGreetingService;
|
||||
@@ -34,6 +33,7 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -42,7 +42,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.socket.client.WebSocketConnectionManager;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(SampleTomcatWebSocketApplication.class)
|
||||
@@ -66,8 +66,9 @@ public class SampleWebSocketsApplicationTests {
|
||||
AtomicReference<String> messagePayloadReference = context
|
||||
.getBean(ClientConfiguration.class).messagePayload;
|
||||
context.close();
|
||||
assertEquals(0, count);
|
||||
assertEquals("Did you say \"Hello world!\"?", messagePayloadReference.get());
|
||||
assertThat(count).isEqualTo(0);
|
||||
assertThat(messagePayloadReference.get())
|
||||
.isEqualTo("Did you say \"Hello world!\"?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,8 +82,8 @@ public class SampleWebSocketsApplicationTests {
|
||||
AtomicReference<String> messagePayloadReference = context
|
||||
.getBean(ClientConfiguration.class).messagePayload;
|
||||
context.close();
|
||||
assertEquals(0, count);
|
||||
assertEquals("Reversed: !dlrow olleH", messagePayloadReference.get());
|
||||
assertThat(count).isEqualTo(0);
|
||||
assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import samples.websocket.tomcat.SampleTomcatWebSocketApplication;
|
||||
import samples.websocket.tomcat.client.GreetingService;
|
||||
import samples.websocket.tomcat.client.SimpleClientWebSocketHandler;
|
||||
@@ -38,6 +37,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -47,7 +47,7 @@ import org.springframework.util.SocketUtils;
|
||||
import org.springframework.web.socket.client.WebSocketConnectionManager;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration({ SampleTomcatWebSocketApplication.class,
|
||||
@@ -72,8 +72,9 @@ public class CustomContainerWebSocketsApplicationTests {
|
||||
AtomicReference<String> messagePayloadReference = context
|
||||
.getBean(ClientConfiguration.class).messagePayload;
|
||||
context.close();
|
||||
assertEquals(0, count);
|
||||
assertEquals("Did you say \"Hello world!\"?", messagePayloadReference.get());
|
||||
assertThat(count).isEqualTo(0);
|
||||
assertThat(messagePayloadReference.get())
|
||||
.isEqualTo("Did you say \"Hello world!\"?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,8 +88,8 @@ public class CustomContainerWebSocketsApplicationTests {
|
||||
AtomicReference<String> messagePayloadReference = context
|
||||
.getBean(ClientConfiguration.class).messagePayload;
|
||||
context.close();
|
||||
assertEquals(0, count);
|
||||
assertEquals("Reversed: !dlrow olleH", messagePayloadReference.get());
|
||||
assertThat(count).isEqualTo(0);
|
||||
assertThat(messagePayloadReference.get()).isEqualTo("Reversed: !dlrow olleH");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.willThrow;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -35,6 +34,6 @@ public class SnakeTimerTests {
|
||||
SnakeTimer.addSnake(snake);
|
||||
|
||||
SnakeTimer.broadcast("");
|
||||
assertThat(SnakeTimer.getSnakes().size(), is(0));
|
||||
assertThat(SnakeTimer.getSnakes()).hasSize(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user