I am writing tests for my Hibernate DAO implementations as I explained here and they run well when I execute them with Maven or on Eclipse with Run as -> Maven test
. The application uses Oracle so I had to define the TimeZone, and I did it adding Duser.timezone
to the pom file as is described here.
The problem is when I want to execute only one test method, because each method has its own running configuration on Eclipse, and it is disappointing to add the timezone to the VM arguments of each configuration.
I have tried adding System.setProperty("user.timezone", "UTC")
and also TimeZone.setDefault(new SimpleTimeZone(...))
to the @beforeClass
method but it doesn't work. It shows the error ORA-01882: timezone region not found
. I think that the cause is that @ContextConfiguration
connects to the database before the @beforeClass
method.
I have found a workaround that is adding it as a default argument to the VM. I have done it at Windows -> Preferences -> Installed JREs
.
Do you know a better way of doing it?