mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2024-11-11 02:10:11 +01:00
Fix: fail JUnit test (#1625)
This commit is contained in:
parent
0f60974a57
commit
e6793bd04a
@ -1,10 +1,11 @@
|
||||
package stirling.software.SPDF.utils;
|
||||
package stirling.software.SPDF;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -14,7 +15,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import stirling.software.SPDF.SPdfApplication;
|
||||
import stirling.software.SPDF.model.ApplicationProperties;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@ -43,12 +43,43 @@ public class SPdfApplicationTest {
|
||||
|
||||
@Test
|
||||
public void testMainApplicationStartup() throws IOException, InterruptedException {
|
||||
// Setup mock environment for the main method
|
||||
Path configPath = Path.of("test/configs");
|
||||
Path settingsPath = Paths.get("test/configs/settings.yml");
|
||||
Path customSettingsPath = Paths.get("test/configs/custom_settings.yml");
|
||||
Path staticPath = Path.of("test/customFiles/static/");
|
||||
Path templatesPath = Path.of("test/customFiles/templates/");
|
||||
|
||||
// Ensure the files do not exist for the test
|
||||
if (Files.exists(settingsPath)) {
|
||||
Files.delete(settingsPath);
|
||||
}
|
||||
if (Files.exists(customSettingsPath)) {
|
||||
Files.delete(customSettingsPath);
|
||||
}
|
||||
if (Files.exists(staticPath)) {
|
||||
Files.delete(staticPath);
|
||||
}
|
||||
if (Files.exists(templatesPath)) {
|
||||
Files.delete(templatesPath);
|
||||
}
|
||||
|
||||
// Ensure the directories are created for testing
|
||||
Files.createDirectories(configPath);
|
||||
Files.createDirectories(staticPath);
|
||||
Files.createDirectories(templatesPath);
|
||||
|
||||
Files.createFile(settingsPath);
|
||||
Files.createFile(customSettingsPath);
|
||||
|
||||
// Run the main method
|
||||
SPdfApplication.main(new String[]{});
|
||||
|
||||
// Verify that the directories were created
|
||||
assertTrue(Files.exists(Path.of("customFiles/static/")));
|
||||
assertTrue(Files.exists(Path.of("customFiles/templates/")));
|
||||
assertTrue(Files.exists(settingsPath));
|
||||
assertTrue(Files.exists(customSettingsPath));
|
||||
assertTrue(Files.exists(staticPath));
|
||||
assertTrue(Files.exists(templatesPath));
|
||||
}
|
||||
|
||||
@Test
|
@ -13,7 +13,7 @@ public class FileToPdfTest {
|
||||
@Test
|
||||
public void testConvertHtmlToPdf() {
|
||||
HTMLToPdfRequest request = new HTMLToPdfRequest();
|
||||
byte[] fileBytes = new byte[10]; // Sample file bytes
|
||||
byte[] fileBytes = new byte[0]; // Sample file bytes
|
||||
String fileName = "test.html"; // Sample file name
|
||||
boolean htmlFormatsInstalled = true; // Sample boolean value
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user