aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-28 10:29:50 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-28 10:29:50 +0200
commitc43f9764b2132ce54a491c1daeeafe6aa4851ef5 (patch)
tree3f900f37b612fffd11a6069dd814f16474957053 /src/test/java/at
parent7eb6db5c837db22055b51988031920599a7e7270 (diff)
downloadmoa-zs-c43f9764b2132ce54a491c1daeeafe6aa4851ef5.tar.gz
moa-zs-c43f9764b2132ce54a491c1daeeafe6aa4851ef5.tar.bz2
moa-zs-c43f9764b2132ce54a491c1daeeafe6aa4851ef5.zip
Separate Test Suite into Unit- And Integration Tests
Per default, integration tests are excluded from build. They can be included with the `-P integration-test` argument. - Pom: Add maven profile for integration tests. - Rename integration tests (add `IT` prefix). - Move Resources into IT* folders. - Add MsgClientTest to test suite and add assertions to each test case.
Diffstat (limited to 'src/test/java/at')
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java (renamed from src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java)4
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java (renamed from src/test/java/at/gv/egiz/moazs/MsgClientTest.java)51
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java (renamed from src/test/java/at/gv/egiz/moazs/MzsServiceTest.java)6
3 files changed, 32 insertions, 29 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java b/src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java
index 7d3e9d1..2c6b978 100644
--- a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java
+++ b/src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java
@@ -18,9 +18,9 @@ import java.nio.file.Files;
//Note: Certificate that signed these delivery responses expires in 2023-09-27.
@RunWith(SpringRunner.class)
@SpringBootTest
- public class MoaSPSSSignatureVerifierTest {
+ public class ITMoaSPSSSignatureVerifierTest {
- private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/";
+ private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/";
@TestConfiguration
public class Config{
diff --git a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java
index 485d01c..10c2859 100644
--- a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
+++ b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java
@@ -7,11 +7,17 @@ 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;
import javax.xml.bind.JAXBElement;
+import javax.xml.ws.soap.SOAPFaultException;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
@@ -20,14 +26,15 @@ import java.math.BigInteger;
import static at.gv.zustellung.app2mzs.xsd.ClientType.clientTypeBuilder;
import static at.gv.zustellung.app2mzs.xsd.KeyStoreType.keyStoreTypeBuilder;
import static at.gv.zustellung.app2mzs.xsd.SSLType.SSLTypeBuilder;
+import static org.assertj.core.api.Assertions.assertThat;
-// @RunWith(SpringRunner.class)
-// @SpringBootTest
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ITMsgClientTest {
-public class MsgClientTest {
-
- private final static Logger log = LoggerFactory.getLogger(MsgClientTest.class);
- private final String basePath = "src/test/resources/at/gv/egiz/moazs/MsgClientTest/";
+ 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/";
@Autowired
private Marshaller msgMarshaller;
@@ -41,27 +48,24 @@ public class MsgClientTest {
private static final ObjectFactory OF = new ObjectFactory();
- // tmp disabled. todo: set up integration tests
-
// Requirements:
// - run zusemsg service under httpServiceURL
- // @Test
+ @Test
public void sendValidMessage() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
var httpServiceURL = "http://localhost:8081/services/DeliveryRequest";
var clientParams = clientTypeBuilder()
.withURL(httpServiceURL)
+ .withConnectionTimeout(BigInteger.ZERO)
+ .withReceiveTimeout(BigInteger.ZERO)
.build();
var client = factory.create(clientParams);
- try{
- var status = client.delivery(request);
- log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryResponse(status)));
- } catch (Exception ex) {
- System.out.println(ex.getMessage());
- }
+ var status = client.delivery(request);
+ assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID);
+
}
// Requirements:
@@ -69,7 +73,7 @@ public class MsgClientTest {
// - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem)
// - server uses the server certificate in ssl/server/server.localhost.*.pem
// - server sends certificate chain ssl/server/ca-chain.cert.pem
- //@Test
+ @Test
public void sendOverSSLWithClientAuthentication() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
@@ -79,7 +83,7 @@ public class MsgClientTest {
var client = factory.create(clientParams);
var status = client.delivery(request);
- log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID);
}
// Requirements:
@@ -87,7 +91,7 @@ public class MsgClientTest {
// - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem)
// - server uses the server certificate in ssl/server/server.localhost.*.pem
// - server sends certificate chain ssl/server/ca-chain.cert.pem
- //@Test
+ @Test
public void sendOverSSLWithClientAuthTrustAll() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
@@ -97,7 +101,7 @@ public class MsgClientTest {
var client = factory.create(clientParams);
var status = client.delivery(request);
- log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID);
}
// Requirements:
@@ -105,7 +109,7 @@ public class MsgClientTest {
// - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem)
// - server uses the server certificate in ssl/server/server.localhost.*.pem
// - server sends certificate chain ssl/server/ca-chain.cert.pem
- //@Test
+ @Test
public void sendOverSSLWithClientAuthLaxHostnameVerification() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
@@ -115,7 +119,7 @@ public class MsgClientTest {
var client = factory.create(clientParams);
var status = client.delivery(request);
- log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID);
}
//Requirements:
@@ -123,7 +127,7 @@ public class MsgClientTest {
// - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem)
// - server uses the server certificate in ssl/server/server.localhost.*.pem
// - server sends certificate chain ssl/server/ca-chain.cert.pem
- //@Test(expected=SOAPFaultException.class)
+ @Test(expected=SOAPFaultException.class)
public void rejectBecauseHostNameVerificationFails() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
@@ -132,8 +136,7 @@ public class MsgClientTest {
var clientParams = generateSSLClientParams(httpsServiceURL, false, false);
var client = factory.create(clientParams);
- var status = client.delivery(request);
- log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ client.delivery(request);
}
private ClientType generateSSLClientParams(String httpsServiceURL, boolean trustAll, boolean laxHostNameVerification) {
diff --git a/src/test/java/at/gv/egiz/moazs/MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java
index 579051d..4f24518 100644
--- a/src/test/java/at/gv/egiz/moazs/MzsServiceTest.java
+++ b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java
@@ -33,13 +33,13 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-public class MzsServiceTest {
+public class ITMzsServiceTest {
private final String serviceUri = "http://localhost:8080/services/DeliveryRequest";
- private final String basePath = "src/test/resources/at/gv/egiz/moazs/MzsServiceTest/";
+ private final String basePath = "src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/";
- private final static Logger logger = LoggerFactory.getLogger(MzsServiceTest.class);
+ private final static Logger logger = LoggerFactory.getLogger(ITMzsServiceTest.class);
@TestConfiguration
public static class TestConfig {