blautenb    2004/02/07 16:25:39

  Modified:    src_unitTests/org/apache/xml/security/test/encryption
                        XMLCipherTester.java
  Log:
  Tests now canonicalise for document comparisons, rather than use Xerces 
serialisers, as the use of c14n in encryption modifies document
  
  Revision  Changes    Path
  1.12      +21 -1     
xml-security/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java
  
  Index: XMLCipherTester.java
  ===================================================================
  RCS file: 
/home/cvs/xml-security/src_unitTests/org/apache/xml/security/test/encryption/XMLCipherTester.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLCipherTester.java      26 Dec 2003 11:20:38 -0000      1.11
  +++ XMLCipherTester.java      8 Feb 2004 00:25:39 -0000       1.12
  @@ -81,6 +81,7 @@
   import junit.framework.Assert;
   import junit.framework.TestCase;
   
  +import org.apache.xml.security.c14n.Canonicalizer;
   import org.apache.xml.security.encryption.XMLCipher;
   import org.apache.xml.security.encryption.EncryptedData;
   import org.apache.xml.security.encryption.EncryptedKey;
  @@ -88,6 +89,7 @@
   import org.apache.xml.security.encryption.CipherData;
   import org.apache.xml.security.transforms.params.XPathContainer;
   import org.apache.xml.security.utils.IdResolver;
  +import org.apache.xml.security.utils.XMLUtils;
   import org.apache.xml.security.keys.KeyInfo;
   import org.apache.xml.serialize.DOMSerializer;
   import org.apache.xml.serialize.Method;
  @@ -95,6 +97,7 @@
   import org.apache.xml.serialize.XMLSerializer;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  +import org.w3c.dom.Node;
   
   
   /**
  @@ -704,6 +707,7 @@
           }
       }
   
  +     /*
       private String toString(Element element) 
                           throws UnsupportedEncodingException {
           OutputFormat of = new OutputFormat();
  @@ -719,7 +723,6 @@
           }
           return (baos.toString("UTF-8"));
       }
  -
       private String toString(Document document) 
                       throws  UnsupportedEncodingException {
           OutputFormat of = new OutputFormat();
  @@ -735,6 +738,23 @@
           }
           return (baos.toString("UTF-8"));
       }
  +     */
  +
  +     private String toString (Node n)
  +             throws Exception {
  +
  +             ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +             Canonicalizer c14n = Canonicalizer.getInstance
  +                     (Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
  +
  +             byte[] serBytes = c14n.canonicalizeSubtree(n);
  +             baos.write(serBytes);
  +             baos.close();
  +
  +             return baos.toString("UTF-8");
  +
  +     }
  +             
       private void toString(Document document, String outputFile) 
                       throws  UnsupportedEncodingException , 
FileNotFoundException {
           OutputFormat of = new OutputFormat();
  
  
  

Reply via email to