Stefan Bodewig wrote:
Erik asked me to forward the mail below since he has trouble with
posting ...
I'm wondering if the below has more to do with how XMLUnit is
recognizing namespaces, as it really shouldn't matter on a difference if
the prefix is specified or not, but what namespaces are defined. In
this case, it looks as if it is expecting certain prefixes, instead of
just checking to see if it has all the required namespaces.
Dave
Stefan
==================
Hi,
I am comparing 2 documents which use different ways to represent the same
namespace. I expected the method XMLAssert.assertXMLEqual(Document,Document) to
treat these as similar.
Here is my code:
Document expectedEdiXml = XMLUtil.parseIntoDocument(ResourceLoader.getResource(this,
"ex2_mvwi10.xml"));
Document actualEdiXml = mvwi10.getPayloadAsDocument();
try {
XMLAssert.assertXMLEqual(expectedEdiXml, actualEdiXml);
} catch (AssertionFailedError e) {
System.out.println("expected: " + XMLUtil.prettyPrint(expectedEdiXml));
System.out.println("actual: " + mvwi10.getPayloadAsString());
throw e;
}
The exception thrown is:
junit.framework.AssertionFailedError: org.custommonkey.xmlunit.Diff
[not identical] Expected namespace prefix 'null' but was '' - comparing <Bericht...>
at /Bericht[1] to <Bericht...> at /Bericht[1]
[different] Expected number of child nodes '7' but was '3' - comparing <Bericht...>
at /Bericht[1] to <Bericht...> at /Bericht[1]
at junit.framework.Assert.fail(Assert.java:47)
at org.custommonkey.xmlunit.XMLAssert.assertXMLEqual(XMLAssert.java:125)
at org.custommonkey.xmlunit.XMLAssert.assertXMLEqual(XMLAssert.java:241)
at org.custommonkey.xmlunit.XMLAssert.assertXMLEqual(XMLAssert.java:188)
at xxxxxxxxxxxx.testTransform(EdiFromHl7_TransformerTest.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
The output on sysout is:
expected: <?xml version="1.0" encoding="UTF-8"?>
<Bericht xmlns="http://www.ozis.nl/medeur32/Mvwi10"
xmlns:cg="http://www.ozis.nl/medeur32/ContactGegevens"
xmlns:pa="http://www.ozis.nl/medeur32/Patient">
<BerichtGegevens>
<BerichtId>1234567890</BerichtId>
<BerichtFormaat naam="MEDEUR" release="2" versie="3"/>
<BerichtToepassing agency="IT"/>
<BerichtFunctie>MH</BerichtFunctie>
<BerichtCreatieDatumTijd>2007-05-08T10:30:00</BerichtCreatieDatumTijd>
<ProcesId>12345</ProcesId>
</BerichtGegevens>
<BetrokkenPartijen>
<BetrokkenPartij Rol="MS"
xmlns="http://www.ozis.nl/medeur32/BetrokkenPartijen">
<ZorgVerlenerId>
<ZorgVerlenerCode>1234</ZorgVerlenerCode>
<ZorgVerlenerCodeLijstAanduiding>AGB</ZorgVerlenerCodeLijstAanduiding>
<ZorgVerlenerCodeLijstBeheerder>VEK</ZorgVerlenerCodeLijstBeheerder>
</ZorgVerlenerId>
<ZorgVerlenerNaam>
<Naam>Groot</Naam>
<Initialen>K</Initialen>
<Voorvoegsel>de</Voorvoegsel>
</ZorgVerlenerNaam>
<Adres format="2" functie="WO" type="PO">
<cg:Straat>12345</cg:Straat>
<cg:PostCode>3000AA</cg:PostCode>
<cg:Plaatsnaam>Rotterdam</cg:Plaatsnaam>
</Adres>
<TelefoonFax type="TE">
<Nummer>01012345678</Nummer>
</TelefoonFax>
<TelefoonFax type="FX">
<Nummer>01087654321</Nummer>
</TelefoonFax>
<Email>
<Value>[EMAIL PROTECTED]</Value>
</Email>
</BetrokkenPartij>
<BetrokkenPartij Rol="MR"
xmlns="http://www.ozis.nl/medeur32/BetrokkenPartijen">
<ZorgVerlenerId>
<ZorgVerlenerCode>4321</ZorgVerlenerCode>
<ZorgVerlenerCodeLijstAanduiding>AGB</ZorgVerlenerCodeLijstAanduiding>
<ZorgVerlenerCodeLijstBeheerder>VEK</ZorgVerlenerCodeLijstBeheerder>
</ZorgVerlenerId>
<ZorgVerlenerNaam>
<Naam>Statenkwartier</Naam>
</ZorgVerlenerNaam>
<Adres format="1" functie="WO" type="PH">
<cg:Straat>Erasmusweg</cg:Straat>
<cg:HuisNummer>1</cg:HuisNummer>
<cg:PostCode>1512BA</cg:PostCode>
<cg:Plaatsnaam>Den Haag</cg:Plaatsnaam>
</Adres>
<TelefoonFax type="TE">
<Nummer>07012341234</Nummer>
</TelefoonFax>
<TelefoonFax type="FX">
<Nummer>07087654321</Nummer>
</TelefoonFax>
</BetrokkenPartij>
<BetrokkenPartij Rol="BV"
xmlns="http://www.ozis.nl/medeur32/BetrokkenPartijen">
<ZorgVerlenerId>
<ZorgVerlenerCode>5678</ZorgVerlenerCode>
<ZorgVerlenerCodeLijstAanduiding>AGB</ZorgVerlenerCodeLijstAanduiding>
<ZorgVerlenerCodeLijstBeheerder>VEK</ZorgVerlenerCodeLijstBeheerder>
</ZorgVerlenerId>
<ZorgVerlenerNaam>
<Naam>Valk</Naam>
<Initialen>M.K.</Initialen>
<Voorvoegsel>van der</Voorvoegsel>
</ZorgVerlenerNaam>
<Adres format="2" functie="WO" type="PH">
<cg:Straat>Erasmusbrug</cg:Straat>
<cg:HuisNummer>123</cg:HuisNummer>
<cg:HuisNummerToevoeging>II</cg:HuisNummerToevoeging>
<cg:PostCode>3925BB</cg:PostCode>
<cg:Plaatsnaam>Zoetermeer</cg:Plaatsnaam>
</Adres>
<TelefoonFax type="TE">
<Nummer>07012345678</Nummer>
</TelefoonFax>
<Email>
<Value>[EMAIL PROTECTED]</Value>
</Email>
</BetrokkenPartij>
</BetrokkenPartijen>
<MedischDossier>
<Patient>
<pa:PatientId type="LOK">
<pa:Nummer>1234567</pa:Nummer>
</pa:PatientId>
<PatientNaam type="4" xmlns="http://www.ozis.nl/medeur32/Patient">
<Achternaam>Kleintje</Achternaam>
<EchtgenootAchternaam>Reus,de</EchtgenootAchternaam>
<Initialen>MA</Initialen>
<Roepnaam>Marie-Anne</Roepnaam>
</PatientNaam>
<PatientAdres format="1" functie="HO" type="PH"
xmlns="http://www.ozis.nl/medeur32/Patient">
<cg:Straat>Hofwijckplein</cg:Straat>
<cg:HuisNummer>321</cg:HuisNummer>
<cg:PostCode>1111AA</cg:PostCode>
<cg:Plaatsnaam>Den Haag</cg:Plaatsnaam>
</PatientAdres>
<pa:PatientGeslacht>2</pa:PatientGeslacht>
<pa:PatientGeboorteDatum>1970-01-01</pa:PatientGeboorteDatum>
<PatientVerzekeringsGegevens xmlns="http://www.ozis.nl/medeur32/Patient">
<VerzekeraarCode>67890</VerzekeraarCode>
<VerzekeraarCodeLijstAanduiding>AGB</VerzekeraarCodeLijstAanduiding>
<VerzekeraarCodeLijstBeheerder>VEK</VerzekeraarCodeLijstBeheerder>
<VerzekeraarBeschrijving>10</VerzekeraarBeschrijving>
<VerzekeringsNummer>34567890</VerzekeringsNummer>
</PatientVerzekeringsGegevens>
</Patient>
<MedischeKarakteristieken>
<ProbleemEpisode/>
</MedischeKarakteristieken>
</MedischDossier>
</Bericht>
actual: <Bericht xmlns="http://www.ozis.nl/medeur32/Mvwi10"
xmlns:bet="http://www.ozis.nl/medeur32/BetrokkenPartijen">
<BerichtGegevens>
<BerichtId>1234567890</BerichtId>
<BerichtFormaat naam="MEDEUR" versie="3" release="2"/>
<BerichtToepassing value="MVWI10" agency="IT"/>
<BerichtFunctie>MH</BerichtFunctie>
<BerichtCreatieDatumTijd>2007-05-08T10:30:00</BerichtCreatieDatumTijd>
<ProcesId>12345</ProcesId>
</BerichtGegevens>
<BetrokkenPartijen>
<bet:BetrokkenPartij Rol="MS">
<bet:ZorgVerlenerId>
<bet:ZorgVerlenerCode>66666</bet:ZorgVerlenerCode>
<bet:ZorgVerlenerCodeLijstAanduiding>AGB</bet:ZorgVerlenerCodeLijstAanduiding>
<bet:ZorgVerlenerCodeLijstBeheerder>VAK</bet:ZorgVerlenerCodeLijstBeheerder>
</bet:ZorgVerlenerId>
<bet:ZorgVerlenerNaam>
<bet:Naam/>
<bet:Initialen/>
</bet:ZorgVerlenerNaam>
</bet:BetrokkenPartij>
<bet:BetrokkenPartij Rol="MR"/>
</BetrokkenPartijen>
<MedischDossier/>
</Bericht>
Obviously, the documents are quite not the same. However, the exception does
not correspond to what I expected.
Any thought to what I might do wrong? Is this a whitespace issue?
Regards,
Erik.
begin:vcard
fn:David Carver
n:Carver;David
org:STAR Standard
adr;dom:;;4670 Wyandotte Dr;Columbus;OH;43230
email;internet:[EMAIL PROTECTED]
title:XML Data Architect
tel;work:614-397-1313
tel;fax:skype: kingargyle
tel;home:614-475-7753
tel;cell:614-397-1313
x-mozilla-html:FALSE
url:http://www.starstandard.org/
version:2.1
end:vcard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Xmlunit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmlunit-general