View Javadoc

1   /*
2    * $Id: CompositeMessageProcessorDefinitionParserTestCase.java 22551 2011-07-25 06:32:00Z mike.schilling $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.config.spring.parsers.specific;
12  
13  import org.mule.api.endpoint.EndpointBuilder;
14  import org.mule.api.endpoint.InboundEndpoint;
15  import org.mule.api.processor.MessageProcessor;
16  import org.mule.processor.NullMessageProcessor;
17  import org.mule.tck.junit4.FunctionalTestCase;
18  
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  
23  public class CompositeMessageProcessorDefinitionParserTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/config/spring/parsers/specific/composite-message-processor.xml";
30      }
31  
32      @Test
33      public void testInterceptingComposite() throws Exception
34      {
35          MessageProcessor composite = muleContext.getRegistry().lookupObject("composite1");
36          assertEquals("0123", composite.process(getTestEvent("0")).getMessageAsString());
37      }
38  
39      @Test
40      public void testInterceptingNestedComposite() throws Exception
41      {
42          MessageProcessor composite = muleContext.getRegistry().lookupObject("composite2");
43          assertEquals("01abc2", composite.process(getTestEvent("0")).getMessageAsString());
44      }
45  
46      @Test
47      public void testInterceptingCompositeOnEndpoint() throws Exception
48      {
49          EndpointBuilder endpointBuilder = muleContext.getRegistry().lookupEndpointBuilder("endpoint");
50          InboundEndpoint endpoint = endpointBuilder.buildInboundEndpoint();
51          assertEquals(3, endpoint.getMessageProcessors().size());
52  
53          MessageProcessor endpointProcessor = endpoint.getMessageProcessorsFactory()
54              .createInboundMessageProcessorChain(endpoint, null, new NullMessageProcessor());
55  
56          assertEquals("01231abc2", endpointProcessor.process(getTestEvent("0")).getMessageAsString());
57      }
58  
59  }