Handling System Properties, Environment Variables, STDOUT/STDERR in JUnit Tests with System Rules

When important data is written to STDIN/STDOUT and an application relies on specific system properties or environment variables, writing tests is getting more complicated. System Rules is a collection of JUnit rules that helps us writing Java tests for everything that deals with java.lang.System. In the following short examples I’d like to demonstrate how to deal with system properties, environment variables, STDOUT and STDERR and capturing both for testing e.g. for some golden master refactoring. ...

December 19, 2016 · 4 min · 718 words · Micha Kops

Object Graph Mapping by Example with Neo4j OGM and Java

When integrating a Neo4j database into a Java application a developer often needs to map nodes and edges of the graph to corresponding Java classes of the domain model. Neo4j OGM eases this work and allows us to map our domain objects to the graph database using simple annotations – similar to the Java Persistence API (JPA) for relational database management systems. In the following tutorial I’d like to demonstrate how to use Neo4j OGM to build a simple train timetable planner and a permission system mapping between graph, nodes, edges and POJOs. ...

July 18, 2016 · 9 min · 1828 words · Micha Kops

Continuous Delivery with GitHub Cloud and GitHub Pipelines

Atlassian has added a continuous integration service as a new feature to their GitHub Cloud product. It’s called GitHub Pipelines and it is similar to Travis CI for GitHub offering a nice integration for continuous integration/delivery pipelines for projects hosted on GitHub. It’s still in the beta phase and requires a sign-up but nevertheless I’d like to demonstrate the current state of this service and how easy it is to add scripted pipelines to a project. ...

July 1, 2016 · 4 min · 760 words · Micha Kops

Testing Asynchronous Applications with Java and Awaitility

Writing tests for asynchronous applications has never been much fun as we’re always struggling with the problem how to determine state changes, handle process terminations, dealing with timeouts or failures and stuff like this. Awaitility eases this process for us offering a nice DSL, rich support for languages like Scala or Groovy and an easy-to-use syntax that’s even more fun when using it with Java 8′s lambda expressions. In the following short introduction I’d like to demonstrate writing some tests different scenarios. ...

August 23, 2015 · 6 min · 1143 words · Micha Kops

Snippet: Creating secure Password Hashes in Java with Heimdall

These days where a cheap GPU for about 100 € is capable to create 3 billion of MD5 Hashes per second, we need not only need to use salts the right way but we also need to choose a strong, non-reversible and slow hashing schemes when storing passwords in our application. Heimdall is a library that implements a secure and upgradable password hashing mechanism and uses at the time of writing this article PBKDF2 SHA-1 HMAC with 20000 iterations and a 192 bit (24 byte) salt per default. ...

July 12, 2015 · 3 min · 588 words · Micha Kops

Integrating Swagger into a Spring Boot RESTful Webservice with Springfox

Spring Boot allows us to create RESTful web-services with ease, Swagger specifies a format to describe the capabilities and operations of these services and with Swagger UI it is possible to explore our REST API with a nice graphical user interface in our browser. Springfox is a project that aims at creating automated JSON API documentation for API’s built with Spring and is used in the following tutorial to integrate Swagger into a sample application. ...

July 1, 2015 · 7 min · 1418 words · Micha Kops

A short Overview of Neo4j Indexing Strategies

When it comes to indexing in a Neo4j graph database, different options exist for a developer to create and maintain the index. In the following short examples I’d like to demonstrate different possibilities for index management. Figure 1. Simple Domain Model Dependencies Only one dependency is needed to run the following examples and start an embedded neo4j server – I’m using Gradle here to manage my dependencies but Maven, Ivy, SBT should work without a problem, too. ...

January 25, 2015 · 6 min · 1227 words · Micha Kops

Creating a Websocket Chat Application with Vert.x and Java

Vert.x is a modern, lightweight framework to build high performance applications running on the Java Virtual Machine. The framework is polyglot so that you’re able to write your application in Java, Groovy, Ruby, Python or even JavaScript. In addition it offers a nice component system, an actor-like concurrency model a distributed event bus and an elegant API to create scalable applications in no time. In the following tutorial we’re going to build a websocket chat by creating a HTTP server and the websocket server using Vert.x, Java and Maven. ...

November 13, 2013 · 8 min · 1527 words · Micha Kops

Embedding Jetty or Tomcat in your Java Application

Recently I needed to control an embedded web container from a Java application and I wanted to see how this could be achieved using an embedded instance of either Tomcat or Jetty here. In the following short examples I would like to show how to embed both servers in an application in no time using Gradle or Maven as build tool. Dependencies We just need to add the web container libraries to our project here .. I’ve added the build config for Gradle and Maven here… ...

July 9, 2013 · 4 min · 782 words · Micha Kops

Creating and Packaging a Game in Java FX 2.2

It’s been a long way for Java FX from the days of the F3 project the current release 2.2. Today there are many options how to create a Java FX application .. you may be using Java, Scala, Groovy or Visage, you may create your application in a programmatic way using the comfortable integrated builders or you may create your views using XML layouts and easy data-bindings with a few annotations. ...

June 23, 2013 · 12 min · 2543 words · Micha Kops