I am trying successfully XmlUnit, and is very helpful in my job. Now, I have a little problem, that I don't know how to solve. I have a java class, that has a Set, and when transforming it into XML, the elements inside can have any order.
When I try these two files in XmlUnit it works (Diff says that they are similar):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Monitor>
<AvailableMeasures>
<MeasureDescriptorA name="netInput_mynetwork"></MeasureDescriptorA>
<MeasureDescriptor name="netInput_myothernetwork"></MeasureDescriptor>
</AvailableMeasures>
</Monitor>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Monitor>
<AvailableMeasures>
<MeasureDescriptor name="netInput_myothernetwork"></MeasureDescriptor>
<MeasureDescriptorA name="netInput_mynetwork"></MeasureDescriptorA>
</AvailableMeasures>
</Monitor>
But when the tags have the same name (with different attributes) it doesn't work (it mixes the attributes, and expect the one in the other tag):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Monitor>
<AvailableMeasures>
<MeasureDescriptor name="netInput_myothernetwork"></MeasureDescriptor>
<MeasureDescriptor name="netInput_mynetwork"></MeasureDescriptor>
</AvailableMeasures>
</Monitor>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Monitor>
<AvailableMeasures>
<MeasureDescriptor name="netInput_mynetwork"></MeasureDescriptor>
<MeasureDescriptor name="netInput_myothernetwork"></MeasureDescriptor>
</AvailableMeasures>
</Monitor>
Is there any workaround?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…