Skip to content

Commit

Permalink
Merge pull request eugenp#6011 from yatendragoel/master
Browse files Browse the repository at this point in the history
BAEL-1978: Added a test to demostrate classpath resource with relative path
  • Loading branch information
lor6 authored Dec 28, 2018
2 parents 5aed1b8 + c3eb5c9 commit be9eed4
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,19 @@ public void whenResourceAsFile_thenReadSuccessful() throws IOException {
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);
}
}

0 comments on commit be9eed4

Please sign in to comment.