|
22 | 22 | import java.nio.file.Path;
|
23 | 23 | import java.nio.file.Paths;
|
24 | 24 |
|
| 25 | +import org.hamcrest.Matchers; |
25 | 26 | import org.junit.Rule;
|
26 | 27 | import org.junit.Test;
|
27 | 28 | import org.junit.rules.ExpectedException;
|
|
37 | 38 | *
|
38 | 39 | * @author Philippe Marschall
|
39 | 40 | * @author Phillip Webb
|
| 41 | + * @author Nicholas Williams |
40 | 42 | */
|
41 | 43 | public class PathResourceTests {
|
42 | 44 |
|
43 |
| - private static final String TEST_DIR = "src/test/java/org/springframework/core/io"; |
| 45 | + private static final String TEST_DIR = platformPath("src/test/java/org/" |
| 46 | + + "springframework/core/io"); |
44 | 47 |
|
45 |
| - private static final String TEST_FILE = "src/test/java/org/springframework/core/io/example.properties"; |
| 48 | + private static final String TEST_FILE = platformPath("src/test/java/org/" |
| 49 | + + "springframework/core/io/example.properties"); |
46 | 50 |
|
47 |
| - private static final String NON_EXISTING_FILE = "src/test/java/org/springframework/core/io/doesnotexist.properties"; |
| 51 | + private static final String NON_EXISTING_FILE = platformPath("src/test/java/org/" |
| 52 | + + "springframework/core/io/doesnotexist.properties"); |
| 53 | + |
| 54 | + |
| 55 | + private static String platformPath(String string) { |
| 56 | + return string.replace('/', File.separatorChar); |
| 57 | + } |
48 | 58 |
|
49 | 59 |
|
50 | 60 | @Rule
|
@@ -167,13 +177,13 @@ public void getInputStreamDoesNotExist() throws Exception {
|
167 | 177 | @Test
|
168 | 178 | public void getUrl() throws Exception {
|
169 | 179 | PathResource resource = new PathResource(TEST_FILE);
|
170 |
| - assertTrue(resource.getURL().toString().endsWith(TEST_FILE)); |
| 180 | + assertThat(resource.getURL().toString(), Matchers.endsWith("core/io/example.properties")); |
171 | 181 | }
|
172 | 182 |
|
173 | 183 | @Test
|
174 | 184 | public void getUri() throws Exception {
|
175 | 185 | PathResource resource = new PathResource(TEST_FILE);
|
176 |
| - assertTrue(resource.getURI().toString().endsWith(TEST_FILE)); |
| 186 | + assertThat(resource.getURI().toString(), Matchers.endsWith("core/io/example.properties")); |
177 | 187 | }
|
178 | 188 |
|
179 | 189 | @Test
|
|
0 commit comments