aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/gv/egiz
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-20 08:18:53 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-20 08:18:53 +0200
commit96f82d09c22853ce3b37db0983ce6ccc34c2587f (patch)
treebc256e9314cc28f3730467b56d310a048a1adce8 /src/test/java/at/gv/egiz
parentaff7c021e37e64162ce4e3fe5abd419072fb464f (diff)
downloadmoa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.tar.gz
moa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.tar.bz2
moa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.zip
Add Testcase for MsgClient
Diffstat (limited to 'src/test/java/at/gv/egiz')
-rw-r--r--src/test/java/at/gv/egiz/moazs/MsgClientTest.java74
-rw-r--r--src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java2
2 files changed, 76 insertions, 0 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
new file mode 100644
index 0000000..6dc94e0
--- /dev/null
+++ b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
@@ -0,0 +1,74 @@
+package at.gv.egiz.moazs;
+
+import at.gv.egiz.moazs.msg.MsgClient;
+import at.gv.egiz.moazs.scheme.Marshaller;
+import at.gv.zustellung.app2mzs.xsd.ConfigType;
+import at.gv.zustellung.msg.xsd.DeliveryRequestType;
+import at.gv.zustellung.msg.xsd.ObjectFactory;
+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;
+
+import javax.xml.bind.JAXBElement;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder;
+import static at.gv.zustellung.app2mzs.xsd.ServerType.serverTypeBuilder;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class MsgClientTest {
+
+ private final static Logger logger = LoggerFactory.getLogger(MsgClient.class);
+
+ private final String serviceUri = "http://localhost:8081/services/DeliveryRequest";
+ private final String basePath = "src/test/resources/at/gv/egiz/moazs/MsgClientTest/";
+
+ @Autowired
+ private Marshaller msgMarshaller;
+
+ private static final ObjectFactory OF = new ObjectFactory();
+
+
+ // this test requires that a zusemsg service runs under serviceUri!
+
+ @Test
+ public void sendValidMessage() throws IOException {
+
+ var request = loadFromFile("validDeliveryRequest.xml");
+ var config = generateConfig();
+ var client = new MsgClient();
+
+ var status = client.send(request, config);
+
+ logger.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ }
+
+ private DeliveryRequestType loadFromFile(String fileName) throws IOException {
+ try (var inputStream = new BufferedInputStream(new FileInputStream(basePath + fileName))) {
+ var request = (JAXBElement<DeliveryRequestType>) msgMarshaller.unmarshallXml(inputStream);
+ return request.getValue();
+ }
+ }
+
+ private ConfigType generateConfig() {
+
+ var server = serverTypeBuilder()
+ .withZUSEUrlID(serviceUri)
+ .build();
+
+ return configTypeBuilder()
+ .withServer(server)
+ .withPerformQueryPersonRequest(false)
+ .build();
+
+ }
+
+}
diff --git a/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java
index 2564121..de72148 100644
--- a/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java
+++ b/src/test/java/at/gv/egiz/moazs/Mzs2MsgConverterTest.java
@@ -52,6 +52,8 @@ public class Mzs2MsgConverterTest {
String msgRequestXML = msgMarshaller.marshallXml(jaxbMsgRequest);
+ logger.info(msgRequestXML);
+
assertThat(msgRequestXML).contains("<AppDeliveryID>valid-delivery-request-id</AppDeliveryID>");
}