Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

resetting a static object?

807588Jun 10 2009 — edited Jun 10 2009
Okay I've created an application to create and monitor a number of other applications. My contorller application consists of a main method and a number of static methods and objects. I'm trying to create tests to test the functionality of the application.

The problem I have is it's static. once I run the main method once variables get set, timers started, sockets locked ect. This makes it very difficult to run independent tests as every test after the first already has the application running and changes made to it's static variables. What I would like is at the end of each test the static object acted as if the application was closed: releasing locks it held, resetting variables to default, and calling the onExit method. That way the next test in the suit won't be effected by changes made to static variables in the previous state.

Does anyone know an easy way of doing that? For now I'm calling the my onExit method directly which stops timers and releases sockets, but I still don't feel confident that my tests are running truely independently so long as they are sharing a static object.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 8 2009
Added on Jun 10 2009
5 comments
1,352 views