-
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
7 changed files
with
122 additions
and
37 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
38 changes: 38 additions & 0 deletions
38
ph-schematron-ant-task/src/test/java/com/helger/schematron/ant/Issue40v2Test.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,38 @@ | ||
package com.helger.schematron.ant; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.BuildFileRule; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class Issue40v2Test | ||
{ | ||
private static final Logger s_aLogger = LoggerFactory.getLogger (Issue40v2Test.class); | ||
|
||
@Rule | ||
public final BuildFileRule m_aBuildRule = new BuildFileRule (); | ||
|
||
@Before | ||
public void init () | ||
{ | ||
m_aBuildRule.configureProject ("src/test/resources/issues/40v2/build.xml"); | ||
m_aBuildRule.getProject ().addBuildListener (new LoggingBuildListener ()); | ||
} | ||
|
||
@Test | ||
public void testWithExternalDTD () | ||
{ | ||
try | ||
{ | ||
// Do not redirect stdout etc. | ||
m_aBuildRule.getProject ().executeTarget ("check"); | ||
} | ||
catch (final BuildException ex) | ||
{ | ||
s_aLogger.error ("Ooops", ex); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
ph-schematron-ant-task/src/test/java/com/helger/schematron/ant/LoggingBuildListener.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,44 @@ | ||
package com.helger.schematron.ant; | ||
|
||
import org.apache.tools.ant.BuildEvent; | ||
import org.apache.tools.ant.BuildListener; | ||
import org.apache.tools.ant.Project; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
final class LoggingBuildListener implements BuildListener | ||
{ | ||
private static final Logger s_aLogger = LoggerFactory.getLogger (LoggingBuildListener.class); | ||
|
||
public void taskStarted (final BuildEvent aEvent) | ||
{} | ||
|
||
public void taskFinished (final BuildEvent aEvent) | ||
{} | ||
|
||
public void targetStarted (final BuildEvent aEvent) | ||
{} | ||
|
||
public void targetFinished (final BuildEvent aEvent) | ||
{} | ||
|
||
public void messageLogged (final BuildEvent aEvent) | ||
{ | ||
if (aEvent.getPriority () <= Project.MSG_ERR) | ||
s_aLogger.error (aEvent.getMessage (), aEvent.getException ()); | ||
else | ||
if (aEvent.getPriority () <= Project.MSG_WARN) | ||
s_aLogger.warn (aEvent.getMessage (), aEvent.getException ()); | ||
else | ||
if (aEvent.getPriority () <= Project.MSG_INFO) | ||
s_aLogger.info (aEvent.getMessage (), aEvent.getException ()); | ||
else | ||
s_aLogger.info (aEvent.getMessage (), aEvent.getException ()); | ||
} | ||
|
||
public void buildStarted (final BuildEvent aEvent) | ||
{} | ||
|
||
public void buildFinished (final BuildEvent aEvent) | ||
{} | ||
} |
16 changes: 16 additions & 0 deletions
16
ph-schematron-ant-task/src/test/resources/issues/40v2/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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project basedir="xml"> | ||
<taskdef name="schematron" classname="com.helger.schematron.ant.Schematron" /> | ||
<target name="check"> | ||
<schematron schematronFile="../sch/test.sch" | ||
expectSuccess="true" | ||
schematronProcessingEngine="pure"> | ||
<fileset dir="."> | ||
<include name="test.xml" /> | ||
</fileset> | ||
<xmlcatalog> | ||
<dtd publicId="-//bla//DTD XML test//EN" location="../dtd/test.dtd"/> | ||
</xmlcatalog> | ||
</schematron> | ||
</target> | ||
</project> |
5 changes: 5 additions & 0 deletions
5
ph-schematron-ant-task/src/test/resources/issues/40v2/dtd/test.dtd
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,5 @@ | ||
<!ELEMENT note (to,from,heading,body)> | ||
<!ELEMENT to (#PCDATA)> | ||
<!ELEMENT from (#PCDATA)> | ||
<!ELEMENT heading (#PCDATA)> | ||
<!ELEMENT body (#PCDATA)> |
10 changes: 10 additions & 0 deletions
10
ph-schematron-ant-task/src/test/resources/issues/40v2/sch/test.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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" | ||
xmlns="http://purl.oclc.org/dsdl/schematron" | ||
queryBinding="xslt2"> | ||
<sch:pattern id="sampleValidation"> | ||
<sch:rule context="/"> | ||
<assert test="note">root element must be 'note'</assert> | ||
</sch:rule> | ||
</sch:pattern> | ||
</sch:schema> |
8 changes: 8 additions & 0 deletions
8
ph-schematron-ant-task/src/test/resources/issues/40v2/xml/test.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,8 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE note PUBLIC "-//bla//DTD XML test//EN" "http://example.org/note.dtd"> | ||
<note> | ||
<to>Tove</to> | ||
<from>Jani</from> | ||
<heading>Reminder</heading> | ||
<body>Don't forget me this weekend!</body> | ||
</note> |