From ce8f3f54c54b3f953085a1b56ab2cb94b37baddf Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sat, 29 Jun 2019 21:34:55 +0530 Subject: [PATCH] [BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-classpath-file-access --- .../baeldung/resource/SpringResourceIntegrationTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java index a7a2a9032a..c7a2984045 100644 --- a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java +++ b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -77,7 +78,7 @@ public class SpringResourceIntegrationTest { @Test public void whenResourceUtils_thenReadSuccessful() throws IOException { - final File employeeFile = ResourceUtils.getFile("classpath:data/employees.dat"); + final File employeeFile = loadEmployeesWithSpringInternalClass(); final String employees = new String(Files.readAllBytes(employeeFile.toPath())); assertEquals(EMPLOYEES_EXPECTED, employees); } @@ -112,4 +113,8 @@ public class SpringResourceIntegrationTest { final String employees = new String(Files.readAllBytes(resource.toPath())); assertEquals(EMPLOYEES_EXPECTED, employees); } + + public File loadEmployeesWithSpringInternalClass() throws FileNotFoundException { + return ResourceUtils.getFile("classpath:data/employees.dat"); + } }