mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
[IMPL] mkvtoolproptest
This commit is contained in:
@@ -6,6 +6,4 @@ public class Main {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
MKVToolProperties.getInstance().defineMKVToolNixPath();
|
MKVToolProperties.getInstance().defineMKVToolNixPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package config;
|
package config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -11,6 +12,7 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@Getter
|
||||||
public class MKVToolProperties {
|
public class MKVToolProperties {
|
||||||
private String directoryPath;
|
private String directoryPath;
|
||||||
private String mkvmergePath;
|
private String mkvmergePath;
|
||||||
@@ -59,7 +61,7 @@ public class MKVToolProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkForSeparator() {
|
private void checkForSeparator() {
|
||||||
if(! (directoryPath.endsWith("/") || directoryPath.endsWith("\\"))){
|
if(! (directoryPath.endsWith("/") || (directoryPath.endsWith("\\") && System.getProperty("os.name").toLowerCase().contains("windows")))){
|
||||||
directoryPath += File.separator;
|
directoryPath += File.separator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +80,7 @@ public class MKVToolProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void searchInDefaultPath() {
|
private void searchInDefaultPath() {
|
||||||
|
directoryPath = "C:\\Program Files\\MKVToolNix";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchWithUserPath(Scanner input) {
|
private void searchWithUserPath(Scanner input) {
|
||||||
|
|||||||
@@ -1,45 +1,77 @@
|
|||||||
package config;
|
package config;
|
||||||
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mock;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
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
|
@Log4j2
|
||||||
public class MKVToolPropertiesTest {
|
public class MKVToolPropertiesTest {
|
||||||
|
|
||||||
@Mock
|
|
||||||
Scanner input;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPathIsValid() {
|
public void testPathIsValid() {
|
||||||
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
|
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
|
||||||
out.print("test/resources");
|
out.print("src/test/resources");
|
||||||
}catch(FileNotFoundException | UnsupportedEncodingException e){
|
}catch(FileNotFoundException | UnsupportedEncodingException e){
|
||||||
log.error("File not found!");
|
log.error("File not found!");
|
||||||
}
|
}
|
||||||
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
|
MKVToolProperties.getInstance().defineMKVToolNixPath();
|
||||||
out.print("test/resources/");
|
assertEquals("src/test/resources\\mkvmerge.exe", MKVToolProperties.getInstance().getMkvmergePath());
|
||||||
}catch(FileNotFoundException | UnsupportedEncodingException e){
|
|
||||||
log.error("File not found!");
|
|
||||||
}finally{
|
|
||||||
File file = new File("mkvDirectoryPath");
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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
|
@Test
|
||||||
public void testCreateFilePath() {
|
public void testCheckForSeparator() {
|
||||||
// input = mock(Scanner.class);
|
try(PrintWriter out = new PrintWriter("mkvDirectoryPath", "UTF-8")){
|
||||||
// when(input.nextLine()).thenReturn("test\\resources\\");
|
out.print("src/test/resources");
|
||||||
// MKVToolProperties.createFilePath();
|
}catch(FileNotFoundException | UnsupportedEncodingException e){
|
||||||
// MKVToolProperties prop = new MKVToolProperties();
|
log.error("File not found!");
|
||||||
// assertEquals(prop.getMkvmergePath(), "test\\resources\\mkvmerge.exe");
|
}
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user