1

I am working on an enterprise application running in JBOSS application server. The application records product subscriptions and creates transactions once a month.

I want to develop an automated test case in which it makes a subscription, shifts the date by 10 months and creates transactions(10 transactions need to be created).

Is there any way to shift the date in JBOSS application server using Java?

lucrussell
  • 5,032
  • 2
  • 33
  • 39
user2307172
  • 141
  • 1
  • 9
  • Something like `Calendar.add(Calendar.MONTH, -10)`? – Luiggi Mendoza Apr 23 '13 at 07:23
  • You mean changing the system time where the Jboss instance is running? – dcernahoschi Apr 23 '13 at 07:37
  • not really. in theory any place in your code that calls System.currentTimeMillis() is a problem. you need to move all time/date related calls to a single EJB and then mock/replace it. – radai Apr 23 '13 at 07:38
  • Here is an idea of how to mock the `System` class to return a fake time during testing: http://virgo47.wordpress.com/2012/06/22/changing-system-time-in-java/ – dcernahoschi Apr 23 '13 at 07:46
  • Mocking the system class just worked. But I have found another problem. This approach change the time of the JVM. Is there anyway to restrict it a particular class loader of the JVM ?. Because I just want to change the time in my application but not the JBOSS itself. – user2307172 Apr 24 '13 at 05:20

0 Answers0