Merge pull request #7214 from amit2103/BAEL-14274-18

[BAEL-14274] - Fixed article code for https://www.baeldung.com/spring
This commit is contained in:
Loredana Crusoveanu 2019-07-20 21:34:11 +03:00 committed by GitHub
commit 3ea05194d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -77,7 +78,7 @@ public class SpringResourceIntegrationTest {
@Test @Test
public void whenResourceUtils_thenReadSuccessful() throws IOException { 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())); final String employees = new String(Files.readAllBytes(employeeFile.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees); assertEquals(EMPLOYEES_EXPECTED, employees);
} }
@ -112,4 +113,8 @@ public class SpringResourceIntegrationTest {
final String employees = new String(Files.readAllBytes(resource.toPath())); final String employees = new String(Files.readAllBytes(resource.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees); assertEquals(EMPLOYEES_EXPECTED, employees);
} }
public File loadEmployeesWithSpringInternalClass() throws FileNotFoundException {
return ResourceUtils.getFile("classpath:data/employees.dat");
}
} }