diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-22 13:02:19 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-22 13:02:19 +0200 |
commit | cb9a76eaafd37f921006822bcfe043655288bc63 (patch) | |
tree | 76c2463e181ac293134f4c5bfc7e342607f3f399 /src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java | |
parent | d873625c0ced62e712dc1b1a7570b63482fd0a0a (diff) | |
download | moa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.tar.gz moa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.tar.bz2 moa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.zip |
Test Flow of DeliveryRequest from "End-To-End" & Fix Bugs
Schema Changes:
- Remove mzs:DeliveryRequest/TnvzMetaData because all metadata fields
can be collected from DeliveryRequest and redundancy is not needed.
Fixes and Refactoring in preprocess:
- MzsDeliveryRequestValidator: Instead of returning false, throw an
exception when a condition is not met, and explain which condition
is not met / why it is not met in the exception's message.
- Integrate interface change in ConfigProfileGenerator and
DeliveryRequestAugmenter.
- Rewrite and simplify DeliveryRequestAugmenter's augmentation.
- ConfigUtil Fixes: Ensure that we do not override the wrong
parameters while merging. This error appeared in tnvz / msg client,
connection / receive timeout, key / trust store, and lax hostname
verification / trust all.
Fix Bugs in Interceptor / SoapUtils:
- Problem: DOM access and information extraction was implemented
somewhat sloppy.
- SolutioN: Change DOM access interface to access DOM more
efficiently. Add boundary checks and handle edge cases while
extracting information from SOAP Messages.
- Test those changes properly.
Testing:
- Implement Delivery Request Flow in ITEndToEndTest.
- Start application on random port instead of fixed port when running
integration tests.
- Add assertions to tests in ITMzsServiceTest suite.
Others Bug Fixes:
- ServicesConfig: Ensure that mzs service and msg service run on
different endpoint addresses (/msg and /mzs).
- DeliveryRequestBackend: Throw exception when binary message is
missing. Don't wrap the exception.
- SaveResponseToFileSink: Wrap Response in JAXB Element (otherwise,
marshaller does not recognize it)
Diffstat (limited to 'src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java')
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java index e9b4f70..3cf0362 100644 --- a/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java @@ -2,12 +2,14 @@ package at.gv.egiz.moazs; import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.RequestStatusResponse; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.test.context.junit4.SpringRunner; @@ -27,17 +29,24 @@ import java.util.function.Consumer; import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Success.successBuilder; import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder; import static java.net.http.HttpClient.Version; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ITMzsServiceTest { - private final String serviceUri = "http://localhost:8080/services/DeliveryRequest"; - private final String basePath = "src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/"; + @LocalServerPort + public int port; + private String serviceUri; + + @Before + public void setupServiceURI() { + this.serviceUri = "http://localhost:" + port + "/services/mzs"; + } + @TestConfiguration public static class TestConfig { @@ -64,50 +73,44 @@ public class ITMzsServiceTest { }; } - private XMLGregorianCalendar genTimeStamp() { - try { - return DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()); - } catch (DatatypeConfigurationException e) { - throw new RuntimeException("ups"); - } - } } @Test public void acceptValidDeliveryRequest() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("validDeliveryRequest.soap"); - assertEquals(200, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(200); + assertThat(response.body()).contains("valid-delivery-request-id"); } @Test public void rejectRequestWithoutSender() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("missingSender.soap"); - assertEquals(500, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(500); } @Test public void rejectBothProfileAndCorporateBody() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("profileAndCorporateBody.soap"); - assertEquals(500, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(500); } @Test public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("formallyIncorrectDeliveryRequest.soap"); - assertEquals(500, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(500); } @Test public void rejectRequestWithoutAppDeliveryID() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("missingAppDeliveryId.soap"); - assertEquals(500, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(500); } @Test public void rejectRequestWithoutMetaData() throws IOException, InterruptedException { var response = sendDeliveryRequestFile("missingMetaData.soap"); - assertEquals(500, response.statusCode()); + assertThat(response.statusCode()).isEqualTo(500); } private HttpResponse<String> sendDeliveryRequestFile(String fileName) throws IOException, InterruptedException { @@ -125,4 +128,13 @@ public class ITMzsServiceTest { } + public static XMLGregorianCalendar genTimeStamp() { + try { + return DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException("ups"); + } + + } + } |