Java, Web and Mobile

Blog

How to unit test hazelcast

|
Java|Testing

Recently I used hazelcast in several projects. Especially in an Application Server environment using the hazelcast JCA connector it is pretty easy to use hazelcast with only a few lines of code. Unfortunately, Hazelcast.getAllHazelcastInstances() returns an empty set in unit tests. So, what we need to do is to mock our HazelcastFactory somehow.

Dynamically resolve Hibernate database dialect

|
Java|Java EE

When using Hibernate as JPA provider you need to tell the application which database vendor you are using. The classic approach is to set the property “hibernate.dialect”. This works in most cases. However, I often have to cope with different database vendors serving the same datasource – depending on the current environment. A solution to this problem is to use a DialectResolver that dynamically detects the needed Hibernate dialect to talk to the database.