my dog learned polymorphism*
The moose likes Java in General and the fly likes Mock object: dump real and restore Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Mock object: dump real and restore" Watch "Mock object: dump real and restore" New topic
Author

Mock object: dump real and restore

surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Hello Partners.
I have a method that I need to test:

To invoke this method I need to run server, send a message to it and only then the method will be invoked.
How would I make snapshot (dump) of objectOfBigClass in normal debug mode, and then use it in tests (without need to run server again)?

P.S. the BigClass has a lot of properties.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3605
    
  14

You could first write a program that sends a message to the server and creates the object. Then save the object to a local file. You can then recreate the object in your test program, by reading the file.

Honestly, why is the object that big? What does it do? Maybe its responsibilities are too much.
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Thanks Stephan. Am I right that to write object to a file, the object needs to be serializable?

Stephan van Hulst wrote:
Honestly, why is the object that big? What does it do? Maybe its responsibilities are too much.


The object is org.apache.synapse.MessageContext, it stores a lot of configuration properties (like info about transport, etc.).
I guess "responsibilities" is OOP related question, right?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock object: dump real and restore
 
Similar Threads
Getting thread dump from service running J app
restoring database using sql file
J2EE and EJB on SDK
use thread to stop application hanging
Garbage collection