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.config.xml;
20:
21: /**
22: *
23: *
24: */
25:
26: public class FaultMediatorSerializationTest extends AbstractTestCase {
27:
28: FaultMediatorFactory faultMediatorFactory;
29: FaultMediatorSerializer faultMediatorSerializer;
30: private static final String SOAP11 = "soap11";
31: private static final String SOAP12 = "soap12";
32: private static final String EMPTY = "";
33:
34: public FaultMediatorSerializationTest() {
35: super (FaultMediatorSerializationTest.class.getName());
36: faultMediatorFactory = new FaultMediatorFactory();
37: faultMediatorSerializer = new FaultMediatorSerializer();
38: }
39:
40: public void testFaultMediatorSerializationSOAP11() throws Exception {
41: String inputXml = getXmlOfMediatorForSOAP11(SOAP11,
42: "ns2:Client", "reason", EMPTY, EMPTY);
43: assertTrue(serialization(inputXml, faultMediatorFactory,
44: faultMediatorSerializer));
45: assertTrue(serialization(inputXml, faultMediatorSerializer));
46: }
47:
48: public void testFaultMediatorSerializationSOAP12() throws Exception {
49: String inputXml = getXmlOfMediatorForSOAP12(SOAP12,
50: "soap:Sender", "reason", EMPTY, EMPTY, EMPTY);
51: assertTrue(serialization(inputXml, faultMediatorFactory,
52: faultMediatorSerializer));
53: assertTrue(serialization(inputXml, faultMediatorSerializer));
54: }
55:
56: private String getXmlOfMediatorForSOAP11(String version,
57: String attrOfCode, String attrOfReasion, String role,
58: String details) throws Exception {
59: return "<makefault version=\""
60: + version
61: + "\" xmlns=\"http://ws.apache.org/ns/synapse\"><code value=\""
62: + attrOfCode
63: + "\" xmlns:ns2=\"http://ws.apache.org/ns/synapse\"/><reason value=\""
64: + attrOfReasion + "\"/>" + "<role>" + role
65: + "</role><detail>" + details + "</detail></makefault>";
66:
67: }
68:
69: private String getXmlOfMediatorForSOAP12(String version,
70: String attrOfCode, String attrOfReasion, String node,
71: String role, String details) throws Exception {
72: return "<makefault xmlns=\"http://ws.apache.org/ns/synapse\" version=\""
73: + version
74: + "\"><code value=\""
75: + attrOfCode
76: + "\" xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"/><reason value=\""
77: + attrOfReasion
78: + "\"/>"
79: + "<node>"
80: + node
81: + "</node><role>"
82: + role
83: + "</role><detail>"
84: + details
85: + "</detail></makefault>";
86:
87: }
88:
89: }
|