1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.usecases.properties;
12
13 import org.mule.DefaultMuleMessage;
14 import org.mule.api.MuleEventContext;
15 import org.mule.api.MuleMessage;
16 import org.mule.api.lifecycle.Callable;
17 import org.mule.tck.testmodels.fruit.Apple;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25 public class PropsComponent implements Callable
26 {
27 private static final Log logger = LogFactory.getLog(PropsComponent.class);
28
29 protected static Apple testObjectProperty = new Apple();
30
31 public Object onCall(MuleEventContext context) throws Exception
32 {
33 logger.debug("org.mule.test.usecases.props.PropsComponent");
34
35 if ("component1".equals(context.getService().getName()))
36 {
37 logger.debug("Adding: " + context.getService().getName());
38 Map props = new HashMap();
39 props.put("stringParam", "param1");
40 props.put("objectParam", testObjectProperty);
41 MuleMessage msg = new DefaultMuleMessage(context.getMessageAsString(), props);
42 logger.debug("Adding done: " + context.getService().getName());
43 return msg;
44 }
45 else
46 {
47 logger.debug("Verifying: " + context.getService().getName());
48 assertEquals("param1", context.getMessage().getProperty("stringParam"));
49 assertEquals(testObjectProperty, context.getMessage().getProperty("objectParam"));
50 logger.debug("Verifying done: " + context.getService().getName());
51 }
52
53 return context;
54 }
55
56 static protected void assertEquals(Object theObject, Object theProperty)
57 {
58 if (!theObject.equals(theProperty))
59 {
60 logger.error(String.valueOf(theObject) + " does not equal:" + String.valueOf(theProperty));
61 }
62 else
63 {
64 logger.debug("Woohoo!");
65 }
66 }
67
68 }