BAEL-6541-convert-relative-path

This commit is contained in:
tienvn
2023-08-03 17:59:49 +07:00
parent 645169a951
commit 8f27b58aa7
2 changed files with 0 additions and 0 deletions

View File

@@ -1,51 +0,0 @@
package com.baeldung.convertpaths;
import org.junit.Test;
public class RelativePathConverterUnitTest {
@Test
public void givenRelativePath_whenConvertingToAbsolutePath_thenPrintOutput() {
String relativePath = "data/sample.txt";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(relativePath));
}
@Test
public void givenAbsolutePath_whenConvertingToAbsolutePath_thenPrintOutput() {
String absolutePath = "/var/www/index.html";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(absolutePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(absolutePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(absolutePath));
}
@Test
public void givenEmptyPath_whenConvertingToAbsolutePath_thenPrintOutput() {
String emptyPath = "";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(emptyPath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(emptyPath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(emptyPath));
}
@Test
public void givenParentDirectoryPath_whenConvertingToAbsolutePath_thenPrintOutput() {
String relativePath = "../data/sample.txt";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(relativePath));
}
@Test
public void givenRelativePathContainingDots_whenConvertingToAbsolutePath_thenPrintOutput() {
String relativePath = "././data/sample.txt";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(relativePath));
}
}