01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.synapse.mediators.bsf;
20:
21: import org.apache.axiom.om.impl.exception.XMLComparisonException;
22: import org.apache.synapse.mediators.AbstractTestCase;
23:
24: public class ScriptMediatorSerializationTest extends AbstractTestCase {
25:
26: ScriptMediatorFactory mediatorFactory;
27: ScriptMediatorSerializer scriptMediatorSerializer;
28:
29: public ScriptMediatorSerializationTest() {
30: mediatorFactory = new ScriptMediatorFactory();
31: scriptMediatorSerializer = new ScriptMediatorSerializer();
32: }
33:
34: public void testScriptMediatorSerializationScenarioOne()
35: throws XMLComparisonException {
36: String inputXml = "<script xmlns=\"http://ws.apache.org/ns/synapse\" key=\"script-key\" function=\"funOne\" language=\"js\"></script> ";
37: assertTrue(serialization(inputXml, mediatorFactory,
38: scriptMediatorSerializer));
39: assertTrue(serialization(inputXml, scriptMediatorSerializer));
40: }
41:
42: public void testScriptMediatorSerializationScenarioTwo()
43: throws XMLComparisonException {
44: String inputXml = "<script xmlns=\"http://ws.apache.org/ns/synapse\" language=\"js\" key=\"script-key\" ></script> ";
45: assertTrue(serialization(inputXml, mediatorFactory,
46: scriptMediatorSerializer));
47: assertTrue(serialization(inputXml, scriptMediatorSerializer));
48: }
49:
50: public void testInlineScriptMediatorSerializationScenarioOne()
51: throws XMLComparisonException {
52: String inputXml = "<syn:script xmlns:syn=\"http://ws.apache.org/ns/synapse\" language='js'>"
53: + "<![CDATA[var symbol = mc.getPayloadXML()..*::Code.toString();mc.setPayloadXML(<m:getQuote xmlns:m=\"http://services.samples/xsd\">\n"
54: + "<m:request><m:symbol>{symbol}</m:symbol></m:request></m:getQuote>);]]></syn:script> ";
55: assertTrue(serialization(inputXml, mediatorFactory,
56: scriptMediatorSerializer));
57: assertTrue(serialization(inputXml, scriptMediatorSerializer));
58: }
59: }
|