Search in sources :

Example 1 with LogicalMessageImpl

use of org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl in project cxf by apache.

the class LogicalMessageImplTest method testGetPayloadOfJAXB.

@Test
public void testGetPayloadOfJAXB() throws Exception {
    // using Dispatch
    JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class);
    Message message = new MessageImpl();
    Exchange e = new ExchangeImpl();
    message.setExchange(e);
    LogicalMessageContextImpl lmci = new LogicalMessageContextImpl(message);
    JAXBElement<AddNumbers> el = new ObjectFactory().createAddNumbers(req);
    LogicalMessageImpl lmi = new LogicalMessageImpl(lmci);
    lmi.setPayload(el, ctx);
    Object obj = lmi.getPayload(ctx);
    assertTrue(obj instanceof JAXBElement);
    JAXBElement<?> el2 = (JAXBElement<?>) obj;
    assertTrue(el2.getValue() instanceof AddNumbers);
    AddNumbers resp = (AddNumbers) el2.getValue();
    assertEquals(req.getArg0(), resp.getArg0());
    assertEquals(req.getArg1(), resp.getArg1());
}
Also used : Message(org.apache.cxf.message.Message) LogicalMessageImpl(org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Exchange(org.apache.cxf.message.Exchange) LogicalMessageContextImpl(org.apache.cxf.jaxws.handler.logical.LogicalMessageContextImpl) ObjectFactory(org.apache.handlers.types.ObjectFactory) AddNumbers(org.apache.handlers.types.AddNumbers) MessageImpl(org.apache.cxf.message.MessageImpl) LogicalMessageImpl(org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

JAXBContext (javax.xml.bind.JAXBContext)1 JAXBElement (javax.xml.bind.JAXBElement)1 LogicalMessageContextImpl (org.apache.cxf.jaxws.handler.logical.LogicalMessageContextImpl)1 LogicalMessageImpl (org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl)1 Exchange (org.apache.cxf.message.Exchange)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1 Message (org.apache.cxf.message.Message)1 MessageImpl (org.apache.cxf.message.MessageImpl)1 AddNumbers (org.apache.handlers.types.AddNumbers)1 ObjectFactory (org.apache.handlers.types.ObjectFactory)1 Test (org.junit.Test)1