You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2006/12/18 22:36:30 UTC

svn commit: r488428 - /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/

Author: joerg
Date: Mon Dec 18 13:36:29 2006
New Revision: 488428

URL: http://svn.apache.org/viewvc?view=rev&rev=488428
Log:
removed the hack from assertEqual(String, Document, Document) adding namespace declarations as attributes as this seems to break the tests now (for whatever reason),
extracted common base class AbstractSelectionListTestCase

Added:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java   (with props)
Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java?view=auto&rev=488428
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java (added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java Mon Dec 18 13:36:29 2006
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.forms.datatype;
+
+import java.io.Writer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.cocoon.core.container.ContainerTestCase;
+
+import org.custommonkey.xmlunit.Diff;
+
+import org.w3c.dom.Document;
+
+/**
+ * Abstract TestCase for CForms's SelectionList datatypes.
+ * @version $Id$
+ */
+public abstract class AbstractSelectionListTestCase extends ContainerTestCase {
+
+    protected DatatypeManager datatypeManager;
+    protected DocumentBuilder parser;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        this.parser = factory.newDocumentBuilder();
+    }
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        if (this.datatypeManager != null) {
+            this.release(this.datatypeManager);
+        }
+        super.tearDown();
+    }
+    
+    /**
+     * Check is the source document is equal to the one produced by the method under test.
+     * @param message A message to print in case of failure.
+     * @param expected The expected (source) document.
+     * @param actual The actual (output) document.
+     */
+    protected static void assertEqual(String message, Document expected, Document actual) {
+        expected.getDocumentElement().normalize();
+        actual.getDocumentElement().normalize();
+
+        Diff diff =  new Diff(expected, actual);
+        assertTrue(message + ", " + diff.toString(), diff.similar());
+    }
+
+    /**
+     * Print a document to a writer for debugging purposes.
+     * @param document The document to print.
+     * @param out The writer to write to.
+     */
+    protected static void print(Document document, Writer out) {
+        TransformerFactory factory = TransformerFactory.newInstance();
+        try {
+            javax.xml.transform.Transformer serializer =
+                factory.newTransformer();
+            serializer.transform(
+                new DOMSource(document),
+                new StreamResult(out));
+            out.write('\n');
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/AbstractSelectionListTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.java?view=diff&rev=488428&r1=488427&r2=488428
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.java Mon Dec 18 13:36:29 2006
@@ -17,20 +17,17 @@
 
 package org.apache.cocoon.forms.datatype;
 
-import java.io.Writer;
+import java.net.MalformedURLException;
+
 import java.util.Locale;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.cocoon.core.container.ContainerTestCase;
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.xml.dom.DOMBuilder;
+
 import org.apache.excalibur.source.impl.ResourceSource;
-import org.custommonkey.xmlunit.Diff;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -38,32 +35,8 @@
  * Test case for CForms's DynamicSelectionList datatype.
  * @version $Id$
  */
-public class DynamicSelectionListTestCase extends ContainerTestCase {
-
-    protected DatatypeManager datatypeManager;
-    protected DocumentBuilder parser;
+public class DynamicSelectionListTestCase extends AbstractSelectionListTestCase {
 
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-        parser = factory.newDocumentBuilder();
-    }
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception {
-        if (datatypeManager != null) {
-            this.release(datatypeManager);
-        }
-        super.tearDown();
-    }
-    
     /**
      * Test the generateSaxFragment method.
      * @throws MalformedURLException
@@ -73,53 +46,17 @@
         DOMBuilder dest = new DOMBuilder();
         ResourceSource source = 
             new ResourceSource("resource://org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.source.xml");
-        Document sourceDoc = parser.parse(source.getInputStream());
+        Document sourceDoc = this.parser.parse(source.getInputStream());
         Element datatypeElement = (Element) sourceDoc.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "convertor").item(0);
-        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
+        Datatype datatype = this.datatypeManager.createDatatype(datatypeElement, false);
         DynamicSelectionList list = 
             new DynamicSelectionList(datatype, null, this.getManager());
         list.generateSaxFragment(dest, Locale.ENGLISH, source);
         ResourceSource expectedSource =
             new ResourceSource("resource://org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.dest.xml");
-        Document expected = parser.parse(expectedSource.getInputStream());
+        Document expected = this.parser.parse(expectedSource.getInputStream());
         assertEqual("Test if output is what is expected",
                 expected, dest.getDocument());
     }
 
-    /**
-     * Check is the source document is equal to the one produced by the method under test.
-     * @param message A message to print in case of failure.
-     * @param expected The expected (source) document.
-     * @param actual The actual (output) document.
-     */
-    private void assertEqual(String message, Document expected, Document actual) {
-        expected.getDocumentElement().normalize();
-        actual.getDocumentElement().normalize();
-        // DIRTY HACK WARNING: we add the "xmlns:wi" attribute reported
-        // by DOM, as expected, but not generated by the method under test,
-        // otherwise the comparison would fail. 
-        actual.getDocumentElement().setAttribute(FormsConstants.INSTANCE_PREFIX,
-                FormsConstants.INSTANCE_NS);
-        Diff diff =  new Diff(expected, actual);
-        assertTrue(message + ", " + diff.toString(), diff.similar());
-    }
-
-    /**
-     * Print a document to a writer for debugging purposes.
-     * @param document The document to print.
-     * @param out The writer to write to.
-     */
-    public final void print(Document document, Writer out) {
-        TransformerFactory factory = TransformerFactory.newInstance();
-        try {
-            javax.xml.transform.Transformer serializer =
-                factory.newTransformer();
-            serializer.transform(
-                new DOMSource(document),
-                new StreamResult(out));
-            out.write('\n');
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java?view=diff&rev=488428&r1=488427&r2=488428
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java Mon Dec 18 13:36:29 2006
@@ -17,22 +17,19 @@
 
 package org.apache.cocoon.forms.datatype;
 
-import java.io.Writer;
+import java.io.FileWriter;
+
+import java.net.MalformedURLException;
+
 import java.util.Locale;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.cocoon.transformation.I18nTransformer;
-import org.apache.cocoon.core.container.ContainerTestCase;
-import org.apache.cocoon.forms.FormsConstants;
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.cocoon.forms.datatype.typeimpl.EnumType;
 import org.apache.cocoon.xml.dom.DOMBuilder;
+
 import org.apache.excalibur.source.impl.ResourceSource;
-import org.custommonkey.xmlunit.Diff;
+
 import org.w3c.dom.Document;
 
 /**
@@ -40,32 +37,8 @@
  *
  * @version $Id$
  */
-public class EnumSelectionListTestCase extends ContainerTestCase {
+public class EnumSelectionListTestCase extends AbstractSelectionListTestCase {
 
-    protected DatatypeManager datatypeManager;
-    protected DocumentBuilder parser;
-
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-        parser = factory.newDocumentBuilder();
-    }
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception {
-        if (datatypeManager != null) {
-            this.release(datatypeManager);
-        }
-        super.tearDown();
-    }
-    
     /**
      * Test the generateSaxFragment method.
      * @throws MalformedURLException
@@ -78,9 +51,12 @@
         list.generateSaxFragment(dest, Locale.ENGLISH);
         ResourceSource expectedSource =
             new ResourceSource("resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml");
-        Document expected = parser.parse(expectedSource.getInputStream());
+        Document expected = this.parser.parse(expectedSource.getInputStream());
+        Document destDocument = dest.getDocument();
+        print(destDocument, new FileWriter("D:/enum.xml"));
+        print(expected, new FileWriter("D:/enum.exp.xml"));
         assertEqual("Test if output is what is expected",
-                expected, dest.getDocument());
+                expected, destDocument);
     }
     
     /**
@@ -95,47 +71,12 @@
         list.generateSaxFragment(dest, Locale.ENGLISH);
         ResourceSource expectedSource =
             new ResourceSource("resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml");
-        Document expected = parser.parse(expectedSource.getInputStream());
+        Document expected = this.parser.parse(expectedSource.getInputStream());
+        Document destDocument = dest.getDocument();
+        print(destDocument, new FileWriter("D:/enumNullable.xml"));
+        print(expected, new FileWriter("D:/enumNullable.exp.xml"));
         assertEqual("Test if output is what is expected",
-                expected, dest.getDocument());
+                expected, destDocument);
     }
     
-    /**
-     * Check is the source document is equal to the one produced by the method under test.
-     * @param message A message to print in case of failure.
-     * @param expected The expected (source) document.
-     * @param actual The actual (output) document.
-     */
-    private void assertEqual(String message, Document expected, Document actual) {
-        expected.getDocumentElement().normalize();
-        actual.getDocumentElement().normalize();
-        // DIRTY HACK WARNING: we add the "xmlns:*" attributes reported
-        // by DOM, as expected, but not generated by the method under test,
-        // otherwise the comparison would fail. 
-        actual.getDocumentElement().setAttribute(FormsConstants.INSTANCE_PREFIX,
-                FormsConstants.INSTANCE_NS);
-        actual.getDocumentElement().setAttribute("i18n",
-                I18nTransformer.I18N_NAMESPACE_URI);
-        Diff diff =  new Diff(expected, actual);
-        assertTrue(message + ", " + diff.toString(), diff.similar());
-    }
-
-    /**
-     * Print a document to a writer for debugging purposes.
-     * @param document The document to print.
-     * @param out The writer to write to.
-     */
-    public final void print(Document document, Writer out) {
-        TransformerFactory factory = TransformerFactory.newInstance();
-        try {
-            javax.xml.transform.Transformer serializer =
-                factory.newTransformer();
-            serializer.transform(
-                new DOMSource(document),
-                new StreamResult(out));
-            out.write('\n');
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java?view=diff&rev=488428&r1=488427&r2=488428
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java Mon Dec 18 13:36:29 2006
@@ -17,32 +17,28 @@
 
 package org.apache.cocoon.forms.datatype;
 
-import java.io.Writer;
+import java.io.FileWriter;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.DefaultContext;
+
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.components.flow.FlowHelper;
-import org.apache.cocoon.core.container.ContainerTestCase;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.mock.MockRequest;
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.xml.dom.DOMBuilder;
+
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.impl.ResourceSource;
-import org.custommonkey.xmlunit.Diff;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -50,32 +46,8 @@
  * Test case for CForms's FlowModelSelectionList datatype.
  * @version $Id$
  */
-public class FlowJXPathSelectionListTestCase extends ContainerTestCase {
-
-    protected DatatypeManager datatypeManager;
-    protected DocumentBuilder parser;
+public class FlowJXPathSelectionListTestCase extends AbstractSelectionListTestCase {
 
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
-        datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-        parser = factory.newDocumentBuilder();
-    }
-    
-    /* (non-Javadoc)
-     * @see junit.framework.TestCase#tearDown()
-     */
-    protected void tearDown() throws Exception {
-        if (datatypeManager != null) {
-            this.release(datatypeManager);
-        }
-        super.tearDown();
-    }
-    
     /**
      * Test the generateSaxFragment method.
      */
@@ -93,17 +65,20 @@
         contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
         Context context = new DefaultContext(contextObjectModel);
         Source sampleSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml");
-        Document sample = parser.parse(sampleSource.getInputStream());
+        Document sample = this.parser.parse(sampleSource.getInputStream());
         Element datatypeElement = (Element) sample.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "datatype").item(0);
-        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
+        Datatype datatype = this.datatypeManager.createDatatype(datatypeElement, false);
         FlowJXPathSelectionList list = new FlowJXPathSelectionList
             (context, "beans", "key", "value", datatype,null,false,null,false);
         DOMBuilder dest = new DOMBuilder();
         list.generateSaxFragment(dest, Locale.ENGLISH);
         Source expectedSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml");
-        Document expected = parser.parse(expectedSource.getInputStream());
+        Document expected = this.parser.parse(expectedSource.getInputStream());
+        Document destDocument = dest.getDocument();
+        print(destDocument, new FileWriter("D:/jx.xml"));
+        print(expected, new FileWriter("D:/jx.exp.xml"));
         assertEqual("Test if generated list matches expected",
-            expected, dest.getDocument());
+            expected, destDocument);
     }
     
     /**
@@ -124,54 +99,20 @@
         contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
         Context context = new DefaultContext(contextObjectModel);
         Source sampleSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml");
-        Document sample = parser.parse(sampleSource.getInputStream());
+        Document sample = this.parser.parse(sampleSource.getInputStream());
         Element datatypeElement = (Element) sample.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "datatype").item(0);
-        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
+        Datatype datatype = this.datatypeManager.createDatatype(datatypeElement, false);
         FlowJXPathSelectionList list = new FlowJXPathSelectionList
             (context, "beans", "key", "value", datatype,null,false,null,false);
         DOMBuilder dest = new DOMBuilder();
         list.generateSaxFragment(dest, Locale.ENGLISH);
         Source expectedSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml");
-        Document expected = parser.parse(expectedSource.getInputStream());
+        Document expected = this.parser.parse(expectedSource.getInputStream());
+        Document destDocument = dest.getDocument();
+        print(destDocument, new FileWriter("D:/jxNull.xml"));
+        print(expected, new FileWriter("D:/jxNull.exp.xml"));
         assertEqual("Test if generated list matches expected",
-                expected, dest.getDocument());
-    }
-    
-    /**
-     * Check is the source document is equal to the one produced by the method under test.
-     * @param message A message to print in case of failure.
-     * @param expected The expected (source) document.
-     * @param actual The actual (output) document.
-     */
-    private void assertEqual(String message, Document expected, Document actual) {
-        expected.getDocumentElement().normalize();
-        actual.getDocumentElement().normalize();
-        // DIRTY HACK WARNING: we add the "xmlns:wi" attribute reported
-        // by DOM, as expected, but not generated by the method under test,
-        // otherwise the comparison would fail. 
-        actual.getDocumentElement().setAttribute(FormsConstants.INSTANCE_PREFIX,
-                FormsConstants.INSTANCE_NS);
-        Diff diff =  new Diff(expected, actual);
-        assertTrue(message + ", " + diff.toString(), diff.similar());
-    }
-
-    /**
-     * Print a document to a writer for debugging purposes.
-     * @param document The document to print.
-     * @param out The writer to write to.
-     */
-    public final void print(Document document, Writer out) {
-        TransformerFactory factory = TransformerFactory.newInstance();
-        try {
-            javax.xml.transform.Transformer serializer =
-                factory.newTransformer();
-            serializer.transform(
-                new DOMSource(document),
-                new StreamResult(out));
-            out.write('\n');
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+                expected, destDocument);
     }
     
     public static class TestBean {
@@ -184,15 +125,15 @@
         }
         
         public String getKey() {
-            return key;
+            return this.key;
         }
         
         public String getValue() {
-            return value;
+            return this.value;
         }
         
         public String toString() {
-            return "{ " + key + " : " + value + " }";
+            return "{ " + this.key + " : " + this.value + " }";
         }
     }
 }