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: import org.apache.synapse.SynapseException;
023:
024: /**
025: * Factory and Serializer tests for the IterateMediator
026: */
027: public class IterateMediatorSerializationTest extends AbstractTestCase {
028:
029: IterateMediatorFactory iterateMediatorFactory;
030: IterateMediatorSerializer iterateMediatorSerializer;
031:
032: public IterateMediatorSerializationTest() {
033: super (IterateMediatorSerializationTest.class.getName());
034: iterateMediatorFactory = new IterateMediatorFactory();
035: iterateMediatorSerializer = new IterateMediatorSerializer();
036: }
037:
038: public void testIterateMediatorSerializationSenarioOne()
039: throws Exception {
040: String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\" "
041: + "continueParent=\"true\" preservePayload=\"true\" expression=\".\" "
042: + "attachPath=\"get-property('to')\"><target sequence=\"sequenceRef1\" "
043: + "endpoint=\"endpointRef1\"/>" + "</iterate>";
044: assertTrue(serialization(inputXml, iterateMediatorFactory,
045: iterateMediatorSerializer));
046: assertTrue(serialization(inputXml, iterateMediatorSerializer));
047: }
048:
049: public void testIterateMediatorSerializationScenarioTwo()
050: throws Exception {
051: String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\">"
052: + "<target endpoint=\"endpointRef1\"><sequence><log/></sequence></target>"
053: + "</iterate>";
054: assertTrue(serialization(inputXml, iterateMediatorFactory,
055: iterateMediatorSerializer));
056: assertTrue(serialization(inputXml, iterateMediatorSerializer));
057: }
058:
059: public void testIterateMediatorSerializationScenarioThree()
060: throws Exception {
061: String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\">"
062: + "<target><sequence><send/></sequence><endpoint><address uri=\"http://testURL2\"/>"
063: + "</endpoint></target></iterate>";
064: assertTrue(serialization(inputXml, iterateMediatorFactory,
065: iterateMediatorSerializer));
066: assertTrue(serialization(inputXml, iterateMediatorSerializer));
067: }
068:
069: public void testIterateMediatorSerializationScenarioFour()
070: throws Exception {
071: String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\">"
072: + "<target soapAction=\"urn:test\" to=\"http://localhost:7777\"><sequence><send/>"
073: + "</sequence><endpoint><address uri=\"http://testURL2\"/></endpoint></target>"
074: + "</iterate>";
075: assertTrue(serialization(inputXml, iterateMediatorFactory,
076: iterateMediatorSerializer));
077: assertTrue(serialization(inputXml, iterateMediatorSerializer));
078: }
079:
080: public void testIterateMediatorSerializationScenarioFive()
081: throws Exception {
082: String inputXml = "<iterate xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\" "
083: + "attachPath=\".\" preservePayload=\"false\"><target to=\"http://localhost:7777\">"
084: + "<sequence><send/></sequence><endpoint><address uri=\"http://testURL2\"/></endpoint>"
085: + "</target></iterate>";
086: try {
087: serialization(inputXml, iterateMediatorFactory,
088: iterateMediatorSerializer);
089: serialization(inputXml, iterateMediatorSerializer);
090: } catch (SynapseException syne) {
091: assertTrue(true);
092: }
093: }
094:
095: public void testIterateMediatorSerializationScenarioSix()
096: throws Exception {
097: String inputXml = "<clone xmlns=\"http://ws.apache.org/ns/synapse\" expression=\".\" attachPath=\".\">"
098: + "<target to=\"http://localhost:7777\"><sequence><send/></sequence><endpoint>"
099: + "<address uri=\"http://testURL2\"/></endpoint></target><target soapAction="
100: + "\"urn:test\" sequence=\"sequenceRef2\" endpoint=\"endpointRef2\"/></clone> ";
101: try {
102: serialization(inputXml, iterateMediatorFactory,
103: iterateMediatorSerializer);
104: serialization(inputXml, iterateMediatorSerializer);
105: } catch (SynapseException syne) {
106: assertTrue(true);
107: }
108: }
109:
110: }
|