ca.uhn.hl7v2.util
Class ParseTester

java.lang.Object
  extended by ca.uhn.hl7v2.util.ParseTester

public class ParseTester
extends java.lang.Object

Tests correctness of message parsing by testing equivalence of re-encoded form with original.

Author:
Bryan Tripp

Nested Class Summary
static class ParseTester.CommentFilterReader
          Removes C and C++ style comments from a reader stream.
 
Constructor Summary
ParseTester()
          Creates a new instance of ParseTester
 
Method Summary
 java.lang.String getNextMessage()
          Retrieves the next message (setSource() must be called first).
static void main(java.lang.String[] args)
          Command line tool for testing messages in files.
static HL7Exception parsesCorrectly(java.lang.String context, java.lang.String message)
          Checks whether the given message parses correctly with a GenericParser.
 void setContext(java.lang.String description)
          Sets a description of the context of the messages (e.g.
 void setSource(java.io.Reader source)
          Sets the source of message data (messages must be delimited by blank lines)
 HL7Exception[] testAll()
          Tests all remaining messages available from the currrent source.
 HL7Exception[] testAll(java.io.File source)
          Sets the source reader to point to the given file, and tests all the messages therein (if a directory, processes all contained files recursively).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseTester

public ParseTester()
Creates a new instance of ParseTester

Method Detail

parsesCorrectly

public static HL7Exception parsesCorrectly(java.lang.String context,
                                           java.lang.String message)
Checks whether the given message parses correctly with a GenericParser. Failure indicates that the parsed and re-encoded message is semantically different than the original, or that the message could not be parsed. This may stem from an error in the parser, or from an error in the message. This may also arise from unexpected message components (e.g. Z-segments) although in future HAPI versions these will be parsed as well.

Parameters:
message - an XML or ER7 encoded message string
Returns:
null if it parses correctly, an HL7Exception otherwise

setSource

public void setSource(java.io.Reader source)
Sets the source of message data (messages must be delimited by blank lines)


setContext

public void setContext(java.lang.String description)
Sets a description of the context of the messages (e.g. file name) that can be reported within error messages.


testAll

public HL7Exception[] testAll(java.io.File source)
                       throws java.io.IOException
Sets the source reader to point to the given file, and tests all the messages therein (if a directory, processes all contained files recursively).

Throws:
java.io.IOException

testAll

public HL7Exception[] testAll()
                       throws java.io.IOException
Tests all remaining messages available from the currrent source.

Throws:
java.io.IOException

getNextMessage

public java.lang.String getNextMessage()
                                throws java.io.IOException
Retrieves the next message (setSource() must be called first). The next message is interpreted as everything up to the next blank line, not including C or C++ style comments (or blank lines themselves). An empty string indicates that there are no more messages.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
Command line tool for testing messages in files.



Copyright © 2001-2011 University Health Network. All Rights Reserved.