axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/encoding TestString3.java PackageTests.java
Date Sat, 20 Aug 2005 02:21:20 GMT
dims        2005/08/19 19:21:20

  Modified:    java/test/encoding PackageTests.java
  Added:       java/test/encoding TestString3.java
  Log:
  Ensure that line feed normalization and character reference processing works as expected
  
  See http://groups.yahoo.com/group/soapbuilders/message/10349 for more information.
  
  Revision  Changes    Path
  1.33      +1 -0      ws-axis/java/test/encoding/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/PackageTests.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- PackageTests.java	17 Feb 2005 20:05:06 -0000	1.32
  +++ PackageTests.java	20 Aug 2005 02:21:20 -0000	1.33
  @@ -27,6 +27,7 @@
           suite.addTestSuite(TestSer.class);
           suite.addTestSuite(TestString.class);
           suite.addTestSuite(TestString2.class);
  +        suite.addTestSuite(TestString3.class);
           suite.addTestSuite(TestHrefs.class);
           suite.addTestSuite(TestBody.class);
           suite.addTestSuite(TestDOM.class);
  
  
  
  1.1                  ws-axis/java/test/encoding/TestString3.java
  
  Index: TestString3.java
  ===================================================================
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.MessageContext;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.message.RPCElement;
  import org.apache.axis.message.RPCParam;
  import org.apache.axis.server.AxisServer;
  import org.xml.sax.InputSource;
  
  import javax.xml.soap.SOAPMessage;
  import javax.xml.soap.MessageFactory;
  import java.io.ByteArrayOutputStream;
  import java.io.ByteArrayInputStream;
  
  /** 
   * line feed normalization and character reference processing 
   */
  public class TestString3 extends TestCase {
  
      public static final String myNS = "urn:myNS";
      
      public TestString3(String name) {
          super(name);
      }
  
      static String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
              "<soapenv:Body>" +
              "<ns1:method1 xmlns:ns1=\"urn:myNamespace\">" +
              "<ns1:testParam xsi:type=\"soapenc:string\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">";
  
      static String xml2 =
              "</ns1:testParam>" +
              "</ns1:method1>" +
              "</soapenv:Body>" +
              "</soapenv:Envelope>";
  
      private void runtest(String value, String expected) throws Exception {
          MessageContext msgContext = new MessageContext(new AxisServer());
          String requestEncoding = "UTF-8";
          msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);
  
          String xml = xml1 + value + xml2;
          ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
  
          DeserializationContext dser = new DeserializationContext(
              new InputSource(bais), msgContext, org.apache.axis.Message.REQUEST);
          dser.parse();
          
          org.apache.axis.message.SOAPEnvelope env = dser.getEnvelope();
          RPCElement rpcElem = (RPCElement)env.getFirstBody();
          RPCParam output = rpcElem.getParam("testParam");
          assertNotNull("No <testParam> param", output);
  
          String nodeValue = (String) output.getObjectValue();
          assertNotNull("No node value for testParam param", nodeValue);
          assertEquals(expected, nodeValue);
      }
  
      public void testEntitizedCRLF() throws Exception {
          runtest("&#xD;&#xA;Hello&#xD;&#xA;World&#xD;&#xA;", "\r\nHello\r\nWorld\r\n");
      }
  
      public void testPlainCRLF() throws Exception {
          runtest("\r\nHello\r\nWorld\r\n", "\nHello\nWorld\n");
      }
  
      public void testEntitizedCR() throws Exception {
          runtest("&#xD;Hello&#xD;World&#xD;", "\rHello\rWorld\r");
      }
  
      public void testPlainCR() throws Exception {
          runtest("\rHello\rWorld\r", "\nHello\nWorld\n");
      }
  }
  
  
  

Mime
View raw message