Skip to content

Commit

Permalink
moving test back
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioGii committed Jan 6, 2025
1 parent 55d4aed commit 4c028c6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 59 deletions.
45 changes: 45 additions & 0 deletions src/test/java/stirling/software/SPDF/SPDFApplicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import org.springframework.core.env.Environment;

import stirling.software.SPDF.model.ApplicationProperties;
import static java.nio.file.Files.createDirectories;
import static java.nio.file.Files.createFile;
import static java.nio.file.Files.delete;
import static java.nio.file.Files.exists;

@ExtendWith(MockitoExtension.class)
public class SPDFApplicationTest {
Expand All @@ -34,6 +38,47 @@ public void setUp() {
SPDFApplication.setServerPortStatic("8080");
}

@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 (exists(settingsPath)) {
delete(settingsPath);
}
if (exists(customSettingsPath)) {
delete(customSettingsPath);
}
if (exists(staticPath)) {
delete(staticPath);
}
if (exists(templatesPath)) {
delete(templatesPath);
}

// Ensure the directories are created for testing
createDirectories(configPath);
createDirectories(staticPath);
createDirectories(templatesPath);

createFile(settingsPath);
createFile(customSettingsPath);

// Run the main method
SPDFApplication.main(new String[] {"-Dspring.profiles.active=default"});

// Verify that the directories were created
assertTrue(exists(settingsPath));
assertTrue(exists(customSettingsPath));
assertTrue(exists(staticPath));
assertTrue(exists(templatesPath));
}

@Test
public void testSetServerPortStatic() {
SPDFApplication.setServerPortStatic("9090");
Expand Down

This file was deleted.

0 comments on commit 4c028c6

Please sign in to comment.