Package com.consol.citrus.message

Examples of com.consol.citrus.message.DefaultMessage


                "</TestMessage>");
    }

    @Test
    public void testTranslateWithVariables() {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text name=\"\">Hello World!</Text><OtherText>No changes</OtherText></TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("TestMessage.Text", "${newText}");
        mappings.put("TestMessage.Text.name", "citrus:upperCase('text')");
View Full Code Here


                "</TestMessage>");
    }

    @Test
    public void testTranslateFromMappingFile() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text name=\"\">Hello World!</Text><OtherText>No changes</OtherText></TestMessage>");

        context.setVariable("newText", "Hello!");

        NodeMappingDataDictionary dictionary = new NodeMappingDataDictionary();
        dictionary.setMappingFile(new ClassPathResource("mapping.properties", DataDictionary.class));
View Full Code Here

                "</TestMessage>");
    }

    @Test
    public void testTranslateWithNestedAndEmptyElements() {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text><value></value></Text><OtherText></OtherText></TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("TestMessage.Text.value", "Hello!");

        NodeMappingDataDictionary dictionary = new NodeMappingDataDictionary();
View Full Code Here

*/
public class XpathMappingDataDictionaryTest extends AbstractTestNGUnitTest {

    @Test
    public void testTranslate() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text>Hello World!</Text><OtherText name=\"foo\">No changes</OtherText></TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("//TestMessage/Text", "Hello!");
        mappings.put("//@name", "bar");

View Full Code Here

                "</TestMessage>");
    }

    @Test
    public void testTranslateWithNamespaceLookup() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns1:TestMessage xmlns:ns1=\"http://www.foo.bar\"><ns1:Text>Hello World!</ns1:Text><ns1:OtherText name=\"foo\">No changes</ns1:OtherText></ns1:TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("//ns1:TestMessage/ns1:Text", "Hello!");
        mappings.put("//@name", "bar");
View Full Code Here

                "</ns1:TestMessage>");
    }

    @Test
    public void testTranslateWithNamespaceBuilder() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns1:TestMessage xmlns:ns1=\"http://www.foo.bar\"><ns1:Text>Hello World!</ns1:Text><ns1:OtherText name=\"foo\">No changes</ns1:OtherText></ns1:TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("//foo:TestMessage/foo:Text", "Hello!");
        mappings.put("//@name", "bar");
View Full Code Here

                "</ns1:TestMessage>");
    }

    @Test
    public void testTranslateWithVariables() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text>Hello World!</Text><OtherText name=\"foo\">No changes</OtherText></TestMessage>");

        Map<String, String> mappings = new HashMap<String, String>();
        mappings.put("//TestMessage/Text", "${hello}");
        mappings.put("//@name", "bar");
View Full Code Here

                "</TestMessage>");
    }

    @Test
    public void testTranslateFromMappingFile() throws Exception {
        Message message = new DefaultMessage("<?xml version=\"1.0\" encoding=\"UTF-8\"?><TestMessage><Text>Hello World!</Text><OtherText name=\"foo\">No changes</OtherText></TestMessage>");

        XpathMappingDataDictionary dictionary = new XpathMappingDataDictionary();
        dictionary.setMappingFile(new ClassPathResource("xpathmapping.properties", DataDictionary.class));
        dictionary.afterPropertiesSet();
View Full Code Here

        JmsEndpoint endpoint = new JmsEndpoint();
        endpoint.getEndpointConfiguration().setConnectionFactory(connectionFactory);

        endpoint.getEndpointConfiguration().setDestination(destination);
       
        final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");

        Map<String, Object> headers = new HashMap<String, Object>();
       
        reset(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);

        expect(connectionFactory.createConnection()).andReturn(connection).once();
        expect(connection.createSession(anyBoolean(), anyInt())).andReturn(session).once();
        expect(session.getTransacted()).andReturn(false).once();
        expect(session.getAcknowledgeMode()).andReturn(Session.AUTO_ACKNOWLEDGE).once();
       
        expect(session.createConsumer(destination, "Operation = 'sayHello'")).andReturn(messageConsumer).once();
       
        connection.start();
        expectLastCall().once();
       
        expect(messageConsumer.receive(5000L)).andReturn(new TextMessageImpl("<TestRequest><Message>Hello World!</Message></TestRequest>", headers)).once();
       
        replay(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
       
        Message receivedMessage = endpoint.createConsumer().receive("Operation = 'sayHello'", context);
        Assert.assertEquals(receivedMessage.getPayload(), controlMessage.getPayload());
       
        verify(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
    }
View Full Code Here

        endpoint.getEndpointConfiguration().setConnectionFactory(connectionFactory);

        endpoint.getEndpointConfiguration().setDestination(destination);
        endpoint.getEndpointConfiguration().setTimeout(10000L);
       
        final Message controlMessage = new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");

        Map<String, Object> headers = new HashMap<String, Object>();
       
        reset(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);

        expect(connectionFactory.createConnection()).andReturn(connection).once();
        expect(connection.createSession(anyBoolean(), anyInt())).andReturn(session).once();
        expect(session.getTransacted()).andReturn(false).once();
        expect(session.getAcknowledgeMode()).andReturn(Session.AUTO_ACKNOWLEDGE).once();
       
        expect(session.createConsumer(destination, "Operation = 'sayHello'")).andReturn(messageConsumer).once();
       
        connection.start();
        expectLastCall().once();
       
        expect(messageConsumer.receive(10000L)).andReturn(new TextMessageImpl("<TestRequest><Message>Hello World!</Message></TestRequest>", headers)).once();
       
        replay(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
       
        Message receivedMessage = endpoint.createConsumer().receive("Operation = 'sayHello'", context);
        Assert.assertEquals(receivedMessage.getPayload(), controlMessage.getPayload());
       
        verify(jmsTemplate, connectionFactory, destination, connection, session, messageConsumer);
    }
View Full Code Here

TOP

Related Classes of com.consol.citrus.message.DefaultMessage

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.