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: package org.apache.synapse.config.xml;
020:
021: import org.apache.axiom.om.OMElement;
022: import org.apache.synapse.core.axis2.ProxyService;
023:
024: /**
025: *
026: *
027: */
028:
029: public class ProxyServiceSerializationTest extends AbstractTestCase {
030:
031: public void testProxyServiceSerializationSenarioOne()
032: throws Exception {
033: String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"name\" "
034: + "startOnLoad=\"true\" transports=\"http\"><description>description</description>"
035: + "<target inSequence=\"inseqname\" outSequence=\"outseqname\" faultSequence=\"faultseqname\" />"
036: + "<publishWSDL uri=\"http://uri\" ></publishWSDL><policy key=\"key\"/>"
037: + "<parameter name=\"para\">text</parameter></proxy>";
038: OMElement inputOM = createOMElement(inputXml);
039: ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
040: OMElement resultOM = ProxyServiceSerializer.serializeProxy(
041: null, proxy);
042: assertTrue(compare(resultOM, inputOM));
043: }
044:
045: public void testProxyServiceSerializationSenarioTwo()
046: throws Exception {
047: String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" startOnLoad=\"true\" "
048: + "name=\"name\" transports=\"http\"><description>description</description>"
049: + "<target endpoint=\"epr\" outSequence=\"out\"/><publishWSDL key=\"key\">"
050: + "</publishWSDL><policy key=\"key\"/><parameter name=\"para\">text</parameter></proxy>";
051: OMElement inputOM = createOMElement(inputXml);
052: ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
053: OMElement resultOM = ProxyServiceSerializer.serializeProxy(
054: null, proxy);
055: assertTrue(compare(resultOM, inputOM));
056: }
057:
058: public void testProxyServiceSerializationSenarioThree()
059: throws Exception {
060: String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" "
061: + "name=\"name\" startOnLoad=\"true\" transports=\"http\"><description>"
062: + "description</description><target><inSequence onError=\"ref\"><send/></inSequence>"
063: + "<outSequence><send/></outSequence></target><publishWSDL key=\"key\"></publishWSDL>"
064: + "<policy key=\"key\"/><parameter name=\"para\">text</parameter></proxy>";
065: OMElement inputOM = createOMElement(inputXml);
066: ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
067: OMElement resultOM = ProxyServiceSerializer.serializeProxy(
068: null, proxy);
069: assertTrue(compare(resultOM, inputOM));
070: }
071:
072: // public void testProxyServiceSerializationSenarioFour() throws Exception {
073: // String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"name\" startOnLoad=\"true\" transports=\"http\"><description>description</description><target><inSequence><send/></inSequence></target><publish-wsdl><wsdl:definitions xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\"></wsdl:definitions></publish-wsdl><policy key=\"key\"/><parameter name=\"para\">text</parameter></proxy>";
074: // OMElement inputOM = createOMElement(inputXml);
075: //
076: // ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
077: // OMElement resultOM = ProxyServiceSerializer.serializeProxy(null, proxy);
078: // assertTrue(comparator.compare(resultOM, inputOM));
079:
080: // }
081: public void testProxyServiceSerializationSenarioFive()
082: throws Exception {
083: String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" startOnLoad=\"true\" "
084: + "name=\"name\" transports=\"http\"><description>description</description><target>"
085: + "<endpoint><address uri=\"http://www.example.com/testepr\"/></endpoint><outSequence><send/>"
086: + "</outSequence></target><publishWSDL uri=\"http://uri\"></publishWSDL><policy key=\"key\"/>"
087: + "<parameter name=\"para\">text</parameter></proxy>";
088: OMElement inputOM = createOMElement(inputXml);
089: ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
090: OMElement resultOM = ProxyServiceSerializer.serializeProxy(
091: null, proxy);
092: assertTrue(compare(resultOM, inputOM));
093: }
094:
095: // public void testProxyServiceSerializationSenarioSix() throws Exception {
096: // String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" startOnLoad=\"true\" name=\"name\" transports=\"http\"><description>description</description><target><endpoint address=\"http://www.example.com/testepr\" /></target><publish-wsdl uri=\"http://uri\" key=\"key\"></publish-wsdl><policy key=\"key\"/><parameter name=\"para\"><inline xmlns=\"http://customns\"><test/></inline></parameter></proxy>";
097: // OMElement inputOM = createOMElement(inputXml);
098: // ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
099: // OMElement resultOM = ProxyServiceSerializer.serializeProxy(null, proxy);
100: // assertTrue(comparator.compare(resultOM, inputOM));
101: // }
102:
103: public void testProxyServiceSerializationWithResourceMap()
104: throws Exception {
105: String inputXml = "<proxy xmlns=\"http://ws.apache.org/ns/synapse\" name=\"name\" "
106: + "startOnLoad=\"true\"><target><endpoint><address uri=\"http://www.example.com/testepr\"/>"
107: + "</endpoint><outSequence><send/></outSequence></target><publishWSDL uri=\"http://uri\">"
108: + "<resource location=\"test1.xsd\" key=\"test-key1\"/><resource location=\"test2.xsd\""
109: + " key=\"test-key2\"/></publishWSDL></proxy>";
110: OMElement inputOM = createOMElement(inputXml);
111: ProxyService proxy = ProxyServiceFactory.createProxy(inputOM);
112: assertNotNull(proxy.getResourceMap());
113: OMElement resultOM = ProxyServiceSerializer.serializeProxy(
114: null, proxy);
115: assertTrue(compare(resultOM, inputOM));
116: }
117: }
|