Merge pull request #6011 from yatendragoel/master

BAEL-1978: Added a test to demostrate classpath resource with relative path
This commit is contained in:
Loredana Crusoveanu 2018-12-28 23:20:48 +02:00 committed by GitHub
commit be9eed4fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -98,4 +98,19 @@ 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);
} }
@Test
public void whenClassPathResourceWithAbsoultePath_thenReadSuccessful() throws IOException {
final File resource = new ClassPathResource("/data/employees.dat", this.getClass()).getFile();
final String employees = new String(Files.readAllBytes(resource.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees);
}
@Test
public void whenClassPathResourceWithRelativePath_thenReadSuccessful() throws IOException {
// final File resource = new ClassPathResource("../../../data/employees.dat", SpringResourceIntegrationTest.class).getFile();
final File resource = new ClassPathResource("/data/employees.dat", SpringResourceIntegrationTest.class).getFile();
final String employees = new String(Files.readAllBytes(resource.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees);
}
} }