From 2e05137ff9f5af8168d07aaca5a2e8be73c48cf1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 5 Oct 2022 15:49:47 +0200 Subject: [PATCH] Polish PathResourceTests --- .../core/io/PathResourceTests.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java index c495335fc4b..3ce05addf0f 100644 --- a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java @@ -69,22 +69,19 @@ class PathResourceTests { @Test void nullPath() { - assertThatIllegalArgumentException().isThrownBy(() -> - new PathResource((Path) null)) + assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((Path) null)) .withMessageContaining("Path must not be null"); } @Test void nullPathString() { - assertThatIllegalArgumentException().isThrownBy(() -> - new PathResource((String) null)) + assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((String) null)) .withMessageContaining("Path must not be null"); } @Test void nullUri() { - assertThatIllegalArgumentException().isThrownBy(() -> - new PathResource((URI) null)) + assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((URI) null)) .withMessageContaining("URI must not be null"); } @@ -166,15 +163,13 @@ class PathResourceTests { @Test void getInputStreamForDir() throws IOException { PathResource resource = new PathResource(TEST_DIR); - assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( - resource::getInputStream); + assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getInputStream); } @Test void getInputStreamDoesNotExist() throws IOException { PathResource resource = new PathResource(NON_EXISTING_FILE); - assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( - resource::getInputStream); + assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getInputStream); } @Test @@ -202,8 +197,7 @@ class PathResourceTests { given(path.normalize()).willReturn(path); given(path.toFile()).willThrow(new UnsupportedOperationException()); PathResource resource = new PathResource(path); - assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( - resource::getFile); + assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getFile); } @Test @@ -283,8 +277,7 @@ class PathResourceTests { @Test void directoryOutputStream() throws IOException { PathResource resource = new PathResource(TEST_DIR); - assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( - resource::getOutputStream); + assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getOutputStream); } @Test @@ -312,8 +305,7 @@ class PathResourceTests { @Test void getReadableByteChannelDoesNotExist() throws IOException { PathResource resource = new PathResource(NON_EXISTING_FILE); - assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( - resource::readableChannel); + assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::readableChannel); } @Test