FileDocCategorySizeDatePackage
TestEncoding.javaAPI DocApache Axis 1.44018Sat Apr 22 18:57:28 BST 2006test.functional

TestEncoding

public class TestEncoding extends TestCase
Test string encoding roundtrip.

Fields Summary
org.apache.axis.client.Call
call
Constructors Summary
public TestEncoding(String s)


       
        super(s);
    
Methods Summary
private voidruntest(java.lang.String send, java.lang.String get)

        String ret = (String) call.invoke("echo", new Object[]{send});
        assertEquals(ret, get);
    
private voidruntest(java.lang.String value)

        runtest(value, value);
    
protected voidsetUp()

        if (call == null) {
            Service service = new Service();
            service.getEngine().setOption(AxisEngine.PROP_XML_ENCODING, "UTF-8");
            call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL("http://localhost:8080/jws/EchoHeaders.jws"));
        }
    
public voidtestFrenchAccents()

        runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
    
public voidtestFrenchAccents2()

        runtest("Une chaîne avec des caractères accentués");
    
public voidtestGermanUmlauts()

        runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
    
public voidtestSimpleString()

        runtest("a simple string");
    
public voidtestStringWithApostrophes()

        runtest("this isn't a simple string");
    
public voidtestStringWithEntities()

        runtest("&<>'"", "&<>'"");
    
public voidtestStringWithLeadingAndTrailingSpaces()

        runtest("          centered          ");
    
public voidtestStringWithRawEntities()

        runtest("&<>'\"", "&<>'\"");
    
public voidtestSynchronization()

        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = scFactory.createConnection();

        MessageFactory factory = MessageFactory.newInstance();
        SOAPMessage message = factory.createMessage();
        String requestEncoding = "UTF-16";
        message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);

        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
        SOAPBody body = envelope.getBody();

        Name bodyName = envelope.createName("echo");
        SOAPBodyElement bodyElement = body.addBodyElement(bodyName);

        Name name = envelope.createName("arg0");
        SOAPElement symbol = bodyElement.addChildElement(name);
        symbol.addTextNode("Hello");

        URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/EchoHeaders.jws");
        SOAPMessage response = con.call(message, endpoint);
        String responseEncoding = (String) response.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
        assertEquals(requestEncoding.toLowerCase(), responseEncoding.toLowerCase());
    
public voidtestWelcomeUnicode()

        // welcome in several languages
        runtest(
                "Chinese (trad.) : \u6b61\u8fce  \n" +
                "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5 \n" +
                "Japanese : \u3088\u3046\u3053\u305d");
    
public voidtestWhitespace()

        runtest(" \n \t "); // note: \r fails