001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019:
020: package org.apache.synapse.config.xml;
021:
022: /**
023: * This Testcase will test the Factory and Serializer of the POJOCommandMediator
024: */
025: public class POJOCommandMediatorSerializationTest extends
026: AbstractTestCase {
027:
028: POJOCommandMediatorFactory pojoCommandMediatorFactory;
029: POJOCommandMediatorSerializer pojoCommandMediatorSerializer;
030:
031: public POJOCommandMediatorSerializationTest() {
032: super (POJOCommandMediatorSerializationTest.class.getName());
033: pojoCommandMediatorFactory = new POJOCommandMediatorFactory();
034: pojoCommandMediatorSerializer = new POJOCommandMediatorSerializer();
035: }
036:
037: public void testPOJOCommandNotImplementedMediatorWithoutPropertySerialization()
038: throws Exception {
039: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
040: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\"/> ";
041: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
042: pojoCommandMediatorSerializer));
043: assertTrue(serialization(inputXml,
044: pojoCommandMediatorSerializer));
045: }
046:
047: public void testPOJOCommandMediatorImplementedWithoutPropertySerialization()
048: throws Exception {
049: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
050: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator\"/> ";
051: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
052: pojoCommandMediatorSerializer));
053: assertTrue(serialization(inputXml,
054: pojoCommandMediatorSerializer));
055: }
056:
057: public void testPOJOCommandNotImplementedMediatorWithPropertySerialization()
058: throws Exception {
059: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
060: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
061: + "<property name=\"testProp\" expression=\"fn:concat('XPATH ', 'FUNC')\" action=\"ReadMessage\"/></pojoCommand>";
062: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
063: pojoCommandMediatorSerializer));
064: assertTrue(serialization(inputXml,
065: pojoCommandMediatorSerializer));
066: }
067:
068: public void testPOJOCommandMediatorImplementedWithPropertySerialization()
069: throws Exception {
070: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
071: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator\">"
072: + "<property name=\"testProp\" expression=\"fn:concat('XPATH ', 'FUNC')\" action=\"UpdateMessage\"/></pojoCommand>";
073: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
074: pojoCommandMediatorSerializer));
075: assertTrue(serialization(inputXml,
076: pojoCommandMediatorSerializer));
077: }
078:
079: public void testPOJOCommandMediatorWithStaticPropertySerialization()
080: throws Exception {
081: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
082: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
083: + "<property name=\"testProp\" value=\"Test Property\"/></pojoCommand>";
084: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
085: pojoCommandMediatorSerializer));
086: assertTrue(serialization(inputXml,
087: pojoCommandMediatorSerializer));
088: }
089:
090: public void testPOJOCommandMediatorWithMessagePropertySerialization()
091: throws Exception {
092: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
093: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
094: + "<property name=\"testProp\" expression=\"fn:concat('XPATH ', 'FUNC')\" action=\"ReadAndUpdateMessage\"/></pojoCommand>";
095: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
096: pojoCommandMediatorSerializer));
097: assertTrue(serialization(inputXml,
098: pojoCommandMediatorSerializer));
099: }
100:
101: public void testPOJOCommandMediatorWithContextPropertySerialization()
102: throws Exception {
103: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
104: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
105: + "<property name=\"testProp\" value=\"Test Property\" context-name=\"prop\"/></pojoCommand>";
106: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
107: pojoCommandMediatorSerializer));
108: assertTrue(serialization(inputXml,
109: pojoCommandMediatorSerializer));
110: }
111:
112: public void testPOJOCommandMediatorWithContextMessagePropertySerialization()
113: throws Exception {
114: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
115: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
116: + "<property name=\"testProp\" expression=\"fn:concat('XPATH ', 'FUNC')\" context-name=\"prop\" action=\"ReadMessage\"/></pojoCommand>";
117: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
118: pojoCommandMediatorSerializer));
119: assertTrue(serialization(inputXml,
120: pojoCommandMediatorSerializer));
121: }
122:
123: public void testPOJOCommandMediatorWithMessage$ContextPropertySerialization()
124: throws Exception {
125: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
126: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
127: + "<property name=\"testProp\" expression=\"fn:concat('XPATH ', 'FUNC')\" context-name=\"prop\" action=\"ReadContext\"/></pojoCommand>";
128: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
129: pojoCommandMediatorSerializer));
130: assertTrue(serialization(inputXml,
131: pojoCommandMediatorSerializer));
132: }
133:
134: public void testPOJOCommandMediatorWithContextUpdatePropertySerialization()
135: throws Exception {
136: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
137: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
138: + "<property name=\"testProp\" context-name=\"prop\" action=\"UpdateContext\"/></pojoCommand>";
139: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
140: pojoCommandMediatorSerializer));
141: assertTrue(serialization(inputXml,
142: pojoCommandMediatorSerializer));
143: }
144:
145: public void testPOJOCommandMediatorWithContextR$UPropertySerialization()
146: throws Exception {
147: String inputXml = "<pojoCommand xmlns=\"http://ws.apache.org/ns/synapse\" "
148: + "name=\"org.apache.synapse.mediators.ext.POJOCommandTestMediator\">"
149: + "<property name=\"testProp\" context-name=\"prop\" action=\"ReadAndUpdateContext\"/></pojoCommand>";
150: assertTrue(serialization(inputXml, pojoCommandMediatorFactory,
151: pojoCommandMediatorSerializer));
152: assertTrue(serialization(inputXml,
153: pojoCommandMediatorSerializer));
154: }
155: }
|