Maven + Jaxb Marshalling Accent Characters + Unit Test -


i have unit test unmarshalling xml file jaxb objects marshalling string , comparing original xml string:

@runwith(springjunit4classrunner.class) @contextconfiguration(locations = {"/info/info-element-reader-test-context.xml"}) public class infoelementreadertest {      private static final logger logger = loggerfactory.getlogger(infoelementreadertest.class);      @autowired     private infoelementreader infoelementreader;      @test     public void testmarshalling() throws exception {          marshaller marshaller = infoelementreader.getjaxbcontext().createmarshaller();         marshaller.setproperty(marshaller.jaxb_formatted_output, true);         marshaller.setproperty(marshaller.jaxb_encoding, "utf-8");          // unmarshall java bean         infoelement infoelement = infoelementreader.unmarshallinfoelement();         bytearrayoutputstream outstream = new bytearrayoutputstream();         marshaller.marshal(infoelement, outstream);         logger.info("marshalled xml: {}", outstream.tostring());          string fromfile = ioutils.tostring(infoelementreader.getinforesource().getinputstream(), "utf-8").replaceall("\\s","");          string marshalled = outstream.tostring().replaceall(""", "\"").replaceall("\\s","");          assertequals("file contents should equal marshalled output", fromfile, marshalled);     } } 

when run test in ide (intellij idea) appears have no issues when compile mvn clean package unit test fails because accented characters in xml, ie. reddetelefoníamóvil, become reddetelefon[?am?vil , strings not equal.

not sure if issue maven or else appreciated. in advance.

have set encoding within pom file? utf-8


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -