Please take a look at the tests in org.hibernate.test.connections. There may already be a test there that has the proper setup for your uses cases. If not, maybe it will give you some ideas about how your use cases can be tested.