master
This commit is contained in:
parent
81b323a695
commit
068f4d1eb6
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung.resourcedirectory;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -9,17 +10,28 @@ import java.nio.file.Paths;
|
|||
public class ReadResourceDirectoryUnitTest {
|
||||
|
||||
@Test
|
||||
public void shouldReadResourceAbsolutePathWithFile() {
|
||||
public void givenResourcePath_whenReadAbsolutePathWithFile_thenAbsolutePathEndsWithDirectory() {
|
||||
String path = "src/test/resources";
|
||||
|
||||
File file = new File(path);
|
||||
String absolutePath = file.getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith("src/test/resources"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadResourceAbsolutePathWithResources() {
|
||||
public void givenResourcePath_whenReadAbsolutePathWithPaths_thenAbsolutePathEndsWithDirectory() {
|
||||
Path resourceDirectory = Paths.get("src", "test", "resources");
|
||||
|
||||
String absolutePath = resourceDirectory.toFile().getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith("src/test/resources"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenResourceFile_whenReadResourceWithClassLoader_thenPathEndWithFilename() {
|
||||
String resourceName = "example_resource.txt";
|
||||
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
|
@ -27,16 +39,7 @@ public class ReadResourceDirectoryUnitTest {
|
|||
String absolutePath = file.getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
Assert.assertTrue(absolutePath.endsWith("/example_resource.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadResourceAbsolutePathWithPaths() {
|
||||
Path resourceDirectory = Paths.get("src", "test", "resources");
|
||||
|
||||
String absolutePath = resourceDirectory.toFile().getAbsolutePath();
|
||||
|
||||
System.out.println(absolutePath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue