View Javadoc
1   /*
2    * Copyright 2010 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.hl7v3;
17  
18  import org.apache.cxf.helpers.IOUtils;
19  import org.junit.Test;
20  import org.openehealth.ipf.commons.core.modules.api.ValidationException;
21  import org.openehealth.ipf.commons.xml.CombinedXmlValidator;
22  
23  public class HL7v3ValidatorTest {
24  
25  	@Test
26  	public void testValidateOk() throws Exception {
27  		String message = IOUtils.readStringFromStream(
28                  getClass().getResourceAsStream("/xsd/prpa-valid.xml"));
29          CombinedXmlValidator validator = new CombinedXmlValidator();
30          validator.validate(message, PIXV3.Interactions.ITI_44_PIX.getRequestValidationProfile());
31  	}
32  	
33  	@Test(expected = ValidationException.class)
34  	public void testValidateError() throws Exception {
35  		String message = IOUtils.readStringFromStream(
36                  getClass().getResourceAsStream("/xsd/prpa-invalid.xml"));
37          CombinedXmlValidator validator = new CombinedXmlValidator();
38          validator.validate(message,PIXV3.Interactions.ITI_44_PIX.getRequestValidationProfile());
39  	}
40  
41  }