• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unmarshalling the XML to create an Object of a class

 
batuk chatuk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing JUnit testcases for my application. In the application there are complex VOs (Value objects) and TO objects which have arrayLists.Now i create an dummy XML from the dummy data, unmarshall it to create dummy object and then Compare it to the above actual object.

For comparing simple objects which have primitive types (int,String,..) i can unmarshall the dummy XML to object and compare it. (with reflection API)
Same thing i am not able to do when there are Arraylists and arraylists within arraylists in an object.. When I try to unmarshall that, i dont get the converted object in proper format.

Is there any way I can unmarshal complex objects with 3 to 4 hierarchies so I can compare them and test???
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you use SAX to walk both trees and fail when they don't match?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the goal of the test to verify the unmarshalling code? If so, sounds like it needs work on the nested collections. Did you write this or is it a library from open source or a tool vendor?
 
batuk chatuk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to test the application we are first of all keeping a dummy XML which will have output parameters as per given input for a specific function.

Now we call that function with same input paras and then take the output object. This object is matched with the Unmarshalled Object of the dummy XML.

So this will be a testcase for our application and if Objects dont match it will return False.. This way all functions of particular class can be tested and any changes that affect the functional part will be easily detected...

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic