Posts

Showing posts from April, 2019

Spring boot Wiremock Integration

What is Wiremock Demonstration of Running WiremockServer as Spring boot application, which helps in various test strategies such as integration, contract and performance testing. — ThirupathiReddy Vajjala What is Wiremock It is a mock server which enables you to stay productive with the following use cases: API you depend on doesn’t exist API you depend on is n’t complete. It supports testing of edge cases and failure modes that the real API won’t reliably produce. Because it’s fast it can reduce your build time from hours down to minutes. Wiremock server can be useful in different test strategies When you don’t have enough test data to do end-to-end testing with the new features you implemented. When you want to verify your producer contracts while running build pipelines such as Consumer driven contract testing. Performing load testing on your application components. When you want to do Integration testing and you don

Client side REST Testing

Test Scenario: Test when server throw 400 BAD_REQUEST exception, PetStoreClient should throw BadRequestException Demonstration of client-side REST testing using MockRestServiceServer — tvajjala This tutorial helps you to understand the testing RESTful WebserviceClient by mocking the underlying webServer. Mocking framework(such as Mockito) with RestTemplate, did not fully test the client layer calls and error handling provided, to overcome this problem , MockRestServiceServer will helps you to write complete integrationTests without actually connecting to real server. MockRestServiceServer comes with DSL syntax to write test scenarios. PetStoreClient is simple client with placeOrder method which talks to external webServer to place the order. Write your WebServiceClient testCase compatible as shown below, which helps you to write tests easy PetStoreClient.java /** * WebService client invokes external webservices using RestTem

Invoking Secured WebServices

Accepting TrustStrategy without TrustMaterial This tutorial demonstrates the invocation of secured webservices using RestTemplate — tvajjala When your web services are secured by HTTPs(self signed) protocol, and you are trying to access them using RestTemplate you will get following exceptions: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target There are two ways we can make it work. Accepting TrustStrategy without TrustMaterial Loading TrustMaterial into SSLContext (Recommended) Accepting TrustStrategy without TrustMaterial We just ignore https certification by customizing restTemplate as shown below /** * default restTemplates since we are skipping sslVerification