Hibernate is required to be on create in test config
Currently in the application.yaml/ properties
Hibernate is configured as create in test. If this is changed to validate the test fail with the following exception:
nl.tudelft.ewi.QueueApplicationTests > contextLoads FAILED
java.lang.IllegalStateException
Caused by: org.springframework.beans.factory.BeanCreationException
Caused by: org.springframework.dao.DataIntegrityViolationException
Caused by: org.hibernate.exception.ConstraintViolationException
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException
2019-11-11 11:33:20 [Thread-25] INFO o.s.m.s.b.SimpleBrokerMessageHandler - Stopping...
2019-11-11 11:33:20 [Thread-25] INFO o.s.m.s.b.SimpleBrokerMessageHandler - BrokerAvailabilityEvent[available=false, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2019-11-11 11:33:20 [Thread-25] INFO o.s.m.s.b.SimpleBrokerMessageHandler - Stopped.
2019-11-11 11:33:20 [Thread-25] INFO o.s.s.c.ThreadPoolTaskExecutor - Shutting down ExecutorService 'brokerChannelExecutor'
2019-11-11 11:33:20 [Thread-25] INFO o.s.s.c.ThreadPoolTaskScheduler - Shutting down ExecutorService 'messageBrokerTaskScheduler'
2019-11-11 11:33:20 [Thread-25] INFO o.s.s.c.ThreadPoolTaskExecutor - Shutting down ExecutorService 'clientOutboundChannelExecutor'
2019-11-11 11:33:20 [Thread-25] INFO o.s.s.c.ThreadPoolTaskExecutor - Shutting down ExecutorService 'clientInboundChannelExecutor'
2019-11-11 11:33:20 [Thread-25] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'default'
2019-11-11 11:33:20 [Thread-25] WARN o.s.b.f.s.DisposableBeanAdapter - Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-199]
2019-11-11 11:33:20 [Thread-25] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-6 - Shutdown initiated...
2019-11-11 11:33:20 [Thread-25] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-6 - Shutdown completed.
This means that there is state being cleaned up by hibernate between tests to avoid this duplicate insertion of data. I don't think anyone currently has an idea what tests influence what state in the database and how to clean that up properly.
The first step would be to catalog our tests and what state they affect. Secondly finding the right mechanism in spring to clean this up. Finally configure hibernate to be validate in test.
Edited by Liam Clark