Package org.switchyard.component.soap.composer

Examples of org.switchyard.component.soap.composer.SOAPContextMapper


    public void testValueContextMapping() throws Exception {
        testStringContextMapping(SOAPHeadersType.VALUE);
    }

    private void testStringContextMapping(SOAPHeadersType soapHeadersType) throws Exception {
        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(soapHeadersType);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("John", getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals("Doe", getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here


        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }

    @Test
    public void testXmlContextMapping() throws Exception {
        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.XML);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("<first xmlns=\"urn:names:1.0\">John</first>", getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals("<last xmlns=\"urn:names:1.0\">Doe</last>", getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here

        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }

    @Test
    public void testConfigContextMapping() throws Exception {
        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.CONFIG);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals(newConfiguration("<first xmlns=\"urn:names:1.0\">John</first>"), getPropertyValue(targetContext, FIRST_NAME));
        Assert.assertEquals(newConfiguration("<last xmlns=\"urn:names:1.0\">Doe</last>"), getPropertyValue(targetContext, LAST_NAME));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMessage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMessage));
        Assert.assertEquals("John", getChildElement(targetMessage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }
View Full Code Here

        Assert.assertEquals("Doe", getChildElement(targetMessage, LAST_NAME).getTextContent());
    }

    @Test
    public void testDomContextMapping() throws Exception {
        SOAPContextMapper mapper = new SOAPContextMapper();
        mapper.setSOAPHeadersType(SOAPHeadersType.DOM);
        // test mapFrom
        SOAPMessage sourceMessage = newSourceMessage();
        Context targetContext = newContext();
        mapper.mapFrom(new SOAPBindingData(sourceMessage), targetContext);
        Assert.assertEquals("<first xmlns=\"urn:names:1.0\">John</first>", toString((Element)getPropertyValue(targetContext, FIRST_NAME)));
        Assert.assertEquals("<last xmlns=\"urn:names:1.0\">Doe</last>", toString((Element)getPropertyValue(targetContext, LAST_NAME)));
        // test mapTo
        Context sourceContext = newSourceContext();
        SOAPMessage targetMesssage = newTargetMessage();
        mapper.mapTo(sourceContext, new SOAPBindingData(targetMesssage));
        Assert.assertEquals("John", getChildElement(targetMesssage, FIRST_NAME).getTextContent());
        Assert.assertEquals("Doe", getChildElement(targetMesssage, LAST_NAME).getTextContent());
    }
View Full Code Here

TOP

Related Classes of org.switchyard.component.soap.composer.SOAPContextMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.