Debian Codegraph @

test/soap12/TestVersionMismatch.java

raw
1 /*
2 * Copyright 2002-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /**
18 * @author Andras Avar ([email protected])
19 */
20
21 package test.soap12;
22
23 import java.lang.reflect.*;
24 import java.util.*;
25 import javax.xml.namespace.*;
26 import junit.framework.*;
27 import org.apache.axis.*;
28 import org.apache.axis.encoding.*;
29 import org.apache.axis.message.*;
30 import org.apache.axis.server.*;
31 import org.apache.axis.soap.*;
32 import org.apache.axis.utils.*;
33
34 /**
35 * Test VersionMismatch fault generation
36 */
37 public class TestVersionMismatch extends TestCase {
38 private AxisServer server = null;
39
40
41 public TestVersionMismatch(String name) {
42 super(name);
43 server = new AxisServer();
44 }
45
46 private final String SOAP_MESSAGE =
47 "<?xml version=\"1.0\"?>\n" +
48 "<soap:Envelope " +
49 "xmlns:soap=\"http://www.w3.org/2002/wrong-envelope-version\" " +
50 "xmlns:soapenc=\"http://www.w3.org/2003/05/soap-encoding\" " +
51 "xmlns:this=\"http://encoding.test\" " +
52 "xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
53 "xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
54 "<item xsi:type=\"xsd:string\">abc</item>\n" +
55 "<soap:Body>\n" +
56 "<methodResult xmlns=\"http://tempuri.org/\">\n" +
57 "<hello/>" +
58 "</methodResult>\n" +
59 "</soap:Body>\n" +
60 "</soap:Envelope>\n";
61
62
63 public void testVersionMismatch() throws Exception {
64 Message message = new Message(SOAP_MESSAGE);
65 MessageContext context = new MessageContext(server);
66 context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
67
68 message.setMessageContext(context);
69
70 boolean expectedExceptionThrown = false;
71 try {
72 SOAPEnvelope envelope = message.getSOAPEnvelope();
73 } catch (AxisFault af) {
74 if (Constants.FAULT_VERSIONMISMATCH.equals(af.getFaultCode()))
75 expectedExceptionThrown = true;
76 }
77
78 assertTrue(expectedExceptionThrown);
79
80 }
81 }