FileDocCategorySizeDatePackage
TestEncodingStyle.javaAPI DocApache Axis 1.46986Sat Apr 22 18:57:28 BST 2006test.soap12

TestEncodingStyle

public class TestEncodingStyle extends TestCase
Test encodingstyle attribute appearance

Fields Summary
private org.apache.axis.server.AxisServer
server
private final String
ENVELOPE
private final String
HEADER
private final String
BODY
private final String
FAULT_HEAD
private final String
FAULT_DETAIL
private final String
FAULT_TAIL
private final String
TAIL
private final String
ENCSTYLE_DEF
private final String
MESSAGE_HEAD
private final String
MESSAGE
private final String
MESSAGE_TAIL
private final String
ITEM
private final String
INVALID_ENCSTYLE
private final String
NO_ENCSTYLE
private final String
INVALID_ENCSTYLE_DEF
private final String
NO_ENCSTYLE_DEF
Constructors Summary
public TestEncodingStyle(String name)


       
        super(name);
        server = new AxisServer();
    
Methods Summary
public booleandeserialize(java.lang.String req, javax.xml.namespace.QName expected_code, java.lang.String expected_str)



              
        Message message = new Message(req);
        MessageContext context = new MessageContext(server);
        context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
        context.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);

        message.setMessageContext(context);

        boolean expectedFault = false;
        try {
            SOAPEnvelope envelope = message.getSOAPEnvelope();
        } catch (AxisFault af) {
            return af.getFaultString().indexOf(expected_str) != -1 &&
                   expected_code.equals(af.getFaultCode());
        }

        return expectedFault;
    
public voidtestAcceptUserEncodingStyle()

        String req = ENVELOPE + HEADER + BODY + MESSAGE_HEAD + INVALID_ENCSTYLE_DEF + MESSAGE + ITEM + MESSAGE_TAIL + TAIL;

        Message message = new Message(req);
        MessageContext context = new MessageContext(server);
        context.setProperty(Constants.MC_NO_OPERATION_OK, Boolean.TRUE);

        // Set the "invalid" encoding style
        TypeMappingRegistry reg = context.getTypeMappingRegistry();
        TypeMapping tm = (TypeMapping) reg.createTypeMapping();
        tm.setSupportedEncodings(new String[] { INVALID_ENCSTYLE });
        reg.register(INVALID_ENCSTYLE, tm);
        context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);

        message.setMessageContext(context);

        SOAPEnvelope envelope = message.getSOAPEnvelope();
        assertTrue(envelope != null);
   
public voidtestEncStyleInBody()

        String req = ENVELOPE +  HEADER + BODY + ENCSTYLE_DEF + FAULT_HEAD + FAULT_DETAIL + FAULT_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_SENDER,
            Messages.getMessage("noEncodingStyleAttrAppear", "Body")));
    
public voidtestEncStyleInDetail()

        String req = ENVELOPE +  HEADER + BODY + FAULT_HEAD + FAULT_DETAIL + ENCSTYLE_DEF + FAULT_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_SENDER,

          Messages.getMessage("noEncodingStyleAttrAppear", "Detail")));
    
public voidtestEncStyleInEnvelope()

        String req = ENVELOPE + ENCSTYLE_DEF + HEADER + BODY + FAULT_HEAD + FAULT_DETAIL + FAULT_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_SENDER,
            Messages.getMessage("noEncodingStyleAttrAppear", "Envelope")));
    
public voidtestEncStyleInFault()

        String req = ENVELOPE +  HEADER + BODY + FAULT_HEAD + ENCSTYLE_DEF + FAULT_DETAIL + FAULT_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_SENDER,
            Messages.getMessage("noEncodingStyleAttrAppear", "Fault")));
    
public voidtestEncStyleInHeader()

        String req = ENVELOPE + HEADER + ENCSTYLE_DEF + BODY + FAULT_HEAD + FAULT_DETAIL + FAULT_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_SENDER,
            Messages.getMessage("noEncodingStyleAttrAppear", "Header")));
    
public voidtestInvalidEncodingStyle()

        String req = ENVELOPE + HEADER + BODY + MESSAGE_HEAD + INVALID_ENCSTYLE_DEF + MESSAGE + ITEM + MESSAGE_TAIL + TAIL;
        assertTrue(deserialize(req, Constants.FAULT_SOAP12_DATAENCODINGUNKNOWN,
            Messages.getMessage("invalidEncodingStyle")));
    
public voidtestNoEncodingStyle()

        String req = ENVELOPE + HEADER + BODY + MESSAGE_HEAD + NO_ENCSTYLE_DEF + MESSAGE + ITEM + MESSAGE_TAIL + TAIL;
        assertTrue(deserialize(req, null, null) == false);