Jonathan and Amol, thank a lot for your response. I liked the idea of
DateProvider implementations.
Few more points though:
1) The solution is not for unit testing. We want virtual system date
for functional testing where tester is not a java programmer.
2) Also the solution has to addres multiple applications under same
app server with different virtual system date rqmt.
Thank you very much,
Keshav
On Tue, 22 Mar 2005 15:55:53 -0500, Amol Deshmukh
<adeshmukh@xxxxxxxxxxxxxx> wrote:
> One minor modification you may want to make to
> AssignableDateProvider (or provide an alternate
> impl of DateProvider interface) is to specify
> the offset in number of days to the constructor
> instead of exact date.
>
> This way if you want to keep your test server
> running (without restart) for more than one day,
> you dont get the same "current date" every day.
>
> Then again, maybe that's not what you want :)
>
> ~ amol
>
>
> > -----Original Message-----
> > From: Jonathan A. Chase [mailto:chaseja@xxxxxxxxxx]
> > Sent: Tuesday, March 22, 2005 3:52 PM
> > To: Keshav Kode; users@xxxxxxxxxx
> > Subject: Re: [cinjug-users] help: How to create virtual current system
> > date for J2EE applications hosted under the same WAS?
> >
> >
> > We had a similar problem. It sounds like we did the same
> > thing you're
> > thinking about:
> >
> > 1) we defined an interface, say, DateProvider, with one
> > method, getDate()
> > 2) our default implementation of the interface, DefaultDateProvider,
> > looked like:
> > /** return the real date, according to the OS */
> > public Date getDate() {
> > return new java.util.Date();
> > }
> > 3) the implementation we used for (junit) testing,
> > AssignableDateProvider,
> > looked like:
> > /** saves a date passed in by the user */
> > public AssignableDateProvider(Date d) {
> > this.date = d;
> > }
> > /** return whatever date you set in the constructor */
> > public Date getDate() {
> > return this.date;
> > }
> >
> > In our test code we used the AssignableDateProvider
> > implementation, in
> > production we used the DefaultDateProvider implementation.
> >
> > So you could either use a sigleton like you suggested with the above
> > strategy, or better yet, make the DateProvider an attribute
> > of whatever
> > class it is that's using it, and make sure the class uses a
> > DefaultDateProvider by default (say, set in the constructor).
> > Then, for
> > testing, call yourObject.setDateProvider(new
> > AssignableDateProvider(your
> > date)) and you should be good to go. With the latter
> > approach, you don't
> > run into any of the nastiness of singletons:D.
> >
> > HTH,
> > Jon
> >
> > On Mon, 21 Mar 2005 16:02:51 -0600, Keshav Kode
> > <keshav.kode@xxxxxxxxx>
> > wrote:
> >
> > > Hello Cinjuggers,
> > >
> > > We are working with a client who has multiple J2EE projects
> > under WAS.
> > > They want to be able to do functional testing of those applications
> > > with different "Current SYSTEM_DATE" then the actual SYSTEM_DATE for
> > > some functionality. To explain this lets say today (i.e. on
> > > 03/21/2005) Tester A wants to test Application APP_A with current
> > > system date as "01/01/2005" a the same time Tester B wants to test
> > > APP_B with system date as "02/24/2003" in same WAS test environment.
> > >
> > > To accomplish it right now they are modifying the SYSTEM_DATE at OS
> > > level and testing their applications. But it is causing lot
> > of problem
> > > to the other application on that server. Also this does not
> > allow them
> > > to test multiple applications at same time with different system
> > > dates.
> > >
> > > To resolve the problem we are suggesting them to add abstraction
> > > layer, which based on Production or test environment will return
> > > actual system date or configured test SYSTEM_DATE. All the
> > application
> > > will have to use this layer (may be Singleton object) to get current
> > > system time. This singleton object will also save different current
> > > time for different applications so that they can be tested
> > separately.
> > >
> > > Is this the right way to solve this problem? Is there are
> > other option
> > > available with minimal performance impact? Has anyone faced similar
> > > problem earlier? Any pointer will be greatly appreciated.
> > >
> > > Thanks a lot in advance,
> > > Keshav.
> > >
> > > ---------
> > > You may unsubscribe from this mailing list
> > > by sending a blank email addressed to:
> > > users-unsubscribe@xxxxxxxxxx
> > >
> > > --
> > > Find additional help by sending a blank email
> > > addressed to:
> > > users-help@xxxxxxxxxx
> > >
> >
> >
> >
> > --
> > Jonathan A. Chase
> > Miami University DARS Project
> > http://www.dars.muohio.edu
> > chaseja@xxxxxxxxxx
> > (513) 529-1401
> >
> > ---------
> > You may unsubscribe from this mailing list
> > by sending a blank email addressed to:
> > users-unsubscribe@xxxxxxxxxx
> >
> > --
> > Find additional help by sending a blank email
> > addressed to:
> > users-help@xxxxxxxxxx
> >
>
--
Thank you,
Keshav Kode
Keshav.Kode@xxxxxxxxx
|