dims        2003/07/18 05:40:41

  Modified:    java/src/org/apache/axis AxisEngine.java
               java/src/org/apache/axis/encoding
                        SerializationContextImpl.java
               java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/transport/http AxisServlet.java
               java/src/org/apache/axis/utils DOM2Writer.java XMLUtils.java
               java/test/encoding TestDOM.java TestOutputter.java
               java/test/httpunit FunctionalTests.java build.xml
               java/test/utils TestXMLUtils.java build.xml
               java/xmls path_refs.xml properties.xml
  Added:       java/src/org/apache/axis/components/encoding
                        AbstractXMLEncoder.java EncodedByteArray.java
                        UTF16Encoder.java UTF8Encoder.java XMLEncoder.java
                        XMLEncoderFactory.java
               java/test AxisTestBase.java
               java/test/encoding EncodingTest.java
               java/test/lib xmlunit1.0.LICENSE xmlunit1.0.jar
  Removed:     java/src/org/apache/axis/test AxisTestBase.java
  Log:
  Reworked Patch from  Jens Schumann ([EMAIL PROTECTED]) which fixes for the following:
  Bug 15133 - Problems serializing german umlauts
  Bug 15494 - zero terminated java string serialize zero to XML
  Bug 19327 - Character entities are escaped too aggressively
  
  Notes:
  - Pluggable XMLEncoder component (see XMLEncoderFactory for details)
  - Fixed memory allocation bugs in EncodedByteArray
  - Keep XMLUtils.xmlEncodeString
  - You can set the encoding in AxisEngine ("axis.xmlEncoding")
  - Use XMLUnit (http://xmlunit.sf.net) to test if two xml's are equal (Don't compare 
them as strings).
  - xmlunit1.0.jar is in test/lib directory. It uses a BSD License.
  
  Revision  Changes    Path
  1.105     +1 -0      xml-axis/java/src/org/apache/axis/AxisEngine.java
  
  Index: AxisEngine.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- AxisEngine.java   22 Apr 2003 19:33:59 -0000      1.104
  +++ AxisEngine.java   18 Jul 2003 12:40:39 -0000      1.105
  @@ -102,6 +102,7 @@
       public static final String PROP_SOAP_ALLOWED_VERSION = "singleSOAPVersion";
       public static final String PROP_TWOD_ARRAY_ENCODING = "enable2DArrayEncoding";
       public static final String PROP_SEND_MINIMIZED_ELEMENTS = 
"axis.sendMinimizedElements";
  +    public static final String PROP_XML_ENCODING = "axis.xmlEncoding";
   
       public static final String 
