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:
20: package org.apache.synapse.mediators.transform;
21:
22: import junit.framework.TestCase;
23: import org.apache.axiom.soap.SOAPEnvelope;
24: import org.apache.axiom.soap.SOAPFault;
25: import org.apache.synapse.MessageContext;
26: import org.apache.synapse.mediators.TestUtils;
27:
28: import javax.xml.namespace.QName;
29: import java.net.URI;
30:
31: public class FaultMediatorTest extends TestCase {
32:
33: private static final QName F_CODE = new QName("http://namespace",
34: "somefaultcode");
35: private static final String F_STRING = "Some fault string";
36: private static final String F_ACTOR_URI = "http://actor";
37: private static final String F_DETAIL = "Some detail text";
38:
39: public void testSOAP11Fault() throws Exception {
40:
41: FaultMediator faultMediator = new FaultMediator();
42: faultMediator.setSoapVersion(FaultMediator.SOAP11);
43: faultMediator.setFaultCodeValue(F_CODE);
44: faultMediator.setFaultReasonValue(F_STRING);
45: faultMediator.setFaultRole(new URI(F_ACTOR_URI));
46: faultMediator.setFaultDetail(F_DETAIL);
47:
48: // invoke transformation, with static enveope
49: MessageContext synCtx = TestUtils.getTestContext("<empty/>");
50: faultMediator.mediate(synCtx);
51:
52: SOAPEnvelope envelope = synCtx.getEnvelope();
53: SOAPFault fault = envelope.getBody().getFault();
54: assertTrue(F_CODE.equals(fault.getCode().getTextAsQName()));
55: assertTrue(F_STRING.equals(fault.getReason().getText()));
56: assertTrue(F_ACTOR_URI.equals(fault.getRole().getRoleValue()));
57: assertTrue(F_DETAIL.equals(fault.getDetail().getText()));
58: }
59: }
|