Remove unnecessary throws declaration in tests
See gh-26441
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.boot.devtools.tests;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
@@ -49,7 +47,7 @@ class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsInt
|
||||
assertThat(template.getForObject(urlBase + "/two", String.class)).isEqualTo("two");
|
||||
}
|
||||
|
||||
static Object[] parameters() throws IOException {
|
||||
static Object[] parameters() {
|
||||
Directories directories = new Directories(buildOutput, temp);
|
||||
return new Object[] { new Object[] { new LocalApplicationLauncher(directories) },
|
||||
new Object[] { new ExplodedRemoteApplicationLauncher(directories) },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -100,13 +100,13 @@ abstract class RemoteApplicationLauncher extends AbstractApplicationLauncher {
|
||||
return StringUtils.collectionToDelimitedString(entries, File.pathSeparator);
|
||||
}
|
||||
|
||||
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) throws Exception {
|
||||
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) {
|
||||
return Awaitility.waitAtMost(Duration.ofMinutes(3))
|
||||
.until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort)
|
||||
.getServerPort();
|
||||
}
|
||||
|
||||
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) throws Exception {
|
||||
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) {
|
||||
FileContents contents = new FileContents(launchedJvm.getStandardOut());
|
||||
try {
|
||||
Awaitility.waitAtMost(Duration.ofMinutes(3)).until(contents::get,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.boot.devtools.autoconfigure;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Duration;
|
||||
@@ -52,7 +51,7 @@ import static org.mockito.Mockito.verify;
|
||||
class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
|
||||
@BeforeEach
|
||||
void before(@TempDir File tempDir) throws IOException {
|
||||
void before(@TempDir File tempDir) {
|
||||
System.setProperty("derby.stream.error.file", new File(tempDir, "derby.log").getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,42 +37,42 @@ class ChangedFileTests {
|
||||
File tempDir;
|
||||
|
||||
@Test
|
||||
void sourceDirectoryMustNotBeNull() throws Exception {
|
||||
void sourceDirectoryMustNotBeNull() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD))
|
||||
.withMessageContaining("SourceDirectory must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileMustNotBeNull() throws Exception {
|
||||
void fileMustNotBeNull() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD))
|
||||
.withMessageContaining("File must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void typeMustNotBeNull() throws Exception {
|
||||
void typeMustNotBeNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null))
|
||||
.withMessageContaining("Type must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFile() throws Exception {
|
||||
void getFile() {
|
||||
File file = new File(this.tempDir, "file");
|
||||
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), file, Type.ADD);
|
||||
assertThat(changedFile.getFile()).isEqualTo(file);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getType() throws Exception {
|
||||
void getType() {
|
||||
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), new File(this.tempDir, "file"),
|
||||
Type.DELETE);
|
||||
assertThat(changedFile.getType()).isEqualTo(Type.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRelativeName() throws Exception {
|
||||
void getRelativeName() {
|
||||
File subDirectory = new File(this.tempDir, "A");
|
||||
File file = new File(subDirectory, "B.txt");
|
||||
ChangedFile changedFile = new ChangedFile(this.tempDir, file, Type.ADD);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ class DirectorySnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void directoryDoesNotHaveToExist() throws Exception {
|
||||
void directoryDoesNotHaveToExist() {
|
||||
File file = new File(this.tempDir, "does/not/exist");
|
||||
DirectorySnapshot snapshot = new DirectorySnapshot(file);
|
||||
assertThat(snapshot).isEqualTo(new DirectorySnapshot(file));
|
||||
@@ -107,7 +107,7 @@ class DirectorySnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() throws Exception {
|
||||
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> this.initialSnapshot.getChangedFiles(new DirectorySnapshot(createTestDirectoryStructure()), null))
|
||||
.withMessageContaining("Snapshot source directory must be '" + this.directory + "'");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class FileSnapshotTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileMustNotBeADirectory() throws Exception {
|
||||
void fileMustNotBeADirectory() {
|
||||
File file = new File(this.tempDir, "file");
|
||||
file.mkdir();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(file))
|
||||
|
||||
@@ -110,7 +110,7 @@ class FileSystemWatcherTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void cannotAddSourceDirectoryToStartedListener() throws Exception {
|
||||
void cannotAddSourceDirectoryToStartedListener() {
|
||||
this.watcher.start();
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.watcher.addSourceDirectory(this.tempDir))
|
||||
.withMessageContaining("FileSystemWatcher already started");
|
||||
@@ -300,7 +300,7 @@ class FileSystemWatcherTests {
|
||||
this.watcher.addListener((changeSet) -> FileSystemWatcherTests.this.changes.add(changeSet));
|
||||
}
|
||||
|
||||
private File startWithNewDirectory() throws IOException {
|
||||
private File startWithNewDirectory() {
|
||||
File directory = new File(this.tempDir, UUID.randomUUID().toString());
|
||||
directory.mkdir();
|
||||
this.watcher.addSourceDirectory(directory);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,13 +58,13 @@ class ConnectionInputStreamTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkedRead() throws Exception {
|
||||
void checkedRead() {
|
||||
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
|
||||
assertThatIOException().isThrownBy(inputStream::checkedRead).withMessageContaining("End of stream");
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkedReadArray() throws Exception {
|
||||
void checkedReadArray() {
|
||||
byte[] buffer = new byte[100];
|
||||
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
|
||||
assertThatIOException().isThrownBy(() -> inputStream.checkedRead(buffer, 0, buffer.length))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,14 +85,14 @@ class FrameTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void readFragmentedNotSupported() throws Exception {
|
||||
void readFragmentedNotSupported() {
|
||||
byte[] bytes = new byte[] { 0x0F };
|
||||
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
|
||||
.withMessageContaining("Fragmented frames are not supported");
|
||||
}
|
||||
|
||||
@Test
|
||||
void readLargeFramesNotSupported() throws Exception {
|
||||
void readLargeFramesNotSupported() {
|
||||
byte[] bytes = new byte[] { (byte) 0x80, (byte) 0xFF };
|
||||
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
|
||||
.withMessageContaining("Large frames are not supported");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -112,7 +112,7 @@ class LiveReloadServerTests {
|
||||
assertThat(this.server.getClosedExceptions().size()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
private void awaitClosedException() throws InterruptedException {
|
||||
private void awaitClosedException() {
|
||||
Awaitility.waitAtMost(Duration.ofSeconds(10)).until(this.server::getClosedExceptions, is(not(empty())));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,7 +69,7 @@ class DelayedLiveReloadTriggerTests {
|
||||
private DelayedLiveReloadTrigger trigger;
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws IOException {
|
||||
void setup() {
|
||||
this.trigger = new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, URL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ class HttpHeaderInterceptorTests {
|
||||
private MockHttpServletRequest httpRequest;
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws Exception {
|
||||
void setup() {
|
||||
this.body = new byte[] {};
|
||||
this.httpRequest = new MockHttpServletRequest();
|
||||
this.request = new ServletServerHttpRequest(this.httpRequest);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,13 +57,13 @@ class MainMethodTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void missingArgsMainMethod() throws Exception {
|
||||
void missingArgsMainMethod() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> new TestThread(MissingArgs::main).test())
|
||||
.withMessageContaining("Unable to find main method");
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonStatic() throws Exception {
|
||||
void nonStatic() {
|
||||
assertThatIllegalStateException().isThrownBy(() -> new TestThread(() -> new NonStaticMain().main()).test())
|
||||
.withMessageContaining("Unable to find main method");
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class RestartClassLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getDeletedClass() throws Exception {
|
||||
void getDeletedClass() {
|
||||
String name = PACKAGE_PATH + "/Sample.class";
|
||||
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
|
||||
assertThatExceptionOfType(ClassNotFoundException.class)
|
||||
@@ -193,7 +193,7 @@ class RestartClassLoaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getUpdatedClass() throws Exception {
|
||||
void getUpdatedClass() {
|
||||
String name = PACKAGE_PATH + "/Sample.class";
|
||||
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, new byte[10]));
|
||||
assertThatExceptionOfType(ClassFormatError.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ class HttpTunnelPayloadForwarderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void overflow() throws Exception {
|
||||
void overflow() {
|
||||
WritableByteChannel channel = Channels.newChannel(new ByteArrayOutputStream());
|
||||
HttpTunnelPayloadForwarder forwarder = new HttpTunnelPayloadForwarder(channel);
|
||||
assertThatIllegalStateException().isThrownBy(() -> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -93,7 +93,7 @@ class HttpTunnelPayloadTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWithMissingHeader() throws Exception {
|
||||
void getWithMissingHeader() {
|
||||
MockHttpServletRequest servletRequest = new MockHttpServletRequest();
|
||||
servletRequest.setContent("hello".getBytes());
|
||||
HttpInputMessage request = new ServletServerHttpRequest(servletRequest);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,7 +83,7 @@ class HttpTunnelServerTests {
|
||||
private MockServerChannel serverChannel;
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws Exception {
|
||||
void setup() {
|
||||
this.server = new HttpTunnelServer(this.serverConnection);
|
||||
this.servletRequest = new MockHttpServletRequest();
|
||||
this.servletRequest.setAsyncSupported(true);
|
||||
|
||||
Reference in New Issue
Block a user