Posts

Showing posts from January, 2015

Priming Ubuntu 14.04 to working with Dropwizard

Image
Here is a link to my Getting Started with Dropwizard course on Udemy. Only $10! To start developing with Dropwizard using Ubuntu we first of all should install Java, Maven project management tool an Git in order to get access to Dropwizard repository on GitHub. We are going to install Oracle Java 8 which is not part of Ubuntu distribution; to host such packages there is a project Launchpadthat allows to upload so-called Personal Package Archives (PPA) and the one for Oracle Java 8 is supported by webupd8.
In order to install Java 8 the following commands should be issued in a terminal window. To open the terminal one could press Alt+Ctrl+T simultaneously.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
The following additional command sets up all the necessary Java environment variables.
sudo apt-get install oracle-java8-set-default
To check the installation ask Java to report its version.
java -version
You should see something like …

Getting started with Dropwizard: First steps

Image
Here is a link to my Getting Started with Dropwizard course on Udemy. Only $10! Dropwizard is a bunch of superb frameworks glued together to provide a fast way of building web applications including REST APIs. We'll talk about great frameworks which are parts of Dropwizard as we go over our examples. The full code for the examples can be obtained here.
The simplest way to create a Dropwizard project is to use the Maven archetype called java-simple which is a part of Dropwizard. This can be accomplished either via the command line or using your favorite IDE. Let's stick to the former approach. The command below is formatted for clarity but it should be pasted as a single line to the terminal.


After the project was created it can be modified using an editor or opened in an IDE. All the three IntelliJ, Eclipse and Netbeans have Maven support. An important parameter to note in the pom.xml file of the newly created project is dropwizard.version, which at the time of writing was autom…

Introduction to Test Doubles with Mockito

It is not uncommon to encounter a situation when the System Under Test (SUT) is dependent on a number of collaborators. Let's imagine that we are developing code that emulates an Automatic Teller Machine (ATM). An ATM can be thought of as a box that host various components such as the keyboard, the display, the cash dispenser and so on, as well as it is a controller that orchestrates the work of constituent parts. In addition, it should have a communication link to the bank it belongs, in order to check user's details and the state of her account.
There is a lot of parts that may not be already produced by the time we write the ATM class and also if they were, it could be slow to use real parts in our tests. Moreover, an attempt to communicate with the bank could lead to unpredictable and not repeatable results. Furthermore, it is easier to emulate communication failures with some code than with hardware.
To solve a problem of testing a system which is dependent on other compone…