Terminal Based Progress Bar for Java Applications

Recently I needed to add a progress bar to a Java based terminal/console application and I used a specific library that I’d like to demonstrate in the following snippet. Figure 1. Terminal based Progress Bar for Java Dependencies Using Maven, we just need to add the following dependency: pom.xml <dependency> <groupId>me.tongfei</groupId> <artifactId>progressbar</artifactId> <version>0.7.3</version> </dependency> Sample Application The application shows how to set up the progress bar and how to advance its status by-one, by a given amount or to a specific number. ...

March 31, 2019 · 2 min · 242 words · Micha Kops

Annotation based Kubernetes and Openshift Manifests for Java Applications with ap4k

Writing our manifest files for Kubernetes / Openshift often forces us to edit xml, json and yml files by hand. A new library, ap4k allows to specify metadata for these manifest files directly in our Java code using annotations. In the following short example I am going to demonstrate how to generate manifest files using Maven and ap4k. Figure 1. ap4k Tutorial Dependencies Using Maven we just need to add the following one dependency to our project’s pom.xml ...

February 28, 2019 · 5 min · 898 words · Micha Kops

Using Throwaway Containers for Integration Testing with Java, JUnit 5 and Testcontainers.

A lot of boilerplate code is written when developers need to test their applications with different connected systems like databases, stream platforms and other collaborators. Docker allows to handle those dependencies but there is still some glue code required to bind the container’s lifecycle and the configuration to the concrete integration test. Testcontainers is a testing library that offers lightweight throwaway instances of anything able to run in a Docker container, with bindings to configure the specific containers and also provides wrappers to manage our own custom containers. ...

January 30, 2019 · 6 min · 1110 words · Micha Kops

Next Steps to Pattern Matching in Java with Java 12 and Switch Expressions aka JEP 325

It is interesting to see how the Java language evolves over time. One thing that I have always missed is pattern matching in a way similar to languages like Scala. Now there are different JDK Enhancement Proposals (JEP) aiming at bringing us a little bit closer to pattern matching, especially JEP 325 aka Switch Expressions that are included in the current Java 12 preview or JEP 305 aka Pattern Matching for instanceof. ...

December 30, 2018 · 4 min · 715 words · Micha Kops

Implementing Reactive Client-Server Communication over TCP or Websockets with RSocket and Java

Reactive design or reactive architecture has an impact on how modern software systems are implemented. RSocket is a project that aims to adapt the benefits of the patterns described in the Reactive Manifesto and resulting tools like Reactive Streams or Reactive Extensions to a formal new communication protocol. RSocket works with TCP, WebSockets and Aeron transport layers and offers additional features like session resumption. In the following tutorial I’m going to demonstrate how to implement simple client-server communication over TCP and Websockets for different interaction models like request-response, request-stream, fire-and-forget and event subscription. ...

November 25, 2018 · 8 min · 1558 words · Micha Kops

Analyzing Java Applications on the Fly with Arthas

Arthas created by Alibaba is a tool that allows developers to connect to running Java applications without stopping them or suspending threads for debugging the application from the console. It offers features like monitoring invocation statistics, searching for classes and methods in the classloaders, view method invocation details (like parameters), show the stack trace of a method invocation, monitor system metrics and others. In the following examples I’m going to demonstrate some of these features applied to a running web application. ...

October 31, 2018 · 8 min · 1525 words · Micha Kops

Capacity Planning using the Universal Scalability Law with Java and usl4j

Capacity planning is an important task when trying to anticipate resources and scaling factors for our applications. The usl4j library offers us an easy abstraction for Neil J. Gunther’s Universal Scalability Law and allows us to build up a predictive model based on the parameters throughput, latency and concurrent operations. With a basic input set of two of these parameters, we are able to predict how these values change if we change one input parameter so that we can build our infrastructure or systems according to our SLAs. ...

September 30, 2018 · 6 min · 1072 words · Micha Kops

Testing OpenAPI Swagger Schema Compliance with Java, JUnit and assertj-swagger

The OpenAPI and Swagger API description format are becoming important standards to specify API contracts for RESTful web services and the Microservices trend pushes the need for such contracts even further. Therefore arises the need for software architects, testers and developers to write tests to verify if an exposed API follows such a specified contract. In the following tutorial I will demonstrate a setup with Java, Maven, JUnit and the designated contract-testing-library, assertj-swagger that verifies the validity of such a contract exposed by a Spring Boot application against a local stored definition. ...

August 31, 2018 · 5 min · 871 words · Micha Kops

Testing Java Applications for Resilience by Simulating Network Problems with Toxiproxy, JUnit and the Docker Maven Plugin

When implementing distributed systems, client-server architectures and simple applications with network related functionalities, everything is fine when we’re in the development or in the testing stage because the network is reliable and the communicating systems are not as stressed as they are in production. But to sleep well we want to validate how resilient we have implemented our systems, how they behave when the network fails, the latency rises, the bandwidth is limited, connections time out and so on. ...

July 29, 2018 · 9 min · 1836 words · Micha Kops

Using jetstreamDB as in-memory Database for Java

JetstreamDB is a in-memory database engine for Java that claims to be built for ultra-high speed and the ability of managing complex data structures by storing real Java objects instead of serializing data structures to other database specific formats. In the following short example I would like to demonstrate how to create and read items from such a database by building a small article management sample app. ...

June 30, 2018 · 4 min · 654 words · Micha Kops