aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-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>");
}