1 16 17 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 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 } 82 | Popular Tags |