Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new ANT parameters
failOnValidation...
; #50
- Loading branch information
Showing
12 changed files
with
284 additions
and
11 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
102 changes: 102 additions & 0 deletions
102
ph-schematron-ant-task/src/test/java/com/helger/schematron/ant/Issue50Test.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,102 @@ | ||
/** | ||
* Copyright (C) 2017-2019 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.ant; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.BuildFileRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public final class Issue50Test | ||
{ | ||
@Rule | ||
public final BuildFileRule m_aBuildRule = new BuildFileRule (); | ||
|
||
@Test | ||
public void testSuccess () | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/50/build.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
m_aBuildRule.getProject ().executeTarget ("schematron"); | ||
} | ||
|
||
@Test | ||
public void testFailureError () | ||
{ | ||
try | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/50/build-fail-error.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
m_aBuildRule.getProject ().executeTarget ("schematron"); | ||
fail (); | ||
} | ||
catch (final BuildException ex) | ||
{ | ||
// Expected | ||
} | ||
} | ||
|
||
@Test | ||
public void testFailureFatal () | ||
{ | ||
try | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/50/build-fail-fatal.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
m_aBuildRule.getProject ().executeTarget ("schematron"); | ||
fail (); | ||
} | ||
catch (final BuildException ex) | ||
{ | ||
// Expected | ||
} | ||
} | ||
|
||
@Test | ||
public void testFailureInfo () | ||
{ | ||
try | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/50/build-fail-info.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
m_aBuildRule.getProject ().executeTarget ("schematron"); | ||
fail (); | ||
} | ||
catch (final BuildException ex) | ||
{ | ||
// Expected | ||
} | ||
} | ||
|
||
@Test | ||
public void testFailureWarn () | ||
{ | ||
try | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/50/build-fail-warn.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
m_aBuildRule.getProject ().executeTarget ("schematron"); | ||
fail (); | ||
} | ||
catch (final BuildException ex) | ||
{ | ||
// Expected | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
ph-schematron-ant-task/src/test/resources/issues/50/build-fail-error.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
|
||
<target name="schematron" description="Schematron rule tests"> | ||
<schematron schematronFile="rule-error.sch" expectSuccess="false" failOnError="false" failOnValidationError="true" failOnValidationWarn="false" failOnValidationInfo="false"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
</target> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
ph-schematron-ant-task/src/test/resources/issues/50/build-fail-fatal.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
|
||
<target name="schematron" description="Schematron rule tests"> | ||
<schematron schematronFile="rule-fatal.sch" expectSuccess="false" failOnError="false" failOnValidationError="true" failOnValidationWarn="false" failOnValidationInfo="false"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
</target> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
ph-schematron-ant-task/src/test/resources/issues/50/build-fail-info.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
|
||
<target name="schematron" description="Schematron rule tests"> | ||
<schematron schematronFile="rule-info.sch" expectSuccess="true" failOnError="false" failOnValidationError="false" failOnValidationWarn="false" failOnValidationInfo="true"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
</target> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
ph-schematron-ant-task/src/test/resources/issues/50/build-fail-warn.xml
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
|
||
<target name="schematron" description="Schematron rule tests"> | ||
<schematron schematronFile="rule-warn.sch" expectSuccess="true" failOnError="false" failOnValidationError="false" failOnValidationWarn="true" failOnValidationInfo="false"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
</target> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
ph-schematron-ant-task/src/test/resources/issues/50/build.xml
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,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
|
||
<target name="schematron" description="Schematron rule tests"> | ||
<schematron schematronFile="rule-error.sch" expectSuccess="false" failOnError="false" failOnValidationError="false" failOnValidationWarn="true" failOnValidationInfo="true"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
|
||
<schematron schematronFile="rule-fatal.sch" expectSuccess="false" failOnError="false" failOnValidationError="false" failOnValidationWarn="true" failOnValidationInfo="true"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
|
||
<schematron schematronFile="rule-info.sch" expectSuccess="true" failOnError="false" failOnValidationError="true" failOnValidationWarn="true" failOnValidationInfo="false"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
|
||
<schematron schematronFile="rule-warn.sch" expectSuccess="true" failOnError="false" failOnValidationError="true" failOnValidationWarn="false" failOnValidationInfo="true"> | ||
<fileset dir="."> | ||
<include name="dog*.xml" /> | ||
</fileset> | ||
</schematron> | ||
</target> | ||
</project> |
4 changes: 4 additions & 0 deletions
4
ph-schematron-ant-task/src/test/resources/issues/50/dog-without-bone.xml
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<dog xml:lang="de"> | ||
<fleas/> | ||
</dog> |
8 changes: 8 additions & 0 deletions
8
ph-schematron-ant-task/src/test/resources/issues/50/rule-error.sch
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,8 @@ | ||
<schema xmlns="http://purl.oclc.org/dsdl/schematron"> | ||
<title>Example of Multi-Lingual Schema</title> | ||
<pattern> | ||
<rule context="dog"> | ||
<assert test="bone" role="error">A dog should have a bone.</assert> | ||
</rule> | ||
</pattern> | ||
</schema> |
8 changes: 8 additions & 0 deletions
8
ph-schematron-ant-task/src/test/resources/issues/50/rule-fatal.sch
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,8 @@ | ||
<schema xmlns="http://purl.oclc.org/dsdl/schematron"> | ||
<title>Example of Multi-Lingual Schema</title> | ||
<pattern> | ||
<rule context="dog"> | ||
<assert test="bone" role="fatal">A dog should have a bone.</assert> | ||
</rule> | ||
</pattern> | ||
</schema> |
8 changes: 8 additions & 0 deletions
8
ph-schematron-ant-task/src/test/resources/issues/50/rule-info.sch
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,8 @@ | ||
<schema xmlns="http://purl.oclc.org/dsdl/schematron"> | ||
<title>Example of Multi-Lingual Schema</title> | ||
<pattern> | ||
<rule context="dog"> | ||
<assert test="bone" role="info">A dog should have a bone.</assert> | ||
</rule> | ||
</pattern> | ||
</schema> |
8 changes: 8 additions & 0 deletions
8
ph-schematron-ant-task/src/test/resources/issues/50/rule-warn.sch
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,8 @@ | ||
<schema xmlns="http://purl.oclc.org/dsdl/schematron"> | ||
<title>Example of Multi-Lingual Schema</title> | ||
<pattern> | ||
<rule context="dog"> | ||
<assert test="bone" role="warn">A dog should have a bone.</assert> | ||
</rule> | ||
</pattern> | ||
</schema> |