Skip to content

Commit

Permalink
Added test for #158
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Aug 16, 2023
1 parent 1e7bd81 commit 28acd6c
Showing 1 changed file with 59 additions and 0 deletions.
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"));
}
}

0 comments on commit 28acd6c

Please sign in to comment.