diff options
Diffstat (limited to 'moaSig/common/src/test/java')
| -rw-r--r-- | moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java b/moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java new file mode 100644 index 0000000..8b745a4 --- /dev/null +++ b/moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java @@ -0,0 +1,58 @@ +package test.at.gv.egovernment.moa.util; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; + +import java.io.IOException; + +import javax.xml.parsers.ParserConfigurationException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import at.gv.egovernment.moaspss.util.Constants; +import at.gv.egovernment.moaspss.util.DOMUtils; + +@RunWith(BlockJUnit4ClassRunner.class) +public class DomUtilsTest { + + @Test + public void xsdTransformationValid() throws SAXException, IOException, ParserConfigurationException { + Element transformation = DOMUtils.parseDocument( + DomUtilsTest.class.getResourceAsStream("/data/SL20_authblock_v1.0.xml"), + true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); + assertNotNull(transformation); + + } + + @Test + public void xsdTransformationInvalidAlgorithm() throws SAXException, IOException, ParserConfigurationException { + Element transformation = DOMUtils.parseDocument( + DomUtilsTest.class.getResourceAsStream("/data/SL20_authblock_v1.1_invalid_transformation.xml"), + true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); + assertNotNull(transformation); + + } + + @Test + public void xsdTransformationIgnoreInvalidSchema() throws SAXException, IOException, ParserConfigurationException { + Element transformation = DOMUtils.parseDocument( + DomUtilsTest.class.getResourceAsStream("/data/SL20_authblock_v1.0_invalid_schema.xml"), + false, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); + assertNotNull(transformation); + + } + + @Test + public void xsdTransformationInvalidSchema() throws SAXException, IOException, ParserConfigurationException { + assertThrows(SAXParseException.class, () -> DOMUtils.parseDocument( + DomUtilsTest.class.getResourceAsStream("/data/SL20_authblock_v1.0_invalid_schema.xml"), + true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement()); + + } +} |
