2020 Q2

My blog posts of 2020 Q2.

Why Do We Need Completable Future?

Why do we need CompletableFuture? What is its strength compared to synchronous code and classic future in Java? How to remember its APIs?

Write An Actor In Akka

How to write a new actor in Akka in Java? This post explains actor creation, message reception, and testing.

3 Ways to Handle Exception In Completable Future

How to handle exception in CompletableFuture? This article explains the difference between handle(), whenComplete(), and exceptionally().

Controlling Time with Java Clock

Use java.time.Clock to control time in your unit tests. This article will mainly focus on usage of fixed clock and offset clock.

How CompletableFuture is tested in OpenJDK?

How CompletableFuture is tested in OpenJDK 14? What can we learn from it?

Mockito: 3 Ways to Init Mock in JUnit 5

Initialize Mockito mock objects in JUnit 5 using MockitoExtension, MockitoAnnotations#initMocks, or Mockito#mock.

Introduction of Immutables

Introduction of Java framework Immutables which creates immutable objects and builders for you. Type-safe, null-safe and thread-safe, with no boilerplate.

Testing Elasticsearch With Docker And Java High Level REST Client

Testing Elasticsearch with docker and Java High Level REST Client

Logback: Test Logging Event

Capture SLF4J + Logback logging events and test them in unit tests using ListAppender.

Mockito: 3 Ways to Init Mock in JUnit 4

Initialize Mockito mock objects in JUnit 4 using MockitoJUnitRunner, MockitoAnnotations#initMocks, or Mockito#mock.

Create Systemd Unit File for Java

This post explains how to create a systemd unit file for Java, so that you can run your Java application as a service in Linux. It also explains the structure of a service file, and tells your the useful commands after service's creation.

OCA Review 1 - Java Basics

I’m preparing the OCAJP: Oracle Certified Associate Java SE 8 Programmer. Here’re something interesting that I learned from the study guide, chapter 1 and chapter 2. They’re rarely used in our daily mission, but I just wrote them down for fun.