Polish
This commit is contained in:
@@ -47,14 +47,14 @@ public class RemoteUrlPropertyExtractorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingUrl() throws Exception {
|
||||
public void missingUrl() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("No remote URL specified");
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void malformedUrl() throws Exception {
|
||||
public void malformedUrl() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("Malformed URL '::://wibble'");
|
||||
doTest("::://wibble");
|
||||
@@ -62,14 +62,14 @@ public class RemoteUrlPropertyExtractorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleUrls() throws Exception {
|
||||
public void multipleUrls() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("Multiple URLs specified");
|
||||
doTest("http://localhost:8080", "http://localhost:9090");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validUrl() throws Exception {
|
||||
public void validUrl() {
|
||||
ApplicationContext context = doTest("http://localhost:8080");
|
||||
assertThat(context.getEnvironment().getProperty("remoteUrl"))
|
||||
.isEqualTo("http://localhost:8080");
|
||||
@@ -78,7 +78,7 @@ public class RemoteUrlPropertyExtractorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanValidUrl() throws Exception {
|
||||
public void cleanValidUrl() {
|
||||
ApplicationContext context = doTest("http://localhost:8080/");
|
||||
assertThat(context.getEnvironment().getProperty("remoteUrl"))
|
||||
.isEqualTo("http://localhost:8080");
|
||||
|
||||
@@ -86,7 +86,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void thymeleafCacheIsFalse() throws Exception {
|
||||
public void thymeleafCacheIsFalse() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
SpringResourceTemplateResolver resolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
@@ -94,7 +94,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPropertyCanBeOverriddenFromCommandLine() throws Exception {
|
||||
public void defaultPropertyCanBeOverriddenFromCommandLine() {
|
||||
this.context = initializeAndRun(Config.class, "--spring.thymeleaf.cache=true");
|
||||
SpringResourceTemplateResolver resolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
@@ -102,7 +102,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPropertyCanBeOverriddenFromUserHomeProperties() throws Exception {
|
||||
public void defaultPropertyCanBeOverriddenFromUserHomeProperties() {
|
||||
String userHome = System.getProperty("user.home");
|
||||
System.setProperty("user.home",
|
||||
new File("src/test/resources/user-home").getAbsolutePath());
|
||||
@@ -118,21 +118,21 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceCachePeriodIsZero() throws Exception {
|
||||
public void resourceCachePeriodIsZero() {
|
||||
this.context = initializeAndRun(WebResourcesConfig.class);
|
||||
ResourceProperties properties = this.context.getBean(ResourceProperties.class);
|
||||
assertThat(properties.getCache().getPeriod()).isEqualTo(Duration.ZERO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadServer() throws Exception {
|
||||
public void liveReloadServer() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
assertThat(server.isStarted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadTriggeredOnContextRefresh() throws Exception {
|
||||
public void liveReloadTriggeredOnContextRefresh() {
|
||||
this.context = initializeAndRun(ConfigWithMockLiveReload.class);
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
@@ -141,7 +141,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
|
||||
public void liveReloadTriggeredOnClassPathChangeWithoutRestart() {
|
||||
this.context = initializeAndRun(ConfigWithMockLiveReload.class);
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
@@ -152,7 +152,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
|
||||
public void liveReloadNotTriggeredOnClassPathChangeWithRestart() {
|
||||
this.context = initializeAndRun(ConfigWithMockLiveReload.class);
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
@@ -163,7 +163,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadDisabled() throws Exception {
|
||||
public void liveReloadDisabled() {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.livereload.enabled", false);
|
||||
this.context = initializeAndRun(Config.class, properties);
|
||||
@@ -172,7 +172,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartTriggeredOnClassPathChangeWithRestart() throws Exception {
|
||||
public void restartTriggeredOnClassPathChangeWithRestart() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
|
||||
Collections.emptySet(), true);
|
||||
@@ -181,7 +181,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartNotTriggeredOnClassPathChangeWithRestart() throws Exception {
|
||||
public void restartNotTriggeredOnClassPathChangeWithRestart() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context,
|
||||
Collections.emptySet(), false);
|
||||
@@ -190,7 +190,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartWatchingClassPath() throws Exception {
|
||||
public void restartWatchingClassPath() {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
ClassPathFileSystemWatcher watcher = this.context
|
||||
.getBean(ClassPathFileSystemWatcher.class);
|
||||
@@ -198,7 +198,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartDisabled() throws Exception {
|
||||
public void restartDisabled() {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.restart.enabled", false);
|
||||
this.context = initializeAndRun(Config.class, properties);
|
||||
@@ -207,7 +207,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartWithTriggerFile() throws Exception {
|
||||
public void restartWithTriggerFile() {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.restart.trigger-file", "somefile.txt");
|
||||
this.context = initializeAndRun(Config.class, properties);
|
||||
@@ -220,7 +220,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void watchingAdditionalPaths() throws Exception {
|
||||
public void watchingAdditionalPaths() {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.restart.additional-paths",
|
||||
"src/main/java,src/test/java");
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.boot.devtools.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -88,7 +86,7 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledIfRemoteSecretIsMissing() throws Exception {
|
||||
public void disabledIfRemoteSecretIsMissing() {
|
||||
loadContext("a:b");
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
this.context.getBean(DispatcherFilter.class);
|
||||
@@ -145,7 +143,7 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableRestart() throws Exception {
|
||||
public void disableRestart() {
|
||||
loadContext("spring.devtools.remote.secret:supersecret",
|
||||
"spring.devtools.remote.restart.enabled:false");
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
@@ -211,8 +209,7 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ServerHttpRequest request, ServerHttpResponse response)
|
||||
throws IOException {
|
||||
public void handle(ServerHttpRequest request, ServerHttpResponse response) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -229,8 +226,7 @@ public class RemoteDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ServerHttpRequest request, ServerHttpResponse response)
|
||||
throws IOException {
|
||||
public void handle(ServerHttpRequest request, ServerHttpResponse response) {
|
||||
this.invoked = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TriggerFileFilterTests {
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void nameMustNotBeNull() throws Exception {
|
||||
public void nameMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Name must not be null");
|
||||
new TriggerFileFilter(null);
|
||||
|
||||
@@ -40,14 +40,14 @@ public class ClassPathChangedEventTests {
|
||||
private Object source = new Object();
|
||||
|
||||
@Test
|
||||
public void changeSetMustNotBeNull() throws Exception {
|
||||
public void changeSetMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ChangeSet must not be null");
|
||||
new ClassPathChangedEvent(this.source, null, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChangeSet() throws Exception {
|
||||
public void getChangeSet() {
|
||||
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.source, changeSet,
|
||||
false);
|
||||
@@ -55,7 +55,7 @@ public class ClassPathChangedEventTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRestartRequired() throws Exception {
|
||||
public void getRestartRequired() {
|
||||
Set<ChangedFiles> changeSet = new LinkedHashSet<>();
|
||||
ClassPathChangedEvent event;
|
||||
event = new ClassPathChangedEvent(this.source, changeSet, false);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ClassPathFileChangeListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventPublisherMustNotBeNull() throws Exception {
|
||||
public void eventPublisherMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("EventPublisher must not be null");
|
||||
new ClassPathFileChangeListener(null, this.restartStrategy,
|
||||
@@ -77,7 +77,7 @@ public class ClassPathFileChangeListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartStrategyMustNotBeNull() throws Exception {
|
||||
public void restartStrategyMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RestartStrategy must not be null");
|
||||
new ClassPathFileChangeListener(this.eventPublisher, null,
|
||||
@@ -85,13 +85,13 @@ public class ClassPathFileChangeListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendsEventWithoutRestart() throws Exception {
|
||||
public void sendsEventWithoutRestart() {
|
||||
testSendsEvent(false);
|
||||
verify(this.fileSystemWatcher, never()).stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendsEventWithRestart() throws Exception {
|
||||
public void sendsEventWithRestart() {
|
||||
testSendsEvent(true);
|
||||
verify(this.fileSystemWatcher).stop();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ClassPathFileSystemWatcherTests {
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void urlsMustNotBeNull() throws Exception {
|
||||
public void urlsMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Urls must not be null");
|
||||
URL[] urls = null;
|
||||
|
||||
@@ -34,19 +34,19 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class PatternClassPathRestartStrategyTests {
|
||||
|
||||
@Test
|
||||
public void nullPattern() throws Exception {
|
||||
public void nullPattern() {
|
||||
ClassPathRestartStrategy strategy = createStrategy(null);
|
||||
assertRestartRequired(strategy, "a/b.txt", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyPattern() throws Exception {
|
||||
public void emptyPattern() {
|
||||
ClassPathRestartStrategy strategy = createStrategy("");
|
||||
assertRestartRequired(strategy, "a/b.txt", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singlePattern() throws Exception {
|
||||
public void singlePattern() {
|
||||
ClassPathRestartStrategy strategy = createStrategy("static/**");
|
||||
assertRestartRequired(strategy, "static/file.txt", false);
|
||||
assertRestartRequired(strategy, "static/folder/file.txt", false);
|
||||
@@ -55,7 +55,7 @@ public class PatternClassPathRestartStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiplePatterns() throws Exception {
|
||||
public void multiplePatterns() {
|
||||
ClassPathRestartStrategy strategy = createStrategy("static/**,public/**");
|
||||
assertRestartRequired(strategy, "static/file.txt", false);
|
||||
assertRestartRequired(strategy, "static/folder/file.txt", false);
|
||||
@@ -66,7 +66,7 @@ public class PatternClassPathRestartStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pomChange() throws Exception {
|
||||
public void pomChange() {
|
||||
ClassPathRestartStrategy strategy = createStrategy("META-INF/maven/**");
|
||||
assertRestartRequired(strategy, "pom.xml", true);
|
||||
String mavenFolder = "META-INF/maven/org.springframework.boot/spring-boot-devtools";
|
||||
|
||||
@@ -79,8 +79,7 @@ public class DevToolPropertiesIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessWhenRestarterDisabledAndRemoteSecretNotSetShouldNotAddPropertySource()
|
||||
throws Exception {
|
||||
public void postProcessWhenRestarterDisabledAndRemoteSecretNotSetShouldNotAddPropertySource() {
|
||||
Restarter.clearInstance();
|
||||
Restarter.disable();
|
||||
SpringApplication application = new SpringApplication(
|
||||
@@ -92,8 +91,7 @@ public class DevToolPropertiesIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessWhenRestarterDisabledAndRemoteSecretSetShouldAddPropertySource()
|
||||
throws Exception {
|
||||
public void postProcessWhenRestarterDisabledAndRemoteSecretSetShouldAddPropertySource() {
|
||||
Restarter.clearInstance();
|
||||
Restarter.disable();
|
||||
SpringApplication application = new SpringApplication(
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DevToolsHomePropertiesPostProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoresMissingHomeProperties() throws Exception {
|
||||
public void ignoresMissingHomeProperties() {
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
MockDevToolHomePropertiesPostProcessor postProcessor = new MockDevToolHomePropertiesPostProcessor();
|
||||
postProcessor.postProcessEnvironment(environment, null);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FileSnapshotTests {
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void fileMustNotBeNull() throws Exception {
|
||||
public void fileMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("File must not be null");
|
||||
new FileSnapshot(null);
|
||||
|
||||
@@ -59,40 +59,40 @@ public class FileSystemWatcherTests {
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
setupWatcher(20, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollIntervalMustBePositive() throws Exception {
|
||||
public void pollIntervalMustBePositive() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PollInterval must be positive");
|
||||
new FileSystemWatcher(true, Duration.ofMillis(0), Duration.ofMillis(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quietPeriodMustBePositive() throws Exception {
|
||||
public void quietPeriodMustBePositive() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("QuietPeriod must be positive");
|
||||
new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollIntervalMustBeGreaterThanQuietPeriod() throws Exception {
|
||||
public void pollIntervalMustBeGreaterThanQuietPeriod() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PollInterval must be greater than QuietPeriod");
|
||||
new FileSystemWatcher(true, Duration.ofMillis(1), Duration.ofMillis(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerMustNotBeNull() throws Exception {
|
||||
public void listenerMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("FileChangeListener must not be null");
|
||||
this.watcher.addListener(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cannotAddListenerToStartedListener() throws Exception {
|
||||
public void cannotAddListenerToStartedListener() {
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("FileSystemWatcher already started");
|
||||
this.watcher.start();
|
||||
@@ -100,14 +100,14 @@ public class FileSystemWatcherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFolderMustNotBeNull() throws Exception {
|
||||
public void sourceFolderMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Folder must not be null");
|
||||
this.watcher.addSourceFolder(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFolderMustExist() throws Exception {
|
||||
public void sourceFolderMustExist() {
|
||||
File folder = new File("does/not/exist");
|
||||
assertThat(folder.exists()).isFalse();
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
@@ -117,7 +117,7 @@ public class FileSystemWatcherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFolderMustBeADirectory() throws Exception {
|
||||
public void sourceFolderMustBeADirectory() {
|
||||
File folder = new File("pom.xml");
|
||||
assertThat(folder.isFile()).isTrue();
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class FolderSnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsWhenNothingHasChanged() throws Exception {
|
||||
public void equalsWhenNothingHasChanged() {
|
||||
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
|
||||
assertThat(this.initialSnapshot).isEqualTo(updatedSnapshot);
|
||||
assertThat(this.initialSnapshot.hashCode()).isEqualTo(updatedSnapshot.hashCode());
|
||||
@@ -82,7 +82,7 @@ public class FolderSnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notEqualsWhenAFileIsDeleted() throws Exception {
|
||||
public void notEqualsWhenAFileIsDeleted() {
|
||||
new File(new File(this.folder, "folder1"), "file1").delete();
|
||||
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
|
||||
assertThat(this.initialSnapshot).isNotEqualTo(updatedSnapshot);
|
||||
@@ -97,7 +97,7 @@ public class FolderSnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChangedFilesSnapshotMustNotBeNull() throws Exception {
|
||||
public void getChangedFilesSnapshotMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Snapshot must not be null");
|
||||
this.initialSnapshot.getChangedFiles(null, null);
|
||||
@@ -112,7 +112,7 @@ public class FolderSnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChangedFilesWhenNothingHasChanged() throws Exception {
|
||||
public void getChangedFilesWhenNothingHasChanged() {
|
||||
FolderSnapshot updatedSnapshot = new FolderSnapshot(this.folder);
|
||||
this.initialSnapshot.getChangedFiles(updatedSnapshot, null);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class HttpTunnelIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void httpServerDirect() throws Exception {
|
||||
public void httpServerDirect() {
|
||||
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
context.register(ServerConfiguration.class);
|
||||
context.refresh();
|
||||
@@ -75,7 +75,7 @@ public class HttpTunnelIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void viaTunnel() throws Exception {
|
||||
public void viaTunnel() {
|
||||
AnnotationConfigServletWebServerApplicationContext serverContext = new AnnotationConfigServletWebServerApplicationContext();
|
||||
serverContext.register(ServerConfiguration.class);
|
||||
serverContext.refresh();
|
||||
|
||||
@@ -37,28 +37,28 @@ public class FrameTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void payloadMustNotBeNull() throws Exception {
|
||||
public void payloadMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Payload must not be null");
|
||||
new Frame((String) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeMustNotBeNull() throws Exception {
|
||||
public void typeMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Type must not be null");
|
||||
new Frame((Frame.Type) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void textPayload() throws Exception {
|
||||
public void textPayload() {
|
||||
Frame frame = new Frame("abc");
|
||||
assertThat(frame.getType()).isEqualTo(Frame.Type.TEXT);
|
||||
assertThat(frame.getPayload()).isEqualTo("abc".getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typedPayload() throws Exception {
|
||||
public void typedPayload() {
|
||||
Frame frame = new Frame(Frame.Type.CLOSE);
|
||||
assertThat(frame.getType()).isEqualTo(Frame.Type.CLOSE);
|
||||
assertThat(frame.getPayload()).isEqualTo(new byte[] {});
|
||||
|
||||
@@ -226,8 +226,7 @@ public class LiveReloadServerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message)
|
||||
throws Exception {
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) {
|
||||
if (message.getPayload().contains("hello")) {
|
||||
this.helloLatch.countDown();
|
||||
}
|
||||
@@ -235,14 +234,12 @@ public class LiveReloadServerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePongMessage(WebSocketSession session, PongMessage message)
|
||||
throws Exception {
|
||||
protected void handlePongMessage(WebSocketSession session, PongMessage message) {
|
||||
this.pongCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status)
|
||||
throws Exception {
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
|
||||
this.closeStatus = status;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,28 +73,28 @@ public class ClassPathChangeUploaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeNull() throws Exception {
|
||||
public void urlMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new ClassPathChangeUploader(null, this.requestFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeEmpty() throws Exception {
|
||||
public void urlMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new ClassPathChangeUploader("", this.requestFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestFactoryMustNotBeNull() throws Exception {
|
||||
public void requestFactoryMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RequestFactory must not be null");
|
||||
new ClassPathChangeUploader("http://localhost:8080", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeMalformed() throws Exception {
|
||||
public void urlMustNotBeMalformed() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Malformed URL 'htttttp:///ttest'");
|
||||
new ClassPathChangeUploader("htttttp:///ttest", this.requestFactory);
|
||||
|
||||
@@ -83,28 +83,28 @@ public class DelayedLiveReloadTriggerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadServerMustNotBeNull() throws Exception {
|
||||
public void liveReloadServerMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("LiveReloadServer must not be null");
|
||||
new DelayedLiveReloadTrigger(null, this.requestFactory, URL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestFactoryMustNotBeNull() throws Exception {
|
||||
public void requestFactoryMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RequestFactory must not be null");
|
||||
new DelayedLiveReloadTrigger(this.liveReloadServer, null, URL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeNull() throws Exception {
|
||||
public void urlMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeEmpty() throws Exception {
|
||||
public void urlMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, "");
|
||||
|
||||
@@ -85,25 +85,25 @@ public class RemoteClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnIfRestartDisabled() throws Exception {
|
||||
public void warnIfRestartDisabled() {
|
||||
configure("spring.devtools.remote.restart.enabled:false");
|
||||
assertThat(this.output.toString()).contains("Remote restart is disabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warnIfNotHttps() throws Exception {
|
||||
public void warnIfNotHttps() {
|
||||
configure("http://localhost", true);
|
||||
assertThat(this.output.toString()).contains("is insecure");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesntWarnIfUsingHttps() throws Exception {
|
||||
public void doesntWarnIfUsingHttps() {
|
||||
configure("https://localhost", true);
|
||||
assertThat(this.output.toString()).doesNotContain("is insecure");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failIfNoSecret() throws Exception {
|
||||
public void failIfNoSecret() {
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("required to secure your connection");
|
||||
configure("http://localhost", false);
|
||||
@@ -124,14 +124,14 @@ public class RemoteClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void liveReloadDisabled() throws Exception {
|
||||
public void liveReloadDisabled() {
|
||||
configure("spring.devtools.livereload.enabled:false");
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
this.context.getBean(OptionalLiveReloadServer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void remoteRestartDisabled() throws Exception {
|
||||
public void remoteRestartDisabled() {
|
||||
configure("spring.devtools.remote.restart.enabled:false");
|
||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||
this.context.getBean(ClassPathFileSystemWatcher.class);
|
||||
|
||||
@@ -70,13 +70,13 @@ public class DispatcherFilterTests {
|
||||
private DispatcherFilter filter;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.filter = new DispatcherFilter(this.dispatcher);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dispatcherMustNotBeNull() throws Exception {
|
||||
public void dispatcherMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Dispatcher must not be null");
|
||||
new DispatcherFilter(null);
|
||||
|
||||
@@ -76,14 +76,14 @@ public class DispatcherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessManagerMustNotBeNull() throws Exception {
|
||||
public void accessManagerMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("AccessManager must not be null");
|
||||
new Dispatcher(null, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mappersMustNotBeNull() throws Exception {
|
||||
public void mappersMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Mappers must not be null");
|
||||
new Dispatcher(this.accessManager, null);
|
||||
|
||||
@@ -56,52 +56,52 @@ public class HttpHeaderAccessManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerNameMustNotBeNull() throws Exception {
|
||||
public void headerNameMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("HeaderName must not be empty");
|
||||
new HttpHeaderAccessManager(null, SECRET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headerNameMustNotBeEmpty() throws Exception {
|
||||
public void headerNameMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("HeaderName must not be empty");
|
||||
new HttpHeaderAccessManager("", SECRET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expectedSecretMustNotBeNull() throws Exception {
|
||||
public void expectedSecretMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ExpectedSecret must not be empty");
|
||||
new HttpHeaderAccessManager(HEADER, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expectedSecretMustNotBeEmpty() throws Exception {
|
||||
public void expectedSecretMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ExpectedSecret must not be empty");
|
||||
new HttpHeaderAccessManager(HEADER, "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowsMatching() throws Exception {
|
||||
public void allowsMatching() {
|
||||
this.request.addHeader(HEADER, SECRET);
|
||||
assertThat(this.manager.isAllowed(this.serverRequest)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disallowsWrongSecret() throws Exception {
|
||||
public void disallowsWrongSecret() {
|
||||
this.request.addHeader(HEADER, "wrong");
|
||||
assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disallowsNoSecret() throws Exception {
|
||||
public void disallowsNoSecret() {
|
||||
assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disallowsWrongHeader() throws Exception {
|
||||
public void disallowsWrongHeader() {
|
||||
this.request.addHeader("X-WRONG", SECRET);
|
||||
assertThat(this.manager.isAllowed(this.serverRequest)).isFalse();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class HttpStatusHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusMustNotBeNull() throws Exception {
|
||||
public void statusMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Status must not be null");
|
||||
new HttpStatusHandler(null);
|
||||
|
||||
@@ -43,28 +43,28 @@ public class UrlHandlerMapperTests {
|
||||
private Handler handler = mock(Handler.class);
|
||||
|
||||
@Test
|
||||
public void requestUriMustNotBeNull() throws Exception {
|
||||
public void requestUriMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new UrlHandlerMapper(null, this.handler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestUriMustNotBeEmpty() throws Exception {
|
||||
public void requestUriMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new UrlHandlerMapper("", this.handler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestUrlMustStartWithSlash() throws Exception {
|
||||
public void requestUrlMustStartWithSlash() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must start with '/'");
|
||||
new UrlHandlerMapper("tunnel", this.handler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesMatchedUrl() throws Exception {
|
||||
public void handlesMatchedUrl() {
|
||||
UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler);
|
||||
HttpServletRequest servletRequest = new MockHttpServletRequest("GET", "/tunnel");
|
||||
ServerHttpRequest request = new ServletServerHttpRequest(servletRequest);
|
||||
@@ -72,7 +72,7 @@ public class UrlHandlerMapperTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoresDifferentUrl() throws Exception {
|
||||
public void ignoresDifferentUrl() {
|
||||
UrlHandlerMapper mapper = new UrlHandlerMapper("/tunnel", this.handler);
|
||||
HttpServletRequest servletRequest = new MockHttpServletRequest("GET",
|
||||
"/tunnel/other");
|
||||
|
||||
@@ -69,19 +69,18 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getClassLoaderShouldReturnClassLoader() throws Exception {
|
||||
public void getClassLoaderShouldReturnClassLoader() {
|
||||
assertThat(this.resolver.getClassLoader()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResourceShouldReturnResource() throws Exception {
|
||||
public void getResourceShouldReturnResource() {
|
||||
Resource resource = this.resolver.getResource("index.html");
|
||||
assertThat(resource).isNotNull().isInstanceOf(ClassPathResource.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getResourceWhenHasServletContextShouldReturnServletResource()
|
||||
throws Exception {
|
||||
public void getResourceWhenHasServletContextShouldReturnServletResource() {
|
||||
GenericWebApplicationContext context = new GenericWebApplicationContext(
|
||||
new MockServletContext());
|
||||
this.resolver = new ClassLoaderFilesResourcePatternResolver(context, this.files);
|
||||
@@ -121,7 +120,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customResourceLoaderIsUsedInNonWebApplication() throws Exception {
|
||||
public void customResourceLoaderIsUsedInNonWebApplication() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ResourceLoader resourceLoader = mock(ResourceLoader.class);
|
||||
context.setResourceLoader(resourceLoader);
|
||||
@@ -131,7 +130,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customProtocolResolverIsUsedInNonWebApplication() throws Exception {
|
||||
public void customProtocolResolverIsUsedInNonWebApplication() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
Resource resource = mock(Resource.class);
|
||||
ProtocolResolver resolver = mockProtocolResolver("foo:some-file.txt", resource);
|
||||
@@ -143,7 +142,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customResourceLoaderIsUsedInWebApplication() throws Exception {
|
||||
public void customResourceLoaderIsUsedInWebApplication() {
|
||||
GenericWebApplicationContext context = new GenericWebApplicationContext(
|
||||
new MockServletContext());
|
||||
ResourceLoader resourceLoader = mock(ResourceLoader.class);
|
||||
@@ -154,7 +153,7 @@ public class ClassLoaderFilesResourcePatternResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customProtocolResolverIsUsedInWebApplication() throws Exception {
|
||||
public void customProtocolResolverIsUsedInWebApplication() {
|
||||
GenericWebApplicationContext context = new GenericWebApplicationContext(
|
||||
new MockServletContext());
|
||||
Resource resource = mock(Resource.class);
|
||||
|
||||
@@ -32,13 +32,13 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
public class DefaultRestartInitializerTests {
|
||||
|
||||
@Test
|
||||
public void nullForTests() throws Exception {
|
||||
public void nullForTests() {
|
||||
MockRestartInitializer initializer = new MockRestartInitializer(true);
|
||||
assertThat(initializer.getInitialUrls(Thread.currentThread())).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validMainThread() throws Exception {
|
||||
public void validMainThread() {
|
||||
MockRestartInitializer initializer = new MockRestartInitializer(false);
|
||||
ClassLoader classLoader = new MockAppClassLoader(getClass().getClassLoader());
|
||||
Thread thread = new Thread();
|
||||
@@ -49,7 +49,7 @@ public class DefaultRestartInitializerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void threadNotNamedMain() throws Exception {
|
||||
public void threadNotNamedMain() {
|
||||
MockRestartInitializer initializer = new MockRestartInitializer(false);
|
||||
ClassLoader classLoader = new MockAppClassLoader(getClass().getClassLoader());
|
||||
Thread thread = new Thread();
|
||||
@@ -60,7 +60,7 @@ public class DefaultRestartInitializerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void threadNotUsingAppClassLoader() throws Exception {
|
||||
public void threadNotUsingAppClassLoader() {
|
||||
MockRestartInitializer initializer = new MockRestartInitializer(false);
|
||||
ClassLoader classLoader = new MockLauncherClassLoader(
|
||||
getClass().getClassLoader());
|
||||
@@ -72,17 +72,17 @@ public class DefaultRestartInitializerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsDueToJUnitStacks() throws Exception {
|
||||
public void skipsDueToJUnitStacks() {
|
||||
testSkipStack("org.junit.runners.Something", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsDueToSpringTest() throws Exception {
|
||||
public void skipsDueToSpringTest() {
|
||||
testSkipStack("org.springframework.boot.test.Something", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsDueToCucumber() throws Exception {
|
||||
public void skipsDueToCucumber() {
|
||||
testSkipStack("cucumber.runtime.Runtime.run", true);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MainMethodTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void threadMustNotBeNull() throws Exception {
|
||||
public void threadMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Thread must not be null");
|
||||
new MainMethod(null);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class OnInitializedRestarterConditionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noInstance() throws Exception {
|
||||
public void noInstance() {
|
||||
Restarter.clearInstance();
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
Config.class);
|
||||
@@ -57,7 +57,7 @@ public class OnInitializedRestarterConditionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noInitialization() throws Exception {
|
||||
public void noInitialization() {
|
||||
Restarter.initialize(new String[0], false, RestartInitializer.NONE);
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
Config.class);
|
||||
|
||||
@@ -55,13 +55,13 @@ public class RestartApplicationListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isHighestPriority() throws Exception {
|
||||
public void isHighestPriority() {
|
||||
assertThat(new RestartApplicationListener().getOrder())
|
||||
.isEqualTo(Ordered.HIGHEST_PRECEDENCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initializeWithReady() throws Exception {
|
||||
public void initializeWithReady() {
|
||||
testInitialize(false);
|
||||
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"))
|
||||
.isEqualTo(ARGS);
|
||||
@@ -71,7 +71,7 @@ public class RestartApplicationListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initializeWithFail() throws Exception {
|
||||
public void initializeWithFail() {
|
||||
testInitialize(true);
|
||||
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "args"))
|
||||
.isEqualTo(ARGS);
|
||||
@@ -81,7 +81,7 @@ public class RestartApplicationListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableWithSystemProperty() throws Exception {
|
||||
public void disableWithSystemProperty() {
|
||||
System.setProperty(ENABLED_PROPERTY, "false");
|
||||
testInitialize(false);
|
||||
assertThat(ReflectionTestUtils.getField(Restarter.getInstance(), "enabled"))
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RestartScopeInitializerTests {
|
||||
private static AtomicInteger refreshCount;
|
||||
|
||||
@Test
|
||||
public void restartScope() throws Exception {
|
||||
public void restartScope() {
|
||||
createCount = new AtomicInteger();
|
||||
refreshCount = new AtomicInteger();
|
||||
ConfigurableApplicationContext context = runApplication();
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RestarterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cantGetInstanceBeforeInitialize() throws Exception {
|
||||
public void cantGetInstanceBeforeInitialize() {
|
||||
Restarter.clearInstance();
|
||||
this.thrown.expect(IllegalStateException.class);
|
||||
this.thrown.expectMessage("Restarter has not been initialized");
|
||||
@@ -94,14 +94,14 @@ public class RestarterTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void getOrAddAttributeWithNewAttribute() throws Exception {
|
||||
public void getOrAddAttributeWithNewAttribute() {
|
||||
ObjectFactory objectFactory = mock(ObjectFactory.class);
|
||||
given(objectFactory.getObject()).willReturn("abc");
|
||||
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
|
||||
assertThat(attribute).isEqualTo("abc");
|
||||
}
|
||||
|
||||
public void addUrlsMustNotBeNull() throws Exception {
|
||||
public void addUrlsMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Urls must not be null");
|
||||
Restarter.getInstance().addUrls(null);
|
||||
@@ -120,7 +120,7 @@ public class RestarterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addClassLoaderFilesMustNotBeNull() throws Exception {
|
||||
public void addClassLoaderFilesMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ClassLoaderFiles must not be null");
|
||||
Restarter.getInstance().addClassLoaderFiles(null);
|
||||
@@ -141,7 +141,7 @@ public class RestarterTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void getOrAddAttributeWithExistingAttribute() throws Exception {
|
||||
public void getOrAddAttributeWithExistingAttribute() {
|
||||
Restarter.getInstance().getOrAddAttribute("x", () -> "abc");
|
||||
ObjectFactory objectFactory = mock(ObjectFactory.class);
|
||||
Object attribute = Restarter.getInstance().getOrAddAttribute("x", objectFactory);
|
||||
@@ -259,13 +259,13 @@ public class RestarterTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Throwable relaunch(ClassLoader classLoader) throws Exception {
|
||||
protected Throwable relaunch(ClassLoader classLoader) {
|
||||
this.relaunchClassLoader = classLoader;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stop() throws Exception {
|
||||
protected void stop() {
|
||||
}
|
||||
|
||||
public ClassLoader getRelaunchClassLoader() {
|
||||
|
||||
@@ -44,42 +44,42 @@ public class ClassLoaderFileTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addedContentsMustNotBeNull() throws Exception {
|
||||
public void addedContentsMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Contents must not be null");
|
||||
new ClassLoaderFile(Kind.ADDED, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifiedContentsMustNotBeNull() throws Exception {
|
||||
public void modifiedContentsMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Contents must not be null");
|
||||
new ClassLoaderFile(Kind.MODIFIED, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletedContentsMustBeNull() throws Exception {
|
||||
public void deletedContentsMustBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Contents must be null");
|
||||
new ClassLoaderFile(Kind.DELETED, new byte[10]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void added() throws Exception {
|
||||
public void added() {
|
||||
ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, BYTES);
|
||||
assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.ADDED);
|
||||
assertThat(file.getContents()).isEqualTo(BYTES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modified() throws Exception {
|
||||
public void modified() {
|
||||
ClassLoaderFile file = new ClassLoaderFile(Kind.MODIFIED, BYTES);
|
||||
assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.MODIFIED);
|
||||
assertThat(file.getContents()).isEqualTo(BYTES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleted() throws Exception {
|
||||
public void deleted() {
|
||||
ClassLoaderFile file = new ClassLoaderFile(Kind.DELETED, null);
|
||||
assertThat(file.getKind()).isEqualTo(ClassLoaderFile.Kind.DELETED);
|
||||
assertThat(file.getContents()).isNull();
|
||||
|
||||
@@ -45,38 +45,38 @@ public class ClassLoaderFilesTests {
|
||||
private ClassLoaderFiles files = new ClassLoaderFiles();
|
||||
|
||||
@Test
|
||||
public void addFileNameMustNotBeNull() throws Exception {
|
||||
public void addFileNameMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Name must not be null");
|
||||
this.files.addFile(null, mock(ClassLoaderFile.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFileFileMustNotBeNull() throws Exception {
|
||||
public void addFileFileMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("File must not be null");
|
||||
this.files.addFile("test", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFileWithNullName() throws Exception {
|
||||
public void getFileWithNullName() {
|
||||
assertThat(this.files.getFile(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addAndGet() throws Exception {
|
||||
public void addAndGet() {
|
||||
ClassLoaderFile file = new ClassLoaderFile(Kind.ADDED, new byte[10]);
|
||||
this.files.addFile("myfile", file);
|
||||
assertThat(this.files.getFile("myfile")).isEqualTo(file);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMissing() throws Exception {
|
||||
public void getMissing() {
|
||||
assertThat(this.files.getFile("missing")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTwice() throws Exception {
|
||||
public void addTwice() {
|
||||
ClassLoaderFile file1 = new ClassLoaderFile(Kind.ADDED, new byte[10]);
|
||||
ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
|
||||
this.files.addFile("myfile", file1);
|
||||
@@ -85,7 +85,7 @@ public class ClassLoaderFilesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addTwiceInDifferentSourceFolders() throws Exception {
|
||||
public void addTwiceInDifferentSourceFolders() {
|
||||
ClassLoaderFile file1 = new ClassLoaderFile(Kind.ADDED, new byte[10]);
|
||||
ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
|
||||
this.files.addFile("a", "myfile", file1);
|
||||
@@ -98,7 +98,7 @@ public class ClassLoaderFilesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSourceFolders() throws Exception {
|
||||
public void getSourceFolders() {
|
||||
ClassLoaderFile file1 = new ClassLoaderFile(Kind.ADDED, new byte[10]);
|
||||
ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
|
||||
ClassLoaderFile file3 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
|
||||
@@ -132,7 +132,7 @@ public class ClassLoaderFilesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addAll() throws Exception {
|
||||
public void addAll() {
|
||||
ClassLoaderFile file1 = new ClassLoaderFile(Kind.ADDED, new byte[10]);
|
||||
this.files.addFile("a", "myfile1", file1);
|
||||
ClassLoaderFiles toAdd = new ClassLoaderFiles();
|
||||
@@ -151,7 +151,7 @@ public class ClassLoaderFilesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSize() throws Exception {
|
||||
public void getSize() {
|
||||
this.files.addFile("s1", "n1", mock(ClassLoaderFile.class));
|
||||
this.files.addFile("s1", "n2", mock(ClassLoaderFile.class));
|
||||
this.files.addFile("s2", "n3", mock(ClassLoaderFile.class));
|
||||
@@ -160,14 +160,14 @@ public class ClassLoaderFilesTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classLoaderFilesMustNotBeNull() throws Exception {
|
||||
public void classLoaderFilesMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ClassLoaderFiles must not be null");
|
||||
new ClassLoaderFiles(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructFromExistingSet() throws Exception {
|
||||
public void constructFromExistingSet() {
|
||||
this.files.addFile("s1", "n1", mock(ClassLoaderFile.class));
|
||||
this.files.addFile("s1", "n2", mock(ClassLoaderFile.class));
|
||||
ClassLoaderFiles copy = new ClassLoaderFiles(this.files);
|
||||
|
||||
@@ -94,14 +94,14 @@ public class RestartClassLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parentMustNotBeNull() throws Exception {
|
||||
public void parentMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Parent must not be null");
|
||||
new RestartClassLoader(null, new URL[] {});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatedFilesMustNotBeNull() throws Exception {
|
||||
public void updatedFilesMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("UpdatedFiles must not be null");
|
||||
new RestartClassLoader(this.parentClassLoader, new URL[] {}, null);
|
||||
@@ -141,14 +141,14 @@ public class RestartClassLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDeletedResource() throws Exception {
|
||||
public void getDeletedResource() {
|
||||
String name = PACKAGE_PATH + "/Sample.txt";
|
||||
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
|
||||
assertThat(this.reloadClassLoader.getResource(name)).isEqualTo(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDeletedResourceAsStream() throws Exception {
|
||||
public void getDeletedResourceAsStream() {
|
||||
String name = PACKAGE_PATH + "/Sample.txt";
|
||||
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
|
||||
assertThat(this.reloadClassLoader.getResourceAsStream(name)).isEqualTo(null);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class HttpRestartServerHandlerTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void serverMustNotBeNull() throws Exception {
|
||||
public void serverMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Server must not be null");
|
||||
new HttpRestartServerHandler(null);
|
||||
|
||||
@@ -66,14 +66,14 @@ public class HttpRestartServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sourceFolderUrlFilterMustNotBeNull() throws Exception {
|
||||
public void sourceFolderUrlFilterMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("SourceFolderUrlFilter must not be null");
|
||||
new HttpRestartServer((SourceFolderUrlFilter) null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartServerMustNotBeNull() throws Exception {
|
||||
public void restartServerMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RestartServer must not be null");
|
||||
new HttpRestartServer((RestartServer) null);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RestartServerTests {
|
||||
public TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void sourceFolderUrlFilterMustNotBeNull() throws Exception {
|
||||
public void sourceFolderUrlFilterMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("SourceFolderUrlFilter must not be null");
|
||||
new RestartServer((SourceFolderUrlFilter) null);
|
||||
|
||||
@@ -78,21 +78,21 @@ public class HttpTunnelConnectionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeNull() throws Exception {
|
||||
public void urlMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new HttpTunnelConnection(null, this.requestFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeEmpty() throws Exception {
|
||||
public void urlMustNotBeEmpty() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("URL must not be empty");
|
||||
new HttpTunnelConnection("", this.requestFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void urlMustNotBeMalformed() throws Exception {
|
||||
public void urlMustNotBeMalformed() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Malformed URL 'htttttp:///ttest'");
|
||||
new HttpTunnelConnection("htttttp:///ttest", this.requestFactory);
|
||||
|
||||
@@ -47,14 +47,14 @@ public class TunnelClientTests {
|
||||
private MockTunnelConnection tunnelConnection = new MockTunnelConnection();
|
||||
|
||||
@Test
|
||||
public void listenPortMustNotBeNegative() throws Exception {
|
||||
public void listenPortMustNotBeNegative() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ListenPort must be greater than or equal to 0");
|
||||
new TunnelClient(-5, this.tunnelConnection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tunnelConnectionMustNotBeNull() throws Exception {
|
||||
public void tunnelConnectionMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("TunnelConnection must not be null");
|
||||
new TunnelClient(1, null);
|
||||
@@ -123,7 +123,7 @@ public class TunnelClientTests {
|
||||
|
||||
@Override
|
||||
public WritableByteChannel open(WritableByteChannel incomingChannel,
|
||||
Closeable closeable) throws Exception {
|
||||
Closeable closeable) {
|
||||
this.openedTimes++;
|
||||
this.open = true;
|
||||
return new TunnelChannel(incomingChannel, closeable);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HttpTunnelPayloadForwarderTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void targetChannelMustNotBeNull() throws Exception {
|
||||
public void targetChannelMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("TargetChannel must not be null");
|
||||
new HttpTunnelPayloadForwarder(null);
|
||||
|
||||
@@ -52,21 +52,21 @@ public class HttpTunnelPayloadTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void sequenceMustBePositive() throws Exception {
|
||||
public void sequenceMustBePositive() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Sequence must be positive");
|
||||
new HttpTunnelPayload(0, ByteBuffer.allocate(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataMustNotBeNull() throws Exception {
|
||||
public void dataMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Data must not be null");
|
||||
new HttpTunnelPayload(1, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSequence() throws Exception {
|
||||
public void getSequence() {
|
||||
HttpTunnelPayload payload = new HttpTunnelPayload(1, ByteBuffer.allocate(1));
|
||||
assertThat(payload.getSequence()).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class HttpTunnelServerHandlerTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void serverMustNotBeNull() throws Exception {
|
||||
public void serverMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Server must not be null");
|
||||
new HttpTunnelServerHandler(null);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HttpTunnelServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverConnectionIsRequired() throws Exception {
|
||||
public void serverConnectionIsRequired() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("ServerConnection must not be null");
|
||||
new HttpTunnelServer(null);
|
||||
@@ -123,7 +123,7 @@ public class HttpTunnelServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void longPollTimeoutMustBePositiveValue() throws Exception {
|
||||
public void longPollTimeoutMustBePositiveValue() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("LongPollTimeout must be a positive value");
|
||||
this.server.setLongPollTimeout(0);
|
||||
@@ -256,7 +256,7 @@ public class HttpTunnelServerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disconnectTimeoutMustBePositive() throws Exception {
|
||||
public void disconnectTimeoutMustBePositive() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("DisconnectTimeout must be a positive value");
|
||||
this.server.setDisconnectTimeout(0);
|
||||
@@ -406,7 +406,7 @@ public class HttpTunnelServerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
this.open.set(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ public class StaticPortProviderTests {
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void portMustBePositive() throws Exception {
|
||||
public void portMustBePositive() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Port must be positive");
|
||||
new StaticPortProvider(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPort() throws Exception {
|
||||
public void getPort() {
|
||||
StaticPortProvider provider = new StaticPortProvider(123);
|
||||
assertThat(provider.getPort()).isEqualTo(123);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user