forked from hapifhir/hapi-hl7v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#251: XML parser should respect HapiContext it has been obtained from…
… (including validation)
- Loading branch information
Showing
2 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
hapi-test/src/test/java/ca/uhn/hl7v2/parser/ValidatingParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ca.uhn.hl7v2.parser; | ||
|
||
import ca.uhn.hl7v2.DefaultHapiContext; | ||
import ca.uhn.hl7v2.HapiContext; | ||
import ca.uhn.hl7v2.model.Message; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Christian Ohr | ||
*/ | ||
public class ValidatingParserTest { | ||
|
||
@Test | ||
public void testValidation() throws Exception { | ||
String inValidMessage = "MSH|^~\\&|MedSeries|CAISI_1-2|PLS|3910|200903230934||ADT^A31^ADT_A05|75535037-1237815294895|P^T|2.4\r" | ||
+ "EVN|A31|THIS-IS-NOT-DATE-VALUE\r" | ||
+ "PID|1||29^^CAISI_1-2^PI~\"\"||Test300^Leticia^^^^^L||19770202|M||||||||||||||||||||||"; | ||
|
||
HapiContext context = new DefaultHapiContext(); | ||
context.getParserConfiguration().setValidating(false); // disable validation | ||
PipeParser parser = context.getPipeParser(); | ||
Message hapiMsg = parser.parse(inValidMessage); // successfull parsed | ||
XMLParser xmlParser = context.getXMLParser(); | ||
String xmlDoc = xmlParser.encode(hapiMsg,"XML"); | ||
xmlParser.parse(xmlDoc); // validation still disabled | ||
} | ||
} |