1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring.parsers.specific;
12
13 import org.mule.api.MuleException;
14 import org.mule.api.endpoint.EndpointBuilder;
15 import org.mule.api.endpoint.InboundEndpoint;
16 import org.mule.api.processor.MessageProcessor;
17 import org.mule.processor.NullMessageProcessor;
18 import org.mule.tck.FunctionalTestCase;
19
20 public class CompositeMessageProcessorDefinitionParserTestCase extends FunctionalTestCase
21 {
22
23 @Override
24 protected String getConfigResources()
25 {
26 return "org/mule/config/spring/parsers/specific/composite-message-processor.xml";
27 }
28
29 public void testInterceptingComposite() throws MuleException, Exception
30 {
31 MessageProcessor composite = muleContext.getRegistry().lookupObject("composite1");
32 assertEquals("0123", composite.process(getTestEvent("0")).getMessageAsString());
33 }
34
35 public void testInterceptingNestedComposite() throws MuleException, Exception
36 {
37 MessageProcessor composite = muleContext.getRegistry().lookupObject("composite2");
38 assertEquals("01abc2", composite.process(getTestEvent("0")).getMessageAsString());
39 }
40
41 public void testInterceptingCompositeOnEndpoint() throws MuleException, Exception
42 {
43 EndpointBuilder endpointBuilder = muleContext.getRegistry().lookupEndpointBuilder("endpoint");
44 InboundEndpoint endpoint = endpointBuilder.buildInboundEndpoint();
45 assertEquals(2, endpoint.getMessageProcessors().size());
46
47 MessageProcessor endpointProcessor = endpoint.getMessageProcessorsFactory()
48 .createInboundMessageProcessorChain(endpoint, null, new NullMessageProcessor());
49
50 assertEquals("01231abc2", endpointProcessor.process(getTestEvent("0")).getMessageAsString());
51 }
52
53 }