org.newsml.toolkit.conformance
Class NewsMLTestManager

java.lang.Object
  |
  +--org.newsml.toolkit.conformance.NewsMLTestManager

public class NewsMLTestManager
extends Object

Top-level manager for NewsML conformance tests.

This manager handles registration, running, and error reporting for NewsML conformance tests. It can be used with a predefined set of core tests, optionally augmented by user-supplied tests for specific business rules, or exclusively with user-supplied tests. The tests managed by this class are intended to augment the DTD conformance that can be (optionally) performed when the NewsML is loaded from XML.

The user can customize error handling by providing an ErrorVisitor through the setErrorVisitor(org.newsml.toolkit.conformance.ErrorVisitor) method.

Version:
2.0
Author:
Reuters PLC

Constructor Summary
NewsMLTestManager()
          Constructor.
 
Method Summary
 void addDefaultTests()
          Add a set of default conformance tests.
 void addTest(String xpath, TestBase test)
          Register a new test for the manager.
 void runTests(BaseNode contextNode, boolean useExternal)
          Run all registered tests against a context node.
 void setErrorVisitor(ErrorVisitor errorVisitor)
          Set the error vistor.
 void setVerbose(boolean verbose)
          Enable or disable the display of messages during processing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewsMLTestManager

public NewsMLTestManager()
Constructor.

Build a new manager with no tests registered.

Method Detail

setVerbose

public void setVerbose(boolean verbose)
Enable or disable the display of messages during processing.
Parameters:
verbose - true if the manager should display progress messages to stdout, false (the default) otherwise.

setErrorVisitor

public void setErrorVisitor(ErrorVisitor errorVisitor)
Set the error vistor.

The error visitor allows the application to customize error handling during a conformance.

Parameters:
errorVisitor - The new error handler.

addTest

public void addTest(String xpath,
                    TestBase test)
Register a new test for the manager.

The caller supplies both a test and an XPath -- the XPath expression will be used to find notes against which the test should be run.

Parameters:
xpath - The XPath for nodes to which the test will be applied.
test - The test itself.

addDefaultTests

public void addDefaultTests()
Add a set of default conformance tests.

The default tests check general problems that can occur but are not caught by DTD conformance.


runTests

public void runTests(BaseNode contextNode,
                     boolean useExternal)
              throws NewsMLException
Run all registered tests against a context node.
Parameters:
contextNode - The context node for matching tests (usually the root NewsML node).
useExternal - true if the tests may attempt to retrieve external resources, false otherwise.