Articles Tagged ‘gradle’

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

Monday, December 19th, 2016

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.

(more…)

Object Graph Mapping by Example with Neo4j OGM and Java

Monday, July 18th, 2016

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.

(more…)

Continuous Delivery with Bitbucket Cloud and Bitbucket Pipelines

Friday, July 1st, 2016

Atlassian has added a continuous integration service as a new feature to their Bitbucket Cloud product. It’s called Bitbucket Pipelines and it is similar to Travis CI for GitHub offering a nice integration for continuous integration/delivery pipelines for projects hosted on Bitbucket.

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.

(more…)

Testing Asynchronous Applications with Java and Awaitility

Sunday, August 23rd, 2015

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.

(more…)

Snippet: Creating secure Password Hashes in Java with Heimdall

Sunday, July 12th, 2015

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.

In the following short examples I’d like to demonstrate how to create password hashes, how to verify passwords and how to check if a password hash needs to be recreated using a more secure algorithm.

(more…)

Integrating Swagger into a Spring Boot RESTful Webservice with Springfox

Wednesday, July 1st, 2015

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.

(more…)

A short Overview of Neo4j Indexing Strategies

Sunday, January 25th, 2015

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.

(more…)

Embedding Jetty or Tomcat in your Java Application

Tuesday, July 9th, 2013

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.

(more…)

Creating and Packaging a Game in Java FX 2.2

Sunday, June 23rd, 2013

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.

If you need to bind your UI component properties to a specific application state, there’s a nice properties- and bindings API that makes your life easier.

In the following tutorial, I’m going to create a simple game application – one version using FXML templates, model- and controller classes and using external stylesheets – the other version as a programmatic version in one java class.

Finally I’m showing how easy it is to create a shippable application either as runnable jar or as Java Web Start/JNLP application by using Gradle and the Java FX Plugin for Gradle.

(more…)

Integration Testing IMAP, SMTP and POP3 with GreenMail

Tuesday, July 31st, 2012

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…

(more…)

Integrating Groovy in your Maven builds using GMaven

Tuesday, July 12th, 2011

Often ant tasks are used in Maven builds but wouldn’t it be more attractive to integrate the Groovy language into our build process?

GMaven is the answers to this problem and brings together Maven and Groovy. It allows us to execute Groovy scripts inline from our Maven configuration, from a local script or even from a remote location. In the following short examples I am going to show how to configure Maven to execute Groovy scripts from different locations.

(more…)

Search
Categories