From 428b4238e3a7280d71697d994a66174a250387a7 Mon Sep 17 00:00:00 2001 From: Dario Ghunney Ware Date: Mon, 6 Jan 2025 16:19:42 +0000 Subject: [PATCH] removing tests --- build.gradle | 2 +- ...r-compose-latest-fat-security-postgres.yml | 4 +- .../software/SPDF/SPDFApplication.java | 2 - .../software/SPDF/SPDFApplicationTest.java | 4 ++ .../database/DatabaseServiceTest.java | 51 ---------------- .../SPDFApplicationIntegrationTest.java | 58 ------------------- 6 files changed, 7 insertions(+), 114 deletions(-) delete mode 100644 src/test/java/stirling/software/SPDF/config/security/database/DatabaseServiceTest.java delete mode 100644 src/test/java/stirling/software/SPDF/integrationtests/SPDFApplicationIntegrationTest.java diff --git a/build.gradle b/build.gradle index 189c5aea..fc8b7c70 100644 --- a/build.gradle +++ b/build.gradle @@ -322,7 +322,7 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-oauth2-client:$springBootVersion" implementation "org.springframework.session:spring-session-core:$springBootVersion" - implementation "org.springframework:spring-jdbc" + implementation "org.springframework:spring-jdbc:6.2.1" implementation 'com.unboundid.product.scim2:scim2-sdk-client:2.3.5' // Don't upgrade h2database diff --git a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml index 1b4989de..2ad3d999 100644 --- a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml +++ b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml @@ -27,8 +27,8 @@ services: UMASK: "022" SYSTEM_DEFAULTLOCALE: en-US UI_APPNAME: Stirling-PDF - UI_HOMEDESCRIPTION: Demo site for Stirling-PDF Latest-fat with Security - UI_APPNAMENAVBAR: Stirling-PDF Latest-fat + UI_HOMEDESCRIPTION: Demo site for Stirling-PDF Latest-fat with Security and PostgreSQL + UI_APPNAMENAVBAR: Stirling-PDF Latest-fat-PostgreSQL SYSTEM_MAXFILESIZE: "100" METRICS_ENABLED: "true" SYSTEM_GOOGLEVISIBILITY: "true" diff --git a/src/main/java/stirling/software/SPDF/SPDFApplication.java b/src/main/java/stirling/software/SPDF/SPDFApplication.java index 9ecf6114..242a0bff 100644 --- a/src/main/java/stirling/software/SPDF/SPDFApplication.java +++ b/src/main/java/stirling/software/SPDF/SPDFApplication.java @@ -11,8 +11,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; diff --git a/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java b/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java index 2b182796..e155527b 100644 --- a/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java +++ b/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java @@ -16,6 +16,10 @@ import org.mockito.junit.jupiter.MockitoExtension; 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 { diff --git a/src/test/java/stirling/software/SPDF/config/security/database/DatabaseServiceTest.java b/src/test/java/stirling/software/SPDF/config/security/database/DatabaseServiceTest.java deleted file mode 100644 index 153ce8dc..00000000 --- a/src/test/java/stirling/software/SPDF/config/security/database/DatabaseServiceTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package stirling.software.SPDF.config.security.database; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import javax.sql.DataSource; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import stirling.software.SPDF.model.ApplicationProperties; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class DatabaseServiceTest { - - public static final String TEST_FILE = "test.txt"; - private final String BACKUP_PATH = "configs/db/backup/"; - - @Mock - private ApplicationProperties applicationProperties; - - @Mock - private DataSource dataSource; - - @InjectMocks - private DatabaseService databaseService; - - @Test - void testHasBackups() throws IOException { - Path backupDir = Paths.get(BACKUP_PATH); - Files.createDirectories(backupDir); - Path testFile = Paths.get(BACKUP_PATH + TEST_FILE); - ApplicationProperties.System system = mock(ApplicationProperties.System.class); - ApplicationProperties.Datasource datasource = mock(ApplicationProperties.Datasource.class); - - Files.createFile(testFile); - - when(applicationProperties.getSystem()).thenReturn(system); - when(system.getDatasource()).thenReturn(datasource); - when(datasource.isEnableCustomDatabase()).thenReturn(false); - - assertTrue(databaseService.hasBackup()); - - Files.deleteIfExists(testFile); - } -} \ No newline at end of file diff --git a/src/test/java/stirling/software/SPDF/integrationtests/SPDFApplicationIntegrationTest.java b/src/test/java/stirling/software/SPDF/integrationtests/SPDFApplicationIntegrationTest.java deleted file mode 100644 index 662ea304..00000000 --- a/src/test/java/stirling/software/SPDF/integrationtests/SPDFApplicationIntegrationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package stirling.software.SPDF.integrationtests; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import stirling.software.SPDF.SPDFApplication; -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; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@SpringBootTest -public class SPDFApplicationIntegrationTest { - - @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)); - } -}