aspose file tools*
The moose likes XML and Related Technologies and the fly likes Unmarshalling the XML to create an Object of a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unmarshalling the XML to create an Object of a class" Watch "Unmarshalling the XML to create an Object of a class" New topic
Author

Unmarshalling the XML to create an Object of a class

batuk chatuk
Greenhorn

Joined: Dec 29, 2006
Posts: 12
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

Joined: Mar 06, 2001
Posts: 13459

can you use SAX to walk both trees and fail when they don't match?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
batuk chatuk
Greenhorn

Joined: Dec 29, 2006
Posts: 12
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Unmarshalling the XML to create an Object of a class