diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-20 08:18:53 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-20 08:18:53 +0200 |
commit | 96f82d09c22853ce3b37db0983ce6ccc34c2587f (patch) | |
tree | bc256e9314cc28f3730467b56d310a048a1adce8 /src | |
parent | aff7c021e37e64162ce4e3fe5abd419072fb464f (diff) | |
download | moa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.tar.gz moa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.tar.bz2 moa-zs-96f82d09c22853ce3b37db0983ce6ccc34c2587f.zip |
Add Testcase for MsgClient
Diffstat (limited to 'src')
6 files changed, 133 insertions, 3 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java b/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java index 5742c83..47ee8c3 100644 --- a/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java +++ b/src/main/java/at/gv/egiz/moazs/msg/MsgClient.java @@ -11,7 +11,6 @@ import org.springframework.stereotype.Component; public class MsgClient { public DeliveryRequestStatusType send(DeliveryRequestType msgRequest, ConfigType config) { - var address = config.getServer().getZUSEUrlID(); var proxy = connect(address); return proxy.delivery(msgRequest); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 9e987bf..a59c460 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -14,7 +14,7 @@ spring: delivery-request-configuration-profiles: default: msg: - url: http://localhost:8090/ + url: http://localhost:8081/ x509: todo! perform-query-person-request: false 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>"); } diff --git a/src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml b/src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml new file mode 100644 index 0000000..f1879eb --- /dev/null +++ b/src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<DeliveryRequest Version="2.0.0" + xmlns="http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#" + xmlns:p="http://reference.e-government.gv.at/namespace/persondata/phase2/20181206#"> + <Sender> + <SenderCorporateBody> + <p:Identification> + <p:Value>kkvj693+tw99uW8UPuEK9en1LzZItkylPajkUUyJJDWQB78VGPkAuhCEk+TD12yQDD/WRglsf+JfQpjubIs/4l/ptluJ9teF3nwkNlu5Dm7mIjzgW1qxrDyomCmPvVxTWOCBuMUbOWRZBhOq+KvDQAu9Vv9KnqSfjYeDZrpHYu4=</p:Value> + <p:Type>urn:publicid:gv:at:cemtoken</p:Type> + </p:Identification> + <p:CorporateBody> + <p:FullName>Bundesministerium für Testzwecke</p:FullName> + </p:CorporateBody> + </SenderCorporateBody> + <ConfirmationAddress> + <WebserviceURL> + <p:Address>https://authority.gv.at/delivery_notification</p:Address> + </WebserviceURL> + </ConfirmationAddress> + </Sender> + <Receiver> + <p:PhysicalPerson> + <p:Name> + <p:GivenName>Maxi</p:GivenName> + <p:FamilyName>Mustermann1</p:FamilyName> + </p:Name> + <p:DateOfBirth>1984-01-24</p:DateOfBirth> + </p:PhysicalPerson> + <p:PostalAddress type="undefined"> + <p:CountryCode>AT</p:CountryCode> + <p:PostalCode>1010</p:PostalCode> + <p:Municipality>Wien</p:Municipality> + <p:DeliveryAddress> + <p:StreetName>Muststrasse</p:StreetName> + <p:BuildingNumber>10</p:BuildingNumber> + </p:DeliveryAddress> + </p:PostalAddress> + </Receiver> + <MetaData> + <AppDeliveryID>valid-delivery-request-id</AppDeliveryID> + <Subject>WichtigeMitteilung</Subject> + <DeliveryQuality>RSa</DeliveryQuality> + </MetaData> + <Attachments> + <Attachment> + <FileName>brief.xml</FileName> + <MimeType>text/xml</MimeType> + <Size>123401</Size> + <CheckSum> + <AlgorithmID>SHA1</AlgorithmID> + <Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</Value> + </CheckSum> + <URL>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</URL> + </Attachment> + </Attachments> +</DeliveryRequest>
\ No newline at end of file |