added ApplicationTests

This commit is contained in:
2026-04-06 03:51:36 +02:00
parent ba7887f6b2
commit 9c3e1469c7
@@ -9,8 +9,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.context.ApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@SpringBootTest @SpringBootTest
@ActiveProfiles("test") @ActiveProfiles("test")
@@ -19,10 +21,23 @@ class ApplicationTests {
@Autowired @Autowired
private DataSource dataSource; private DataSource dataSource;
@Autowired
private ApplicationContext context;
@Test
void contextLoads() {
}
@Test @Test
void connectionToTestDbWorks() throws SQLException { void connectionToTestDbWorks() throws SQLException {
try (Connection connection = dataSource.getConnection()) { try (Connection connection = dataSource.getConnection()) {
assertThat(connection.getMetaData().getURL()).contains("vaessl_test"); assertThat(connection.getMetaData().getURL()).contains("vaessl_test");
} }
} }
@Test
void main() {
Application.main(new String[] {});
assertNotNull(context, "The Spring context should not be null");
}
} }