1 17 package org.apache.servicemix.components.mps; 18 19 import javax.jbi.messaging.InOut; 20 import javax.jbi.messaging.NormalizedMessage; 21 import javax.xml.namespace.QName ; 22 23 import org.apache.servicemix.jbi.jaxp.StringSource; 24 import org.apache.servicemix.tck.TestSupport; 25 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 26 import org.springframework.context.support.AbstractXmlApplicationContext; 27 28 32 public class MPSSettingTest extends TestSupport { 33 34 35 39 public void testStaticStringPropertySet() throws Exception { 40 QName service = new QName ("http://servicemix.org/cheese/", "mpsFixed"); 41 42 InOut exchange = client.createInOutExchange(); 43 exchange.setService(service); 44 45 NormalizedMessage message = exchange.getInMessage(); 46 message.setContent(new StringSource(createMessageXmlText(777888))); 47 message.setProperty("prop.xpath.or.keep.existing","someValue"); 48 message.setProperty("other.set.property","thatOtherValue"); 49 client.sendSync(exchange); 50 51 NormalizedMessage outMessage = exchange.getOutMessage(); 52 53 assertTrue(outMessage.getProperty("property.1").equals("foobarAndCheese")); 54 assertTrue(outMessage.getProperty("property.2").equals("777888")); 55 assertTrue(outMessage.getProperty("prop.xpath.or.keep.existing").equals("someValue")); 56 assertTrue(outMessage.getProperty("new.prop.name") == null); 58 assertTrue(outMessage.getProperty("property.3").equals("thatOtherValue")); 59 60 } 61 62 63 67 public void testtestXpathLoadingPropertySet() throws Exception { 68 QName service = new QName ("http://servicemix.org/cheese/", "mpsXpath"); 69 70 InOut exchange = client.createInOutExchange(); 71 exchange.setService(service); 72 73 NormalizedMessage message = exchange.getInMessage(); 74 message.setContent(new StringSource(createMessageXmlText(400))); 75 client.sendSync(exchange); 76 77 NormalizedMessage outMessage = exchange.getOutMessage(); 78 79 assertTrue(outMessage.getProperty("my-superdooper.property").equals("wishAusMadeItTotheFinals")); 80 81 } 82 83 87 public void testJBIPropertyLoadingPropertySet() throws Exception { 88 QName service = new QName ("http://servicemix.org/cheese/", "mpsJBIPropsPS"); 89 90 InOut exchange = client.createInOutExchange(); 91 exchange.setService(service); 92 93 NormalizedMessage message = exchange.getInMessage(); 94 message.setProperty(MessagePropertySetterXML.MPS_PROP_NAME_PROPERTYSET,"hello"); 95 message.setContent(new StringSource(createMessageXmlText(54))); 96 client.sendSync(exchange); 97 98 NormalizedMessage outMessage = exchange.getOutMessage(); 99 100 assertTrue(outMessage.getProperty("my-superdooper.property").equals("wishAusMadeItTotheFinals")); 101 102 } 103 104 105 protected AbstractXmlApplicationContext createBeanFactory() { 106 return new ClassPathXmlApplicationContext("org/apache/servicemix/components/mps/servicemix-mps-test.xml"); 107 } 108 } 109 110 111 | Popular Tags |