[IMPL] mkvtoolproptest

This commit is contained in:
RatzzFatzz
2019-11-23 16:22:14 +01:00
parent 6744597363
commit 7c2e292da2
3 changed files with 56 additions and 24 deletions

View File

@@ -1,45 +1,77 @@
package config;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Scanner;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Log4j2
public class MKVToolPropertiesTest {
@Mock
Scanner input;
@Test
public void testPathIsValid() {
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("test/resources");
out.print("src/test/resources");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("test/resources/");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}finally{
File file = new File("mkvDirectoryPath");
file.delete();
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertEquals("src/test/resources\\mkvmerge.exe", MKVToolProperties.getInstance().getMkvmergePath());
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("src/test/resources/");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertEquals("src/test/resources/mkvmerge.exe", MKVToolProperties.getInstance().getMkvmergePath());
}
@Test
public void testCreateFilePath() {
// input = mock(Scanner.class);
// when(input.nextLine()).thenReturn("test\\resources\\");
// MKVToolProperties.createFilePath();
// MKVToolProperties prop = new MKVToolProperties();
// assertEquals(prop.getMkvmergePath(), "test\\resources\\mkvmerge.exe");
public void testCheckForSeparator() {
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("src/test/resources");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertTrue(MKVToolProperties.getInstance().getDirectoryPath().endsWith("/") || MKVToolProperties.getInstance().getDirectoryPath().endsWith("\\"));
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("src/test/resources/");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertTrue(MKVToolProperties.getInstance().getDirectoryPath().endsWith("/") || MKVToolProperties.getInstance().getDirectoryPath().endsWith("\\"));
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("src\\test\\resources");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertTrue(MKVToolProperties.getInstance().getDirectoryPath().endsWith("/") || MKVToolProperties.getInstance().getDirectoryPath().endsWith("\\"));
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
out.print("src\\test\\resources\\");
}catch(FileNotFoundException | UnsupportedEncodingException e){
log.error("File not found!");
}
MKVToolProperties.getInstance().defineMKVToolNixPath();
assertTrue(MKVToolProperties.getInstance().getDirectoryPath().endsWith("/") || MKVToolProperties.getInstance().getDirectoryPath().endsWith("\\"));
}
@AfterEach
public void afterAll() {
File file = new File("mkvDirectoryPath");
file.delete();
}
}