mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
Merge branch 'main' into securityFixes
This commit is contained in:
commit
8605bf0716
@ -134,7 +134,7 @@ Stirling-PDF currently supports 40 languages!
|
|||||||
| Hungarian (Magyar) (hu_HU) |  |
|
| Hungarian (Magyar) (hu_HU) |  |
|
||||||
| Indonesian (Bahasa Indonesia) (id_ID) |  |
|
| Indonesian (Bahasa Indonesia) (id_ID) |  |
|
||||||
| Irish (Gaeilge) (ga_IE) |  |
|
| Irish (Gaeilge) (ga_IE) |  |
|
||||||
| Italian (Italiano) (it_IT) |  |
|
| Italian (Italiano) (it_IT) |  |
|
||||||
| Japanese (日本語) (ja_JP) |  |
|
| Japanese (日本語) (ja_JP) |  |
|
||||||
| Korean (한국어) (ko_KR) |  |
|
| Korean (한국어) (ko_KR) |  |
|
||||||
| Norwegian (Norsk) (no_NB) |  |
|
| Norwegian (Norsk) (no_NB) |  |
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
package stirling.software.common.util;
|
package stirling.software.common.util;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyList;
|
||||||
|
import static org.mockito.Mockito.mockStatic;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.MockedStatic;
|
import org.mockito.MockedStatic;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
|
import stirling.software.common.util.ProcessExecutor.ProcessExecutorResult;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.Mockito.mockStatic;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
class CheckProgramInstallTest {
|
class CheckProgramInstallTest {
|
||||||
|
|
||||||
@ -140,7 +142,7 @@ class CheckProgramInstallTest {
|
|||||||
void testGetAvailablePythonCommand_WhenNoPythonIsAvailable()
|
void testGetAvailablePythonCommand_WhenNoPythonIsAvailable()
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
// Arrange
|
// Arrange
|
||||||
when(mockExecutor.runCommandWithOutputHandling(any(List.class)))
|
when(mockExecutor.runCommandWithOutputHandling(anyList()))
|
||||||
.thenThrow(new IOException("Command not found"));
|
.thenThrow(new IOException("Command not found"));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@ -168,7 +170,7 @@ class CheckProgramInstallTest {
|
|||||||
String firstCall = CheckProgramInstall.getAvailablePythonCommand();
|
String firstCall = CheckProgramInstall.getAvailablePythonCommand();
|
||||||
|
|
||||||
// Change the mock to simulate a change in the environment
|
// Change the mock to simulate a change in the environment
|
||||||
when(mockExecutor.runCommandWithOutputHandling(any(List.class)))
|
when(mockExecutor.runCommandWithOutputHandling(anyList()))
|
||||||
.thenThrow(new IOException("Command not found"));
|
.thenThrow(new IOException("Command not found"));
|
||||||
|
|
||||||
String secondCall = CheckProgramInstall.getAvailablePythonCommand();
|
String secondCall = CheckProgramInstall.getAvailablePythonCommand();
|
||||||
|
@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyList;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
import static org.mockito.ArgumentMatchers.argThat;
|
||||||
import static org.mockito.Mockito.mockStatic;
|
import static org.mockito.Mockito.mockStatic;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@ -132,7 +133,7 @@ class PDFToFileTest {
|
|||||||
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
||||||
.thenReturn(mockProcessExecutor);
|
.thenReturn(mockProcessExecutor);
|
||||||
|
|
||||||
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
|
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
|
||||||
.thenAnswer(
|
.thenAnswer(
|
||||||
invocation -> {
|
invocation -> {
|
||||||
// When command is executed, simulate creation of output files
|
// When command is executed, simulate creation of output files
|
||||||
@ -175,7 +176,7 @@ class PDFToFileTest {
|
|||||||
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
||||||
.thenReturn(mockProcessExecutor);
|
.thenReturn(mockProcessExecutor);
|
||||||
|
|
||||||
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
|
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
|
||||||
.thenAnswer(
|
.thenAnswer(
|
||||||
invocation -> {
|
invocation -> {
|
||||||
// When command is executed, simulate creation of output files
|
// When command is executed, simulate creation of output files
|
||||||
@ -251,7 +252,7 @@ class PDFToFileTest {
|
|||||||
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.PDFTOHTML))
|
||||||
.thenReturn(mockProcessExecutor);
|
.thenReturn(mockProcessExecutor);
|
||||||
|
|
||||||
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class), any(File.class)))
|
when(mockProcessExecutor.runCommandWithOutputHandling(anyList(), any(File.class)))
|
||||||
.thenAnswer(
|
.thenAnswer(
|
||||||
invocation -> {
|
invocation -> {
|
||||||
// When command is executed, simulate creation of output files
|
// When command is executed, simulate creation of output files
|
||||||
@ -537,7 +538,7 @@ class PDFToFileTest {
|
|||||||
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE))
|
.when(() -> ProcessExecutor.getInstance(ProcessExecutor.Processes.LIBRE_OFFICE))
|
||||||
.thenReturn(mockProcessExecutor);
|
.thenReturn(mockProcessExecutor);
|
||||||
|
|
||||||
when(mockProcessExecutor.runCommandWithOutputHandling(any(List.class)))
|
when(mockProcessExecutor.runCommandWithOutputHandling(anyList()))
|
||||||
.thenAnswer(
|
.thenAnswer(
|
||||||
invocation -> {
|
invocation -> {
|
||||||
// When command is executed, find the output directory argument
|
// When command is executed, find the output directory argument
|
||||||
|
Loading…
Reference in New Issue
Block a user