Denis Bolshakov
Denis Bolshakov

Reputation: 315

Incorrect output with log object to xml

I need to log XML message. I use this code:

    //From object to xml
public String createMarshalerDealInfoType(DealInfoType dealInfoType) {
    StringWriter contactStr = null;
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(DealInfoType.class);
        Marshaller jaxbUnmarshaller = jaxbContext.createMarshaller();
        contactStr = new StringWriter();
        jaxbUnmarshaller.marshal(dealInfoType, contactStr);
    } catch (JAXBException e) {
        log.error(e.getMessage());
    }
    return contactStr.toString();
}

In test class:

        ResponseType ResponseType = woNspDealWS.createRequestWS(DealRequestType);
        String DealResponce = updateDealEsb.createMarshalerDealInfoType(ResponseType.getDealInfo());
        log.debug("Response: \n " + DealResponce);

Problem: in log output I see only first line of responce, not whole message

    18:01:42,975 DEBUG updateDeal_Test:73 - Response:  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

How do I make to print all response in XML?

SOLVED: resolved problem with use annotation @XmlRootElement for test class.

Upvotes: 1

Views: 142

Answers (2)

Denis Bolshakov
Denis Bolshakov

Reputation: 315

For solving this problem need use annotation @XmlRootElement in test class

Upvotes: 1

Kiran
Kiran

Reputation: 366

The object which you have passed in test class might be empty ResponseType.getDealInfo()

Upvotes: 1

Related Questions