diff options
| author | Thomas <> | 2023-08-22 12:17:21 +0200 |
|---|---|---|
| committer | Thomas <> | 2023-08-22 12:17:21 +0200 |
| commit | 57098c2d96a0aa39bb9c919bbb73b6857e74dc7f (patch) | |
| tree | aaa362a13cac686797c47f8386abb89d89739b69 /moaSig/moa-sig-lib/src/test/java | |
| parent | 5e1cd49419e6b1653569ade365ed97a718a7c018 (diff) | |
| download | moa-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/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.java | 68 |
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()); + + } + +} |
