Package org.mule.transformer.simple

Examples of org.mule.transformer.simple.StringAppendTransformer


    public void testDynamicPipeline() throws Exception
    {
        flow.initialise();
        flow.start();

        MessageProcessor appendPre = new StringAppendTransformer("1");
        MessageProcessor appendPost2 = new StringAppendTransformer("4");

        String pipelineId = flow.dynamicPipeline(null).injectBefore(appendPre, new StringAppendTransformer("2"))
                .injectAfter(new StringAppendTransformer("3"), appendPost2)
                .resetAndUpdate();
        MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestEvent("hello", REQUEST_RESPONSE, muleContext));
        assertEquals("hello12abcdef34", response.getMessageAsString());

        flow.dynamicPipeline(pipelineId).injectBefore(new StringAppendTransformer("2")).injectAfter(new StringAppendTransformer("3")).resetAndUpdate();
        response = directInboundMessageSource.process(MuleTestUtils.getTestEvent("hello", REQUEST_RESPONSE, muleContext));
        assertEquals("hello2abcdef3", response.getMessageAsString());

        flow.dynamicPipeline(pipelineId).reset();
        response = directInboundMessageSource.process(MuleTestUtils.getTestEvent("hello", REQUEST_RESPONSE, muleContext));
View Full Code Here


    }

    @Test
    public void testNestedParsing() throws Exception
    {
        muleContext.getRegistry().registerObject("proc1", new StringAppendTransformer("c"));
        muleContext.getRegistry().registerObject("proc2", new StringAppendTransformer("e"));

        MuleEvent event = getTestEvent("b");
        RequestContext.setEvent(event);

        assertEquals(
View Full Code Here

                event.getMessage().setPayload(Integer.valueOf(1));
                return event;
            }
        };

        FirstSuccessful fs = createFirstSuccessfulRouter(intSetter, new StringAppendTransformer("abc"));
        fs.setFailureExpression("#[payload-type:java.lang.Integer]");
        fs.initialise();

        assertEquals("abc", fs.process(getTestEvent("")).getMessageAsString());
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testEndpointBuilderTransformersState() throws Exception
    {
        muleContext.getRegistry().registerObject("tran1", new StringAppendTransformer("1"));
        muleContext.getRegistry().registerObject("tran2", new StringAppendTransformer("2"));

        String uri = "test://address?transformers=tran1&responseTransformers=tran2";
        EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder(uri, muleContext);
        endpointBuilder.setTransformers(java.util.Collections.<Transformer> singletonList(new StringAppendTransformer(
            "3")));
        endpointBuilder.setResponseTransformers(java.util.Collections.<Transformer> singletonList(new StringAppendTransformer(
            "4")));

        InboundEndpoint endpoint = endpointBuilder.buildInboundEndpoint();

        assertEquals(2, endpoint.getMessageProcessors().size());
View Full Code Here

    {
        final WSProxy wsProxy = new WSProxyBuilder().name("test-ws-proxy-full-file-wsdl")
            .wsdlFile(new File(getTestWsdlUri()))
            .inboundAddress("test://foo")
            .outboundAddress("test://bar")
            .transformers(new StringAppendTransformer("bar"))
            .responseTransformers(new ObjectToByteArray(), new GZipCompressTransformer())
            .exceptionStrategy(new DefaultMessagingExceptionStrategy(muleContext))
            .build(muleContext);

        assertEquals("test-ws-proxy-full-file-wsdl", wsProxy.getName());
View Full Code Here

    }

    @Test
    public void testEnrichHeaderNestedEvaluator() throws Exception
    {
        muleContext.getRegistry().registerObject("appender", new StringAppendTransformer(" append"));

        MessageEnricher enricher = new MessageEnricher();
        enricher.setMuleContext(muleContext);
        enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[process:appender:#[header:header1]]",
            "#[header:myHeader]"));
View Full Code Here

        private String appendBefore;
        private String appendAfter;
      
        MuleEvent fireEvent(MuleEvent event) throws MuleException
        {
            Transformer before = new StringAppendTransformer(appendBefore);
            Transformer after = new StringAppendTransformer(appendAfter);
            return after.process(listener.process(before.process(event)));
        }
View Full Code Here

    {
        MuleMessage result = client.send("vm://dynamic", "source->", null);
        assertEquals("source->(static)", result.getPayloadAsString());

        Flow flow = getFlow("dynamicFlow");
        String pipelineId = flow.dynamicPipeline(null).injectBefore(new StringAppendTransformer("(pre)")).resetAndUpdate();
        result = client.send("vm://dynamic", "source->", null);
        assertEquals("source->(pre)(static)", result.getPayloadAsString());

        flow.dynamicPipeline(pipelineId).injectBefore(new StringAppendTransformer("(pre1)"), new StringAppendTransformer("(pre2)")).resetAndUpdate();
        result = client.send("vm://dynamic", "source->", null);
        assertEquals("source->(pre1)(pre2)(static)", result.getPayloadAsString());
    }
View Full Code Here

    @Test
    public void addPrePostMessageProccesor() throws Exception
    {
        Flow flow = getFlow("dynamicFlow");
        String pipelineId = flow.dynamicPipeline(null).injectBefore(new StringAppendTransformer("(pre)"))
                .injectAfter(new StringAppendTransformer("(post)"))
                .resetAndUpdate();
        MuleMessage result = client.send("vm://dynamic", "source->", null);
        assertEquals("source->(pre)(static)(post)", result.getPayloadAsString());

        flow.dynamicPipeline(pipelineId).injectBefore(new StringAppendTransformer("(pre)"))
                .injectAfter(new StringAppendTransformer("(post1)"), new StringAppendTransformer("(post2)"))
                .resetAndUpdate();
        result = client.send("vm://dynamic", "source->", null);
        assertEquals("source->(pre)(static)(post1)(post2)", result.getPayloadAsString());
    }
View Full Code Here

    {
        List<MessageProcessor> preList = new ArrayList<MessageProcessor>();
        List<MessageProcessor> postList = new ArrayList<MessageProcessor>();

        Flow flow = getFlow("exceptionFlow");
        preList.add(new StringAppendTransformer("(pre)"));
        preList.add(new MessageProcessor()
        {
            @Override
            public MuleEvent process(MuleEvent event) throws MuleException
            {
                throw new RuntimeException("force exception!");
            }
        });
        postList.add(new StringAppendTransformer("(post)"));
        flow.dynamicPipeline(null).injectBefore(preList).injectAfter(postList).resetAndUpdate();
        MuleMessage result = client.send("vm://exception", "source->", null);
        assertEquals("source->(pre)(handled)", result.getPayloadAsString());
    }
View Full Code Here

TOP

Related Classes of org.mule.transformer.simple.StringAppendTransformer

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.