Merge pull request #6011 from yatendragoel/master
BAEL-1978: Added a test to demostrate classpath resource with relative path
This commit is contained in:
commit
be9eed4fd7
|
@ -98,4 +98,19 @@ public class SpringResourceIntegrationTest {
|
|||
final String employees = new String(Files.readAllBytes(resource.toPath()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue