diff options
author | mrfoxygmfr <mrfoxygmfr@sch9.ru> | 2025-03-23 14:53:14 +0300 |
---|---|---|
committer | mrfoxygmfr <mrfoxygmfr@sch9.ru> | 2025-03-23 14:53:14 +0300 |
commit | 249c81ef4cf1db3cf4248c33fe614ff299e2dd57 (patch) | |
tree | 2bfcea9b6e0b2f07426327d55b945ecd962d4c55 | |
parent | e06ab0f9e796e914529bdd55dbeb6f04846aed02 (diff) |
test(db): add simple hibernate config test
-rw-r--r-- | src/test/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfigTest.java | 26 | ||||
-rw-r--r-- | src/test/resources/application.properties | 6 |
2 files changed, 32 insertions, 0 deletions
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 |