From 9556dc6bd7e327dfbfc3c2d5228ad920ad7b9f8e Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Thu, 27 Jun 2019 14:41:51 +0200 Subject: Inject Configurable HTTP Policies to MsgClient - Refactor: Get rid of MsgClient, because MsgClientFactory can do all the work. - Add Connection Timeout and Request Timeout (Policies of HTTP Client) to mzs:DeliveryRequest/Config and application.yaml. - Update readme: Add JDK 12 Requirement --- src/test/java/at/gv/egiz/moazs/MsgClientTest.java | 10 ++++++---- .../at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java | 12 ++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/test') diff --git a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java index 294b2b8..7c9bf7d 100644 --- a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java +++ b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java @@ -1,6 +1,5 @@ package at.gv.egiz.moazs; -import at.gv.egiz.moazs.msg.MsgClient; import at.gv.egiz.moazs.msg.MsgClientFactory; import at.gv.egiz.moazs.msg.StoreSOAPBodyBinaryInRepositoryInterceptor; import at.gv.egiz.moazs.scheme.Marshaller; @@ -19,6 +18,7 @@ import javax.xml.bind.JAXBElement; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; +import java.math.BigInteger; import static at.gv.zustellung.app2mzs.xsd.KeyStoreType.keyStoreTypeBuilder; import static at.gv.zustellung.app2mzs.xsd.SSLType.SSLTypeBuilder; @@ -28,7 +28,7 @@ import static at.gv.zustellung.app2mzs.xsd.SSLType.SSLTypeBuilder; public class MsgClientTest { - private final static Logger log = LoggerFactory.getLogger(MsgClient.class); + private final static Logger log = LoggerFactory.getLogger(MsgClientTest.class); private final String basePath = "src/test/resources/at/gv/egiz/moazs/MsgClientTest/"; @Autowired @@ -54,7 +54,7 @@ public class MsgClientTest { var client = factory.create(clientParams); try{ - var status = client.send(request); + var status = client.delivery(request); log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryResponse(status))); } catch (Exception ex) { System.out.println(ex.getMessage()); @@ -69,7 +69,7 @@ public class MsgClientTest { var clientParams = generateSSLClientParams(sslServiceUri); var client = factory.create(clientParams); - var status = client.send(request); + var status = client.delivery(request); log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status))); } @@ -98,6 +98,8 @@ public class MsgClientTest { return ClientType.clientTypeBuilder() .withURL(sslServiceUri) .withSSL(sslParams) + .withReceiveTimeout(BigInteger.ZERO) + .withConnectionTimeout(BigInteger.ZERO) .build(); } diff --git a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java index df54ef7..e685816 100644 --- a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java +++ b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java @@ -1,8 +1,6 @@ package at.gv.egiz.moazs; -import at.gv.egiz.moazs.msg.MsgClient; import at.gv.egiz.moazs.msg.MsgClientFactory; -import at.gv.egiz.moazs.msg.StoreSOAPBodyBinaryInRepositoryInterceptor; import at.gv.egiz.moazs.pipeline.DeliveryPipeline; import at.gv.egiz.moazs.pipeline.SameThreadDeliveryPipeline; import at.gv.egiz.moazs.repository.DeliveryRepository; @@ -12,6 +10,7 @@ import at.gv.egiz.moazs.tnvz.TnvzClient; import at.gv.egiz.moazs.tnvz.TnvzResultVerifier; import at.gv.egiz.moazs.verify.MoaSPSSSignatureVerifier; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; +import at.gv.zustellung.msg.xsd.App2ZusePort; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.MetaData; import at.gv.zustellung.tnvz.xsd.MimeTypeList; @@ -55,14 +54,11 @@ public class SameThreadDeliveryPipelineTest { private MsgClientFactory msgClientFactory; @Mock - private MsgClient msgClient; + private App2ZusePort msgClient; @Mock private Mzs2MsgConverter converter; - @Mock - private StoreSOAPBodyBinaryInRepositoryInterceptor interceptor; - @Mock private MoaSPSSSignatureVerifier verifier; @@ -72,7 +68,7 @@ public class SameThreadDeliveryPipelineTest { @Before public void setup() { pipeline = new SameThreadDeliveryPipeline(repository, tnvzClient, new TnvzResultVerifier(), - converter,interceptor, msgClientFactory, verifier); + converter, msgClientFactory, verifier); } @Test @@ -174,7 +170,7 @@ public class SameThreadDeliveryPipelineTest { when(converter.convert(eq(mzsRequest) )).thenReturn(msgRequest); when(converter.convert(eq(mzsRequest), any())).thenReturn(msgRequest); when(msgClientFactory.create(any())).thenReturn(msgClient); - when(msgClient.send(msgRequest)).thenReturn(status); + when(msgClient.delivery(msgRequest)).thenReturn(status); return status; -- cgit v1.2.3