DEFAULT_ATTACHMENT_IMPL="org.apache.axis.attachments.AttachmentsImpl";
   
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/AbstractXMLEncoder.java
  
  Index: AbstractXMLEncoder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  import org.apache.axis.utils.Messages;
  
  import java.io.UnsupportedEncodingException;
  
  /**
   *
   * Abstract class for XML String encoders.
   *
   * The new encoding mechanism fixes the following bugs/issues:
   *   http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15133
   *   http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15494
   *   http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19327
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Jens Schumann</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
   *
   */
  public abstract class AbstractXMLEncoder implements XMLEncoder {
      private static final byte[] AMP = "&amp;".getBytes();
      private static final byte[] QUOTE = "&quot;".getBytes();
      private static final byte[] LESS = "&lt;".getBytes();
      private static final byte[] GREATER = "&gt;".getBytes();
      private static final byte[] LF = "&#xa;".getBytes();
      private static final byte[] CR = "&#xd;".getBytes();
      private static final byte[] TAB = "&#x9;".getBytes();
  
      /**
       * Encode a string
       * @param xmlString string to be encoded
       * @return encoded string
       */
      public String encode(String xmlString) {
          if(xmlString == null) {
              return "";
          }
          char[] characters = xmlString.toCharArray();
          EncodedByteArray out = null;
          char character;
  
          for (int i = 0; i < characters.length; i++) {
              character = characters[i];
              switch (character) {
                  // we don't care about single quotes since axis will
                  // use double quotes anyway
                  case '&':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(AMP);
                      break;
                  case '"':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(QUOTE);
                      break;
                  case '<':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(LESS);
                      break;
                  case '>':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(GREATER);
                      break;
                  case '\n':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(LF);
                      break;
                  case '\r':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(CR);
                      break;
                  case '\t':
                      if (out == null) {
                          out = getInitialByteArray(xmlString, i);
                      }
                      out.append(TAB);
                      break;
                  default:
                      if (character < 0x20) {
                          throw new 
IllegalArgumentException(Messages.getMessage("invalidXmlCharacter00", 
Integer.toHexString(character), xmlString));
                      } else if (needsEncoding(character)) {
                          if (out == null) {
                              out = getInitialByteArray(xmlString, i);
                          }
                          appendEncoded(out, character);
                      } else {
                          if (out != null) {
                              out.append(character);
                          }
                      }
                      break;
              }
          }
          return (out == null) ? xmlString : out.toString();
      }
  
      public abstract String getEncoding();
  
      public abstract boolean needsEncoding(char c);
  
      public abstract void appendEncoded(EncodedByteArray out, char c);
  
      private EncodedByteArray getInitialByteArray(String aXmlString, int pos) {
          try {
              return new EncodedByteArray(aXmlString.getBytes(getEncoding()), 0, pos);
          } catch (UnsupportedEncodingException e) {
              // we tested it ealier, should work.
              throw new 
IllegalStateException(Messages.getMessage("encodingDisappeared00", getEncoding()));
          }
      }
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/EncodedByteArray.java
  
  Index: EncodedByteArray.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  /**
   *
   * Simple byte array with variable array length, used within the
   * XMLEncoder.
   *
   * It is used as a ByteArrayOutputStream replacement to limit
   * the size of created temporary objects
   *
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Jens Schumann</a>
   * @version $Id: EncodedByteArray.java,v 1.1 2003/07/18 12:40:39 dims Exp $
   *
   */
  class EncodedByteArray {
      private byte[] array = null;
      private int pointer;
      
      private final double PADDING = 1.5;
  
      public EncodedByteArray(byte[] bytes, int startPos, int length) {
          // string length will be at least the size of the byte array
          array = new byte[(int) (bytes.length * PADDING)];
          System.arraycopy(bytes, startPos, array, 0, length);
          pointer = length;
      }
  
      public EncodedByteArray(int size) {
          array = new byte[size];
      }
  
      public void append(int aByte) {
          if (pointer + 1 >= array.length) {
              byte[] newArray = new byte[(int) (array.length * PADDING)];
              System.arraycopy(array, 0, newArray, 0, pointer);
              array = newArray;
          }
          array[pointer] = (byte) aByte;
          pointer++;
      }
  
      public void append(byte[] byteArray) {
          if (pointer + byteArray.length >= array.length) {
              byte[] newArray = new byte[((int)(array.length * PADDING)) + 
byteArray.length];
              System.arraycopy(array, 0, newArray, 0, pointer);
              array = newArray;
          }
  
          System.arraycopy(byteArray, 0, array, pointer, byteArray.length);
          pointer += byteArray.length;
      }
  
      public void append(byte[] byteArray, int pos, int length) {
          if (pointer + length >= array.length) {
              byte[] newArray = new byte[((int) (array.length * PADDING)) + 
byteArray.length];
              System.arraycopy(array, 0, newArray, 0, pointer);
              array = newArray;
          }
          System.arraycopy(byteArray, pos, array, pointer, length);
          pointer += length;
      }
  
      public String toString() {
          return new String(array, 0, pointer);
      }
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/UTF16Encoder.java
  
  Index: UTF16Encoder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  /**
   * UTF-16 Encoder.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Jens Schumann</a>
   *
   * @see <a href="http://encoding.org";>encoding.org</a>
   * @see <a href="http://czyborra.com/utf/#UTF-16";>UTF 16 explained</a>
   *
   */
  class UTF16Encoder extends AbstractXMLEncoder {
      public String getEncoding() {
          return XMLEncoderFactory.ENCODING_UTF_16;
      }
  
      public boolean needsEncoding(char c) {
          return c > 0xFFFF;
      }
  
      public void appendEncoded(EncodedByteArray out, char c) {
          if (c > 0xFFFF) {
              out.append((0xD7C0 + (c >> 10)));
              out.append((0xDC00 | c & 0x3FF));
          }
      }
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/UTF8Encoder.java
  
  Index: UTF8Encoder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  /**
   * UTF-8 Encoder.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Jens Schumann</a>
   *
   * @see <a href="http://encoding.org";>encoding.org</a>
   * @see <a href="http://czyborra.com/utf/#UTF-8";>UTF 8 explained</a>
   *
   */
  class UTF8Encoder extends AbstractXMLEncoder {
      public String getEncoding() {
          return XMLEncoderFactory.ENCODING_UTF_8;
      }
  
      public boolean needsEncoding(char c) {
          return c > 0x7F;
      }
  
      public void appendEncoded(EncodedByteArray out, char c) {
          if (c < 0x80) {
              out.append(c);
          } else if (c < 0x800) {
              out.append((0xC0 | c >> 6));
              out.append((0x80 | c & 0x3F));
          } else if (c < 0x10000) {
              out.append((0xE0 | c >> 12));
              out.append((0x80 | c >> 6 & 0x3F));
              out.append((0x80 | c & 0x3F));
          } else if (c < 0x200000) {
              out.append((0xF0 | c >> 18));
              out.append((0x80 | c >> 12 & 0x3F));
              out.append((0x80 | c >> 6 & 0x3F));
              out.append((0x80 | c & 0x3F));
          }
      }
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/XMLEncoder.java
  
  Index: XMLEncoder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  /**
   * Interface for XMLEncoders
   */
  public interface XMLEncoder {
      /**
       * gets the encoding supported by this encoder
       * @return
       */
      public String getEncoding();
  
      /**
       * encode a given string
       * @param xmlString string to be encoded
       * @return encoded string
       */
      String encode(String xmlString);
  }
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/components/encoding/XMLEncoderFactory.java
  
  Index: XMLEncoderFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.encoding;
  
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.Messages;
  import org.apache.commons.discovery.ResourceNameIterator;
  import org.apache.commons.discovery.resource.ClassLoaders;
  import org.apache.commons.discovery.resource.names.DiscoverServiceNames;
  import org.apache.commons.logging.Log;
  
  import java.io.UnsupportedEncodingException;
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * Factory for XMLEncoder
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">Jens Schumann</a>
   * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
   */
  public class XMLEncoderFactory {
      protected static Log log = LogFactory.getLog(XMLEncoderFactory.class.getName());
      
      public static final String ENCODING_UTF_8 = "UTF-8";
      public static final String ENCODING_UTF_16 = "UTF-16";
      public static final String DEFAULT_ENCODING = ENCODING_UTF_8;
      
      private static Map encoderMap = new HashMap();
      private static final String PLUGABLE_PROVIDER_FILENAME = 
"org.apache.axis.components.encoding.XMLEncoder";
  
      static {
          encoderMap.put(ENCODING_UTF_8, new UTF8Encoder());
          encoderMap.put(ENCODING_UTF_16, new UTF16Encoder());
          try {
              loadPluggableEncoders();
          } catch (Throwable t){
              String msg=t + JavaUtils.LS + JavaUtils.stackToString(t);
              log.info(Messages.getMessage("exception01",msg));
          }
      }
  
      /** 
       * Returns the default encoder
       * @return
       */
      public static XMLEncoder getDefaultEncoder() {
          try {
              return getEncoder(DEFAULT_ENCODING);
          } catch (UnsupportedEncodingException e) {
              //  as far I know J++ VMs will throw this exception
              throw new 
IllegalStateException(Messages.getMessage("unsupportedDefaultEncoding00", 
DEFAULT_ENCODING));
          }
      }
  
      /**
       * Returns the requested encoder
       * @param encoding
       * @return
       * @throws UnsupportedEncodingException
       */
      public static XMLEncoder getEncoder(String encoding) throws 
UnsupportedEncodingException {
          XMLEncoder encoder = (XMLEncoder) encoderMap.get(encoding.toUpperCase());
          if (encoder == null) {
              throw new 
UnsupportedEncodingException(Messages.getMessage("unsupportedEncoding00", encoding));
          }
          // test local encoding so we can ensure that getBytes()
          // will not fail later
          "test".getBytes(encoder.getEncoding());
          return encoder;
      }
  
      /**
       Look for file META-INF/services/org.apache.axis.components.encoding.XMLEncoder
       in all the JARS, get the classes listed in those files and add them to 
       encoders list if they are valid encoders. 
  
       Here is how the scheme would work.
  
       A company providing a new encoder will jar up their encoder related
       classes in a JAR file. The following file containing the name of the new 
       encoder class is also made part of this JAR file. 
  
       META-INF/services/org.apache.axis.components.encoding.XMLEncoder
  
       By making this JAR part of the webapp, the new encoder will be 
       automatically discovered. 
       */
      private static void loadPluggableEncoders() {
          ClassLoader clzLoader = XMLEncoder.class.getClassLoader();
          ClassLoaders loaders = new ClassLoaders();
          loaders.put(clzLoader);
          DiscoverServiceNames dsn = new DiscoverServiceNames(loaders);
          ResourceNameIterator iter = 
dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME);
          while (iter.hasNext()) {
              String className = iter.nextResourceName();
              try {
                  Object o = Class.forName(className).newInstance();
                  if (o instanceof XMLEncoder) {
                      XMLEncoder encoder = (XMLEncoder) o;
                      encoderMap.put(encoder.getEncoding(), encoder);
                  }
              } catch (Exception e) {
                  String msg = e + JavaUtils.LS + JavaUtils.stackToString(e);
                  log.info(Messages.getMessage("exception01", msg));
                  continue;
              }
          }
      }
  }
  
  
  
  1.96      +3 -1      
xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- SerializationContextImpl.java     2 Jul 2003 20:51:28 -0000       1.95
  +++ SerializationContextImpl.java     18 Jul 2003 12:40:40 -0000      1.96
  @@ -907,7 +907,9 @@
           }
   
           if (startOfDocument && sendXMLDecl) {
  -            writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  +            writer.write("<?xml version=\"1.0\" encoding=\"");
  +            writer.write(XMLUtils.getEncoding());
  +            writer.write("\"?>\n");
               startOfDocument = false;
           }
   
  
  
  
  1.66      +6 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- resource.properties       18 Jul 2003 07:16:23 -0000      1.65
  +++ resource.properties       18 Jul 2003 12:40:40 -0000      1.66
  @@ -270,6 +270,8 @@
   
   invalidWSDD00=Invalid WSDD element ''{0}'' (wanted ''{1}'')
   
  +invalidXmlCharacter00=The char ''0x{0}'' in ''{1}'' is not a valid XML character.
  +
   # NOTE:  in invokeGet00, do no translate "GET"
   invokeGet00=invoking via GET
   
  @@ -349,6 +351,7 @@
   
   engineConfigNoInstance00=''{0}'' class cannot be instantiated
   engineConfigIllegalAccess00=Illegal access while instantiating class ''{0}''
  +encodingDisappeared00=XML Encoding runtime error: Previously supported encoding {0} 
disappeared.
   
   jndiNotFound00=JNDI InitialContext() returned null, default to non-JNDI behavior 
(DefaultAxisServerFactory)
   
  @@ -571,6 +574,9 @@
   returnChain00={0} returning chain ''{1}''
   saveConfigFail00=Could not write engine config!
   registerTypeMappingFor01=Please register a typemapping/beanmapping for ''{0}''
  +
  +unsupportedEncoding00=Encoding {0} not supported.
  +unsupportedDefaultEncoding00=Failed to initialize default encoding. Ensure your VM 
supports at least {0} encoding.
   
   # NOTE:  in semanticCheck00, do not translate "SOAP"
   semanticCheck00=Doing SOAP semantic checks...
  
  
  
  1.163     +1 -1      
xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.162
  retrieving revision 1.163
  diff -u -r1.162 -r1.163
  --- AxisServlet.java  22 Apr 2003 19:35:51 -0000      1.162
  +++ AxisServlet.java  18 Jul 2003 12:40:40 -0000      1.163
  @@ -536,7 +536,7 @@
           Message responseMsg=null;
           try {
               ByteArrayInputStream istream =
  -                new ByteArrayInputStream(msgtxt.getBytes(XMLUtils.charEncoding));
  +                new 
ByteArrayInputStream(msgtxt.getBytes(XMLUtils.httpAuthCharEncoding));
   
               AxisEngine engine = getEngine();
               Message msg = new Message(istream, false);
  
  
  
  1.17      +6 -60     xml-axis/java/src/org/apache/axis/utils/DOM2Writer.java
  
  Index: DOM2Writer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/DOM2Writer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DOM2Writer.java   2 Jul 2003 20:51:28 -0000       1.16
  +++ DOM2Writer.java   18 Jul 2003 12:40:40 -0000      1.17
  @@ -109,8 +109,11 @@
                                         boolean pretty)
       {
           PrintWriter out = new PrintWriter(writer);
  -        if (!omitXMLDecl)
  -            out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  +        if (!omitXMLDecl) {
  +            out.print("<?xml version=\"1.0\" encoding=\"");
  +            out.print(XMLUtils.getEncoding());
  +            out.println("\"?>");
  +        }
           NSStack namespaceStack = new NSStack();
           print(node, namespaceStack, out, pretty, 0);
           out.flush();
  @@ -374,63 +377,6 @@
   
       public static String normalize(String s)
       {
  -        StringBuffer str = new StringBuffer();
  -        int len = (s != null) ? s.length() : 0;
  -
  -        for (int i = 0; i < len; i++)
  -        {
  -            char ch = s.charAt(i);
  -
  -            switch (ch)
  -            {
  -            case '<' :
  -                {
  -                    str.append("&lt;");
  -                    break;
  -                }
  -            case '>' :
  -                {
  -                    str.append("&gt;");
  -                    break;
  -                }
  -            case '&' :
  -                {
  -                    str.append("&amp;");
  -                    break;
  -                }
  -            case '"' :
  -                {
  -                    str.append("&quot;");
  -                    break;
  -                }
  -            case JavaUtils.NL :
  -                {
  -                    if (i > 0)
  -                    {
  -                        char lastChar = str.charAt(str.length() - 1);
  -
  -                        if (lastChar != JavaUtils.CR)
  -                        {
  -                            str.append(JavaUtils.LS);
  -                        }
  -                        else
  -                        {
  -                            str.append(JavaUtils.NL);
  -                        }
  -                    }
  -                    else
  -                    {
  -                        str.append(JavaUtils.LS);
  -                    }
  -                    break;
  -                }
  -            default :
  -                {
  -                    str.append(ch);
  -                }
  -            }
  -        }
  -
  -        return (str.toString());
  +        return XMLUtils.xmlEncodeString(s);
       }
   }
  
  
  
  1.84      +40 -47    xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- XMLUtils.java     28 Jun 2003 22:18:44 -0000      1.83
  +++ XMLUtils.java     18 Jul 2003 12:40:40 -0000      1.84
  @@ -57,7 +57,11 @@
   
   import org.apache.axis.Constants;
   import org.apache.axis.InternalException;
  +import org.apache.axis.MessageContext;
  +import org.apache.axis.AxisEngine;
   import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.components.encoding.XMLEncoder;
  +import org.apache.axis.components.encoding.XMLEncoderFactory;
   import org.apache.commons.logging.Log;
   import org.w3c.dom.Attr;
   import org.w3c.dom.CharacterData;
  @@ -103,7 +107,7 @@
       protected static Log log =
           LogFactory.getLog(XMLUtils.class.getName());
           
  -    public static final String charEncoding = "ISO-8859-1";
  +    public static final String httpAuthCharEncoding = "ISO-8859-1";
       private static final String saxParserFactoryProperty =
           "javax.xml.parsers.SAXParserFactory";
   
  @@ -119,60 +123,49 @@
           initSAXFactory(null, true, false);
       }
   
  -    /** Encode a string appropriately for XML.
  -     *
  -     * Lifted from ApacheSOAP 2.2 (org.apache.soap.Utils)
  -     *
  +    /** 
  +     * Encode a string appropriately for XML.
        * @param orig the String to encode
        * @return a String in which XML special chars are repalced by entities
        */
       public static String xmlEncodeString(String orig)
       {
  -        if (orig == null)
  -        {
  -            return "";
  -        }
  -
  -        char[] chars = orig.toCharArray();
  -
  -        // if the string doesn't have any of the magic characters, leave
  -        // it alone.
  -        boolean needsEncoding = false;
  -
  -        search:
  -        for(int i = 0; i < chars.length; i++) {
  -            switch(chars[i]) {
  -            case '&': case '"': case '\'': case '<': case '>':
  -                needsEncoding = true;
  -                break search;
  -            }
  -        }
  -
  -        if (!needsEncoding) return orig;
  +        XMLEncoder encoder = getXMLEncoder();
  +        return encoder.encode(orig);
  +    }
   
  -        StringBuffer strBuf = new StringBuffer();
  -        for (int i = 0; i < chars.length; i++)
  -        {
  -            switch (chars[i])
  -            {
  -            case '&'  : strBuf.append("&amp;");
  -                        break;
  -            case '\"' : strBuf.append("&quot;");
  -                        break;
  -            case '\'' : strBuf.append("&apos;");
  -                        break;
  -            case '<'  : strBuf.append("&lt;");
  -                        break;
  -            case '\r' : strBuf.append("&#xd;");
  -                        break;
  -            case '>'  : strBuf.append("&gt;");
  -                        break;
  -            default   : strBuf.append(chars[i]);
  -                        break;
  +    /**
  +     * Get the current XMLEncoder
  +     * @return XMLEncoder
  +     */ 
  +    private static XMLEncoder getXMLEncoder() {
  +        MessageContext msgContext = MessageContext.getCurrentContext();
  +        XMLEncoder encoder = null;
  +        if(msgContext == null) {
  +            encoder = XMLEncoderFactory.getDefaultEncoder();
  +        } else {
  +            String encoding = (String) 
msgContext.getAxisEngine().getOption(AxisEngine.PROP_XML_ENCODING);
  +            try {
  +                if(encoding != null) {
  +                    encoder = XMLEncoderFactory.getEncoder(encoding);
  +                } else {
  +                    encoder = XMLEncoderFactory.getDefaultEncoder();
  +                }
  +            } catch (Exception e) {
  +                log.error(Messages.getMessage("exception00"), e);
  +                encoder = XMLEncoderFactory.getDefaultEncoder();
               }
           }
  +        return encoder;
  +    }
   
  -        return strBuf.toString();
  +    /**
  +     * Get the current encoding in effect
  +     * @return string 
  +     */ 
  +    public static String getEncoding() {
  +        XMLEncoder encoder = getXMLEncoder();
  +        return encoder.getEncoding();        
       }
   
       /** Initialize the SAX parser factory.
  @@ -751,7 +744,7 @@
           if (auth != null) {
               uconn.setRequestProperty("Authorization",
                                        "Basic " + 
  -                                     base64encode(auth.getBytes(charEncoding)));
  +                                     
base64encode(auth.getBytes(httpAuthCharEncoding)));
           }
           
           uconn.connect();
  
  
  
  1.1                  xml-axis/java/test/AxisTestBase.java
  
  Index: AxisTestBase.java
  ===================================================================
  /*
   *  The Apache Software License, Version 1.1
   *
   *  Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
   *  reserved.
   *
   *  Redistribution and use in source and binary forms, with or without
   *  modification, are permitted provided that the following conditions
   *  are met:
   *
   *  1. Redistributions of source code must retain the above copyright
   *  notice, this list of conditions and the following disclaimer.
   *
   *  2. Redistributions in binary form must reproduce the above copyright
   *  notice, this list of conditions and the following disclaimer in
   *  the documentation and/or other materials provided with the
   *  distribution.
   *
   *  3. The end-user documentation included with the redistribution, if
   *  any, must include the following acknowlegement:
   *  "This product includes software developed by the
   *  Apache Software Foundation (http://www.apache.org/)."
   *  Alternately, this acknowlegement may appear in the software itself,
   *  if and wherever such third-party acknowlegements normally appear.
   *
   *  4. The names "The Jakarta Project", "Ant", and "Apache Software
   *  Foundation" must not be used to endorse or promote products derived
   *  from this software without prior written permission. For written
   *  permission, please contact [EMAIL PROTECTED]
   *
   *  5. Products derived from this software may not be called "Apache"
   *  nor may "Apache" appear in their names without prior written
   *  permission of the Apache Group.
   *
   *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   *  SUCH DAMAGE.
   *  ====================================================================
   *
   *  This software consists of voluntary contributions made by many
   *  individuals on behalf of the Apache Software Foundation.  For more
   *  information on the Apache Software Foundation, please see
   *  <http://www.apache.org/>.
   */
  
  
  package test;
  
  import org.custommonkey.xmlunit.XMLTestCase;
  
  /**
   *  base test class for Axis test cases.
   * @author steve loughran
   */
  public abstract class AxisTestBase extends XMLTestCase {
  
      public AxisTestBase(String s) {
          super(s);
      }
  
      /**
       * probe for a property being set in ant terms.
       * @param propertyname
       * @return true if the system property is set and set to true or yes
       */
      public static boolean isPropertyTrue(String propertyname) {
          String setting = System.getProperty(propertyname);
          return "true".equalsIgnoreCase(setting) ||
                  "yes".equalsIgnoreCase(setting);
      }
  
      /**
       * test for the online tests being enabled
       * @return true if 'online' tests are allowed.
       */
      public static boolean isOnline() {
          return isPropertyTrue("test.functional.online");
      }
  }
  
  
  
  1.17      +3 -2      xml-axis/java/test/encoding/TestDOM.java
  
  Index: TestDOM.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestDOM.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TestDOM.java      30 Jun 2003 18:25:06 -0000      1.16
  +++ TestDOM.java      18 Jul 2003 12:40:41 -0000      1.17
  @@ -10,6 +10,7 @@
   import org.apache.axis.message.SOAPHeaderElement;
   import org.apache.axis.server.AxisServer;
   import org.apache.axis.utils.XMLUtils;
  +import org.custommonkey.xmlunit.XMLTestCase;
   
   /**
   
  @@ -19,7 +20,7 @@
   
    */
   
  -public class TestDOM extends TestCase {
  +public class TestDOM extends XMLTestCase {
   
       public TestDOM(String name) {
           super(name);
  @@ -69,7 +70,7 @@
          // Element dom = message.getAsDOM();
          String result = message.getSOAPPartAsString();
   
  -       assertEquals("Request is not the same as the result.", request, result);
  +       assertXMLEqual("Request is not the same as the result.", request, result);
       }
   
       public void testHeaders() throws Exception {
  
  
  
  1.6       +3 -2      xml-axis/java/test/encoding/TestOutputter.java
  
  Index: TestOutputter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestOutputter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestOutputter.java        11 Dec 2002 22:40:15 -0000      1.5
  +++ TestOutputter.java        18 Jul 2003 12:40:41 -0000      1.6
  @@ -5,11 +5,12 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.server.AxisServer;
  +import org.custommonkey.xmlunit.XMLTestCase;
   
   /**
    * Test deserialization of SOAP responses
    */
  -public class TestOutputter extends TestCase {
  +public class TestOutputter extends XMLTestCase {
   
       private String header;
       private String footer;
  @@ -50,7 +51,7 @@
   
          message.getSOAPEnvelope();
   
  -       assertEquals(header+data+footer, message.getSOAPPartAsString());
  +       assertXMLEqual(header+data+footer, message.getSOAPPartAsString());
       }
   
       public void testString() throws Exception {
  
  
  
  1.1                  xml-axis/java/test/encoding/EncodingTest.java
  
  Index: EncodingTest.java
  ===================================================================
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.components.encoding.XMLEncoder;
  import org.apache.axis.components.encoding.XMLEncoderFactory;
  
  import java.io.UnsupportedEncodingException;
  
  /**
   * Tests for the new XMLEncoder components
   */
  public class EncodingTest extends TestCase {
      public static final String GERMAN_UMLAUTS = " Some text \u00df with \u00fc 
special \u00f6 chars \u00e4.";
      public static final String XML_SPECIAL_CHARS = "< > \" &";
      public static final String ENCODED_XML_SPECIAL_CHARS = "&lt; &gt; &quot; &amp;";
      public static final String SUPPORT_CHARS_LESS_HEX_20 = "\t \r \n";
      public static final String ENCODED_SUPPORT_CHARS_LESS_HEX_20 = "&#x9; &#xd; 
&#xa;";
      public static final String INVALID_XML_STRING = "Invalid XML String \u0000";
  
      public EncodingTest(String s) {
          super(s);
      }
  
      public void testEncodingFailure() throws Exception {
          try {
              XMLEncoderFactory.getEncoder("XYZ");
              fail("A UnsupportedEncodingException should have been thrown.");
          } catch (UnsupportedEncodingException e) {
              // expected
          }
          try {
              XMLEncoder encoder = 
XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_8);
              encoder.encode(INVALID_XML_STRING);
              fail("A UnsupportedEncodingException should have been thrown.");
          } catch (IllegalArgumentException e) {
              // expected
          }
      }
  
      public void testUTF8() throws Exception {
          XMLEncoder encoder = 
XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_8);
          String encodedUmlauts = encoder.encode(GERMAN_UMLAUTS);
          String encodedXMLChars = encoder.encode(XML_SPECIAL_CHARS);
  
          assertEquals(XMLEncoderFactory.ENCODING_UTF_8, encoder.getEncoding());
          assertEquals(ENCODED_XML_SPECIAL_CHARS, encodedXMLChars);
          assertEquals(GERMAN_UMLAUTS, new String(encodedUmlauts.getBytes(), 
XMLEncoderFactory.ENCODING_UTF_8));
          assertEquals(ENCODED_SUPPORT_CHARS_LESS_HEX_20, 
encoder.encode(SUPPORT_CHARS_LESS_HEX_20));
      }
  
      public void testUTF16() throws Exception {
          // this test needs to be improved, currently is does not test a lot
          XMLEncoder encoder = 
XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_16);
          String encodedUmlauts = encoder.encode(GERMAN_UMLAUTS);
          String encodedXMLChars = encoder.encode(XML_SPECIAL_CHARS);
  
          assertEquals(XMLEncoderFactory.ENCODING_UTF_16, encoder.getEncoding());
          assertEquals(ENCODED_XML_SPECIAL_CHARS, encodedXMLChars);
          // java uses UTF-16 internally, should be equal
          assertEquals(GERMAN_UMLAUTS, encodedUmlauts);
          assertEquals(ENCODED_SUPPORT_CHARS_LESS_HEX_20, 
encoder.encode(SUPPORT_CHARS_LESS_HEX_20));
      }
  
      public static void main(String[] args) {
          junit.textui.TestRunner.run(EncodingTest.class);
      }
  }
  
  
  
  1.3       +1 -1      xml-axis/java/test/httpunit/FunctionalTests.java
  
  Index: FunctionalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/httpunit/FunctionalTests.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FunctionalTests.java      22 Apr 2003 19:36:52 -0000      1.2
  +++ FunctionalTests.java      18 Jul 2003 12:40:41 -0000      1.3
  @@ -55,7 +55,7 @@
   package test.httpunit;
   import junit.framework.Test;
   import junit.framework.TestSuite;
  -import org.apache.axis.test.AxisTestBase;
  +import test.AxisTestBase;
   
   /**
    * test httpunit
  
  
  
  1.14      +1 -0      xml-axis/java/test/httpunit/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/httpunit/build.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build.xml 13 Mar 2003 15:34:17 -0000      1.13
  +++ build.xml 18 Jul 2003 12:40:41 -0000      1.14
  @@ -124,6 +124,7 @@
              srcdir="${axis.home}">
         <classpath refid="test.compile.classpath"/>
         <include name="${componentName}/*.java"/>
  +      <include name="test/AxisTestBase.java"/>
       </javac>
     </target>
     
  
  
  
  1.1                  xml-axis/java/test/lib/xmlunit1.0.LICENSE
  
  Index: xmlunit1.0.LICENSE
  ===================================================================
  /*
  ******************************************************************
  Copyright (c) 2001, Jeff Martin, Tim Bacon
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:
  
      * Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above
        copyright notice, this list of conditions and the following
        disclaimer in the documentation and/or other materials provided
        with the distribution.
      * Neither the name of the xmlunit.sourceforge.net nor the names
        of its contributors may be used to endorse or promote products
        derived from this software without specific prior written
        permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.
  
  ******************************************************************
  */
  
  
  
  
  1.1                  xml-axis/java/test/lib/xmlunit1.0.jar
  
        <<Binary file>>
  
  
  1.19      +3 -3      xml-axis/java/test/utils/TestXMLUtils.java
  
  Index: TestXMLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/utils/TestXMLUtils.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestXMLUtils.java 2 Jun 2003 13:16:22 -0000       1.18
  +++ TestXMLUtils.java 18 Jul 2003 12:40:41 -0000      1.19
  @@ -4,7 +4,7 @@
   import junit.framework.TestSuite;
   import org.apache.axis.encoding.DeserializationContext;
   import org.apache.axis.encoding.DeserializationContextImpl;
  -import org.apache.axis.test.AxisTestBase;
  +import test.AxisTestBase;
   import org.apache.axis.utils.XMLUtils;
   import org.apache.axis.message.PrefixedQName;
   import org.apache.axis.message.MessageElement;
  @@ -83,7 +83,7 @@
   
           String xmlString = (String)this.getTestXml("string");
           String result = XMLUtils.DocumentToString(doc);
  -        assertEquals("xmlString is not the same as result", xmlString, result);
  +        assertXMLEqual("xmlString is not the same as result", xmlString, result);
       }
   
       /**
  @@ -149,7 +149,7 @@
           out.close();
   
           String expected = (String)this.getTestXml("string");
  -        assertEquals("Did not get the expected result", expected, result);
  +        assertXMLEqual("Did not get the expected result", expected, result);
       }
   
       public void testElementToString() throws Exception
  
  
  
  1.7       +1 -0      xml-axis/java/test/utils/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/utils/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.xml 21 Sep 2002 23:50:05 -0000      1.6
  +++ build.xml 18 Jul 2003 12:40:41 -0000      1.7
  @@ -59,6 +59,7 @@
       </classpath>
       <include name="test/utils/*.java"/>
       <include name="test/utils/cache/*.java"/>
  +    <include name="test/AxisTestBase.java"/>
     </javac>
   </target>
   
  
  
  
  1.12      +1 -0      xml-axis/java/xmls/path_refs.xml
  
  Index: path_refs.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/xmls/path_refs.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- path_refs.xml     26 Apr 2003 22:13:52 -0000      1.11
  +++ path_refs.xml     18 Jul 2003 12:40:41 -0000      1.12
  @@ -1,6 +1,7 @@
     <path id="classpath">
       <pathelement location="${xerces.jar}"/>
       <pathelement location="${regexp.jar}"/>
  +    <pathelement location="${xmlunit.jar}"/>
       <pathelement location="${jsse.jar}"/>
       <pathelement location="${jimi.jar}"/>
       <pathelement location="${activation.jar}"/>
  
  
  
  1.45      +2 -1      xml-axis/java/xmls/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/xmls/properties.xml,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- properties.xml    9 Jul 2003 01:28:46 -0000       1.44
  +++ properties.xml    18 Jul 2003 12:40:41 -0000      1.45
  @@ -54,8 +54,9 @@
   <!-- there is no commons-httpunit, AFAIK it is a sourceforge project -->
   <!-- <property name="httpunit.jar" location="${lib.dir}/commons-httpunit.jar"/> -->
   
  -<!-- this jar is only in the test lib dir -->
  +<!-- these jars are in the test lib dir -->
   <property name="regexp.jar" location="${test.dir}/lib/jakarta-oro-2.0.5.jar"/>
  +<property name="xmlunit.jar" location="${test.dir}/lib/xmlunit1.0.jar"/>
   
   <!-- pull this in from the compiler -->
   <property name="tools.jar" location="${java.home}/../lib/tools.jar"/>
  
  
  

Reply via email to