com.ssx.xml.output
Class TestsForXmlOutput

java.lang.Object
  extended byTestCase
      extended bycom.ssx.xml.output.TestsForXmlOutput
Direct Known Subclasses:
Test_TextSink

public abstract class TestsForXmlOutput
extends TestCase

Common tests for all XmlOutput derivatives.

See Also:
Serialized Form

Field Summary
protected static String END_OF_LINE_MARKER
          The line break sequence to use when formatting
protected static String EXPAND_QNAMES
          A testing switch - show namespace names rather than prefixes on output where applicable (ie.
protected static String INDENT_SPACER
          The characters used in a single indentation when formating
protected static String USE_FORMATTING
          Add line breaks and indenting to the XML output where applicable (ie.
protected static String USE_SINGLE_QUOTE
          Surround attribute values with single quotes
 
Constructor Summary
TestsForXmlOutput(String name)
           
 
Method Summary
protected abstract  String getXmlText(XmlOutput output)
          Convert the XmlOutput object to a string
protected abstract  XmlOutput newXmlOutput(HashMap properties)
          Create a new XmlOutput instance
 void testAddDuplicateAttribute_Name()
          Attempting to add a duplicate attribute will cause an exception
 void testAddDuplicateAttribute_Namespace()
          Attempting to add a duplicate attribute will cause an exception
 void testAddNamespaceNodes()
          Namespace nodes can be added to any entity
 void testAttributes_AddComment()
          Comments can be added to the XML anywhere
 void testAttributes_AddInvalidComment()
          Comments may not contain the stirng '-->' and they can not end with a dash (-).
 void testAttributes_addProcessingInstruction()
          Processing instructions can be added to the HTML
 void testAttributes_addText()
          Text can be added anywhere in the body of the root element
 void testAttributes_addTextWithEncoding()
          Any reserved values found in text are encoded (Note that ' and " do not need to be encoded here)
 void testAttributes_CallAfterClose()
          An method called after the output has been closed will throw and Exception.
 void testAttributes_DigitStartingName()
          Attribute names can only start with a leter or the allowed punctuation.
 void testAttributes_EncodeSpecialChars()
          Other illeagal characters will be replaced if they are found in an attribute value.
 void testAttributes_EscapeQuotes()
          If the same quote is used in an attribute value as is used to delimit attribute values it will need to be escaped using an entity reference.
 void testAttributes_Invalid()
          Attributes can only be added to entities directly after a call to startElement.
 void testAttributes()
          Attributes can be added to entities with the writeAttribute method.
 void testAttributesNullValue()
          If the attribute value is null the attribute will not be added to the entity.
 void testElements_DigitStartingName()
          element names can only start with a leter or the allowed punctuation.
 void testElements_Nested()
          Subsequent calls after startElement, excluding endElement, will fill the body of the initial element.
 void testElements_rootElements()
          An XML document requires exaclty one root element
 void testElements_Sequential()
          To write an empty element call endElement directly after calling startElement.
 void testElements_startEndMatching()
          The each start element call must be matched by exactly one endElement call.
 void testElements_Unballanced()
          Each startElement call must be matched by an endElement call or an error will be thrown when the stream is closed.
 void testFormatting()
          Line breaks and indenting can be added to the output stream to format is for human reading.
 void testFormatting2()
          Formatting will only be added between entities that have no intervening character data.
 void testFormatting3()
          Testing a larger collection of entities - just to see what happens.
 void testRedundantNamespaceDeclarationsAreIgnored()
           
 void testResolveNamespacePrefixes()
          The prefixes used with entities and attributes are resolved into namespaces and associated with the entities base on the XML Namspace spec.
 void testValidateNamespacePrefixes()
          Namespace prefixes used with attribute names are validated against the namespaces in scope.
 void testValidateNamespacePrefixes2()
          Namespace prefixes used with entity names are validated against the namespaces in scope.
 void testWritePIFirst()
          Test that a PI can be written as the first output
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_SINGLE_QUOTE

protected static final String USE_SINGLE_QUOTE
Surround attribute values with single quotes

See Also:
Constant Field Values

USE_FORMATTING

protected static final String USE_FORMATTING
Add line breaks and indenting to the XML output where applicable (ie. TextSink)

See Also:
Constant Field Values

END_OF_LINE_MARKER

protected static final String END_OF_LINE_MARKER
The line break sequence to use when formatting

See Also:
Constant Field Values

INDENT_SPACER

protected static final String INDENT_SPACER
The characters used in a single indentation when formating

See Also:
Constant Field Values

EXPAND_QNAMES

protected static final String EXPAND_QNAMES
A testing switch - show namespace names rather than prefixes on output where applicable (ie. TextSink)

See Also:
Constant Field Values
Constructor Detail

TestsForXmlOutput

public TestsForXmlOutput(String name)
Parameters:
name - The test suite name
Method Detail

newXmlOutput

protected abstract XmlOutput newXmlOutput(HashMap properties)
Create a new XmlOutput instance

Parameters:
properties - The Sink configuration properties
Returns:
An XmlOutput instance

getXmlText

protected abstract String getXmlText(XmlOutput output)
Convert the XmlOutput object to a string

Parameters:
output - An XmlOutput instance
Returns:
The Xml text that has been output since the given XmlOutput instance has been created.

testElements_rootElements

public void testElements_rootElements()
An XML document requires exaclty one root element


testElements_Nested

public void testElements_Nested()
Subsequent calls after startElement, excluding endElement, will fill the body of the initial element.


testElements_Sequential

public void testElements_Sequential()
To write an empty element call endElement directly after calling startElement.


testElements_startEndMatching

public void testElements_startEndMatching()
The each start element call must be matched by exactly one endElement call.


testElements_Unballanced

public void testElements_Unballanced()
Each startElement call must be matched by an endElement call or an error will be thrown when the stream is closed.


testElements_DigitStartingName

public void testElements_DigitStartingName()
element names can only start with a leter or the allowed punctuation. element names can not start with a digit.


testAttributes

public void testAttributes()
Attributes can be added to entities with the writeAttribute method.


testAttributes_Invalid

public void testAttributes_Invalid()
Attributes can only be added to entities directly after a call to startElement. Any other call that writes bytes to the stream will cause the start element tag to be closed so no more attributes can be added.


testAttributes_DigitStartingName

public void testAttributes_DigitStartingName()
Attribute names can only start with a leter or the allowed punctuation. Attribute names can not start with a digit.


testAttributes_EscapeQuotes

public void testAttributes_EscapeQuotes()
If the same quote is used in an attribute value as is used to delimit attribute values it will need to be escaped using an entity reference.


testAttributes_EncodeSpecialChars

public void testAttributes_EncodeSpecialChars()
Other illeagal characters will be replaced if they are found in an attribute value.


testAttributes_AddComment

public void testAttributes_AddComment()
Comments can be added to the XML anywhere


testAttributes_AddInvalidComment

public void testAttributes_AddInvalidComment()
Comments may not contain the stirng '-->' and they can not end with a dash (-).


testAttributes_addText

public void testAttributes_addText()
Text can be added anywhere in the body of the root element


testAttributes_addTextWithEncoding

public void testAttributes_addTextWithEncoding()
Any reserved values found in text are encoded (Note that ' and " do not need to be encoded here)


testAttributes_addProcessingInstruction

public void testAttributes_addProcessingInstruction()
Processing instructions can be added to the HTML


testAttributes_CallAfterClose

public void testAttributes_CallAfterClose()
An method called after the output has been closed will throw and Exception.


testFormatting

public void testFormatting()
Line breaks and indenting can be added to the output stream to format is for human reading.


testFormatting2

public void testFormatting2()
Formatting will only be added between entities that have no intervening character data.


testFormatting3

public void testFormatting3()
Testing a larger collection of entities - just to see what happens.


testAddNamespaceNodes

public void testAddNamespaceNodes()
Namespace nodes can be added to any entity


testResolveNamespacePrefixes

public void testResolveNamespacePrefixes()
The prefixes used with entities and attributes are resolved into namespaces and associated with the entities base on the XML Namspace spec. Note how entites with no specified namespace are associated with the default namespace while attributes with no specified namespace have no namespace.


testValidateNamespacePrefixes

public void testValidateNamespacePrefixes()
Namespace prefixes used with attribute names are validated against the namespaces in scope.


testValidateNamespacePrefixes2

public void testValidateNamespacePrefixes2()
Namespace prefixes used with entity names are validated against the namespaces in scope.


testAddDuplicateAttribute_Name

public void testAddDuplicateAttribute_Name()
Attempting to add a duplicate attribute will cause an exception


testAddDuplicateAttribute_Namespace

public void testAddDuplicateAttribute_Namespace()
Attempting to add a duplicate attribute will cause an exception


testAttributesNullValue

public void testAttributesNullValue()
If the attribute value is null the attribute will not be added to the entity. Use the empty string to add an empty attriute.


testWritePIFirst

public void testWritePIFirst()
Test that a PI can be written as the first output


testRedundantNamespaceDeclarationsAreIgnored

public void testRedundantNamespaceDeclarationsAreIgnored()