aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-28 13:13:35 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-28 13:13:35 +0200
commit45c717760a6efc74f4f15dbc3f55bafc5e9a02d9 (patch)
tree26a1dd9cb326c6e78a34028827e36aea6e86a8ef /src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
parent9bb0e41fc0226d159aa7f6f3c0eadc86b37df2c7 (diff)
downloadmoa-zs-45c717760a6efc74f4f15dbc3f55bafc5e9a02d9.tar.gz
moa-zs-45c717760a6efc74f4f15dbc3f55bafc5e9a02d9.tar.bz2
moa-zs-45c717760a6efc74f4f15dbc3f55bafc5e9a02d9.zip
Remove EgovUtils Dependency
- EgovUtils were needed because of DomUtils. Replace it with eaaf components' DomUtils. - Add test case to ensure SoapUtils still works as intended. - Remove unused import statement
Diffstat (limited to 'src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java')
-rw-r--r--src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
new file mode 100644
index 0000000..31aa197
--- /dev/null
+++ b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java
@@ -0,0 +1,63 @@
+package at.gv.egiz.moazs;
+
+import at.gv.egiz.moazs.scheme.SOAPUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class SOAPUtilsTest {
+
+ SOAPUtils utils;
+
+ private static final String SOAP_MESSAGE =
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>" +
+ "<DeliveryResponse xmlns=\"http://reference.e-government.gv.at/namespace/zustellung/msg/phas" +
+ "e2/20181206#\" xmlns:ns2=\"http://reference.e-government.gv.at/namespace/persondata/phase2/" +
+ "20181206#\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\"><PartialSuccess><DeliverySyste" +
+ "m>https://testzustellsystem.egiz.gv.at</DeliverySystem><ZSDeliveryID>zs-valid-delivery-requ" +
+ "est-id</ZSDeliveryID><AppDeliveryID>valid-delivery-request-id</AppDeliveryID><GZ>12345</GZ>" +
+ "</PartialSuccess></DeliveryResponse></soap:Body></soap:Envelope>";
+
+ @Before
+ public void setup() {
+ utils = new SOAPUtils();
+ }
+
+ @Test
+ public void toDom() throws ParserConfigurationException, SAXException, IOException {
+ byte[] bytes = SOAP_MESSAGE.getBytes(StandardCharsets.UTF_8);
+
+ Element root = utils.toDOM(bytes);
+
+ assertThat(root.getTagName()).isEqualTo("soap:Envelope");
+ }
+
+ @Test
+ public void unwrapSoapEnvelope() throws ParserConfigurationException, SAXException, IOException {
+ byte[] bytes = SOAP_MESSAGE.getBytes(StandardCharsets.UTF_8);
+ Element soapRoot = utils.toDOM(bytes);
+
+ byte[] unwrappedMessage = utils.unwrapSoapEnvelope(soapRoot);
+
+ Element deliveryResponseRoot = utils.toDOM(unwrappedMessage);
+ assertThat(deliveryResponseRoot.getTagName()).isEqualTo("DeliveryResponse");
+ }
+
+ @Test
+ public void getAppDeliveryID() throws ParserConfigurationException, SAXException, IOException {
+ byte[] bytes = SOAP_MESSAGE.getBytes(StandardCharsets.UTF_8);
+ Element soapRoot = utils.toDOM(bytes);
+
+ String appDeliveryID = utils.getAppDeliveryIDFrom(soapRoot);
+
+ assertThat(appDeliveryID).isEqualTo("valid-delivery-request-id");
+ }
+
+}