From 57098c2d96a0aa39bb9c919bbb73b6857e74dc7f Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 22 Aug 2023 12:17:21 +0200 Subject: chore(core): log transformation in case of missing or unknown Algorithm --- .../at/gv/egovernment/moa/util/DomUtilsTest.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java (limited to 'moaSig/common/src/test/java') 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()); + + } +} -- cgit v1.2.3