com.ail.coretest
Class TestXMLString

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.ail.coretest.TestXMLString
All Implemented Interfaces:
junit.framework.Test

public class TestXMLString
extends junit.framework.TestCase

Tests for the XMLString class. These tests use the following example xml/xsl strings:

xml1 <doc>
  <person forename='fred' surname='clucknasty'/>
  <person forename='wilma' surname='clucknasty'/>
</doc>
xml2 <doc>Hello</doc>
xsl1 <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="doc">
    <out><xsl:value-of select="."/></out>
  </xsl:template>
</xsl:stylesheet>

Version:
$Revision: 1.6 $

Field Summary
static java.lang.String eol
           
static XMLString loadedXML
           
 
Constructor Summary
TestXMLString(java.lang.String name)
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testMultiNodeXPathMatch()
          Test an xpath eval that matches multiple nodes.
 void testOddSectionError()
          Test an xpath query that causes problems in a server side environment.
 void testSafeXmlToString()
          Test that the stringToSafeXML correctly converts string chars that would upset XML into entity chars that won't
 void testStringToSafeXml()
          Test that the stringToSafeXML correctly converts string chars that would upset XML into entity chars that won't
 void testXpathEval()
          Test that XMLString's eval method correctly handles an xpath.
 void testXpathEvalInline()
          Test that XMLString's inline eval method correctly handles an xpath.
 void testXsiTypeDetectionWithSpace()
          Test that an XMLString correctly returns the xsi:type of the XML even if there are spaces before the root tag.
 void testXSLT()
          Test that XMLString's transform method works.
 void testXSLTInline()
          Test that XMLString's inline transform method works.
 
Methods inherited from class junit.framework.TestCase
countTestCases, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loadedXML

public static XMLString loadedXML

eol

public static java.lang.String eol
Constructor Detail

TestXMLString

public TestXMLString(java.lang.String name)
Method Detail

suite

public static junit.framework.Test suite()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

testXpathEval

public void testXpathEval()
                   throws java.lang.Exception
Test that XMLString's eval method correctly handles an xpath.
  1. Apply the xpath expression "doc/person[1]/@forename" to xml1
  2. Fail if any exceptions are thrown
  3. Fail if the result returned is not "fred"

Throws:
java.lang.Exception

testXpathEvalInline

public void testXpathEvalInline()
                         throws java.lang.Exception
Test that XMLString's inline eval method correctly handles an xpath.
  1. Apply the xpath expression "doc/person[1]/@forename" to a copy of xml1
  2. Fail if any exceptions are thrown
  3. Fail if the copy does not equal "fred"

Throws:
java.lang.Exception

testXSLT

public void testXSLT()
              throws java.lang.Exception
Test that XMLString's transform method works.
  1. Apply xsl1 to a copy of xml2
  2. Fail if any exceptions are thrown
  3. Fail if the return string does not equal "<out>Hello</out>" (with an XML header)

Throws:
java.lang.Exception

testXSLTInline

public void testXSLTInline()
                    throws java.lang.Exception
Test that XMLString's inline transform method works.
  1. Apply xsl1 to a copy of xml2
  2. Fail if any exceptions are thrown
  3. Fail if the copy does not equal "<out>Hello</out>" (with an XML header)

Throws:
java.lang.Exception

testMultiNodeXPathMatch

public void testMultiNodeXPathMatch()
                             throws java.lang.Exception
Test an xpath eval that matches multiple nodes.

Throws:
java.lang.Exception

testOddSectionError

public void testOddSectionError()
                         throws java.lang.Exception
Test an xpath query that causes problems in a server side environment. Note: this test depends on an external xml file - it will not run unless the name of the file is passed as an argument to main() in this class.

Throws:
java.lang.Exception

testStringToSafeXml

public void testStringToSafeXml()
Test that the stringToSafeXML correctly converts string chars that would upset XML into entity chars that won't


testSafeXmlToString

public void testSafeXmlToString()
Test that the stringToSafeXML correctly converts string chars that would upset XML into entity chars that won't


testXsiTypeDetectionWithSpace

public void testXsiTypeDetectionWithSpace()
Test that an XMLString correctly returns the xsi:type of the XML even if there are spaces before the root tag.