aboutsummaryrefslogtreecommitdiff
path: root/moaSig/common/src/test/java
diff options
context:
space:
mode:
authorThomas <>2023-08-22 12:17:21 +0200
committerThomas <>2023-08-22 12:17:21 +0200
commit57098c2d96a0aa39bb9c919bbb73b6857e74dc7f (patch)
treeaaa362a13cac686797c47f8386abb89d89739b69 /moaSig/common/src/test/java
parent5e1cd49419e6b1653569ade365ed97a718a7c018 (diff)
downloadmoa-sig-57098c2d96a0aa39bb9c919bbb73b6857e74dc7f.tar.gz
moa-sig-57098c2d96a0aa39bb9c919bbb73b6857e74dc7f.tar.bz2
moa-sig-57098c2d96a0aa39bb9c919bbb73b6857e74dc7f.zip
chore(core): log transformation in case of missing or unknown Algorithm
Diffstat (limited to 'moaSig/common/src/test/java')
-rw-r--r--moaSig/common/src/test/java/test/at/gv/egovernment/moa/util/DomUtilsTest.java58
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());
+
+ }
+}