(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 28 Mar 2006 09:51:01 +0000 (09:51 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 28 Mar 2006 09:51:01 +0000 (09:51 +0000)
support/resources/test/org/wamblee/xml/output-reportToHtml-report.xml [new file with mode: 0644]
support/resources/test/org/wamblee/xml/reportToHtml-invalid.xsl [new file with mode: 0644]
support/resources/test/org/wamblee/xml/reportToHtml-nonwellformed.xsl [new file with mode: 0644]
support/resources/test/org/wamblee/xml/reportToHtml.xsl
support/resources/test/org/wamblee/xml/reportToHtml2.xsl [new file with mode: 0644]
support/resources/test/org/wamblee/xml/reportToText.xsl [new file with mode: 0644]
support/src/org/wamblee/xml/DomUtils.java
support/src/org/wamblee/xml/XslTransformer.java
support/test/org/wamblee/xml/XmlUtils.java
support/test/org/wamblee/xml/XslTransformerTest.java

diff --git a/support/resources/test/org/wamblee/xml/output-reportToHtml-report.xml b/support/resources/test/org/wamblee/xml/output-reportToHtml-report.xml
new file mode 100644 (file)
index 0000000..40f29fd
--- /dev/null
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<html>
+    <head>
+        <title>KiSS crawler report</title>
+    </head>
+    <body>
+        <h1>KiSS crawler report</h1>
+        <h2>Successfully recorded programs <p>
+                <table align="left" cellpadding="5">
+                    <tr align="left">
+                        <td>23:25 - 00:10: <strong>Wintertijd</strong> (Nederland
+                        1/Documentaire)</td>
+                    </tr>
+                    <tr>
+                        <td>
+                            <blockquote>
+                                <font size="-1">Some description MINSK - De presidentsverkiezingen
+                                    in Wit-Rusland zijn zondag met ruime cijfers gewonnen door
+                                    zittend president Aleksandr Loekasjenko. Dat bleek zondag uit
+                                    exitpolls uitgevoerd in opdracht van het totalitaire regime. Het
+                                    staatshoofd zou kunnen rekenen op ruim 82 procent van de
+                                    stemmen. Volgens de eerste gedeeltelijke uitslagen zou
+                                    Loekasjenko zelfs kunnen rekenen op bijna 89 procent. </font>
+                            </blockquote>
+                        </td>
+                    </tr>
+                </table>
+                <br clear="left"/>
+            </p></h2>
+        <h2>Possibly interesting programs</h2>
+        <p>
+            <table align="left" cellpadding="5">
+                <tr align="left">
+                    <td>23:30 - 00:15: <strong>Brainiac</strong> (Discovery Channel/science)</td>
+                </tr>
+                <tr>
+                    <td>
+                        <blockquote>
+                            <font size="-1">Humor</font>
+                        </blockquote>
+                    </td>
+                </tr>
+            </table>
+            <br clear="left"/>
+        </p>
+        <h3>Category: horror</h3>
+        <p>
+            <table align="left" cellpadding="5">
+                <tr align="left">
+                    <td>23:30 - 00:15: <strong>Andere tijden</strong> (Nederland 1/docu)</td>
+                </tr>
+                <tr>
+                    <td>
+                        <blockquote>
+                            <font size="-1">Documentaire</font>
+                        </blockquote>
+                    </td>
+                </tr>
+            </table>
+            <br clear="left"/>
+        </p>
+    </body>
+</html>
diff --git a/support/resources/test/org/wamblee/xml/reportToHtml-invalid.xsl b/support/resources/test/org/wamblee/xml/reportToHtml-invalid.xsl
new file mode 100644 (file)
index 0000000..104234e
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="xml"/>
+    <xsl:template match="report">
+        <html>
+            <head>
+                <title>KiSS crawler report</title>
+            </head>
+            <body>
+                <h1>KiSS crawler report</h1>
+                <xsl:apply-templates select="recorded"/>
+                <xsl:ifdd test="count(interesting) > 0">
+                    <h2>Possibly interesting programs</h2>
+                    <xsl:apply-templates select="interesting"/>
+                </xsl:ifdd>
+                <xsl:if test="count(//program) = 0">
+                    <xsl:text>No suitable programs found </xsl:text>
+                </xsl:if>
+            </body>
+        </html>
+
+    </xsl:template>
+
+    <xsl:template name="programTable">
+        <p>
+        <table align="left" cellpadding="5">
+            <!-- 
+            <tr align="left">
+                <th align="left">Time</th>
+                <th align="left">Channel</th>
+                <th align="left">Program</th>
+            </tr>
+            -->
+            <xsl:apply-templates select="program"/>
+        </table>
+        <br clear="left"/>
+        </p>
+    </xsl:template>
+
+    <xsl:template match="recorded">
+        <h2>
+            <xsl:choose>
+                <xsl:when test="@result = 'OK'">
+                    <xsl:text>Successfully recorded programs </xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'DUPLICATE'">
+                    <xsl:text>Already recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'CONFLICT'">
+                    <xsl:text>Conflicts with other recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result='ERROR'">
+                    <xsl:text>Programs that could not be recorded for
+                    technical reasons.</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+            </xsl:choose>
+        </h2>
+    </xsl:template>
+
+    <xsl:template name="addProgramInfo">
+        <tr align="left">
+            <td><xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>: <strong>
+                    <xsl:value-of select="name"/>
+                </strong> (<xsl:value-of select="channel"/>/<xsl:value-of select="keywords"/>)</td>
+
+        </tr>
+        <tr>
+            <td>
+                <blockquote>
+                        <font size="-1">
+                            <xsl:value-of select="description"/>
+                        </font>
+                </blockquote>
+            </td>
+
+
+        </tr>
+    </xsl:template>
+
+    <xsl:template match="program">
+        <xsl:call-template name="addProgramInfo"/>
+    </xsl:template>
+
+    <xsl:template match="interesting">
+        <xsl:call-template name="programTable"/>
+        <xsl:apply-templates select="category"/>
+    </xsl:template>
+
+    <xsl:template match="category">
+        <h3>Category: <xsl:value-of select="@name"/></h3>
+        <xsl:call-template name="programTable"/>
+    </xsl:template>
+</xsl:stylesheet>
+
diff --git a/support/resources/test/org/wamblee/xml/reportToHtml-nonwellformed.xsl b/support/resources/test/org/wamblee/xml/reportToHtml-nonwellformed.xsl
new file mode 100644 (file)
index 0000000..03d1908
--- /dev/null
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:output method="xml"/>
+    <xsl:template match="report">
+        <html>
+            <head>
+                <title>KiSS crawler report</title>
+            </head>
+            <body>
+                <h1>KiSS crawler report</h1>
+                <xsl:apply-templates select="recorded"/>
+                <xsl:ifx test="count(interesting) > 0">
+                    <h2>Possibly interesting programs</h2>
+                    <xsl:apply-templates select="interesting"/>
+                </xsl:if>
+                <xsl:if test="count(//program) = 0">
+                    <xsl:text>No suitable programs found </xsl:text>
+                </xsl:if>
+            </body>
+        </html>
+
+    </xsl:template>
+
+    <xsl:template name="programTable">
+        <p>
+        <table align="left" cellpadding="5">
+            <!-- 
+            <tr align="left">
+                <th align="left">Time</th>
+                <th align="left">Channel</th>
+                <th align="left">Program</th>
+            </tr>
+            -->
+            <xsl:apply-templates select="program"/>
+        </table>
+        <br clear="left"/>
+        </p>
+    </xsl:template>
+
+    <xsl:template match="recorded">
+        <h2>
+            <xsl:choose>
+                <xsl:when test="@result = 'OK'">
+                    <xsl:text>Successfully recorded programs </xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'DUPLICATE'">
+                    <xsl:text>Already recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'CONFLICT'">
+                    <xsl:text>Conflicts with other recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result='ERROR'">
+                    <xsl:text>Programs that could not be recorded for
+                    technical reasons.</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+            </xsl:choose>
+        </h2>
+    </xsl:template>
+
+    <xsl:template name="addProgramInfo">
+        <tr align="left">
+            <td><xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>: <strong>
+                    <xsl:value-of select="name"/>
+                </strong> (<xsl:value-of select="channel"/>/<xsl:value-of select="keywords"/>)</td>
+
+        </tr>
+        <tr>
+            <td>
+                <blockquote>
+                        <font size="-1">
+                            <xsl:value-of select="description"/>
+                        </font>
+                </blockquote>
+            </td>
+
+
+        </tr>
+    </xsl:template>
+
+    <xsl:template match="program">
+        <xsl:call-template name="addProgramInfo"/>
+    </xsl:template>
+
+    <xsl:template match="interesting">
+        <xsl:call-template name="programTable"/>
+        <xsl:apply-templates select="category"/>
+    </xsl:template>
+
+    <xsl:template match="category">
+        <h3>Category: <xsl:value-of select="@name"/></h3>
+        <xsl:call-template name="programTable"/>
+    </xsl:template>
+</xsl:stylesheet>
+
index 44765a3202b37d00ba8f01aa152da1b034b324fe..ce113d5a6aef6a3450cf0a7f9e7b883ace7525d0 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
+<xsl:output method="xml"/>
     <xsl:template match="report">
         <html>
             <head>
diff --git a/support/resources/test/org/wamblee/xml/reportToHtml2.xsl b/support/resources/test/org/wamblee/xml/reportToHtml2.xsl
new file mode 100644 (file)
index 0000000..2cec21f
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:include href="org/wamblee/xml/utilities.xsl"/>
+
+<xsl:output method="xml"/>
+    <xsl:template match="report">
+        <html>
+            <head>
+                <title>KiSS crawler report</title>
+            </head>
+            <body>
+                <h1>KiSS crawler report</h1>
+                <xsl:apply-templates select="recorded"/>
+                <xsl:if test="count(interesting) > 0">
+                    <h2>Possibly interesting programs</h2>
+                    <xsl:apply-templates select="interesting"/>
+                </xsl:if>
+                <xsl:if test="count(//program) = 0">
+                    <xsl:text>No suitable programs found </xsl:text>
+                </xsl:if>
+            </body>
+        </html>
+
+    </xsl:template>
+
+    <xsl:template name="programTable">
+        <p>
+        <table align="left" cellpadding="5">
+            <!-- 
+            <tr align="left">
+                <th align="left">Time</th>
+                <th align="left">Channel</th>
+                <th align="left">Program</th>
+            </tr>
+            -->
+            <xsl:apply-templates select="program"/>
+        </table>
+        <br clear="left"/>
+        </p>
+    </xsl:template>
+
+    <xsl:template match="recorded">
+        <h2>
+            <xsl:choose>
+                <xsl:when test="@result = 'OK'">
+                    <xsl:text>Successfully recorded programs </xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'DUPLICATE'">
+                    <xsl:text>Already recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result = 'CONFLICT'">
+                    <xsl:text>Conflicts with other recorded programs</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+                <xsl:when test="@result='ERROR'">
+                    <xsl:text>Programs that could not be recorded for
+                    technical reasons.</xsl:text>
+                    <xsl:call-template name="programTable"/>
+                </xsl:when>
+            </xsl:choose>
+        </h2>
+    </xsl:template>
+
+    <xsl:template name="addProgramInfo">
+        <tr align="left">
+            <td><xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>: <strong>
+                    <xsl:value-of select="name"/>
+                </strong> (<xsl:value-of select="channel"/>/<xsl:value-of select="keywords"/>)</td>
+
+        </tr>
+        <tr>
+            <td>
+                <blockquote>
+                        <font size="-1">
+                            <xsl:value-of select="description"/>
+                        </font>
+                </blockquote>
+            </td>
+
+
+        </tr>
+    </xsl:template>
+
+    <xsl:template match="program">
+        <xsl:call-template name="addProgramInfo"/>
+    </xsl:template>
+
+    <xsl:template match="interesting">
+        <xsl:call-template name="programTable"/>
+        <xsl:apply-templates select="category"/>
+    </xsl:template>
+
+    <xsl:template match="category">
+        <h3>Category: <xsl:value-of select="@name"/></h3>
+        <xsl:call-template name="programTable"/>
+    </xsl:template>
+</xsl:stylesheet>
+
diff --git a/support/resources/test/org/wamblee/xml/reportToText.xsl b/support/resources/test/org/wamblee/xml/reportToText.xsl
new file mode 100644 (file)
index 0000000..c1f7023
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="text"/>
+  
+  <xsl:template match="report">
+     <xsl:text>Hello world!</xsl:text> 
+  </xsl:template>
+  
+</xsl:stylesheet>
index 75ba7f6ddefeb1d4a20a35e9f30651d05608d5b7..3718debf782529b075591a141813cd6e83162d98 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.wamblee.xml;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -56,6 +57,15 @@ public final class DomUtils {
         // Empty. 
     }
     
+    /**
+     * Parses an XML document from a string. 
+     * @param aDocument document. 
+     * @return 
+     */
+    public static Document read(String aDocument) throws SAXException, ParserConfigurationException, IOException {
+        ByteArrayInputStream is = new ByteArrayInputStream(aDocument.getBytes());
+        return read(is);          
+    }
     
     /**
      * Parses an XML document from a stream. 
index 9cc70feda8c2e249d3fba2224fd3652605f7a75a..3fd65bfe955df9f3f2004b1542bb3e5e685ef087 100644 (file)
@@ -167,7 +167,7 @@ public class XslTransformer {
             Transformer transformer = _factory.newTransformer(aXslt);
             transformer.transform(aSource, aResult);
         } catch (TransformerConfigurationException e) {
-            throw new RuntimeException(
+            throw new TransformerException(
                     "Configuration problem of XSLT transformation", e);
         }
     }
index 5c6bf43c2b7b47738649458c392e3985b3129ba4..7d0fb123c1c50a4f79dd252a4de7efd53a102cc6 100644 (file)
@@ -67,7 +67,7 @@ public final class XmlUtils {
      */
     public static void assertEquals(String aMsg, Document aExpected,
             Document aActual) {
-        assertEquals(aMsg, aExpected.getRootElement(), aActual.getRootElement());
+        assertEquals(aMsg + "/" + aExpected.getRootElement().getName(), aExpected.getRootElement(), aActual.getRootElement());
     }
 
     /**
index cede6bb0ec8118f363039e0b2b7ce039dbd489f8..71c8e58216e3c334b8f919c257bad97b97ea5af8 100644 (file)
  * 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.wamblee.xml;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
 import junit.framework.TestCase;
 
+import org.springframework.core.io.ClassPathResource;
 import org.w3c.dom.Document;
 import org.wamblee.io.FileSystemUtils;
 import org.wamblee.io.InputResource;
@@ -37,78 +40,230 @@ import org.wamblee.io.TestResource;
  * Tests the XSL transformer.
  */
 public class XslTransformerTest extends TestCase {
-    
+
     private static final String REPORT_XML = "report.xml";
+
     private static final String REPORT_TO_HTML_XSLT = "reportToHtml.xsl";
 
+    private static final String REPORT_TO_HTML2_XSLT = "reportToHtml2.xsl";
+    
+    private static final String REPORT_TO_HTML_INVALID_XSLT = "reportToHtml-invalid.xsl";
+    
+    private static final String REPORT_TO_HTML_NONWELLFORMED_XSLT = "reportToHtml-nonwellformed.xsl";
+    
+    private static final String REPORT_TO_TEXT_XSLT = "reportToText.xsl";
+
+
     /**
-     * Transforms a file while using the default resolver, 
-     * where the included file can be found. 
-     * Verifies the transformation is done correctly.
-     *
+     * Transforms a file while using the default resolver, where the included
+     * file can be found. Verifies the transformation is done correctly.
+     * 
      */
     public void testTransformUsingDefaultResolver() throws Exception {
         XslTransformer transformer = new XslTransformer();
-        
-        InputResource xmlResource = new TestResource(XslTransformerTest.class, REPORT_XML);
-        Source xslt = new StreamSource(new File( FileSystemUtils.getTestInputDir(XslTransformerTest.class), REPORT_TO_HTML_XSLT));
-        
-        byte[] documentData = FileSystemUtils.read(xmlResource.getInputStream()).getBytes();
-        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(
+                new File(FileSystemUtils
+                        .getTestInputDir(XslTransformerTest.class),
+                        REPORT_TO_HTML_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
+                .newDocumentBuilder();
         Document document = builder.parse(xmlResource.getInputStream());
         Source documentSource = new StreamSource(xmlResource.getInputStream());
-        
-        Document output1 = transformer.transform(documentData, xslt); 
+
+        Document expected = DomUtils.read(new TestResource(
+                XslTransformerTest.class, "output-reportToHtml-report.xml")
+                .getInputStream());
+
+        Document output1 = transformer.transform(documentData, xslt);
+        XmlUtils.assertEquals("byte[] transform", expected, output1);
+
         Document output2 = transformer.transform(document, xslt);
-        XmlUtils.assertEquals("output", output1, output2);
-        ByteArrayOutputStream os = new ByteArrayOutputStream(); 
+        XmlUtils.assertEquals("document transform", expected, output2);
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
         Result output = new StreamResult(os);
         transformer.transform(documentSource, output, xslt);
-        transformer.textTransform(documentData, xslt);
+        XmlUtils.assertEquals("document source transform", expected, DomUtils
+                .read(os.toString()));
+
+        String result = transformer.textTransform(documentData, xslt);
+        XmlUtils
+                .assertEquals("text transform", expected, DomUtils.read(result));
     }
-    
+
     /**
-     * Transforms a file using the default resolver where the
-     * included file cannot be found. 
-     * Verifies that a TransformerException is thrown. 
-     *
+     * Transforms a file using the default resolver where the included file
+     * cannot be found. Verifies that a TransformerException is thrown.
+     * 
      */
-    public void testTransformUsingDefaultResolverFails() { 
-        fail(); 
+    public void testTransformUsingDefaultResolverFails() throws IOException {
+        XslTransformer transformer = new XslTransformer();
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(new File(FileSystemUtils
+                .getTestInputDir(XslTransformerTest.class),
+                REPORT_TO_HTML2_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        try {
+            Document output1 = transformer.transform(documentData, xslt);
+        } catch (TransformerException e) {
+            return; // ok
+        }
+        fail();
     }
-    
+
     /**
-     * Transforms a file using an invalid Xslt. 
-     * Verifies that a TransformerException is thrown. 
-     *
+     * Transforms a file using an invalid Xslt. Verifies that a
+     * TransformerException is thrown.
+     * 
      */
-    public void testTransformInvalidXslt() { 
-        fail(); 
+    public void testTransformInvalidXslt() throws IOException {
+        XslTransformer transformer = new XslTransformer();
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(new File(FileSystemUtils
+                .getTestInputDir(XslTransformerTest.class),
+                REPORT_TO_HTML_INVALID_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        try {
+            Document output1 = transformer.transform(documentData, xslt);
+        } catch (TransformerException e) {
+            return; // ok
+        }
+        fail();
     }
-    
+
     /**
-     * Transforms a file using a non-well formed xslt. 
-     * Verifies that a TransformerException is thrown. 
-     *
+     * Transforms a file using a non-well formed xslt. Verifies that a
+     * TransformerException is thrown.
+     * 
      */
-    public void testTransformNonWellformedXslt() { 
+    public void testTransformNonWellformedXslt() throws IOException {
+        XslTransformer transformer = new XslTransformer();
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(new File(FileSystemUtils
+                .getTestInputDir(XslTransformerTest.class),
+                REPORT_TO_HTML_NONWELLFORMED_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        try {
+            Document output1 = transformer.transform(documentData, xslt);
+        } catch (TransformerException e) {
+            return; // ok
+        }
         fail();
     }
+
+    /**
+     * Transforms a file using a class path resolver.
+     * 
+     */
+    public void testTransformUsingClassPathResolver() throws Exception {
+        XslTransformer transformer = new XslTransformer(new ClasspathUriResolver());
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(new File(FileSystemUtils
+                .getTestInputDir(XslTransformerTest.class),
+                REPORT_TO_HTML2_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        
+        Document output1 = transformer.transform(documentData, xslt);
+        Document expected = DomUtils.read(new TestResource(
+                XslTransformerTest.class, "output-reportToHtml-report.xml")
+                .getInputStream());
+        XmlUtils.assertEquals("doc", expected, output1);
+    }
+
+    /**
+     * Transforms a file to text output. Verifies the file is transformed
+     * correctly.
+     * 
+     */
+    public void testTransformToTextOutput() throws Exception {
+        XslTransformer transformer = new XslTransformer(new ClasspathUriResolver());
+
+        InputResource xmlResource = new TestResource(XslTransformerTest.class,
+                REPORT_XML);
+        Source xslt = new StreamSource(
+                new File(FileSystemUtils
+                        .getTestInputDir(XslTransformerTest.class),
+                        REPORT_TO_TEXT_XSLT));
+
+        byte[] documentData = FileSystemUtils
+                .read(xmlResource.getInputStream()).getBytes();
+        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
+                .newDocumentBuilder();
+
    
+        String result = transformer.textTransform(documentData, xslt);
+        String expected = "Hello world!";
+        assertEquals("text transform", expected, result);
+    }
+    
     /**
-     * Transforms a file using a class path resolver. 
+     * Tests resolving a file using {@link XslTransformer#resolve(String)}.
      *
      */
-    public void testTransformUsingClassPathResolver() { 
-        fail();    
+    public void testResolveWithDefaultResolver() throws Exception { 
+        XslTransformer transformer = new XslTransformer();
+        File utilities = new File(FileSystemUtils.getTestInputDir(XslTransformerTest.class), "utilities.xsl");
+        Source source = transformer.resolve(utilities.getAbsolutePath());
+        assert(source instanceof StreamSource);
+        StreamSource ssource = (StreamSource)source;
+        String data = FileSystemUtils.read(ssource.getInputStream());
+        String expected = FileSystemUtils.read(new ClassPathResource("org/wamblee/xml/utilities.xsl").getInputStream());
+        assertEquals(expected, data);
     }
-
     /**
-     * Transforms a file to text output. 
-     * Verifies the file is transformed correctly
+     * Tests resolving a file using {@link XslTransformer#resolve(String)} with the 
+     * default resolver where the file does not exist
      *
      */
-    public void testTransformToTextOutput() { 
+    public void testResolveWithDefaultResolverFileNotFound() { 
+        XslTransformer transformer = new XslTransformer();
+        try { 
+            Source source = transformer.resolve("org/wamblee/xml/utilities-nonexistent.xsl");
+        } catch (TransformerException e) { 
+            return; // ok
+        }
         fail();
     }
+    
+    
+    /**
+     * Tests resolving a file using {@link XslTransformer#resolve(String)} with the 
+     * default resolver. 
+     *
+     */
+    public void testResolveWithClasspathResolver() throws Exception { 
+        XslTransformer transformer = new XslTransformer(new ClasspathUriResolver());
+        Source source = transformer.resolve("org/wamblee/xml/utilities.xsl");
+        assert(source instanceof StreamSource);
+        StreamSource ssource = (StreamSource)source;
+        String data = FileSystemUtils.read(ssource.getInputStream());
+        String expected = FileSystemUtils.read(new ClassPathResource("org/wamblee/xml/utilities.xsl").getInputStream());
+        assertEquals(expected, data);
+    }
+    
 }
+
+    
\ No newline at end of file