Mocking HTTP Interaction with Java, JUnit and MockServer

When writing tests for our software components sometimes we need to mock external services based on the HTTP protocol, might it be a RESTful web-service, an XML-RPC call or a simple GET request to some web-server. In the following short tutorial I’d like to demonstrate how to create a mock HTTP server for testing and how to bootstrap and bind it to the life-cycle of a classical build-management tool like Maven. ...

January 5, 2016 · 4 min · 821 words · Micha Kops

Integration Testing IMAP, SMTP and POP3 with GreenMail

Having written some e-mail handling, sending or receiving library you’d like to run some integration tests against a real mail server? Then GreenMail might help you out here .. the framework is not quite new on the market but it is really easy to setup IMAP,SMTP or POP3 services with it and it comes with some helpful libraries making your life a bit easier here. That’s why I’ve come to the idea to share some examples for setting up different server instances, creating user accounts and – at last – fetching and validating e-mails… ...

July 30, 2012 · 9 min · 1833 words · Micha Kops

REST-assured vs Jersey-Test-Framework: Testing your RESTful Web-Services

Today we’re going to take a look at two specific frameworks that enables you to efficiently test your REST-ful services: On the one side there is the framework REST-assured that offers a nice DSL-like syntax to create well readable tests – on the other side there is the Jersey-Test-Framework that offers a nice execution environment and is built upon the JAX-RS reference implementation, Jersey. In the following tutorial we’re going to create a simple REST service first and then implement integration tests for this service using both frameworks. ...

September 5, 2011 · 6 min · 1094 words · Micha Kops