Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock object: dump real and restore

 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 5415
52
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic