Commit 7f9358f4 authored by Phillip Webb's avatar Phillip Webb

Use AssertJ in spring-boot-devtools

See gh-5083
parent 94677b35
...@@ -27,10 +27,7 @@ import org.springframework.boot.SpringApplication; ...@@ -27,10 +27,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link RemoteUrlPropertyExtractor}. * Tests for {@link RemoteUrlPropertyExtractor}.
...@@ -73,17 +70,17 @@ public class RemoteUrlPropertyExtractorTests { ...@@ -73,17 +70,17 @@ public class RemoteUrlPropertyExtractorTests {
@Test @Test
public void validUrl() throws Exception { public void validUrl() throws Exception {
ApplicationContext context = doTest("http://localhost:8080"); ApplicationContext context = doTest("http://localhost:8080");
assertThat(context.getEnvironment().getProperty("remoteUrl"), assertThat(context.getEnvironment().getProperty("remoteUrl"))
equalTo("http://localhost:8080")); .isEqualTo("http://localhost:8080");
assertThat(context.getEnvironment().getProperty("spring.thymeleaf.cache"), assertThat(context.getEnvironment().getProperty("spring.thymeleaf.cache"))
is(nullValue())); .isNull();
} }
@Test @Test
public void cleanValidUrl() throws Exception { public void cleanValidUrl() throws Exception {
ApplicationContext context = doTest("http://localhost:8080/"); ApplicationContext context = doTest("http://localhost:8080/");
assertThat(context.getEnvironment().getProperty("remoteUrl"), assertThat(context.getEnvironment().getProperty("remoteUrl"))
equalTo("http://localhost:8080")); .isEqualTo("http://localhost:8080");
} }
private ApplicationContext doTest(String... args) { private ApplicationContext doTest(String... args) {
......
...@@ -18,8 +18,7 @@ package org.springframework.boot.devtools.autoconfigure; ...@@ -18,8 +18,7 @@ package org.springframework.boot.devtools.autoconfigure;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.arrayContaining; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link DevToolsProperties}. * Tests for {@link DevToolsProperties}.
...@@ -34,11 +33,10 @@ public class DevToolsPropertiesTests { ...@@ -34,11 +33,10 @@ public class DevToolsPropertiesTests {
public void additionalExcludeKeepsDefaults() { public void additionalExcludeKeepsDefaults() {
DevToolsProperties.Restart restart = this.devToolsProperties.getRestart(); DevToolsProperties.Restart restart = this.devToolsProperties.getRestart();
restart.setAdditionalExclude("foo/**,bar/**"); restart.setAdditionalExclude("foo/**,bar/**");
assertThat(restart.getAllExclude(), assertThat(restart.getAllExclude()).containsOnly("META-INF/maven/**",
arrayContaining("META-INF/maven/**", "META-INF/resources/**", "META-INF/resources/**", "resources/**", "static/**", "public/**",
"resources/**", "static/**", "public/**", "templates/**", "templates/**", "**/*Test.class", "**/*Tests.class", "git.properties",
"**/*Test.class", "**/*Tests.class", "git.properties", "foo/**", "foo/**", "bar/**");
"bar/**"));
} }
@Test @Test
...@@ -46,7 +44,7 @@ public class DevToolsPropertiesTests { ...@@ -46,7 +44,7 @@ public class DevToolsPropertiesTests {
DevToolsProperties.Restart restart = this.devToolsProperties.getRestart(); DevToolsProperties.Restart restart = this.devToolsProperties.getRestart();
restart.setExclude(""); restart.setExclude("");
restart.setAdditionalExclude("foo/**,bar/**"); restart.setAdditionalExclude("foo/**,bar/**");
assertThat(restart.getAllExclude(), arrayContaining("foo/**", "bar/**")); assertThat(restart.getAllExclude()).containsOnly("foo/**", "bar/**");
} }
@Test @Test
...@@ -54,8 +52,7 @@ public class DevToolsPropertiesTests { ...@@ -54,8 +52,7 @@ public class DevToolsPropertiesTests {
DevToolsProperties.Restart restart = this.devToolsProperties.getRestart(); DevToolsProperties.Restart restart = this.devToolsProperties.getRestart();
restart.setExclude("biz/**"); restart.setExclude("biz/**");
restart.setAdditionalExclude("foo/**,bar/**"); restart.setAdditionalExclude("foo/**,bar/**");
assertThat(restart.getAllExclude(), assertThat(restart.getAllExclude()).containsOnly("biz/**", "foo/**", "bar/**");
arrayContaining("biz/**", "foo/**", "bar/**"));
} }
} }
...@@ -51,12 +51,7 @@ import org.springframework.session.ExpiringSession; ...@@ -51,12 +51,7 @@ import org.springframework.session.ExpiringSession;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
...@@ -94,7 +89,7 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -94,7 +89,7 @@ public class LocalDevToolsAutoConfigurationTests {
this.context = initializeAndRun(Config.class); this.context = initializeAndRun(Config.class);
TemplateResolver resolver = this.context.getBean(TemplateResolver.class); TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
resolver.initialize(); resolver.initialize();
assertThat(resolver.isCacheable(), equalTo(false)); assertThat(resolver.isCacheable()).isFalse();
} }
@Test @Test
...@@ -102,7 +97,7 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -102,7 +97,7 @@ public class LocalDevToolsAutoConfigurationTests {
this.context = initializeAndRun(Config.class, "--spring.thymeleaf.cache=true"); this.context = initializeAndRun(Config.class, "--spring.thymeleaf.cache=true");
TemplateResolver resolver = this.context.getBean(TemplateResolver.class); TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
resolver.initialize(); resolver.initialize();
assertThat(resolver.isCacheable(), equalTo(true)); assertThat(resolver.isCacheable()).isTrue();
} }
@Test @Test
...@@ -114,7 +109,7 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -114,7 +109,7 @@ public class LocalDevToolsAutoConfigurationTests {
this.context = initializeAndRun(Config.class); this.context = initializeAndRun(Config.class);
TemplateResolver resolver = this.context.getBean(TemplateResolver.class); TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
resolver.initialize(); resolver.initialize();
assertThat(resolver.isCacheable(), equalTo(true)); assertThat(resolver.isCacheable()).isTrue();
} }
finally { finally {
System.setProperty("user.home", userHome); System.setProperty("user.home", userHome);
...@@ -125,14 +120,14 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -125,14 +120,14 @@ public class LocalDevToolsAutoConfigurationTests {
public void resourceCachePeriodIsZero() throws Exception { public void resourceCachePeriodIsZero() throws Exception {
this.context = initializeAndRun(WebResourcesConfig.class); this.context = initializeAndRun(WebResourcesConfig.class);
ResourceProperties properties = this.context.getBean(ResourceProperties.class); ResourceProperties properties = this.context.getBean(ResourceProperties.class);
assertThat(properties.getCachePeriod(), equalTo(0)); assertThat(properties.getCachePeriod()).isEqualTo(0);
} }
@Test @Test
public void liveReloadServer() throws Exception { public void liveReloadServer() throws Exception {
this.context = initializeAndRun(Config.class); this.context = initializeAndRun(Config.class);
LiveReloadServer server = this.context.getBean(LiveReloadServer.class); LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
assertThat(server.isStarted(), equalTo(true)); assertThat(server.isStarted()).isTrue();
} }
@Test @Test
...@@ -198,7 +193,7 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -198,7 +193,7 @@ public class LocalDevToolsAutoConfigurationTests {
this.context = initializeAndRun(Config.class); this.context = initializeAndRun(Config.class);
ClassPathFileSystemWatcher watcher = this.context ClassPathFileSystemWatcher watcher = this.context
.getBean(ClassPathFileSystemWatcher.class); .getBean(ClassPathFileSystemWatcher.class);
assertThat(watcher, notNullValue()); assertThat(watcher).isNotNull();
} }
@Test @Test
...@@ -220,7 +215,7 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -220,7 +215,7 @@ public class LocalDevToolsAutoConfigurationTests {
Object watcher = ReflectionTestUtils.getField(classPathWatcher, Object watcher = ReflectionTestUtils.getField(classPathWatcher,
"fileSystemWatcher"); "fileSystemWatcher");
Object filter = ReflectionTestUtils.getField(watcher, "triggerFilter"); Object filter = ReflectionTestUtils.getField(watcher, "triggerFilter");
assertThat(filter, instanceOf(TriggerFileFilter.class)); assertThat(filter).isInstanceOf(TriggerFileFilter.class);
} }
@Test @Test
...@@ -236,9 +231,9 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -236,9 +231,9 @@ public class LocalDevToolsAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<File, Object> folders = (Map<File, Object>) ReflectionTestUtils Map<File, Object> folders = (Map<File, Object>) ReflectionTestUtils
.getField(watcher, "folders"); .getField(watcher, "folders");
assertThat(folders.size(), is(equalTo(2))); assertThat(folders).hasSize(2)
assertThat(folders, hasKey(new File("src/main/java").getAbsoluteFile())); .containsKey(new File("src/main/java").getAbsoluteFile())
assertThat(folders, hasKey(new File("src/test/java").getAbsoluteFile())); .containsKey(new File("src/test/java").getAbsoluteFile());
} }
@Test @Test
...@@ -263,14 +258,14 @@ public class LocalDevToolsAutoConfigurationTests { ...@@ -263,14 +258,14 @@ public class LocalDevToolsAutoConfigurationTests {
this.context = application.run(); this.context = application.run();
RedisTemplate<?, ?> redisTemplate = this.context.getBean("sessionRedisTemplate", RedisTemplate<?, ?> redisTemplate = this.context.getBean("sessionRedisTemplate",
RedisTemplate.class); RedisTemplate.class);
assertThat(redisTemplate.getHashKeySerializer(), assertThat(redisTemplate.getHashKeySerializer())
is(instanceOf(RestartCompatibleRedisSerializer.class))); .isInstanceOf(RestartCompatibleRedisSerializer.class);
assertThat(redisTemplate.getHashValueSerializer(), assertThat(redisTemplate.getHashValueSerializer())
is(instanceOf(RestartCompatibleRedisSerializer.class))); .isInstanceOf(RestartCompatibleRedisSerializer.class);
assertThat(redisTemplate.getKeySerializer(), assertThat(redisTemplate.getKeySerializer())
is(instanceOf(RestartCompatibleRedisSerializer.class))); .isInstanceOf(RestartCompatibleRedisSerializer.class);
assertThat(redisTemplate.getValueSerializer(), assertThat(redisTemplate.getValueSerializer())
is(instanceOf(RestartCompatibleRedisSerializer.class))); .isInstanceOf(RestartCompatibleRedisSerializer.class);
} }
private ConfigurableApplicationContext initializeAndRun(Class<?> config, private ConfigurableApplicationContext initializeAndRun(Class<?> config,
......
...@@ -47,8 +47,7 @@ import org.springframework.mock.web.MockHttpServletResponse; ...@@ -47,8 +47,7 @@ import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -204,7 +203,7 @@ public class RemoteDevToolsAutoConfigurationTests { ...@@ -204,7 +203,7 @@ public class RemoteDevToolsAutoConfigurationTests {
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret"); this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
this.response.setStatus(500); this.response.setStatus(500);
filter.doFilter(this.request, this.response, this.chain); filter.doFilter(this.request, this.response, this.chain);
assertThat(this.response.getStatus(), equalTo(200)); assertThat(this.response.getStatus()).isEqualTo(200);
} }
@Test @Test
...@@ -216,17 +215,17 @@ public class RemoteDevToolsAutoConfigurationTests { ...@@ -216,17 +215,17 @@ public class RemoteDevToolsAutoConfigurationTests {
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret"); this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
this.response.setStatus(500); this.response.setStatus(500);
filter.doFilter(this.request, this.response, this.chain); filter.doFilter(this.request, this.response, this.chain);
assertThat(this.response.getStatus(), equalTo(200)); assertThat(this.response.getStatus()).isEqualTo(200);
} }
private void assertTunnelInvoked(boolean value) { private void assertTunnelInvoked(boolean value) {
assertThat(this.context.getBean(MockHttpTunnelServer.class).invoked, assertThat(this.context.getBean(MockHttpTunnelServer.class).invoked)
equalTo(value)); .isEqualTo(value);
} }
private void assertRestartInvoked(boolean value) { private void assertRestartInvoked(boolean value) {
assertThat(this.context.getBean(MockHttpRestartServer.class).invoked, assertThat(this.context.getBean(MockHttpRestartServer.class).invoked)
equalTo(value)); .isEqualTo(value);
} }
private void loadContext(String... properties) { private void loadContext(String... properties) {
......
...@@ -23,8 +23,7 @@ import org.junit.Test; ...@@ -23,8 +23,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link TriggerFileFilter}. * Tests for {@link TriggerFileFilter}.
...@@ -49,13 +48,13 @@ public class TriggerFileFilterTests { ...@@ -49,13 +48,13 @@ public class TriggerFileFilterTests {
@Test @Test
public void acceptNameMatch() throws Exception { public void acceptNameMatch() throws Exception {
File file = this.temp.newFile("thefile.txt"); File file = this.temp.newFile("thefile.txt");
assertThat(new TriggerFileFilter("thefile.txt").accept(file), equalTo(true)); assertThat(new TriggerFileFilter("thefile.txt").accept(file)).isTrue();
} }
@Test @Test
public void doesNotAcceptNameMismatch() throws Exception { public void doesNotAcceptNameMismatch() throws Exception {
File file = this.temp.newFile("notthefile.txt"); File file = this.temp.newFile("notthefile.txt");
assertThat(new TriggerFileFilter("thefile.txt").accept(file), equalTo(false)); assertThat(new TriggerFileFilter("thefile.txt").accept(file)).isFalse();
} }
} }
...@@ -25,9 +25,7 @@ import org.junit.rules.ExpectedException; ...@@ -25,9 +25,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.boot.devtools.filewatch.ChangedFiles; import org.springframework.boot.devtools.filewatch.ChangedFiles;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ClassPathChangedEvent}. * Tests for {@link ClassPathChangedEvent}.
...@@ -53,7 +51,7 @@ public class ClassPathChangedEventTests { ...@@ -53,7 +51,7 @@ public class ClassPathChangedEventTests {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>(); Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
ClassPathChangedEvent event = new ClassPathChangedEvent(this.source, changeSet, ClassPathChangedEvent event = new ClassPathChangedEvent(this.source, changeSet,
false); false);
assertThat(event.getChangeSet(), sameInstance(changeSet)); assertThat(event.getChangeSet()).isSameAs(changeSet);
} }
@Test @Test
...@@ -61,9 +59,9 @@ public class ClassPathChangedEventTests { ...@@ -61,9 +59,9 @@ public class ClassPathChangedEventTests {
Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>(); Set<ChangedFiles> changeSet = new LinkedHashSet<ChangedFiles>();
ClassPathChangedEvent event; ClassPathChangedEvent event;
event = new ClassPathChangedEvent(this.source, changeSet, false); event = new ClassPathChangedEvent(this.source, changeSet, false);
assertThat(event.isRestartRequired(), equalTo(false)); assertThat(event.isRestartRequired()).isFalse();
event = new ClassPathChangedEvent(this.source, changeSet, true); event = new ClassPathChangedEvent(this.source, changeSet, true);
assertThat(event.isRestartRequired(), equalTo(true)); assertThat(event.isRestartRequired()).isTrue();
} }
} }
...@@ -36,8 +36,7 @@ import org.springframework.boot.devtools.filewatch.FileSystemWatcher; ...@@ -36,8 +36,7 @@ import org.springframework.boot.devtools.filewatch.FileSystemWatcher;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -116,8 +115,8 @@ public class ClassPathFileChangeListenerTests { ...@@ -116,8 +115,8 @@ public class ClassPathFileChangeListenerTests {
verify(this.eventPublisher).publishEvent(this.eventCaptor.capture()); verify(this.eventPublisher).publishEvent(this.eventCaptor.capture());
ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor ClassPathChangedEvent actualEvent = (ClassPathChangedEvent) this.eventCaptor
.getValue(); .getValue();
assertThat(actualEvent.getChangeSet(), equalTo(changeSet)); assertThat(actualEvent.getChangeSet()).isEqualTo(changeSet);
assertThat(actualEvent.isRestartRequired(), equalTo(restart)); assertThat(actualEvent.isRestartRequired()).isEqualTo(restart);
} }
} }
...@@ -40,8 +40,7 @@ import org.springframework.core.env.Environment; ...@@ -40,8 +40,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MapPropertySource;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -84,9 +83,9 @@ public class ClassPathFileSystemWatcherTests { ...@@ -84,9 +83,9 @@ public class ClassPathFileSystemWatcherTests {
FileCopyUtils.copy("file".getBytes(), classFile); FileCopyUtils.copy("file".getBytes(), classFile);
Thread.sleep(1100); Thread.sleep(1100);
List<ClassPathChangedEvent> events = context.getBean(Listener.class).getEvents(); List<ClassPathChangedEvent> events = context.getBean(Listener.class).getEvents();
assertThat(events.size(), equalTo(1)); assertThat(events.size()).isEqualTo(1);
assertThat(events.get(0).getChangeSet().iterator().next().getFiles().iterator() assertThat(events.get(0).getChangeSet().iterator().next().getFiles().iterator()
.next().getFile(), equalTo(classFile)); .next().getFile()).isEqualTo(classFile);
context.close(); context.close();
} }
......
...@@ -23,8 +23,7 @@ import org.junit.Test; ...@@ -23,8 +23,7 @@ import org.junit.Test;
import org.springframework.boot.devtools.filewatch.ChangedFile; import org.springframework.boot.devtools.filewatch.ChangedFile;
import org.springframework.boot.devtools.filewatch.ChangedFile.Type; import org.springframework.boot.devtools.filewatch.ChangedFile.Type;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link PatternClassPathRestartStrategy}. * Tests for {@link PatternClassPathRestartStrategy}.
...@@ -90,7 +89,8 @@ public class PatternClassPathRestartStrategyTests { ...@@ -90,7 +89,8 @@ public class PatternClassPathRestartStrategyTests {
private void assertRestartRequired(ClassPathRestartStrategy strategy, private void assertRestartRequired(ClassPathRestartStrategy strategy,
String relativeName, boolean expected) { String relativeName, boolean expected) {
assertThat(strategy.isRestartRequired(mockFile(relativeName)), equalTo(expected)); assertThat(strategy.isRestartRequired(mockFile(relativeName)))
.isEqualTo(expected);
} }
private ChangedFile mockFile(String relativeName) { private ChangedFile mockFile(String relativeName) {
......
...@@ -30,9 +30,7 @@ import org.junit.rules.TemporaryFolder; ...@@ -30,9 +30,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockEnvironment;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link DevToolsHomePropertiesPostProcessor}. * Tests for {@link DevToolsHomePropertiesPostProcessor}.
...@@ -63,7 +61,7 @@ public class DevToolsHomePropertiesPostProcessorTests { ...@@ -63,7 +61,7 @@ public class DevToolsHomePropertiesPostProcessorTests {
ConfigurableEnvironment environment = new MockEnvironment(); ConfigurableEnvironment environment = new MockEnvironment();
MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor(); MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor();
postProcessor.postProcessEnvironment(environment, null); postProcessor.postProcessEnvironment(environment, null);
assertThat(environment.getProperty("abc"), equalTo("def")); assertThat(environment.getProperty("abc")).isEqualTo("def");
} }
@Test @Test
...@@ -71,7 +69,7 @@ public class DevToolsHomePropertiesPostProcessorTests { ...@@ -71,7 +69,7 @@ public class DevToolsHomePropertiesPostProcessorTests {
ConfigurableEnvironment environment = new MockEnvironment(); ConfigurableEnvironment environment = new MockEnvironment();
MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor(); MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor();
postProcessor.postProcessEnvironment(environment, null); postProcessor.postProcessEnvironment(environment, null);
assertThat(environment.getProperty("abc"), nullValue()); assertThat(environment.getProperty("abc")).isNull();
} }
private class MockDevToolHomePropertiesPostProcessor private class MockDevToolHomePropertiesPostProcessor
......
...@@ -25,8 +25,7 @@ import org.junit.rules.TemporaryFolder; ...@@ -25,8 +25,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.boot.devtools.filewatch.ChangedFile.Type; import org.springframework.boot.devtools.filewatch.ChangedFile.Type;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ChangedFile}. * Tests for {@link ChangedFile}.
...@@ -66,14 +65,14 @@ public class ChangedFileTests { ...@@ -66,14 +65,14 @@ public class ChangedFileTests {
public void getFile() throws Exception { public void getFile() throws Exception {
File file = this.temp.newFile(); File file = this.temp.newFile();
ChangedFile changedFile = new ChangedFile(this.temp.newFolder(), file, Type.ADD); ChangedFile changedFile = new ChangedFile(this.temp.newFolder(), file, Type.ADD);
assertThat(changedFile.getFile(), equalTo(file)); assertThat(changedFile.getFile()).isEqualTo(file);
} }
@Test @Test
public void getType() throws Exception { public void getType() throws Exception {
ChangedFile changedFile = new ChangedFile(this.temp.newFolder(), ChangedFile changedFile = new ChangedFile(this.temp.newFolder(),
this.temp.newFile(), Type.DELETE); this.temp.newFile(), Type.DELETE);
assertThat(changedFile.getType(), equalTo(Type.DELETE)); assertThat(changedFile.getType()).isEqualTo(Type.DELETE);
} }
@Test @Test
...@@ -82,7 +81,7 @@ public class ChangedFileTests { ...@@ -82,7 +81,7 @@ public class ChangedFileTests {
File subFolder = new File(folder, "A"); File subFolder = new File(folder, "A");
File file = new File(subFolder, "B.txt"); File file = new File(subFolder, "B.txt");
ChangedFile changedFile = new ChangedFile(folder, file, Type.ADD); ChangedFile changedFile = new ChangedFile(folder, file, Type.ADD);
assertThat(changedFile.getRelativeName(), equalTo("A/B.txt")); assertThat(changedFile.getRelativeName()).isEqualTo("A/B.txt");
} }
} }
...@@ -28,9 +28,7 @@ import org.junit.rules.TemporaryFolder; ...@@ -28,9 +28,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link FileSnapshot}. * Tests for {@link FileSnapshot}.
...@@ -70,8 +68,8 @@ public class FileSnapshotTests { ...@@ -70,8 +68,8 @@ public class FileSnapshotTests {
File fileCopy = new File(file, "x").getParentFile(); File fileCopy = new File(file, "x").getParentFile();
FileSnapshot snapshot1 = new FileSnapshot(file); FileSnapshot snapshot1 = new FileSnapshot(file);
FileSnapshot snapshot2 = new FileSnapshot(fileCopy); FileSnapshot snapshot2 = new FileSnapshot(fileCopy);
assertThat(snapshot1, equalTo(snapshot2)); assertThat(snapshot1).isEqualTo(snapshot2);
assertThat(snapshot1.hashCode(), equalTo(snapshot2.hashCode())); assertThat(snapshot1.hashCode()).isEqualTo(snapshot2.hashCode());
} }
@Test @Test
...@@ -79,7 +77,7 @@ public class FileSnapshotTests { ...@@ -79,7 +77,7 @@ public class FileSnapshotTests {
File file = createNewFile("abc", MODIFIED); File file = createNewFile("abc", MODIFIED);
FileSnapshot snapshot1 = new FileSnapshot(file); FileSnapshot snapshot1 = new FileSnapshot(file);
file.delete(); file.delete();
assertThat(snapshot1, not(equalTo(new FileSnapshot(file)))); assertThat(snapshot1).isNotEqualTo(new FileSnapshot(file));
} }
@Test @Test
...@@ -87,7 +85,7 @@ public class FileSnapshotTests { ...@@ -87,7 +85,7 @@ public class FileSnapshotTests {
File file = createNewFile("abc", MODIFIED); File file = createNewFile("abc", MODIFIED);
FileSnapshot snapshot1 = new FileSnapshot(file); FileSnapshot snapshot1 = new FileSnapshot(file);
setupFile(file, "abcd", MODIFIED); setupFile(file, "abcd", MODIFIED);
assertThat(snapshot1, not(equalTo(new FileSnapshot(file)))); assertThat(snapshot1).isNotEqualTo(new FileSnapshot(file));
} }
@Test @Test
...@@ -95,7 +93,7 @@ public class FileSnapshotTests { ...@@ -95,7 +93,7 @@ public class FileSnapshotTests {
File file = createNewFile("abc", MODIFIED); File file = createNewFile("abc", MODIFIED);
FileSnapshot snapshot1 = new FileSnapshot(file); FileSnapshot snapshot1 = new FileSnapshot(file);
setupFile(file, "abc", MODIFIED + TWO_MINS); setupFile(file, "abc", MODIFIED + TWO_MINS);
assertThat(snapshot1, not(equalTo(new FileSnapshot(file)))); assertThat(snapshot1).isNotEqualTo(new FileSnapshot(file));
} }
private File createNewFile(String content, long lastModified) throws IOException { private File createNewFile(String content, long lastModified) throws IOException {
......
...@@ -22,7 +22,6 @@ import java.io.FileNotFoundException; ...@@ -22,7 +22,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
...@@ -37,11 +36,7 @@ import org.junit.rules.TemporaryFolder; ...@@ -37,11 +36,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.boot.devtools.filewatch.ChangedFile.Type; import org.springframework.boot.devtools.filewatch.ChangedFile.Type;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.contains; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -112,7 +107,7 @@ public class FileSystemWatcherTests { ...@@ -112,7 +107,7 @@ public class FileSystemWatcherTests {
@Test @Test
public void sourceFolderMustExist() throws Exception { public void sourceFolderMustExist() throws Exception {
File folder = new File("does/not/exist"); File folder = new File("does/not/exist");
assertThat(folder.exists(), is(false)); assertThat(folder.exists()).isFalse();
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage( this.thrown.expectMessage(
"Folder '" + folder + "' must exist and must be a directory"); "Folder '" + folder + "' must exist and must be a directory");
...@@ -122,7 +117,7 @@ public class FileSystemWatcherTests { ...@@ -122,7 +117,7 @@ public class FileSystemWatcherTests {
@Test @Test
public void sourceFolderMustBeADirectory() throws Exception { public void sourceFolderMustBeADirectory() throws Exception {
File folder = new File("pom.xml"); File folder = new File("pom.xml");
assertThat(folder.isFile(), is(true)); assertThat(folder.isFile()).isTrue();
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Folder 'pom.xml' must exist and must be a directory"); this.thrown.expectMessage("Folder 'pom.xml' must exist and must be a directory");
this.watcher.addSourceFolder(new File("pom.xml")); this.watcher.addSourceFolder(new File("pom.xml"));
...@@ -143,7 +138,7 @@ public class FileSystemWatcherTests { ...@@ -143,7 +138,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
ChangedFile expected = new ChangedFile(folder, file, Type.ADD); ChangedFile expected = new ChangedFile(folder, file, Type.ADD);
assertThat(changedFiles.getFiles(), contains(expected)); assertThat(changedFiles.getFiles()).contains(expected);
} }
@Test @Test
...@@ -153,7 +148,7 @@ public class FileSystemWatcherTests { ...@@ -153,7 +148,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
ChangedFile expected = new ChangedFile(folder, file, Type.ADD); ChangedFile expected = new ChangedFile(folder, file, Type.ADD);
assertThat(changedFiles.getFiles(), contains(expected)); assertThat(changedFiles.getFiles()).contains(expected);
} }
@Test @Test
...@@ -165,7 +160,7 @@ public class FileSystemWatcherTests { ...@@ -165,7 +160,7 @@ public class FileSystemWatcherTests {
Thread.sleep(200); Thread.sleep(200);
touch(new File(folder, "test2.txt")); touch(new File(folder, "test2.txt"));
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
assertThat(this.changes.size(), equalTo(2)); assertThat(this.changes.size()).isEqualTo(2);
} }
@Test @Test
...@@ -178,7 +173,7 @@ public class FileSystemWatcherTests { ...@@ -178,7 +173,7 @@ public class FileSystemWatcherTests {
} }
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
assertThat(changedFiles.getFiles().size(), equalTo(10)); assertThat(changedFiles.getFiles().size()).isEqualTo(10);
} }
@Test @Test
...@@ -191,7 +186,7 @@ public class FileSystemWatcherTests { ...@@ -191,7 +186,7 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
ChangedFile expected = new ChangedFile(folder, file, Type.ADD); ChangedFile expected = new ChangedFile(folder, file, Type.ADD);
assertThat(changedFiles.getFiles(), contains(expected)); assertThat(changedFiles.getFiles()).contains(expected);
} }
@Test @Test
...@@ -205,17 +200,15 @@ public class FileSystemWatcherTests { ...@@ -205,17 +200,15 @@ public class FileSystemWatcherTests {
File file2 = touch(new File(folder2, "test.txt")); File file2 = touch(new File(folder2, "test.txt"));
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
Set<ChangedFiles> change = getSingleOnChange(); Set<ChangedFiles> change = getSingleOnChange();
assertThat(change.size(), equalTo(2)); assertThat(change.size()).isEqualTo(2);
for (ChangedFiles changedFiles : change) { for (ChangedFiles changedFiles : change) {
if (changedFiles.getSourceFolder().equals(folder1)) { if (changedFiles.getSourceFolder().equals(folder1)) {
ChangedFile file = new ChangedFile(folder1, file1, Type.ADD); ChangedFile file = new ChangedFile(folder1, file1, Type.ADD);
assertEquals(new HashSet<ChangedFile>(Arrays.asList(file)), assertThat(changedFiles.getFiles()).containsOnly(file);
changedFiles.getFiles());
} }
else { else {
ChangedFile file = new ChangedFile(folder2, file2, Type.ADD); ChangedFile file = new ChangedFile(folder2, file2, Type.ADD);
assertEquals(new HashSet<ChangedFile>(Arrays.asList(file)), assertThat(changedFiles.getFiles()).containsOnly(file);
changedFiles.getFiles());
} }
} }
} }
...@@ -236,8 +229,8 @@ public class FileSystemWatcherTests { ...@@ -236,8 +229,8 @@ public class FileSystemWatcherTests {
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
ChangedFile expected = new ChangedFile(folder, file, Type.ADD); ChangedFile expected = new ChangedFile(folder, file, Type.ADD);
assertThat(changedFiles.getFiles(), contains(expected)); assertThat(changedFiles.getFiles()).contains(expected);
assertEquals(this.changes.get(0), listener2Changes); assertThat(listener2Changes).isEqualTo(this.changes.get(0));
} }
@Test @Test
...@@ -257,7 +250,7 @@ public class FileSystemWatcherTests { ...@@ -257,7 +250,7 @@ public class FileSystemWatcherTests {
expected.add(new ChangedFile(folder, modify, Type.MODIFY)); expected.add(new ChangedFile(folder, modify, Type.MODIFY));
expected.add(new ChangedFile(folder, delete, Type.DELETE)); expected.add(new ChangedFile(folder, delete, Type.DELETE));
expected.add(new ChangedFile(folder, add, Type.ADD)); expected.add(new ChangedFile(folder, add, Type.ADD));
assertEquals(expected, actual); assertThat(actual).isEqualTo(expected);
} }
@Test @Test
...@@ -277,14 +270,14 @@ public class FileSystemWatcherTests { ...@@ -277,14 +270,14 @@ public class FileSystemWatcherTests {
this.watcher.start(); this.watcher.start();
FileCopyUtils.copy("abc".getBytes(), file); FileCopyUtils.copy("abc".getBytes(), file);
Thread.sleep(100); Thread.sleep(100);
assertThat(this.changes.size(), equalTo(0)); assertThat(this.changes.size()).isEqualTo(0);
FileCopyUtils.copy("abc".getBytes(), trigger); FileCopyUtils.copy("abc".getBytes(), trigger);
this.watcher.stopAfter(1); this.watcher.stopAfter(1);
ChangedFiles changedFiles = getSingleChangedFiles(); ChangedFiles changedFiles = getSingleChangedFiles();
Set<ChangedFile> actual = changedFiles.getFiles(); Set<ChangedFile> actual = changedFiles.getFiles();
Set<ChangedFile> expected = new HashSet<ChangedFile>(); Set<ChangedFile> expected = new HashSet<ChangedFile>();
expected.add(new ChangedFile(folder, file, Type.MODIFY)); expected.add(new ChangedFile(folder, file, Type.MODIFY));
assertEquals(expected, actual); assertThat(actual).isEqualTo(expected);
} }
private void setupWatcher(long pollingInterval, long quietPeriod) { private void setupWatcher(long pollingInterval, long quietPeriod) {
...@@ -306,12 +299,12 @@ public class FileSystemWatcherTests { ...@@ -306,12 +299,12 @@ public class FileSystemWatcherTests {
private ChangedFiles getSingleChangedFiles() { private ChangedFiles getSingleChangedFiles() {
Set<ChangedFiles> singleChange = getSingleOnChange(); Set<ChangedFiles> singleChange = getSingleOnChange();
assertThat(singleChange.size(), equalTo(1)); assertThat(singleChange.size()).isEqualTo(1);
return singleChange.iterator().next(); return singleChange.iterator().next();
} }
private Set<ChangedFiles> getSingleOnChange() { private Set<ChangedFiles> getSingleOnChange() {
assertThat(this.changes.size(), equalTo(1)); assertThat(this.changes.size()).isEqualTo(1);
return this.changes.get(0); return this.changes.get(0);
} }
......
...@@ -28,9 +28,7 @@ import org.junit.rules.TemporaryFolder; ...@@ -28,9 +28,7 @@ import org.junit.rules.TemporaryFolder;
import org.springframework.boot.devtools.filewatch.ChangedFile.Type; import org.springframework.boot.devtools.filewatch.ChangedFile.Type;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link FolderSnapshot}. * Tests for {@link FolderSnapshot}.
...@@ -72,22 +70,22 @@ public class FolderSnapshotTests { ...@@ -72,22 +70,22 @@ public class FolderSnapshotTests {
@Test @Test
public void equalsWhenNothingHasChanged() throws Exception { public void equalsWhenNothingHasChanged() throws Exception {
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder); FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
assertThat(this.initialSnapshot, equalTo(updatedSnapshot)); assertThat(this.initialSnapshot).isEqualTo(updatedSnapshot);
assertThat(this.initialSnapshot.hashCode(), equalTo(updatedSnapshot.hashCode())); assertThat(this.initialSnapshot.hashCode()).isEqualTo(updatedSnapshot.hashCode());
} }
@Test @Test
public void notEqualsWhenAFileIsAdded() throws Exception { public void notEqualsWhenAFileIsAdded() throws Exception {
new File(new File(this.folder, "folder1"), "newfile").createNewFile(); new File(new File(this.folder, "folder1"), "newfile").createNewFile();
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder); FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
assertThat(this.initialSnapshot, not(equalTo(updatedSnapshot))); assertThat(this.initialSnapshot).isNotEqualTo(updatedSnapshot);
} }
@Test @Test
public void notEqualsWhenAFileIsDeleted() throws Exception { public void notEqualsWhenAFileIsDeleted() throws Exception {
new File(new File(this.folder, "folder1"), "file1").delete(); new File(new File(this.folder, "folder1"), "file1").delete();
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder); FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
assertThat(this.initialSnapshot, not(equalTo(updatedSnapshot))); assertThat(this.initialSnapshot).isNotEqualTo(updatedSnapshot);
} }
@Test @Test
...@@ -95,7 +93,7 @@ public class FolderSnapshotTests { ...@@ -95,7 +93,7 @@ public class FolderSnapshotTests {
File file1 = new File(new File(this.folder, "folder1"), "file1"); File file1 = new File(new File(this.folder, "folder1"), "file1");
FileCopyUtils.copy("updatedcontent".getBytes(), file1); FileCopyUtils.copy("updatedcontent".getBytes(), file1);
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder); FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
assertThat(this.initialSnapshot, not(equalTo(updatedSnapshot))); assertThat(this.initialSnapshot).isNotEqualTo(updatedSnapshot);
} }
@Test @Test
...@@ -131,10 +129,10 @@ public class FolderSnapshotTests { ...@@ -131,10 +129,10 @@ public class FolderSnapshotTests {
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder); FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
ChangedFiles changedFiles = this.initialSnapshot.getChangedFiles(updatedSnapshot, ChangedFiles changedFiles = this.initialSnapshot.getChangedFiles(updatedSnapshot,
null); null);
assertThat(changedFiles.getSourceFolder(), equalTo(this.folder)); assertThat(changedFiles.getSourceFolder()).isEqualTo(this.folder);
assertThat(getChangedFile(changedFiles, file1).getType(), equalTo(Type.MODIFY)); assertThat(getChangedFile(changedFiles, file1).getType()).isEqualTo(Type.MODIFY);
assertThat(getChangedFile(changedFiles, file2).getType(), equalTo(Type.DELETE)); assertThat(getChangedFile(changedFiles, file2).getType()).isEqualTo(Type.DELETE);
assertThat(getChangedFile(changedFiles, newFile).getType(), equalTo(Type.ADD)); assertThat(getChangedFile(changedFiles, newFile).getType()).isEqualTo(Type.ADD);
} }
private ChangedFile getChangedFile(ChangedFiles changedFiles, File file) { private ChangedFile getChangedFile(ChangedFiles changedFiles, File file) {
......
...@@ -54,7 +54,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -54,7 +54,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Simple integration tests for HTTP tunneling. * Simple integration tests for HTTP tunneling.
...@@ -74,8 +74,8 @@ public class HttpTunnelIntegrationTests { ...@@ -74,8 +74,8 @@ public class HttpTunnelIntegrationTests {
String url = "http://localhost:" + this.config.httpServerPort + "/hello"; String url = "http://localhost:" + this.config.httpServerPort + "/hello";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url,
String.class); String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertEquals("Hello World", entity.getBody()); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
@Test @Test
...@@ -83,8 +83,8 @@ public class HttpTunnelIntegrationTests { ...@@ -83,8 +83,8 @@ public class HttpTunnelIntegrationTests {
String url = "http://localhost:" + this.config.clientPort + "/hello"; String url = "http://localhost:" + this.config.clientPort + "/hello";
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url,
String.class); String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode()); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertEquals("Hello World", entity.getBody()); assertThat(entity.getBody()).isEqualTo("Hello World");
} }
@Configuration @Configuration
......
...@@ -25,8 +25,7 @@ import org.junit.Rule; ...@@ -25,8 +25,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ConnectionInputStream}. * Tests for {@link ConnectionInputStream}.
...@@ -51,7 +50,7 @@ public class ConnectionInputStreamTests { ...@@ -51,7 +50,7 @@ public class ConnectionInputStreamTests {
String data = header + "\r\n\r\n" + "content\r\n"; String data = header + "\r\n\r\n" + "content\r\n";
ConnectionInputStream inputStream = new ConnectionInputStream( ConnectionInputStream inputStream = new ConnectionInputStream(
new ByteArrayInputStream(data.getBytes())); new ByteArrayInputStream(data.getBytes()));
assertThat(inputStream.readHeader(), equalTo(header)); assertThat(inputStream.readHeader()).isEqualTo(header);
} }
@Test @Test
...@@ -62,7 +61,7 @@ public class ConnectionInputStreamTests { ...@@ -62,7 +61,7 @@ public class ConnectionInputStreamTests {
ConnectionInputStream inputStream = new ConnectionInputStream(source); ConnectionInputStream inputStream = new ConnectionInputStream(source);
byte[] buffer = new byte[bytes.length]; byte[] buffer = new byte[bytes.length];
inputStream.readFully(buffer, 0, buffer.length); inputStream.readFully(buffer, 0, buffer.length);
assertThat(buffer, equalTo(bytes)); assertThat(buffer).isEqualTo(bytes);
} }
@Test @Test
......
...@@ -22,8 +22,7 @@ import java.io.OutputStream; ...@@ -22,8 +22,7 @@ import java.io.OutputStream;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -55,7 +54,7 @@ public class ConnectionOutputStreamTests { ...@@ -55,7 +54,7 @@ public class ConnectionOutputStreamTests {
expected += "Content-Length: 2\r\n"; expected += "Content-Length: 2\r\n";
expected += "Connection: close\r\n\r\n"; expected += "Connection: close\r\n\r\n";
expected += "hi"; expected += "hi";
assertThat(out.toString(), equalTo(expected)); assertThat(out.toString()).isEqualTo(expected);
} }
@Test @Test
...@@ -67,7 +66,7 @@ public class ConnectionOutputStreamTests { ...@@ -67,7 +66,7 @@ public class ConnectionOutputStreamTests {
String expected = ""; String expected = "";
expected += "A: a\r\n"; expected += "A: a\r\n";
expected += "B: b\r\n\r\n"; expected += "B: b\r\n\r\n";
assertThat(out.toString(), equalTo(expected)); assertThat(out.toString()).isEqualTo(expected);
} }
} }
...@@ -24,8 +24,7 @@ import org.junit.Rule; ...@@ -24,8 +24,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link Frame}. * Tests for {@link Frame}.
...@@ -54,15 +53,15 @@ public class FrameTests { ...@@ -54,15 +53,15 @@ public class FrameTests {
@Test @Test
public void textPayload() throws Exception { public void textPayload() throws Exception {
Frame frame = new Frame("abc"); Frame frame = new Frame("abc");
assertThat(frame.getType(), equalTo(Frame.Type.TEXT)); assertThat(frame.getType()).isEqualTo(Frame.Type.TEXT);
assertThat(frame.getPayload(), equalTo("abc".getBytes())); assertThat(frame.getPayload()).isEqualTo("abc".getBytes());
} }
@Test @Test
public void typedPayload() throws Exception { public void typedPayload() throws Exception {
Frame frame = new Frame(Frame.Type.CLOSE); Frame frame = new Frame(Frame.Type.CLOSE);
assertThat(frame.getType(), equalTo(Frame.Type.CLOSE)); assertThat(frame.getType()).isEqualTo(Frame.Type.CLOSE);
assertThat(frame.getPayload(), equalTo(new byte[] {})); assertThat(frame.getPayload()).isEqualTo(new byte[] {});
} }
@Test @Test
...@@ -71,7 +70,7 @@ public class FrameTests { ...@@ -71,7 +70,7 @@ public class FrameTests {
Frame frame = new Frame(payload); Frame frame = new Frame(payload);
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
frame.write(bos); frame.write(bos);
assertThat(bos.toByteArray(), equalTo(new byte[] { (byte) 0x81, 0x01, 0x41 })); assertThat(bos.toByteArray()).isEqualTo(new byte[] { (byte) 0x81, 0x01, 0x41 });
} }
@Test @Test
...@@ -81,13 +80,13 @@ public class FrameTests { ...@@ -81,13 +80,13 @@ public class FrameTests {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
frame.write(bos); frame.write(bos);
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
assertThat(bytes.length, equalTo(130)); assertThat(bytes.length).isEqualTo(130);
assertThat(bytes[0], equalTo((byte) 0x81)); assertThat(bytes[0]).isEqualTo((byte) 0x81);
assertThat(bytes[1], equalTo((byte) 0x7E)); assertThat(bytes[1]).isEqualTo((byte) 0x7E);
assertThat(bytes[2], equalTo((byte) 0x00)); assertThat(bytes[2]).isEqualTo((byte) 0x00);
assertThat(bytes[3], equalTo((byte) 126)); assertThat(bytes[3]).isEqualTo((byte) 126);
assertThat(bytes[4], equalTo((byte) 0x41)); assertThat(bytes[4]).isEqualTo((byte) 0x41);
assertThat(bytes[5], equalTo((byte) 0x41)); assertThat(bytes[5]).isEqualTo((byte) 0x41);
} }
@Test @Test
...@@ -110,8 +109,8 @@ public class FrameTests { ...@@ -110,8 +109,8 @@ public class FrameTests {
public void readSmallTextFrame() throws Exception { public void readSmallTextFrame() throws Exception {
byte[] bytes = new byte[] { (byte) 0x81, (byte) 0x02, 0x41, 0x41 }; byte[] bytes = new byte[] { (byte) 0x81, (byte) 0x02, 0x41, 0x41 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.TEXT)); assertThat(frame.getType()).isEqualTo(Frame.Type.TEXT);
assertThat(frame.getPayload(), equalTo(new byte[] { 0x41, 0x41 })); assertThat(frame.getPayload()).isEqualTo(new byte[] { 0x41, 0x41 });
} }
@Test @Test
...@@ -119,8 +118,8 @@ public class FrameTests { ...@@ -119,8 +118,8 @@ public class FrameTests {
byte[] bytes = new byte[] { (byte) 0x81, (byte) 0x82, 0x0F, 0x0F, 0x0F, 0x0F, byte[] bytes = new byte[] { (byte) 0x81, (byte) 0x82, 0x0F, 0x0F, 0x0F, 0x0F,
0x4E, 0x4E }; 0x4E, 0x4E };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.TEXT)); assertThat(frame.getType()).isEqualTo(Frame.Type.TEXT);
assertThat(frame.getPayload(), equalTo(new byte[] { 0x41, 0x41 })); assertThat(frame.getPayload()).isEqualTo(new byte[] { 0x41, 0x41 });
} }
@Test @Test
...@@ -136,43 +135,43 @@ public class FrameTests { ...@@ -136,43 +135,43 @@ public class FrameTests {
bytes[6] = 0x0F; bytes[6] = 0x0F;
bytes[7] = 0x0F; bytes[7] = 0x0F;
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.TEXT)); assertThat(frame.getType()).isEqualTo(Frame.Type.TEXT);
assertThat(frame.getPayload(), equalTo(createString(126).getBytes())); assertThat(frame.getPayload()).isEqualTo(createString(126).getBytes());
} }
@Test @Test
public void readContinuation() throws Exception { public void readContinuation() throws Exception {
byte[] bytes = new byte[] { (byte) 0x80, (byte) 0x00 }; byte[] bytes = new byte[] { (byte) 0x80, (byte) 0x00 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.CONTINUATION)); assertThat(frame.getType()).isEqualTo(Frame.Type.CONTINUATION);
} }
@Test @Test
public void readBinary() throws Exception { public void readBinary() throws Exception {
byte[] bytes = new byte[] { (byte) 0x82, (byte) 0x00 }; byte[] bytes = new byte[] { (byte) 0x82, (byte) 0x00 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.BINARY)); assertThat(frame.getType()).isEqualTo(Frame.Type.BINARY);
} }
@Test @Test
public void readClose() throws Exception { public void readClose() throws Exception {
byte[] bytes = new byte[] { (byte) 0x88, (byte) 0x00 }; byte[] bytes = new byte[] { (byte) 0x88, (byte) 0x00 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.CLOSE)); assertThat(frame.getType()).isEqualTo(Frame.Type.CLOSE);
} }
@Test @Test
public void readPing() throws Exception { public void readPing() throws Exception {
byte[] bytes = new byte[] { (byte) 0x89, (byte) 0x00 }; byte[] bytes = new byte[] { (byte) 0x89, (byte) 0x00 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.PING)); assertThat(frame.getType()).isEqualTo(Frame.Type.PING);
} }
@Test @Test
public void readPong() throws Exception { public void readPong() throws Exception {
byte[] bytes = new byte[] { (byte) 0x8A, (byte) 0x00 }; byte[] bytes = new byte[] { (byte) 0x8A, (byte) 0x00 };
Frame frame = Frame.read(newConnectionInputStream(bytes)); Frame frame = Frame.read(newConnectionInputStream(bytes));
assertThat(frame.getType(), equalTo(Frame.Type.PONG)); assertThat(frame.getType()).isEqualTo(Frame.Type.PONG);
} }
private ConnectionInputStream newConnectionInputStream(byte[] bytes) { private ConnectionInputStream newConnectionInputStream(byte[] bytes) {
......
...@@ -40,10 +40,7 @@ import org.junit.Test; ...@@ -40,10 +40,7 @@ import org.junit.Test;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import static org.hamcrest.Matchers.containsString; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link LiveReloadServer}. * Tests for {@link LiveReloadServer}.
...@@ -78,7 +75,7 @@ public class LiveReloadServerTests { ...@@ -78,7 +75,7 @@ public class LiveReloadServerTests {
RestTemplate template = new RestTemplate(); RestTemplate template = new RestTemplate();
URI uri = new URI("http://localhost:" + this.port + "/livereload.js"); URI uri = new URI("http://localhost:" + this.port + "/livereload.js");
String script = template.getForObject(uri, String.class); String script = template.getForObject(uri, String.class);
assertThat(script, containsString("livereload.com/protocols/official-7")); assertThat(script).contains("livereload.com/protocols/official-7");
} }
@Test @Test
...@@ -89,9 +86,9 @@ public class LiveReloadServerTests { ...@@ -89,9 +86,9 @@ public class LiveReloadServerTests {
this.server.triggerReload(); this.server.triggerReload();
Thread.sleep(500); Thread.sleep(500);
this.server.stop(); this.server.stop();
assertThat(socket.getMessages(0), assertThat(socket.getMessages(0))
containsString("http://livereload.com/protocols/official-7")); .contains("http://livereload.com/protocols/official-7");
assertThat(socket.getMessages(1), containsString("command\":\"reload\"")); assertThat(socket.getMessages(1)).contains("command\":\"reload\"");
} }
finally { finally {
client.stop(); client.stop();
...@@ -107,7 +104,7 @@ public class LiveReloadServerTests { ...@@ -107,7 +104,7 @@ public class LiveReloadServerTests {
socket.getRemote().sendPing(NO_DATA); socket.getRemote().sendPing(NO_DATA);
Thread.sleep(200); Thread.sleep(200);
this.server.stop(); this.server.stop();
assertThat(driver.getPongCount(), equalTo(1)); assertThat(driver.getPongCount()).isEqualTo(1);
} }
finally { finally {
client.stop(); client.stop();
...@@ -125,7 +122,7 @@ public class LiveReloadServerTests { ...@@ -125,7 +122,7 @@ public class LiveReloadServerTests {
client.stop(); client.stop();
} }
awaitClosedException(); awaitClosedException();
assertThat(this.server.getClosedExceptions().size(), greaterThan(0)); assertThat(this.server.getClosedExceptions().size()).isGreaterThan(0);
} }
private void awaitClosedException() throws InterruptedException { private void awaitClosedException() throws InterruptedException {
...@@ -144,7 +141,7 @@ public class LiveReloadServerTests { ...@@ -144,7 +141,7 @@ public class LiveReloadServerTests {
Thread.sleep(200); Thread.sleep(200);
this.server.stop(); this.server.stop();
Thread.sleep(200); Thread.sleep(200);
assertThat(socket.getCloseStatus(), equalTo(1006)); assertThat(socket.getCloseStatus()).isEqualTo(1006);
} }
finally { finally {
client.stop(); client.stop();
......
...@@ -44,8 +44,7 @@ import org.springframework.http.HttpStatus; ...@@ -44,8 +44,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.mock.http.client.MockClientHttpRequest; import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ClassPathChangeUploader}. * Tests for {@link ClassPathChangeUploader}.
...@@ -117,20 +116,20 @@ public class ClassPathChangeUploaderTests { ...@@ -117,20 +116,20 @@ public class ClassPathChangeUploaderTests {
MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0); MockClientHttpRequest request = this.requestFactory.getExecutedRequests().get(0);
ClassLoaderFiles classLoaderFiles = deserialize(request.getBodyAsBytes()); ClassLoaderFiles classLoaderFiles = deserialize(request.getBodyAsBytes());
Collection<SourceFolder> sourceFolders = classLoaderFiles.getSourceFolders(); Collection<SourceFolder> sourceFolders = classLoaderFiles.getSourceFolders();
assertThat(sourceFolders.size(), equalTo(1)); assertThat(sourceFolders.size()).isEqualTo(1);
SourceFolder classSourceFolder = sourceFolders.iterator().next(); SourceFolder classSourceFolder = sourceFolders.iterator().next();
assertThat(classSourceFolder.getName(), equalTo(sourceFolder.getAbsolutePath())); assertThat(classSourceFolder.getName()).isEqualTo(sourceFolder.getAbsolutePath());
Iterator<ClassLoaderFile> classFiles = classSourceFolder.getFiles().iterator(); Iterator<ClassLoaderFile> classFiles = classSourceFolder.getFiles().iterator();
assertClassFile(classFiles.next(), "File1", ClassLoaderFile.Kind.ADDED); assertClassFile(classFiles.next(), "File1", ClassLoaderFile.Kind.ADDED);
assertClassFile(classFiles.next(), "File2", ClassLoaderFile.Kind.MODIFIED); assertClassFile(classFiles.next(), "File2", ClassLoaderFile.Kind.MODIFIED);
assertClassFile(classFiles.next(), null, ClassLoaderFile.Kind.DELETED); assertClassFile(classFiles.next(), null, ClassLoaderFile.Kind.DELETED);
assertThat(classFiles.hasNext(), equalTo(false)); assertThat(classFiles.hasNext()).isFalse();
} }
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) { private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
assertThat(file.getContents(), assertThat(file.getContents())
equalTo(content == null ? null : content.getBytes())); .isEqualTo(content == null ? null : content.getBytes());
assertThat(file.getKind(), equalTo(kind)); assertThat(file.getKind()).isEqualTo(kind);
} }
private File createFile(File sourceFolder, String name) throws IOException { private File createFile(File sourceFolder, String name) throws IOException {
......
...@@ -33,8 +33,7 @@ import org.springframework.http.client.ClientHttpRequest; ...@@ -33,8 +33,7 @@ import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.ClientHttpResponse;
import static org.hamcrest.Matchers.greaterThan; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -119,7 +118,7 @@ public class DelayedLiveReloadTriggerTests { ...@@ -119,7 +118,7 @@ public class DelayedLiveReloadTriggerTests {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
this.trigger.setTimings(10, 200, 30000); this.trigger.setTimings(10, 200, 30000);
this.trigger.run(); this.trigger.run();
assertThat(System.currentTimeMillis() - startTime, greaterThan(300L)); assertThat(System.currentTimeMillis() - startTime).isGreaterThan(300L);
verify(this.liveReloadServer).triggerReload(); verify(this.liveReloadServer).triggerReload();
} }
......
...@@ -32,8 +32,7 @@ import org.springframework.http.client.ClientHttpResponse; ...@@ -32,8 +32,7 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
/** /**
...@@ -109,8 +108,8 @@ public class HttpHeaderInterceptorTests { ...@@ -109,8 +108,8 @@ public class HttpHeaderInterceptorTests {
public void intercept() throws IOException { public void intercept() throws IOException {
ClientHttpResponse result = this.interceptor.intercept(this.request, this.body, ClientHttpResponse result = this.interceptor.intercept(this.request, this.body,
this.execution); this.execution);
assertThat(this.request.getHeaders().getFirst(this.name), equalTo(this.value)); assertThat(this.request.getHeaders().getFirst(this.name)).isEqualTo(this.value);
assertThat(result, equalTo(this.response)); assertThat(result).isEqualTo(this.response);
} }
} }
...@@ -28,8 +28,7 @@ import org.springframework.context.annotation.ConditionContext; ...@@ -28,8 +28,7 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockEnvironment;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -47,8 +46,8 @@ public class LocalDebugPortAvailableConditionTests { ...@@ -47,8 +46,8 @@ public class LocalDebugPortAvailableConditionTests {
@Test @Test
public void portAvailable() throws Exception { public void portAvailable() throws Exception {
ConditionOutcome outcome = getOutcome(); ConditionOutcome outcome = getOutcome();
assertThat(outcome.isMatch(), equalTo(true)); assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage(), equalTo("Local debug port available")); assertThat(outcome.getMessage()).isEqualTo("Local debug port available");
} }
@Test @Test
...@@ -57,8 +56,8 @@ public class LocalDebugPortAvailableConditionTests { ...@@ -57,8 +56,8 @@ public class LocalDebugPortAvailableConditionTests {
.createServerSocket(this.port); .createServerSocket(this.port);
ConditionOutcome outcome = getOutcome(); ConditionOutcome outcome = getOutcome();
serverSocket.close(); serverSocket.close();
assertThat(outcome.isMatch(), equalTo(false)); assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage(), equalTo("Local debug port unavailable")); assertThat(outcome.getMessage()).isEqualTo("Local debug port unavailable");
} }
private ConditionOutcome getOutcome() { private ConditionOutcome getOutcome() {
......
...@@ -49,9 +49,7 @@ import org.springframework.http.server.ServerHttpRequest; ...@@ -49,9 +49,7 @@ import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse; import org.springframework.http.server.ServerHttpResponse;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.containsString; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -88,20 +86,20 @@ public class RemoteClientConfigurationTests { ...@@ -88,20 +86,20 @@ public class RemoteClientConfigurationTests {
public void warnIfDebugAndRestartDisabled() throws Exception { public void warnIfDebugAndRestartDisabled() throws Exception {
configure("spring.devtools.remote.debug.enabled:false", configure("spring.devtools.remote.debug.enabled:false",
"spring.devtools.remote.restart.enabled:false"); "spring.devtools.remote.restart.enabled:false");
assertThat(this.output.toString(), assertThat(this.output.toString())
containsString("Remote restart and debug are both disabled")); .contains("Remote restart and debug are both disabled");
} }
@Test @Test
public void warnIfNotHttps() throws Exception { public void warnIfNotHttps() throws Exception {
configure("http://localhost", true); configure("http://localhost", true);
assertThat(this.output.toString(), containsString("is insecure")); assertThat(this.output.toString()).contains("is insecure");
} }
@Test @Test
public void doesntWarnIfUsingHttps() throws Exception { public void doesntWarnIfUsingHttps() throws Exception {
configure("https://localhost", true); configure("https://localhost", true);
assertThat(this.output.toString(), not(containsString("is insecure"))); assertThat(this.output.toString()).doesNotContain("is insecure");
} }
@Test @Test
......
...@@ -38,8 +38,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -38,8 +38,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.willReturn; import static org.mockito.BDDMockito.willReturn;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -114,8 +113,8 @@ public class DispatcherFilterTests { ...@@ -114,8 +113,8 @@ public class DispatcherFilterTests {
ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest; ServletServerHttpRequest actualRequest = (ServletServerHttpRequest) dispatcherRequest;
ServerHttpResponse dispatcherResponse = this.serverResponseCaptor.getValue(); ServerHttpResponse dispatcherResponse = this.serverResponseCaptor.getValue();
ServletServerHttpResponse actualResponse = (ServletServerHttpResponse) dispatcherResponse; ServletServerHttpResponse actualResponse = (ServletServerHttpResponse) dispatcherResponse;
assertThat(actualRequest.getServletRequest(), equalTo(request)); assertThat(actualRequest.getServletRequest()).isEqualTo(request);
assertThat(actualResponse.getServletResponse(), equalTo(response)); assertThat(actualResponse.getServletResponse()).isEqualTo(response);
} }
} }
...@@ -36,8 +36,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -36,8 +36,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.inOrder;
...@@ -101,7 +100,7 @@ public class DispatcherTests { ...@@ -101,7 +100,7 @@ public class DispatcherTests {
Collections.singleton(mapper)); Collections.singleton(mapper));
dispatcher.handle(this.serverRequest, this.serverResponse); dispatcher.handle(this.serverRequest, this.serverResponse);
verifyZeroInteractions(handler); verifyZeroInteractions(handler);
assertThat(this.response.getStatus(), equalTo(403)); assertThat(this.response.getStatus()).isEqualTo(403);
} }
@Test @Test
......
...@@ -25,8 +25,7 @@ import org.springframework.http.server.ServerHttpRequest; ...@@ -25,8 +25,7 @@ import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link HttpHeaderAccessManager}. * Tests for {@link HttpHeaderAccessManager}.
...@@ -87,24 +86,24 @@ public class HttpHeaderAccessManagerTests { ...@@ -87,24 +86,24 @@ public class HttpHeaderAccessManagerTests {
@Test @Test
public void allowsMatching() throws Exception { public void allowsMatching() throws Exception {
this.request.addHeader(HEADER, SECRET); this.request.addHeader(HEADER, SECRET);
assertThat(this.manager.isAllowed(this.serverRequest), equalTo(true)); assertThat(this.manager.isAllowed(this.serverRequest)).isTrue();
} }
@Test @Test
public void disallowsWrongSecret() throws Exception { public void disallowsWrongSecret() throws Exception {
this.request.addHeader(HEADER, "wrong"); this.request.addHeader(HEADER, "wrong");
assertThat(this.manager.isAllowed(this.serverRequest), equalTo(false)); assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
} }
@Test @Test
public void disallowsNoSecret() throws Exception { public void disallowsNoSecret() throws Exception {
assertThat(this.manager.isAllowed(this.serverRequest), equalTo(false)); assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
} }
@Test @Test
public void disallowsWrongHeader() throws Exception { public void disallowsWrongHeader() throws Exception {
this.request.addHeader("X-WRONG", SECRET); this.request.addHeader("X-WRONG", SECRET);
assertThat(this.manager.isAllowed(this.serverRequest), equalTo(false)); assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
} }
} }
...@@ -29,8 +29,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -29,8 +29,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link HttpStatusHandler}. * Tests for {@link HttpStatusHandler}.
...@@ -69,14 +68,14 @@ public class HttpStatusHandlerTests { ...@@ -69,14 +68,14 @@ public class HttpStatusHandlerTests {
public void respondsOk() throws Exception { public void respondsOk() throws Exception {
HttpStatusHandler handler = new HttpStatusHandler(); HttpStatusHandler handler = new HttpStatusHandler();
handler.handle(this.request, this.response); handler.handle(this.request, this.response);
assertThat(this.servletResponse.getStatus(), equalTo(200)); assertThat(this.servletResponse.getStatus()).isEqualTo(200);
} }
@Test @Test
public void respondsWithStatus() throws Exception { public void respondsWithStatus() throws Exception {
HttpStatusHandler handler = new HttpStatusHandler(HttpStatus.I_AM_A_TEAPOT); HttpStatusHandler handler = new HttpStatusHandler(HttpStatus.I_AM_A_TEAPOT);
handler.handle(this.request, this.response); handler.handle(this.request, this.response);
assertThat(this.servletResponse.getStatus(), equalTo(418)); assertThat(this.servletResponse.getStatus()).isEqualTo(418);
} }
} }
...@@ -26,9 +26,7 @@ import org.springframework.http.server.ServerHttpRequest; ...@@ -26,9 +26,7 @@ import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -70,7 +68,7 @@ public class UrlHandlerMapperTests { ...@@ -70,7 +68,7 @@ public class UrlHandlerMapperTests {
UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler); UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler);
HttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/tunnel"); HttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/tunnel");
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest); ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
assertThat(mapper.getHandler(request), equalTo(this.handler)); assertThat(mapper.getHandler(request)).isEqualTo(this.handler);
} }
@Test @Test
...@@ -79,7 +77,7 @@ public class UrlHandlerMapperTests { ...@@ -79,7 +77,7 @@ public class UrlHandlerMapperTests {
HttpServletRequest servletRequest = new MockHttpServletRequest("GET", HttpServletRequest servletRequest = new MockHttpServletRequest("GET",
"/tunnel/other"); "/tunnel/other");
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest); ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
assertThat(mapper.getHandler(request), nullValue()); assertThat(mapper.getHandler(request)).isNull();
} }
} }
...@@ -24,8 +24,7 @@ import org.junit.Rule; ...@@ -24,8 +24,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ChangeableUrls}. * Tests for {@link ChangeableUrls}.
...@@ -40,19 +39,19 @@ public class ChangeableUrlsTests { ...@@ -40,19 +39,19 @@ public class ChangeableUrlsTests {
@Test @Test
public void folderUrl() throws Exception { public void folderUrl() throws Exception {
URL url = makeUrl("myproject"); URL url = makeUrl("myproject");
assertThat(ChangeableUrls.fromUrls(url).size(), equalTo(1)); assertThat(ChangeableUrls.fromUrls(url).size()).isEqualTo(1);
} }
@Test @Test
public void fileUrl() throws Exception { public void fileUrl() throws Exception {
URL url = this.temporaryFolder.newFile().toURI().toURL(); URL url = this.temporaryFolder.newFile().toURI().toURL();
assertThat(ChangeableUrls.fromUrls(url).size(), equalTo(0)); assertThat(ChangeableUrls.fromUrls(url).size()).isEqualTo(0);
} }
@Test @Test
public void httpUrl() throws Exception { public void httpUrl() throws Exception {
URL url = new URL("http://spring.io"); URL url = new URL("http://spring.io");
assertThat(ChangeableUrls.fromUrls(url).size(), equalTo(0)); assertThat(ChangeableUrls.fromUrls(url).size()).isEqualTo(0);
} }
@Test @Test
...@@ -61,7 +60,7 @@ public class ChangeableUrlsTests { ...@@ -61,7 +60,7 @@ public class ChangeableUrlsTests {
makeUrl("spring-boot-autoconfigure"), makeUrl("spring-boot-actuator"), makeUrl("spring-boot-autoconfigure"), makeUrl("spring-boot-actuator"),
makeUrl("spring-boot-starter"), makeUrl("spring-boot-starter"),
makeUrl("spring-boot-starter-some-thing")); makeUrl("spring-boot-starter-some-thing"));
assertThat(urls.size(), equalTo(0)); assertThat(urls.size()).isEqualTo(0);
} }
private URL makeUrl(String name) throws IOException { private URL makeUrl(String name) throws IOException {
......
...@@ -20,10 +20,8 @@ import java.net.URL; ...@@ -20,10 +20,8 @@ import java.net.URL;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link DefaultRestartInitializer}. * Tests for {@link DefaultRestartInitializer}.
...@@ -35,7 +33,7 @@ public class DefaultRestartInitializerTests { ...@@ -35,7 +33,7 @@ public class DefaultRestartInitializerTests {
@Test @Test
public void nullForTests() throws Exception { public void nullForTests() throws Exception {
MockRestartInitializer initializer = new MockRestartInitializer(true); MockRestartInitializer initializer = new MockRestartInitializer(true);
assertThat(initializer.getInitialUrls(Thread.currentThread()), nullValue()); assertThat(initializer.getInitialUrls(Thread.currentThread())).isNull();
} }
@Test @Test
...@@ -45,8 +43,8 @@ public class DefaultRestartInitializerTests { ...@@ -45,8 +43,8 @@ public class DefaultRestartInitializerTests {
Thread thread = new Thread(); Thread thread = new Thread();
thread.setName("main"); thread.setName("main");
thread.setContextClassLoader(classLoader); thread.setContextClassLoader(classLoader);
assertThat(initializer.isMain(thread), equalTo(true)); assertThat(initializer.isMain(thread)).isTrue();
assertThat(initializer.getInitialUrls(thread), not(nullValue())); assertThat(initializer.getInitialUrls(thread)).isNotEqualTo(nullValue());
} }
@Test @Test
...@@ -56,8 +54,8 @@ public class DefaultRestartInitializerTests { ...@@ -56,8 +54,8 @@ public class DefaultRestartInitializerTests {
Thread thread = new Thread(); Thread thread = new Thread();
thread.setName("buscuit"); thread.setName("buscuit");
thread.setContextClassLoader(classLoader); thread.setContextClassLoader(classLoader);
assertThat(initializer.isMain(thread), equalTo(false)); assertThat(initializer.isMain(thread)).isFalse();
assertThat(initializer.getInitialUrls(thread), nullValue()); assertThat(initializer.getInitialUrls(thread)).isNull();
} }
@Test @Test
...@@ -68,8 +66,8 @@ public class DefaultRestartInitializerTests { ...@@ -68,8 +66,8 @@ public class DefaultRestartInitializerTests {
Thread thread = new Thread(); Thread thread = new Thread();
thread.setName("main"); thread.setName("main");
thread.setContextClassLoader(classLoader); thread.setContextClassLoader(classLoader);
assertThat(initializer.isMain(thread), equalTo(false)); assertThat(initializer.isMain(thread)).isFalse();
assertThat(initializer.getInitialUrls(thread), nullValue()); assertThat(initializer.getInitialUrls(thread)).isNull();
} }
@Test @Test
...@@ -86,7 +84,7 @@ public class DefaultRestartInitializerTests { ...@@ -86,7 +84,7 @@ public class DefaultRestartInitializerTests {
MockRestartInitializer initializer = new MockRestartInitializer(true); MockRestartInitializer initializer = new MockRestartInitializer(true);
StackTraceElement element = new StackTraceElement(className, "someMethod", StackTraceElement element = new StackTraceElement(className, "someMethod",
"someFile", 123); "someFile", 123);
assertThat(initializer.isSkippedStackElement(element), equalTo(expected)); assertThat(initializer.isSkippedStackElement(element)).isEqualTo(expected);
} }
private static class MockAppClassLoader extends ClassLoader { private static class MockAppClassLoader extends ClassLoader {
......
...@@ -25,8 +25,7 @@ import org.junit.rules.ExpectedException; ...@@ -25,8 +25,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link MainMethod}. * Tests for {@link MainMethod}.
...@@ -62,9 +61,9 @@ public class MainMethodTests { ...@@ -62,9 +61,9 @@ public class MainMethodTests {
Valid.main(); Valid.main();
} }
}).test(); }).test();
assertThat(method.getMethod(), equalTo(this.actualMain)); assertThat(method.getMethod()).isEqualTo(this.actualMain);
assertThat(method.getDeclaringClassName(), assertThat(method.getDeclaringClassName())
equalTo(this.actualMain.getDeclaringClass().getName())); .isEqualTo(this.actualMain.getDeclaringClass().getName());
} }
@Test @Test
......
...@@ -27,8 +27,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext ...@@ -27,8 +27,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -53,7 +52,7 @@ public class OnInitializedRestarterConditionTests { ...@@ -53,7 +52,7 @@ public class OnInitializedRestarterConditionTests {
Restarter.clearInstance(); Restarter.clearInstance();
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
Config.class); Config.class);
assertThat(context.containsBean("bean"), equalTo(false)); assertThat(context.containsBean("bean")).isFalse();
context.close(); context.close();
} }
...@@ -62,7 +61,7 @@ public class OnInitializedRestarterConditionTests { ...@@ -62,7 +61,7 @@ public class OnInitializedRestarterConditionTests {
Restarter.initialize(new String[0], false, RestartInitializer.NONE); Restarter.initialize(new String[0], false, RestartInitializer.NONE);
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
Config.class); Config.class);
assertThat(context.containsBean("bean"), equalTo(false)); assertThat(context.containsBean("bean")).isFalse();
context.close(); context.close();
} }
...@@ -90,7 +89,7 @@ public class OnInitializedRestarterConditionTests { ...@@ -90,7 +89,7 @@ public class OnInitializedRestarterConditionTests {
Restarter.initialize(new String[0], false, initializer); Restarter.initialize(new String[0], false, initializer);
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
Config.class); Config.class);
assertThat(context.containsBean("bean"), equalTo(true)); assertThat(context.containsBean("bean")).isTrue();
context.close(); context.close();
synchronized (wait) { synchronized (wait) {
wait.notify(); wait.notify();
......
...@@ -28,10 +28,8 @@ import org.springframework.context.ConfigurableApplicationContext; ...@@ -28,10 +28,8 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -54,32 +52,32 @@ public class RestartApplicationListenerTests { ...@@ -54,32 +52,32 @@ public class RestartApplicationListenerTests {
@Test @Test
public void isHighestPriority() throws Exception { public void isHighestPriority() throws Exception {
assertThat(new RestartApplicationListener().getOrder(), assertThat(new RestartApplicationListener().getOrder())
equalTo(Ordered.HIGHEST_PRECEDENCE)); .isEqualTo(Ordered.HIGHEST_PRECEDENCE);
} }
@Test @Test
public void initializeWithReady() throws Exception { public void initializeWithReady() throws Exception {
testInitialize(false); testInitialize(false);
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"), assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"))
equalTo((Object) ARGS)); .isEqualTo(ARGS);
assertThat(Restarter.getInstance().isFinished(), equalTo(true)); assertThat(Restarter.getInstance().isFinished()).isTrue();
} }
@Test @Test
public void initializeWithFail() throws Exception { public void initializeWithFail() throws Exception {
testInitialize(true); testInitialize(true);
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"), assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"))
equalTo((Object) ARGS)); .isEqualTo(ARGS);
assertThat(Restarter.getInstance().isFinished(), equalTo(true)); assertThat(Restarter.getInstance().isFinished()).isTrue();
} }
@Test @Test
public void disableWithSystemProperty() throws Exception { public void disableWithSystemProperty() throws Exception {
System.setProperty(ENABLED_PROPERTY, "false"); System.setProperty(ENABLED_PROPERTY, "false");
testInitialize(false); testInitialize(false);
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "enabled"), assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "enabled"))
equalTo((Object) false)); .isEqualTo(false);
} }
private void testInitialize(boolean failed) { private void testInitialize(boolean failed) {
...@@ -89,8 +87,8 @@ public class RestartApplicationListenerTests { ...@@ -89,8 +87,8 @@ public class RestartApplicationListenerTests {
ConfigurableApplicationContext context = mock( ConfigurableApplicationContext context = mock(
ConfigurableApplicationContext.class); ConfigurableApplicationContext.class);
listener.onApplicationEvent(new ApplicationStartedEvent(application, ARGS)); listener.onApplicationEvent(new ApplicationStartedEvent(application, ARGS));
assertThat(Restarter.getInstance(), not(nullValue())); assertThat(Restarter.getInstance()).isNotEqualTo(nullValue());
assertThat(Restarter.getInstance().isFinished(), equalTo(false)); assertThat(Restarter.getInstance().isFinished()).isFalse();
if (failed) { if (failed) {
listener.onApplicationEvent(new ApplicationFailedEvent(application, ARGS, listener.onApplicationEvent(new ApplicationFailedEvent(application, ARGS,
context, new RuntimeException())); context, new RuntimeException()));
......
...@@ -27,8 +27,7 @@ import org.springframework.context.annotation.Bean; ...@@ -27,8 +27,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link RestartScopeInitializer}. * Tests for {@link RestartScopeInitializer}.
...@@ -49,8 +48,8 @@ public class RestartScopeInitializerTests { ...@@ -49,8 +48,8 @@ public class RestartScopeInitializerTests {
context.close(); context.close();
context = runApplication(); context = runApplication();
context.close(); context.close();
assertThat(createCount.get(), equalTo(1)); assertThat(createCount.get()).isEqualTo(1);
assertThat(refreshCount.get(), equalTo(2)); assertThat(refreshCount.get()).isEqualTo(2);
} }
private ConfigurableApplicationContext runApplication() { private ConfigurableApplicationContext runApplication() {
......
...@@ -41,9 +41,7 @@ import org.springframework.stereotype.Component; ...@@ -41,9 +41,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -94,9 +92,9 @@ public class RestarterTests { ...@@ -94,9 +92,9 @@ public class RestarterTests {
thread.start(); thread.start();
Thread.sleep(2600); Thread.sleep(2600);
String output = this.out.toString(); String output = this.out.toString();
assertThat(StringUtils.countOccurrencesOf(output, "Tick 0"), greaterThan(1)); assertThat(StringUtils.countOccurrencesOf(output, "Tick 0")).isGreaterThan(1);
assertThat(StringUtils.countOccurrencesOf(output, "Tick 1"), greaterThan(1)); assertThat(StringUtils.countOccurrencesOf(output, "Tick 1")).isGreaterThan(1);
assertThat(TestRestartListener.restarts, greaterThan(0)); assertThat(TestRestartListener.restarts).isGreaterThan(0);
} }
@Test @Test
...@@ -105,7 +103,7 @@ public class RestarterTests { ...@@ -105,7 +103,7 @@ public class RestarterTests {
ObjectFactory objectFactory = mock(ObjectFactory.class); ObjectFactory objectFactory = mock(ObjectFactory.class);
given(objectFactory.getObject()).willReturn("abc"); given(objectFactory.getObject()).willReturn("abc");
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory); Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
assertThat(attribute, equalTo((Object) "abc")); assertThat(attribute).isEqualTo("abc");
} }
public void addUrlsMustNotBeNull() throws Exception { public void addUrlsMustNotBeNull() throws Exception {
...@@ -123,7 +121,7 @@ public class RestarterTests { ...@@ -123,7 +121,7 @@ public class RestarterTests {
restarter.restart(); restarter.restart();
ClassLoader classLoader = ((TestableRestarter) restarter) ClassLoader classLoader = ((TestableRestarter) restarter)
.getRelaunchClassLoader(); .getRelaunchClassLoader();
assertThat(((URLClassLoader) classLoader).getURLs()[0], equalTo(url)); assertThat(((URLClassLoader) classLoader).getURLs()[0]).isEqualTo(url);
} }
@Test @Test
...@@ -142,8 +140,8 @@ public class RestarterTests { ...@@ -142,8 +140,8 @@ public class RestarterTests {
restarter.restart(); restarter.restart();
ClassLoader classLoader = ((TestableRestarter) restarter) ClassLoader classLoader = ((TestableRestarter) restarter)
.getRelaunchClassLoader(); .getRelaunchClassLoader();
assertThat(FileCopyUtils.copyToByteArray(classLoader.getResourceAsStream("f")), assertThat(FileCopyUtils.copyToByteArray(classLoader.getResourceAsStream("f")))
equalTo("abc".getBytes())); .isEqualTo("abc".getBytes());
} }
@Test @Test
...@@ -157,7 +155,7 @@ public class RestarterTests { ...@@ -157,7 +155,7 @@ public class RestarterTests {
}); });
ObjectFactory objectFactory = mock(ObjectFactory.class); ObjectFactory objectFactory = mock(ObjectFactory.class);
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory); Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
assertThat(attribute, equalTo((Object) "abc")); assertThat(attribute).isEqualTo("abc");
verifyZeroInteractions(objectFactory); verifyZeroInteractions(objectFactory);
} }
...@@ -173,9 +171,9 @@ public class RestarterTests { ...@@ -173,9 +171,9 @@ public class RestarterTests {
ThreadFactory factory = Restarter.getInstance().getThreadFactory(); ThreadFactory factory = Restarter.getInstance().getThreadFactory();
Thread viaFactory = factory.newThread(runnable); Thread viaFactory = factory.newThread(runnable);
// Regular threads will inherit the current thread // Regular threads will inherit the current thread
assertThat(regular.getContextClassLoader(), equalTo(contextClassLoader)); assertThat(regular.getContextClassLoader()).isEqualTo(contextClassLoader);
// Factory threads should should inherit from the initial thread // Factory threads should should inherit from the initial thread
assertThat(viaFactory.getContextClassLoader(), equalTo(parentLoader)); assertThat(viaFactory.getContextClassLoader()).isEqualTo(parentLoader);
}; };
}; };
thread.setContextClassLoader(contextClassLoader); thread.setContextClassLoader(contextClassLoader);
...@@ -190,7 +188,7 @@ public class RestarterTests { ...@@ -190,7 +188,7 @@ public class RestarterTests {
URL[] urls = new URL[] { new URL("file:/proj/module-a.jar!/") }; URL[] urls = new URL[] { new URL("file:/proj/module-a.jar!/") };
given(initializer.getInitialUrls(any(Thread.class))).willReturn(urls); given(initializer.getInitialUrls(any(Thread.class))).willReturn(urls);
Restarter.initialize(new String[0], false, initializer, false); Restarter.initialize(new String[0], false, initializer, false);
assertThat(Restarter.getInstance().getInitialUrls(), equalTo(urls)); assertThat(Restarter.getInstance().getInitialUrls()).isEqualTo(urls);
} }
@Component @Component
......
...@@ -18,9 +18,7 @@ package org.springframework.boot.devtools.restart; ...@@ -18,9 +18,7 @@ package org.springframework.boot.devtools.restart;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
/** /**
...@@ -41,7 +39,7 @@ public class SilentExitExceptionHandlerTests { ...@@ -41,7 +39,7 @@ public class SilentExitExceptionHandlerTests {
}; };
SilentExitExceptionHandler.setup(testThread); SilentExitExceptionHandler.setup(testThread);
testThread.startAndJoin(); testThread.startAndJoin();
assertThat(testThread.getThrown(), nullValue()); assertThat(testThread.getThrown()).isNull();
} }
@Test @Test
...@@ -54,7 +52,7 @@ public class SilentExitExceptionHandlerTests { ...@@ -54,7 +52,7 @@ public class SilentExitExceptionHandlerTests {
}; };
SilentExitExceptionHandler.setup(testThread); SilentExitExceptionHandler.setup(testThread);
testThread.startAndJoin(); testThread.startAndJoin();
assertThat(testThread.getThrown().getMessage(), equalTo("Expected")); assertThat(testThread.getThrown().getMessage()).isEqualTo("Expected");
} }
private static abstract class TestThread extends Thread { private static abstract class TestThread extends Thread {
......
...@@ -22,9 +22,7 @@ import org.junit.rules.ExpectedException; ...@@ -22,9 +22,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind; import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link ClassLoaderFile}. * Tests for {@link ClassLoaderFile}.
...@@ -69,22 +67,22 @@ public class ClassLoaderFileTests { ...@@ -69,22 +67,22 @@ public class ClassLoaderFileTests {
@Test @Test
public void added() throws Exception { public void added() throws Exception {
ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, BYTES); ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, BYTES);
assertThat(file.getKind(), equalTo(ClassLoaderFile.Kind.ADDED)); assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.ADDED);
assertThat(file.getContents(), equalTo(BYTES)); assertThat(file.getContents()).isEqualTo(BYTES);
} }
@Test @Test
public void modified() throws Exception { public void modified() throws Exception {
ClassLoaderFile file = new ClassLoaderFile(Kind.MODIFIED, BYTES); ClassLoaderFile file = new ClassLoaderFile(Kind.MODIFIED, BYTES);
assertThat(file.getKind(), equalTo(ClassLoaderFile.Kind.MODIFIED)); assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.MODIFIED);
assertThat(file.getContents(), equalTo(BYTES)); assertThat(file.getContents()).isEqualTo(BYTES);
} }
@Test @Test
public void deleted() throws Exception { public void deleted() throws Exception {
ClassLoaderFile file = new ClassLoaderFile(Kind.DELETED, null); ClassLoaderFile file = new ClassLoaderFile(Kind.DELETED, null);
assertThat(file.getKind(), equalTo(ClassLoaderFile.Kind.DELETED)); assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.DELETED);
assertThat(file.getContents(), nullValue()); assertThat(file.getContents()).isNull();
} }
} }
...@@ -20,8 +20,6 @@ import java.io.ByteArrayInputStream; ...@@ -20,8 +20,6 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import org.junit.Rule; import org.junit.Rule;
...@@ -31,10 +29,7 @@ import org.junit.rules.ExpectedException; ...@@ -31,10 +29,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind; import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kind;
import org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder; import org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
...@@ -65,19 +60,19 @@ public class ClassLoaderFilesTests { ...@@ -65,19 +60,19 @@ public class ClassLoaderFilesTests {
@Test @Test
public void getFileWithNullName() throws Exception { public void getFileWithNullName() throws Exception {
assertThat(this.files.getFile(null), nullValue()); assertThat(this.files.getFile(null)).isNull();
} }
@Test @Test
public void addAndGet() throws Exception { public void addAndGet() throws Exception {
ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, new byte[10]); ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, new byte[10]);
this.files.addFile("myfile", file); this.files.addFile("myfile", file);
assertThat(this.files.getFile("myfile"), equalTo(file)); assertThat(this.files.getFile("myfile")).isEqualTo(file);
} }
@Test @Test
public void getMissing() throws Exception { public void getMissing() throws Exception {
assertThat(this.files.getFile("missing"), nullValue()); assertThat(this.files.getFile("missing")).isNull();
} }
@Test @Test
...@@ -86,7 +81,7 @@ public class ClassLoaderFilesTests { ...@@ -86,7 +81,7 @@ public class ClassLoaderFilesTests {
ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]); ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
this.files.addFile("myfile", file1); this.files.addFile("myfile", file1);
this.files.addFile("myfile", file2); this.files.addFile("myfile", file2);
assertThat(this.files.getFile("myfile"), equalTo(file2)); assertThat(this.files.getFile("myfile")).isEqualTo(file2);
} }
@Test @Test
...@@ -95,9 +90,11 @@ public class ClassLoaderFilesTests { ...@@ -95,9 +90,11 @@ public class ClassLoaderFilesTests {
ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]); ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
this.files.addFile("a", "myfile", file1); this.files.addFile("a", "myfile", file1);
this.files.addFile("b", "myfile", file2); this.files.addFile("b", "myfile", file2);
assertThat(this.files.getFile("myfile"), equalTo(file2)); assertThat(this.files.getFile("myfile")).isEqualTo(file2);
assertThat(this.files.getOrCreateSourceFolder("a").getFiles().size(), equalTo(0)); assertThat(this.files.getOrCreateSourceFolder("a").getFiles().size())
assertThat(this.files.getOrCreateSourceFolder("b").getFiles().size(), equalTo(1)); .isEqualTo(0);
assertThat(this.files.getOrCreateSourceFolder("b").getFiles().size())
.isEqualTo(1);
} }
@Test @Test
...@@ -113,13 +110,11 @@ public class ClassLoaderFilesTests { ...@@ -113,13 +110,11 @@ public class ClassLoaderFilesTests {
Iterator<SourceFolder> sourceFolders = this.files.getSourceFolders().iterator(); Iterator<SourceFolder> sourceFolders = this.files.getSourceFolders().iterator();
SourceFolder sourceFolder1 = sourceFolders.next(); SourceFolder sourceFolder1 = sourceFolders.next();
SourceFolder sourceFolder2 = sourceFolders.next(); SourceFolder sourceFolder2 = sourceFolders.next();
assertThat(sourceFolders.hasNext(), equalTo(false)); assertThat(sourceFolders.hasNext()).isFalse();
assertThat(sourceFolder1.getName(), equalTo("a")); assertThat(sourceFolder1.getName()).isEqualTo("a");
assertThat(sourceFolder2.getName(), equalTo("b")); assertThat(sourceFolder2.getName()).isEqualTo("b");
assertThat(new ArrayList<ClassLoaderFile>(sourceFolder1.getFiles()), assertThat(sourceFolder1.getFiles()).containsOnly(file1, file2);
equalTo(Arrays.asList(file1, file2))); assertThat(sourceFolder2.getFiles()).containsOnly(file3, file4);
assertThat(new ArrayList<ClassLoaderFile>(sourceFolder2.getFiles()),
equalTo(Arrays.asList(file3, file4)));
} }
@Test @Test
...@@ -133,7 +128,7 @@ public class ClassLoaderFilesTests { ...@@ -133,7 +128,7 @@ public class ClassLoaderFilesTests {
ObjectInputStream ois = new ObjectInputStream( ObjectInputStream ois = new ObjectInputStream(
new ByteArrayInputStream(bos.toByteArray())); new ByteArrayInputStream(bos.toByteArray()));
ClassLoaderFiles readObject = (ClassLoaderFiles) ois.readObject(); ClassLoaderFiles readObject = (ClassLoaderFiles) ois.readObject();
assertThat(readObject.getFile("myfile"), notNullValue()); assertThat(readObject.getFile("myfile")).isNotNull();
} }
@Test @Test
...@@ -149,11 +144,10 @@ public class ClassLoaderFilesTests { ...@@ -149,11 +144,10 @@ public class ClassLoaderFilesTests {
Iterator<SourceFolder> sourceFolders = this.files.getSourceFolders().iterator(); Iterator<SourceFolder> sourceFolders = this.files.getSourceFolders().iterator();
SourceFolder sourceFolder1 = sourceFolders.next(); SourceFolder sourceFolder1 = sourceFolders.next();
SourceFolder sourceFolder2 = sourceFolders.next(); SourceFolder sourceFolder2 = sourceFolders.next();
assertThat(sourceFolders.hasNext(), equalTo(false)); assertThat(sourceFolders.hasNext()).isFalse();
assertThat(sourceFolder1.getName(), equalTo("a")); assertThat(sourceFolder1.getName()).isEqualTo("a");
assertThat(sourceFolder2.getName(), equalTo("b")); assertThat(sourceFolder2.getName()).isEqualTo("b");
assertThat(new ArrayList<ClassLoaderFile>(sourceFolder1.getFiles()), assertThat(sourceFolder1.getFiles()).containsOnly(file1, file2);
equalTo(Arrays.asList(file1, file2)));
} }
@Test @Test
...@@ -162,7 +156,7 @@ public class ClassLoaderFilesTests { ...@@ -162,7 +156,7 @@ public class ClassLoaderFilesTests {
this.files.addFile("s1", "n2", mock(ClassLoaderFile.class)); this.files.addFile("s1", "n2", mock(ClassLoaderFile.class));
this.files.addFile("s2", "n3", mock(ClassLoaderFile.class)); this.files.addFile("s2", "n3", mock(ClassLoaderFile.class));
this.files.addFile("s2", "n1", mock(ClassLoaderFile.class)); this.files.addFile("s2", "n1", mock(ClassLoaderFile.class));
assertThat(this.files.size(), equalTo(3)); assertThat(this.files.size()).isEqualTo(3);
} }
@Test @Test
...@@ -178,8 +172,8 @@ public class ClassLoaderFilesTests { ...@@ -178,8 +172,8 @@ public class ClassLoaderFilesTests {
this.files.addFile("s1", "n2", mock(ClassLoaderFile.class)); this.files.addFile("s1", "n2", mock(ClassLoaderFile.class));
ClassLoaderFiles copy = new ClassLoaderFiles(this.files); ClassLoaderFiles copy = new ClassLoaderFiles(this.files);
this.files.addFile("s2", "n3", mock(ClassLoaderFile.class)); this.files.addFile("s2", "n3", mock(ClassLoaderFile.class));
assertThat(this.files.size(), equalTo(3)); assertThat(this.files.size()).isEqualTo(3);
assertThat(copy.size(), equalTo(2)); assertThat(copy.size()).isEqualTo(2);
} }
} }
...@@ -39,9 +39,7 @@ import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kin ...@@ -39,9 +39,7 @@ import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kin
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.util.StreamUtils; import org.springframework.util.StreamUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link RestartClassLoader}. * Tests for {@link RestartClassLoader}.
...@@ -115,48 +113,47 @@ public class RestartClassLoaderTests { ...@@ -115,48 +113,47 @@ public class RestartClassLoaderTests {
public void getResourceFromReloadableUrl() throws Exception { public void getResourceFromReloadableUrl() throws Exception {
String content = readString( String content = readString(
this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Sample.txt")); this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Sample.txt"));
assertThat(content, startsWith("fromchild")); assertThat(content).startsWith("fromchild");
} }
@Test @Test
public void getResourceFromParent() throws Exception { public void getResourceFromParent() throws Exception {
String content = readString( String content = readString(
this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Parent.txt")); this.reloadClassLoader.getResourceAsStream(PACKAGE_PATH + "/Parent.txt"));
assertThat(content, startsWith("fromparent")); assertThat(content).startsWith("fromparent");
} }
@Test @Test
public void getResourcesFiltersDuplicates() throws Exception { public void getResourcesFiltersDuplicates() throws Exception {
List<URL> resources = toList( List<URL> resources = toList(
this.reloadClassLoader.getResources(PACKAGE_PATH + "/Sample.txt")); this.reloadClassLoader.getResources(PACKAGE_PATH + "/Sample.txt"));
assertThat(resources.size(), equalTo(1)); assertThat(resources.size()).isEqualTo(1);
} }
@Test @Test
public void loadClassFromReloadableUrl() throws Exception { public void loadClassFromReloadableUrl() throws Exception {
Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".Sample"); Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".Sample");
assertThat(loaded.getClassLoader(), assertThat(loaded.getClassLoader()).isEqualTo(this.reloadClassLoader);
equalTo((ClassLoader) this.reloadClassLoader));
} }
@Test @Test
public void loadClassFromParent() throws Exception { public void loadClassFromParent() throws Exception {
Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".SampleParent"); Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".SampleParent");
assertThat(loaded.getClassLoader(), equalTo(getClass().getClassLoader())); assertThat(loaded.getClassLoader()).isEqualTo(getClass().getClassLoader());
} }
@Test @Test
public void getDeletedResource() throws Exception { public void getDeletedResource() throws Exception {
String name = PACKAGE_PATH + "/Sample.txt"; String name = PACKAGE_PATH + "/Sample.txt";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
assertThat(this.reloadClassLoader.getResource(name), equalTo(null)); assertThat(this.reloadClassLoader.getResource(name)).isEqualTo(null);
} }
@Test @Test
public void getDeletedResourceAsStream() throws Exception { public void getDeletedResourceAsStream() throws Exception {
String name = PACKAGE_PATH + "/Sample.txt"; String name = PACKAGE_PATH + "/Sample.txt";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
assertThat(this.reloadClassLoader.getResourceAsStream(name), equalTo(null)); assertThat(this.reloadClassLoader.getResourceAsStream(name)).isEqualTo(null);
} }
@Test @Test
...@@ -165,7 +162,7 @@ public class RestartClassLoaderTests { ...@@ -165,7 +162,7 @@ public class RestartClassLoaderTests {
byte[] bytes = "abc".getBytes(); byte[] bytes = "abc".getBytes();
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, bytes)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, bytes));
URL resource = this.reloadClassLoader.getResource(name); URL resource = this.reloadClassLoader.getResource(name);
assertThat(FileCopyUtils.copyToByteArray(resource.openStream()), equalTo(bytes)); assertThat(FileCopyUtils.copyToByteArray(resource.openStream())).isEqualTo(bytes);
} }
@Test @Test
...@@ -173,7 +170,7 @@ public class RestartClassLoaderTests { ...@@ -173,7 +170,7 @@ public class RestartClassLoaderTests {
String name = PACKAGE_PATH + "/Sample.txt"; String name = PACKAGE_PATH + "/Sample.txt";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
List<URL> resources = toList(this.reloadClassLoader.getResources(name)); List<URL> resources = toList(this.reloadClassLoader.getResources(name));
assertThat(resources.size(), equalTo(0)); assertThat(resources.size()).isEqualTo(0);
} }
@Test @Test
...@@ -182,8 +179,8 @@ public class RestartClassLoaderTests { ...@@ -182,8 +179,8 @@ public class RestartClassLoaderTests {
byte[] bytes = "abc".getBytes(); byte[] bytes = "abc".getBytes();
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, bytes)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, bytes));
List<URL> resources = toList(this.reloadClassLoader.getResources(name)); List<URL> resources = toList(this.reloadClassLoader.getResources(name));
assertThat(FileCopyUtils.copyToByteArray(resources.get(0).openStream()), assertThat(FileCopyUtils.copyToByteArray(resources.get(0).openStream()))
equalTo(bytes)); .isEqualTo(bytes);
} }
@Test @Test
...@@ -209,8 +206,7 @@ public class RestartClassLoaderTests { ...@@ -209,8 +206,7 @@ public class RestartClassLoaderTests {
.copyToByteArray(getClass().getResourceAsStream("SampleParent.class")); .copyToByteArray(getClass().getResourceAsStream("SampleParent.class"));
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.ADDED, bytes)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.ADDED, bytes));
Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".SampleParent"); Class<?> loaded = this.reloadClassLoader.loadClass(PACKAGE + ".SampleParent");
assertThat(loaded.getClassLoader(), assertThat(loaded.getClassLoader()).isEqualTo(this.reloadClassLoader);
equalTo((ClassLoader) this.reloadClassLoader));
} }
private String readString(InputStream in) throws IOException { private String readString(InputStream in) throws IOException {
......
...@@ -24,8 +24,7 @@ import java.util.List; ...@@ -24,8 +24,7 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link DefaultSourceFolderUrlFilter}. * Tests for {@link DefaultSourceFolderUrlFilter}.
...@@ -76,14 +75,14 @@ public class DefaultSourceFolderUrlFilterTests { ...@@ -76,14 +75,14 @@ public class DefaultSourceFolderUrlFilterTests {
+ "spring-boot-sample-devtools"; + "spring-boot-sample-devtools";
URL jarUrl = new URL("jar:file:/Users/me/tmp/" URL jarUrl = new URL("jar:file:/Users/me/tmp/"
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/"); + "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/");
assertThat(this.filter.isMatch(sourceFolder, jarUrl), equalTo(true)); assertThat(this.filter.isMatch(sourceFolder, jarUrl)).isTrue();
URL nestedJarUrl = new URL("jar:file:/Users/me/tmp/" URL nestedJarUrl = new URL("jar:file:/Users/me/tmp/"
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/" + "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/"
+ "lib/spring-boot-1.3.0.BUILD-SNAPSHOT.jar!/"); + "lib/spring-boot-1.3.0.BUILD-SNAPSHOT.jar!/");
assertThat(this.filter.isMatch(sourceFolder, nestedJarUrl), equalTo(false)); assertThat(this.filter.isMatch(sourceFolder, nestedJarUrl)).isFalse();
URL fileUrl = new URL("file:/Users/me/tmp/" URL fileUrl = new URL("file:/Users/me/tmp/"
+ "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar"); + "spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar");
assertThat(this.filter.isMatch(sourceFolder, fileUrl), equalTo(true)); assertThat(this.filter.isMatch(sourceFolder, fileUrl)).isTrue();
} }
private void doTest(String sourcePostfix) throws MalformedURLException { private void doTest(String sourcePostfix) throws MalformedURLException {
...@@ -99,7 +98,8 @@ public class DefaultSourceFolderUrlFilterTests { ...@@ -99,7 +98,8 @@ public class DefaultSourceFolderUrlFilterTests {
for (String postfix : COMMON_POSTFIXES) { for (String postfix : COMMON_POSTFIXES) {
for (URL url : getUrls(moduleRoot + postfix)) { for (URL url : getUrls(moduleRoot + postfix)) {
boolean match = this.filter.isMatch(sourceFolder, url); boolean match = this.filter.isMatch(sourceFolder, url);
assertThat(url + " against " + sourceFolder, match, equalTo(expected)); assertThat(match).as(url + " against " + sourceFolder)
.isEqualTo(expected);
} }
} }
} }
......
...@@ -37,9 +37,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -37,9 +37,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
...@@ -92,8 +90,8 @@ public class HttpRestartServerTests { ...@@ -92,8 +90,8 @@ public class HttpRestartServerTests {
this.server.handle(new ServletServerHttpRequest(request), this.server.handle(new ServletServerHttpRequest(request),
new ServletServerHttpResponse(response)); new ServletServerHttpResponse(response));
verify(this.delegate).updateAndRestart(this.filesCaptor.capture()); verify(this.delegate).updateAndRestart(this.filesCaptor.capture());
assertThat(this.filesCaptor.getValue().getFile("name"), notNullValue()); assertThat(this.filesCaptor.getValue().getFile("name")).isNotNull();
assertThat(response.getStatus(), equalTo(200)); assertThat(response.getStatus()).isEqualTo(200);
} }
@Test @Test
...@@ -103,7 +101,7 @@ public class HttpRestartServerTests { ...@@ -103,7 +101,7 @@ public class HttpRestartServerTests {
this.server.handle(new ServletServerHttpRequest(request), this.server.handle(new ServletServerHttpRequest(request),
new ServletServerHttpResponse(response)); new ServletServerHttpResponse(response));
verifyZeroInteractions(this.delegate); verifyZeroInteractions(this.delegate);
assertThat(response.getStatus(), equalTo(500)); assertThat(response.getStatus()).isEqualTo(500);
} }
...@@ -115,7 +113,7 @@ public class HttpRestartServerTests { ...@@ -115,7 +113,7 @@ public class HttpRestartServerTests {
this.server.handle(new ServletServerHttpRequest(request), this.server.handle(new ServletServerHttpRequest(request),
new ServletServerHttpResponse(response)); new ServletServerHttpResponse(response));
verifyZeroInteractions(this.delegate); verifyZeroInteractions(this.delegate);
assertThat(response.getStatus(), equalTo(500)); assertThat(response.getStatus()).isEqualTo(500);
} }
private byte[] serialize(Object object) throws IOException { private byte[] serialize(Object object) throws IOException {
......
...@@ -34,9 +34,7 @@ import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kin ...@@ -34,9 +34,7 @@ import org.springframework.boot.devtools.restart.classloader.ClassLoaderFile.Kin
import org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles; import org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link RestartServer}. * Tests for {@link RestartServer}.
...@@ -76,8 +74,8 @@ public class RestartServerTests { ...@@ -76,8 +74,8 @@ public class RestartServerTests {
files.addFile("my/module-c", "ClassB.class", fileB); files.addFile("my/module-c", "ClassB.class", fileB);
server.updateAndRestart(files); server.updateAndRestart(files);
Set<URL> expectedUrls = new LinkedHashSet<URL>(Arrays.asList(url1, url3)); Set<URL> expectedUrls = new LinkedHashSet<URL>(Arrays.asList(url1, url3));
assertThat(server.restartUrls, equalTo(expectedUrls)); assertThat(server.restartUrls).isEqualTo(expectedUrls);
assertThat(server.restartFiles, equalTo(files)); assertThat(server.restartFiles).isEqualTo(files);
} }
@Test @Test
...@@ -95,7 +93,7 @@ public class RestartServerTests { ...@@ -95,7 +93,7 @@ public class RestartServerTests {
ClassLoaderFile fileA = new ClassLoaderFile(Kind.ADDED, new byte[0]); ClassLoaderFile fileA = new ClassLoaderFile(Kind.ADDED, new byte[0]);
files.addFile("my/module-a", "ClassA.class", fileA); files.addFile("my/module-a", "ClassA.class", fileA);
server.updateAndRestart(files); server.updateAndRestart(files);
assertThat(jarFile.lastModified(), greaterThan(startTime - 1000)); assertThat(jarFile.lastModified()).isGreaterThan(startTime - 1000);
} }
@Test @Test
...@@ -114,7 +112,7 @@ public class RestartServerTests { ...@@ -114,7 +112,7 @@ public class RestartServerTests {
ClassLoaderFile fileA = new ClassLoaderFile(Kind.ADDED, "def".getBytes()); ClassLoaderFile fileA = new ClassLoaderFile(Kind.ADDED, "def".getBytes());
files.addFile("my/module-a", "ClassA.class", fileA); files.addFile("my/module-a", "ClassA.class", fileA);
server.updateAndRestart(files); server.updateAndRestart(files);
assertThat(FileCopyUtils.copyToByteArray(classFile), equalTo("def".getBytes())); assertThat(FileCopyUtils.copyToByteArray(classFile)).isEqualTo("def".getBytes());
} }
private static class MockRestartServer extends RestartServer { private static class MockRestartServer extends RestartServer {
......
...@@ -24,9 +24,7 @@ import org.junit.Rule; ...@@ -24,9 +24,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/** /**
* Tests for {@link DevToolsSettings}. * Tests for {@link DevToolsSettings}.
...@@ -45,28 +43,30 @@ public class DevToolsSettingsTests { ...@@ -45,28 +43,30 @@ public class DevToolsSettingsTests {
public void includePatterns() throws Exception { public void includePatterns() throws Exception {
DevToolsSettings settings = DevToolsSettings DevToolsSettings settings = DevToolsSettings
.load(ROOT + "spring-devtools-include.properties"); .load(ROOT + "spring-devtools-include.properties");
assertThat(settings.isRestartInclude(new URL("file://test/a")), equalTo(true)); assertThat(settings.isRestartInclude(new URL("file://test/a"))).isTrue();
assertThat(settings.isRestartInclude(new URL("file://test/b")), equalTo(true)); assertThat(settings.isRestartInclude(new URL("file://test/b"))).isTrue();
assertThat(settings.isRestartInclude(new URL("file://test/c")), equalTo(false)); assertThat(settings.isRestartInclude(new URL("file://test/c"))).isFalse();
} }
@Test @Test
public void excludePatterns() throws Exception { public void excludePatterns() throws Exception {
DevToolsSettings settings = DevToolsSettings DevToolsSettings settings = DevToolsSettings
.load(ROOT + "spring-devtools-exclude.properties"); .load(ROOT + "spring-devtools-exclude.properties");
assertThat(settings.isRestartExclude(new URL("file://test/a")), equalTo(true)); assertThat(settings.isRestartExclude(new URL("file://test/a"))).isTrue();
assertThat(settings.isRestartExclude(new URL("file://test/b")), equalTo(true)); assertThat(settings.isRestartExclude(new URL("file://test/b"))).isTrue();
assertThat(settings.isRestartExclude(new URL("file://test/c")), equalTo(false)); assertThat(settings.isRestartExclude(new URL("file://test/c"))).isFalse();
} }
@Test @Test
public void defaultIncludePatterns() throws Exception { public void defaultIncludePatterns() throws Exception {
DevToolsSettings settings = DevToolsSettings.get(); DevToolsSettings settings = DevToolsSettings.get();
assertTrue(settings.isRestartExclude(makeUrl("spring-boot"))); assertThat(settings.isRestartExclude(makeUrl("spring-boot"))).isTrue();
assertTrue(settings.isRestartExclude(makeUrl("spring-boot-autoconfigure"))); assertThat(settings.isRestartExclude(makeUrl("spring-boot-autoconfigure")))
assertTrue(settings.isRestartExclude(makeUrl("spring-boot-actuator"))); .isTrue();
assertTrue(settings.isRestartExclude(makeUrl("spring-boot-starter"))); assertThat(settings.isRestartExclude(makeUrl("spring-boot-actuator"))).isTrue();
assertTrue(settings.isRestartExclude(makeUrl("spring-boot-starter-some-thing"))); assertThat(settings.isRestartExclude(makeUrl("spring-boot-starter"))).isTrue();
assertThat(settings.isRestartExclude(makeUrl("spring-boot-starter-some-thing")))
.isTrue();
} }
private URL makeUrl(String name) throws IOException { private URL makeUrl(String name) throws IOException {
......
...@@ -36,9 +36,7 @@ import org.springframework.boot.devtools.tunnel.client.HttpTunnelConnection.Tunn ...@@ -36,9 +36,7 @@ import org.springframework.boot.devtools.tunnel.client.HttpTunnelConnection.Tunn
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -107,9 +105,9 @@ public class HttpTunnelConnectionTests { ...@@ -107,9 +105,9 @@ public class HttpTunnelConnectionTests {
public void closeTunnelChangesIsOpen() throws Exception { public void closeTunnelChangesIsOpen() throws Exception {
this.requestFactory.willRespondAfterDelay(1000, HttpStatus.GONE); this.requestFactory.willRespondAfterDelay(1000, HttpStatus.GONE);
WritableByteChannel channel = openTunnel(false); WritableByteChannel channel = openTunnel(false);
assertThat(channel.isOpen(), equalTo(true)); assertThat(channel.isOpen()).isTrue();
channel.close(); channel.close();
assertThat(channel.isOpen(), equalTo(false)); assertThat(channel.isOpen()).isFalse();
} }
@Test @Test
...@@ -129,7 +127,7 @@ public class HttpTunnelConnectionTests { ...@@ -129,7 +127,7 @@ public class HttpTunnelConnectionTests {
write(channel, "hello"); write(channel, "hello");
write(channel, "1+1"); write(channel, "1+1");
write(channel, "1+2"); write(channel, "1+2");
assertThat(this.incomingData.toString(), equalTo("hi=2=3")); assertThat(this.incomingData.toString()).isEqualTo("hi=2=3");
} }
@Test @Test
...@@ -140,8 +138,8 @@ public class HttpTunnelConnectionTests { ...@@ -140,8 +138,8 @@ public class HttpTunnelConnectionTests {
this.requestFactory.willRespond("hi"); this.requestFactory.willRespond("hi");
TunnelChannel channel = openTunnel(true); TunnelChannel channel = openTunnel(true);
write(channel, "hello"); write(channel, "hello");
assertThat(this.incomingData.toString(), equalTo("hi")); assertThat(this.incomingData.toString()).isEqualTo("hi");
assertThat(this.requestFactory.getExecutedRequests().size(), greaterThan(10)); assertThat(this.requestFactory.getExecutedRequests().size()).isGreaterThan(10);
} }
private void write(TunnelChannel channel, String string) throws IOException { private void write(TunnelChannel channel, String string) throws IOException {
......
...@@ -31,8 +31,7 @@ import org.junit.rules.ExpectedException; ...@@ -31,8 +31,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -76,7 +75,7 @@ public class TunnelClientTests { ...@@ -76,7 +75,7 @@ public class TunnelClientTests {
channel.read(buffer); channel.read(buffer);
channel.close(); channel.close();
this.tunnelConnection.verifyWritten("hello"); this.tunnelConnection.verifyWritten("hello");
assertThat(new String(buffer.array()), equalTo("olleh")); assertThat(new String(buffer.array())).isEqualTo("olleh");
} }
@Test @Test
...@@ -89,8 +88,8 @@ public class TunnelClientTests { ...@@ -89,8 +88,8 @@ public class TunnelClientTests {
channel.close(); channel.close();
client.getServerThread().stopAcceptingConnections(); client.getServerThread().stopAcceptingConnections();
client.getServerThread().join(2000); client.getServerThread().join(2000);
assertThat(this.tunnelConnection.getOpenedTimes(), equalTo(1)); assertThat(this.tunnelConnection.getOpenedTimes()).isEqualTo(1);
assertThat(this.tunnelConnection.isOpen(), equalTo(false)); assertThat(this.tunnelConnection.isOpen()).isFalse();
} }
@Test @Test
...@@ -101,9 +100,9 @@ public class TunnelClientTests { ...@@ -101,9 +100,9 @@ public class TunnelClientTests {
.open(new InetSocketAddress(this.listenPort)); .open(new InetSocketAddress(this.listenPort));
Thread.sleep(200); Thread.sleep(200);
client.stop(); client.stop();
assertThat(this.tunnelConnection.getOpenedTimes(), equalTo(1)); assertThat(this.tunnelConnection.getOpenedTimes()).isEqualTo(1);
assertThat(this.tunnelConnection.isOpen(), equalTo(false)); assertThat(this.tunnelConnection.isOpen()).isFalse();
assertThat(channel.read(ByteBuffer.allocate(1)), equalTo(-1)); assertThat(channel.read(ByteBuffer.allocate(1))).isEqualTo(-1);
} }
@Test @Test
...@@ -144,7 +143,7 @@ public class TunnelClientTests { ...@@ -144,7 +143,7 @@ public class TunnelClientTests {
public void verifyWritten(byte[] expected) { public void verifyWritten(byte[] expected) {
synchronized (this.written) { synchronized (this.written) {
assertThat(this.written.toByteArray(), equalTo(expected)); assertThat(this.written.toByteArray()).isEqualTo(expected);
this.written.reset(); this.written.reset();
} }
} }
......
...@@ -25,8 +25,7 @@ import org.junit.Rule; ...@@ -25,8 +25,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link HttpTunnelPayloadForwarder}. * Tests for {@link HttpTunnelPayloadForwarder}.
...@@ -53,7 +52,7 @@ public class HttpTunnelPayloadForwarderTests { ...@@ -53,7 +52,7 @@ public class HttpTunnelPayloadForwarderTests {
forwarder.forward(payload(1, "he")); forwarder.forward(payload(1, "he"));
forwarder.forward(payload(2, "ll")); forwarder.forward(payload(2, "ll"));
forwarder.forward(payload(3, "o")); forwarder.forward(payload(3, "o"));
assertThat(out.toByteArray(), equalTo("hello".getBytes())); assertThat(out.toByteArray()).isEqualTo("hello".getBytes());
} }
@Test @Test
...@@ -64,7 +63,7 @@ public class HttpTunnelPayloadForwarderTests { ...@@ -64,7 +63,7 @@ public class HttpTunnelPayloadForwarderTests {
forwarder.forward(payload(3, "o")); forwarder.forward(payload(3, "o"));
forwarder.forward(payload(2, "ll")); forwarder.forward(payload(2, "ll"));
forwarder.forward(payload(1, "he")); forwarder.forward(payload(1, "he"));
assertThat(out.toByteArray(), equalTo("hello".getBytes())); assertThat(out.toByteArray()).isEqualTo("hello".getBytes());
} }
@Test @Test
......
...@@ -36,9 +36,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -36,9 +36,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -70,14 +68,14 @@ public class HttpTunnelPayloadTests { ...@@ -70,14 +68,14 @@ public class HttpTunnelPayloadTests {
@Test @Test
public void getSequence() throws Exception { public void getSequence() throws Exception {
HttpTunnelPayload payload = new HttpTunnelPayload(1, ByteBuffer.allocate(1)); HttpTunnelPayload payload = new HttpTunnelPayload(1, ByteBuffer.allocate(1));
assertThat(payload.getSequence(), equalTo(1L)); assertThat(payload.getSequence()).isEqualTo(1L);
} }
@Test @Test
public void getData() throws Exception { public void getData() throws Exception {
ByteBuffer data = ByteBuffer.wrap("hello".getBytes()); ByteBuffer data = ByteBuffer.wrap("hello".getBytes());
HttpTunnelPayload payload = new HttpTunnelPayload(1, data); HttpTunnelPayload payload = new HttpTunnelPayload(1, data);
assertThat(getData(payload), equalTo(data.array())); assertThat(getData(payload)).isEqualTo(data.array());
} }
@Test @Test
...@@ -87,8 +85,8 @@ public class HttpTunnelPayloadTests { ...@@ -87,8 +85,8 @@ public class HttpTunnelPayloadTests {
MockHttpServletResponse servletResponse = new MockHttpServletResponse(); MockHttpServletResponse servletResponse = new MockHttpServletResponse();
HttpOutputMessage response = new ServletServerHttpResponse(servletResponse); HttpOutputMessage response = new ServletServerHttpResponse(servletResponse);
payload.assignTo(response); payload.assignTo(response);
assertThat(servletResponse.getHeader("x-seq"), equalTo("2")); assertThat(servletResponse.getHeader("x-seq")).isEqualTo("2");
assertThat(servletResponse.getContentAsString(), equalTo("hello")); assertThat(servletResponse.getContentAsString()).isEqualTo("hello");
} }
@Test @Test
...@@ -96,7 +94,7 @@ public class HttpTunnelPayloadTests { ...@@ -96,7 +94,7 @@ public class HttpTunnelPayloadTests {
MockHttpServletRequest servletRequest = new MockHttpServletRequest(); MockHttpServletRequest servletRequest = new MockHttpServletRequest();
HttpInputMessage request = new ServletServerHttpRequest(servletRequest); HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
HttpTunnelPayload payload = HttpTunnelPayload.get(request); HttpTunnelPayload payload = HttpTunnelPayload.get(request);
assertThat(payload, nullValue()); assertThat(payload).isNull();
} }
@Test @Test
...@@ -116,8 +114,8 @@ public class HttpTunnelPayloadTests { ...@@ -116,8 +114,8 @@ public class HttpTunnelPayloadTests {
servletRequest.addHeader("x-seq", 123); servletRequest.addHeader("x-seq", 123);
HttpInputMessage request = new ServletServerHttpRequest(servletRequest); HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
HttpTunnelPayload payload = HttpTunnelPayload.get(request); HttpTunnelPayload payload = HttpTunnelPayload.get(request);
assertThat(payload.getSequence(), equalTo(123L)); assertThat(payload.getSequence()).isEqualTo(123L);
assertThat(getData(payload), equalTo("hello".getBytes())); assertThat(getData(payload)).isEqualTo("hello".getBytes());
} }
@Test @Test
...@@ -130,7 +128,7 @@ public class HttpTunnelPayloadTests { ...@@ -130,7 +128,7 @@ public class HttpTunnelPayloadTests {
while (payloadData.hasRemaining()) { while (payloadData.hasRemaining()) {
writeChannel.write(payloadData); writeChannel.write(payloadData);
} }
assertThat(out.toByteArray(), equalTo("hello".getBytes())); assertThat(out.toByteArray()).isEqualTo("hello".getBytes());
} }
@Test @Test
...@@ -139,7 +137,7 @@ public class HttpTunnelPayloadTests { ...@@ -139,7 +137,7 @@ public class HttpTunnelPayloadTests {
given(channel.read(any(ByteBuffer.class))) given(channel.read(any(ByteBuffer.class)))
.willThrow(new SocketTimeoutException()); .willThrow(new SocketTimeoutException());
ByteBuffer payload = HttpTunnelPayload.getPayloadData(channel); ByteBuffer payload = HttpTunnelPayload.getPayloadData(channel);
assertThat(payload, nullValue()); assertThat(payload).isNull();
} }
private byte[] getData(HttpTunnelPayload payload) throws IOException { private byte[] getData(HttpTunnelPayload payload) throws IOException {
......
...@@ -47,8 +47,7 @@ import org.springframework.http.server.ServletServerHttpResponse; ...@@ -47,8 +47,7 @@ import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -154,7 +153,7 @@ public class HttpTunnelServerTests { ...@@ -154,7 +153,7 @@ public class HttpTunnelServerTests {
this.serverChannel.send("hello"); this.serverChannel.send("hello");
this.serverChannel.disconnect(); this.serverChannel.disconnect();
this.server.getServerThread().join(); this.server.getServerThread().join();
assertThat(this.servletResponse.getContentAsString(), equalTo("hello")); assertThat(this.servletResponse.getContentAsString()).isEqualTo("hello");
this.serverChannel.verifyReceived("hello"); this.serverChannel.verifyReceived("hello");
} }
...@@ -193,7 +192,7 @@ public class HttpTunnelServerTests { ...@@ -193,7 +192,7 @@ public class HttpTunnelServerTests {
this.server.handle(h1); this.server.handle(h1);
this.serverChannel.disconnect(); this.serverChannel.disconnect();
this.server.getServerThread().join(); this.server.getServerThread().join();
assertThat(h1.getServletResponse().getStatus(), equalTo(410)); assertThat(h1.getServletResponse().getStatus()).isEqualTo(410);
} }
@Test @Test
...@@ -204,8 +203,8 @@ public class HttpTunnelServerTests { ...@@ -204,8 +203,8 @@ public class HttpTunnelServerTests {
h2.getServletRequest().addHeader("Content-Type", "application/x-disconnect"); h2.getServletRequest().addHeader("Content-Type", "application/x-disconnect");
this.server.handle(h2); this.server.handle(h2);
this.server.getServerThread().join(); this.server.getServerThread().join();
assertThat(h1.getServletResponse().getStatus(), equalTo(410)); assertThat(h1.getServletResponse().getStatus()).isEqualTo(410);
assertThat(this.serverChannel.isOpen(), equalTo(false)); assertThat(this.serverChannel.isOpen()).isFalse();
} }
@Test @Test
...@@ -217,7 +216,7 @@ public class HttpTunnelServerTests { ...@@ -217,7 +216,7 @@ public class HttpTunnelServerTests {
MockHttpConnection h3 = new MockHttpConnection("2", 3); MockHttpConnection h3 = new MockHttpConnection("2", 3);
this.server.handle(h3); this.server.handle(h3);
h1.waitForResponse(); h1.waitForResponse();
assertThat(h1.getServletResponse().getStatus(), equalTo(429)); assertThat(h1.getServletResponse().getStatus()).isEqualTo(429);
this.serverChannel.disconnect(); this.serverChannel.disconnect();
this.server.getServerThread().join(); this.server.getServerThread().join();
} }
...@@ -246,8 +245,8 @@ public class HttpTunnelServerTests { ...@@ -246,8 +245,8 @@ public class HttpTunnelServerTests {
Thread.sleep(400); Thread.sleep(400);
this.serverChannel.disconnect(); this.serverChannel.disconnect();
this.server.getServerThread().join(); this.server.getServerThread().join();
assertThat(h1.getServletResponse().getStatus(), equalTo(204)); assertThat(h1.getServletResponse().getStatus()).isEqualTo(204);
assertThat(h2.getServletResponse().getStatus(), equalTo(204)); assertThat(h2.getServletResponse().getStatus()).isEqualTo(204);
} }
@Test @Test
...@@ -258,7 +257,7 @@ public class HttpTunnelServerTests { ...@@ -258,7 +257,7 @@ public class HttpTunnelServerTests {
this.server.handle(h1); this.server.handle(h1);
this.serverChannel.send("hello"); this.serverChannel.send("hello");
this.server.getServerThread().join(); this.server.getServerThread().join();
assertThat(this.serverChannel.isOpen(), equalTo(false)); assertThat(this.serverChannel.isOpen()).isFalse();
} }
@Test @Test
...@@ -273,9 +272,9 @@ public class HttpTunnelServerTests { ...@@ -273,9 +272,9 @@ public class HttpTunnelServerTests {
HttpConnection connection = new HttpConnection(this.request, this.response); HttpConnection connection = new HttpConnection(this.request, this.response);
connection.waitForResponse(); connection.waitForResponse();
connection.respond(new HttpTunnelPayload(1, ByteBuffer.wrap("hello".getBytes()))); connection.respond(new HttpTunnelPayload(1, ByteBuffer.wrap("hello".getBytes())));
assertThat(this.servletResponse.getStatus(), equalTo(200)); assertThat(this.servletResponse.getStatus()).isEqualTo(200);
assertThat(this.servletResponse.getContentAsString(), equalTo("hello")); assertThat(this.servletResponse.getContentAsString()).isEqualTo("hello");
assertThat(this.servletResponse.getHeader(SEQ_HEADER), equalTo("1")); assertThat(this.servletResponse.getHeader(SEQ_HEADER)).isEqualTo("1");
} }
@Test @Test
...@@ -283,8 +282,8 @@ public class HttpTunnelServerTests { ...@@ -283,8 +282,8 @@ public class HttpTunnelServerTests {
HttpConnection connection = new HttpConnection(this.request, this.response); HttpConnection connection = new HttpConnection(this.request, this.response);
connection.waitForResponse(); connection.waitForResponse();
connection.respond(HttpStatus.I_AM_A_TEAPOT); connection.respond(HttpStatus.I_AM_A_TEAPOT);
assertThat(this.servletResponse.getStatus(), equalTo(418)); assertThat(this.servletResponse.getStatus()).isEqualTo(418);
assertThat(this.servletResponse.getContentLength(), equalTo(0)); assertThat(this.servletResponse.getContentLength()).isEqualTo(0);
} }
@Test @Test
...@@ -322,19 +321,19 @@ public class HttpTunnelServerTests { ...@@ -322,19 +321,19 @@ public class HttpTunnelServerTests {
}; };
connectionThread.start(); connectionThread.start();
assertThat(responded.get(), equalTo(false)); assertThat(responded.get()).isFalse();
Thread.sleep(sleepBeforeResponse); Thread.sleep(sleepBeforeResponse);
connection.respond(HttpStatus.NO_CONTENT); connection.respond(HttpStatus.NO_CONTENT);
connectionThread.join(); connectionThread.join();
assertThat(responded.get(), equalTo(true)); assertThat(responded.get()).isTrue();
} }
@Test @Test
public void httpConnectionRunning() throws Exception { public void httpConnectionRunning() throws Exception {
HttpConnection connection = new HttpConnection(this.request, this.response); HttpConnection connection = new HttpConnection(this.request, this.response);
assertThat(connection.isOlderThan(100), equalTo(false)); assertThat(connection.isOlderThan(100)).isFalse();
Thread.sleep(200); Thread.sleep(200);
assertThat(connection.isOlderThan(100), equalTo(true)); assertThat(connection.isOlderThan(100)).isTrue();
} }
/** /**
...@@ -374,7 +373,7 @@ public class HttpTunnelServerTests { ...@@ -374,7 +373,7 @@ public class HttpTunnelServerTests {
public void verifyReceived(byte[] expected) { public void verifyReceived(byte[] expected) {
synchronized (this.written) { synchronized (this.written) {
assertThat(this.written.toByteArray(), equalTo(expected)); assertThat(this.written.toByteArray()).isEqualTo(expected);
this.written.reset(); this.written.reset();
} }
} }
...@@ -466,8 +465,8 @@ public class HttpTunnelServerTests { ...@@ -466,8 +465,8 @@ public class HttpTunnelServerTests {
throws Exception { throws Exception {
waitForServletResponse(); waitForServletResponse();
MockHttpServletResponse resp = getServletResponse(); MockHttpServletResponse resp = getServletResponse();
assertThat(resp.getContentAsString(), equalTo(expectedContent)); assertThat(resp.getContentAsString()).isEqualTo(expectedContent);
assertThat(resp.getHeader(SEQ_HEADER), equalTo(String.valueOf(expectedSeq))); assertThat(resp.getHeader(SEQ_HEADER)).isEqualTo(String.valueOf(expectedSeq));
} }
public void waitForServletResponse() throws InterruptedException { public void waitForServletResponse() throws InterruptedException {
......
...@@ -29,10 +29,7 @@ import org.junit.Test; ...@@ -29,10 +29,7 @@ import org.junit.Test;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
/** /**
...@@ -65,7 +62,7 @@ public class SocketTargetServerConnectionTests { ...@@ -65,7 +62,7 @@ public class SocketTargetServerConnectionTests {
ByteChannel channel = this.connection.open(DEFAULT_TIMEOUT); ByteChannel channel = this.connection.open(DEFAULT_TIMEOUT);
ByteBuffer buffer = ByteBuffer.allocate(5); ByteBuffer buffer = ByteBuffer.allocate(5);
channel.read(buffer); channel.read(buffer);
assertThat(buffer.array(), equalTo("hello".getBytes())); assertThat(buffer.array()).isEqualTo("hello".getBytes());
} }
@Test @Test
...@@ -91,8 +88,8 @@ public class SocketTargetServerConnectionTests { ...@@ -91,8 +88,8 @@ public class SocketTargetServerConnectionTests {
catch (SocketTimeoutException ex) { catch (SocketTimeoutException ex) {
// Expected // Expected
long runTime = System.currentTimeMillis() - startTime; long runTime = System.currentTimeMillis() - startTime;
assertThat(runTime, greaterThanOrEqualTo(10L)); assertThat(runTime).isGreaterThanOrEqualTo(10L);
assertThat(runTime, lessThan(10000L)); assertThat(runTime).isLessThan(10000L);
} }
} }
...@@ -134,7 +131,7 @@ public class SocketTargetServerConnectionTests { ...@@ -134,7 +131,7 @@ public class SocketTargetServerConnectionTests {
public void closeAndVerify() throws InterruptedException { public void closeAndVerify() throws InterruptedException {
close(); close();
assertThat(this.actualRead.array(), equalTo(this.expect)); assertThat(this.actualRead.array()).isEqualTo(this.expect);
} }
public void close() throws InterruptedException { public void close() throws InterruptedException {
......
...@@ -20,8 +20,7 @@ import org.junit.Rule; ...@@ -20,8 +20,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import static org.hamcrest.Matchers.equalTo; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThat;
/** /**
* Tests for {@link StaticPortProvider}. * Tests for {@link StaticPortProvider}.
...@@ -43,7 +42,7 @@ public class StaticPortProviderTests { ...@@ -43,7 +42,7 @@ public class StaticPortProviderTests {
@Test @Test
public void getPort() throws Exception { public void getPort() throws Exception {
StaticPortProvider provider = new StaticPortProvider(123); StaticPortProvider provider = new StaticPortProvider(123);
assertThat(provider.getPort(), equalTo(123)); assertThat(provider.getPort()).isEqualTo(123);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment