From 45c717760a6efc74f4f15dbc3f55bafc5e9a02d9 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Fri, 28 Jun 2019 13:13:35 +0200 Subject: 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 --- .../java/at/gv/egiz/moazs/ITMsgClientTest.java | 7 --- src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java | 63 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java (limited to 'src/test/java/at') diff --git a/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java index 10c2859..2b758a9 100644 --- a/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java @@ -7,11 +7,8 @@ import at.gv.zustellung.app2mzs.xsd.ClientType; import at.gv.zustellung.app2mzs.xsd.KeyStoreType; import at.gv.zustellung.msg.xsd.DeliveryRequestType; import at.gv.zustellung.msg.xsd.ObjectFactory; -import org.assertj.core.api.Assertions; import org.junit.Test; import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -32,7 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest public class ITMsgClientTest { - private final static Logger log = LoggerFactory.getLogger(ITMsgClientTest.class); private static final Object VALID_MZS_REQUEST_ID = "valid-delivery-request-id" ; private final String basePath = "src/test/resources/at/gv/egiz/moazs/ITMsgClientTest/"; @@ -42,9 +38,6 @@ public class ITMsgClientTest { @Autowired private MsgClientFactory factory; - @Autowired - private StoreSOAPBodyBinaryInRepositoryInterceptor interceptor; - private static final ObjectFactory OF = new ObjectFactory(); 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 = + "" + + "https://testzustellsystem.egiz.gv.atzs-valid-delivery-requ" + + "est-idvalid-delivery-request-id12345" + + ""; + + @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"); + } + +} -- cgit v1.2.3