aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/test/java')
-rw-r--r--moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ProfileParseTest.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ProfileParseTest.java b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ProfileParseTest.java
new file mode 100644
index 0000000..887772d
--- /dev/null
+++ b/moaSig/moa-sig-lib/src/test/java/test/at/gv/egovernment/moa/spss/server/config/ProfileParseTest.java
@@ -0,0 +1,68 @@
+package test.at.gv.egovernment.moa.spss.server.config;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+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 at.gv.egovernment.moaspss.util.Constants;
+import at.gv.egovernment.moaspss.util.DOMUtils;
+import at.gv.egovernment.moa.spss.MOAApplicationException;
+import at.gv.egovernment.moa.spss.api.xmlbind.ProfileParser;
+import at.gv.egovernment.moa.spss.api.xmlverify.VerifyTransformsInfoProfile;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class ProfileParseTest {
+
+ @Test
+ public void xsdTransformationValid() throws SAXException, IOException, ParserConfigurationException, MOAApplicationException {
+ Element transformation = DOMUtils.parseDocument(
+ ProfileParseTest.class.getResourceAsStream("/data/SL20_authblock_v1.0.xml"),
+ true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement();
+ assertNotNull("missing transformation", transformation);
+
+ ProfileParser profileParser = new ProfileParser();
+ VerifyTransformsInfoProfile profile = profileParser.parseVerifyTransformsInfoProfile(transformation);
+ assertNotNull(profile);
+
+ }
+
+ @Test
+ public void xsdTransformationInvalidAlgorithm() throws SAXException, IOException, ParserConfigurationException {
+ Element transformation = DOMUtils.parseDocument(
+ ProfileParseTest.class.getResourceAsStream("/data/SL20_authblock_v1.1_invalid_transformation.xml"),
+ true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement();
+ assertNotNull("missing transformation", transformation);
+
+
+ ProfileParser profileParser = new ProfileParser();
+ MOAApplicationException error = assertThrows(MOAApplicationException.class, () -> profileParser.parseVerifyTransformsInfoProfile(transformation));
+ assertEquals("1108", error.getMessageId());
+
+ }
+
+ @Test
+ public void xsdTransformationInvalidSchema() throws SAXException, IOException, ParserConfigurationException {
+ Element transformation = DOMUtils.parseDocument(
+ ProfileParseTest.class.getResourceAsStream("/data/SL20_authblock_v1.0_invalid_schema.xml"),
+ false, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement();
+ assertNotNull("missing transformation", transformation);
+
+
+ ProfileParser profileParser = new ProfileParser();
+ MOAApplicationException error = assertThrows(MOAApplicationException.class, () -> profileParser.parseVerifyTransformsInfoProfile(transformation));
+ assertEquals("1108", error.getMessageId());
+
+ }
+
+}