add unit test

This commit is contained in:
tienvn 2023-07-08 00:39:27 +07:00
parent b693287519
commit cd4167c462
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
package com.baeldung.convertpaths;
import org.junit.Test;
public class RelativePathConverterUnitTest {
@Test
public void testConvertToAbsolutePath() {
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 testConvertToAbsolutePath_withAbsolutePath() {
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 testConvertToAbsolutePath_withEmptyPath() {
String emptyPath = "";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(emptyPath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(emptyPath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(emptyPath));
}
@Test
public void testConvertToAbsolutePath_withParentDirectory() {
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 testConvertToAbsolutePath_withRelativePathContainingDots() {
String relativePath = "././data/sample.txt";
System.out.println(RelativePathConverter.convertToAbsoluteUsePathsClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileClass(relativePath));
System.out.println(RelativePathConverter.convertToAbsoluteUseFileSystemsClass(relativePath));
}
}