-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
ph-schematron-xslt/src/test/java/com/helger/schematron/supplementary/Issue158Test.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,59 @@ | ||
/* | ||
* Copyright (C) 2014-2023 Philip Helger (www.helger.com) | ||
* philip[at]helger[dot]com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.helger.schematron.supplementary; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.io.File; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.junit.Test; | ||
|
||
import com.helger.commons.collection.impl.ICommonsList; | ||
import com.helger.commons.io.resource.FileSystemResource; | ||
import com.helger.schematron.sch.SchematronResourceSCH; | ||
import com.helger.schematron.svrl.AbstractSVRLMessage; | ||
import com.helger.schematron.svrl.SVRLHelper; | ||
import com.helger.schematron.svrl.jaxb.SchematronOutputType; | ||
|
||
public final class Issue158Test | ||
{ | ||
public static void validateAndProduceSVRL (@Nonnull final File aSchematron, final File aXML) throws Exception | ||
{ | ||
final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile (aSchematron); | ||
|
||
// Perform validation | ||
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (new FileSystemResource (aXML)); | ||
assertNotNull (aSVRL); | ||
|
||
final ICommonsList <AbstractSVRLMessage> aAssertions = SVRLHelper.getAllFailedAssertionsAndSuccessfulReports (aSVRL); | ||
assertEquals (2, aAssertions.size ()); | ||
|
||
final AbstractSVRLMessage aAssert0 = aAssertions.get (0); | ||
assertEquals (2, aAssert0.getDiagnosticReferences ().size ()); | ||
assertEquals ("d_role_en", aAssert0.getDiagnosticReferences ().get (0).getDiagnostic ()); | ||
} | ||
|
||
@Test | ||
public void testIssue () throws Exception | ||
{ | ||
validateAndProduceSVRL (new File ("src/test/resources/external/issues/github156/schematron.sch"), | ||
new File ("src/test/resources/external/issues/github156/test.xml")); | ||
} | ||
} |