From 249c81ef4cf1db3cf4248c33fe614ff299e2dd57 Mon Sep 17 00:00:00 2001 From: mrfoxygmfr Date: Sun, 23 Mar 2025 14:53:14 +0300 Subject: test(db): add simple hibernate config test --- .../db/config/HibernateConfigTest.java | 26 ++++++++++++++++++++++ src/test/resources/application.properties | 6 +++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfigTest.java create mode 100644 src/test/resources/application.properties (limited to 'src/test') diff --git a/src/test/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfigTest.java b/src/test/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfigTest.java new file mode 100644 index 0000000..0fba515 --- /dev/null +++ b/src/test/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfigTest.java @@ -0,0 +1,26 @@ +package ru.mrfoxygmfr.warehouse_accounting.db.config; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +import org.springframework.test.context.TestPropertySource; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@SpringBootTest +@TestPropertySource(locations="classpath:application.properties") +class HibernateConfigTest { + @Autowired + private LocalSessionFactoryBean sessionFactory; + + @Test + public void test() { + SessionFactory sessionFactoryObject = sessionFactory.getObject(); + assertNotNull(sessionFactoryObject); + Session session = sessionFactoryObject.openSession(); + assertNotNull(session); + } +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..f1d166d --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,6 @@ +spring.application.name=warehouse_accounting + +database.driver=org.postgresql.Driver +database.url=jdbc:postgresql://localhost:5432/warehouse_accounting +database.username=postgres +database.password=postgres -- cgit mrf-deployment