Introduction to Creational Design Patterns
1. Introduction In software engineering, a Design Pattern describes an established solution to the most commonly encountered problems in software design. It represents the best practices evolved over...
View ArticleSpring 5 Testing with @EnabledIf Annotation
1. Introduction In this quick article, we’ll discover the @EnabledIf and @DisabledIf annotations in Spring 5 using JUnit 5. Simply put, those annotations make it possible to disable/enable particular...
View ArticleDisplay All Time Zones With GMT And UTC in Java
1. Overview Whenever we deal with times and dates, we need a frame of reference. The standard for that is UTC, but we also see GMT in some applications. In short, UTC is the standard, while GMT is a...
View ArticleJava Weekly, Issue 204
Lots of interesting writeups on Java 9 this week. Here we go… 1. Spring and Java >> First Contact With ‘var’ In Java 10 [blog.codefx.org] Java 9 was released two months ago and there’s already...
View ArticleHow to Copy a File with Java
1. Overview In this article, we’ll cover common ways of copying files in Java. First, we’ll use the standard IO and NIO.2 APIs, and two external libraries: commons-io and guava. 2. IO API (Before...
View ArticleIntroduction to Gradle
1. Overview Gradle is a Groovy-based build management system designed specifically for building Java-based projects. Installation instructions can be found here. 2. Building Blocks – Projects and...
View ArticleSend the Logs of a Java App to the Elastic Stack (ELK)
1. Overview In this quick tutorial, we’ll discuss, step by step, how to send out application logs to the Elastic Stack (ELK). In an earlier article, we focused on setting up the Elastic Stack and...
View ArticleCAS SSO With Spring Security
1. Overview In this article, we’re going to look at integrating the Central Authentication Service (CAS) with Spring Security. CAS is a Single Sign-On (SSO) service. Let’s say we have applications...
View ArticleQuick Guide on data.sql and schema.sql Files in Spring Boot
1. Overview Spring Boot makes it really easy to manage our database changes in an easy way. If we leave the default configuration, it’ll search for entities in our packages and create the respective...
View ArticleCustomizing the Order of Tests in JUnit 5
1. Overview By default, JUnit runs tests using a deterministic, but unpredictable order (MethodSorters.DEFAULT). In most cases, that behavior is perfectly fine and acceptable; but there’re cases when...
View ArticleMock Final Classes and Methods with Mockito
1. Overview In this short article, we’ll focus on how to mock final classes and methods – using Mockito. As with other articles focused on the Mockito framework (like Mockito Verify, Mockito...
View ArticleHibernate Inheritance Mapping
1. Overview Relational databases don’t have a straightforward way to map class hierarchies onto database tables. To address this, the JPA specification provides several strategies: MappedSuperclass –...
View ArticleJava – Append Data to a File
1. Introduction In this quick tutorial, we’ll see how we use Java to append data to the content of a file – in a few simple ways. Let’s start with how we can do this using core Java’s FileWriter. 2....
View ArticleIntroduction to OSGi
1. Introduction Several Java mission-critical and middleware applications have some hard technological requirements. Some have to support hot deploy, so as not to disrupt the running services – and...
View ArticleIntroduction to the Java ArrayDeque
1. Overview In this tutorial, we’ll show how to use the Java’s ArrayDeque class – which is an implementation of Deque interface. An ArrayDeque (also known as an “Array Double Ended Queue”, pronounced...
View ArticleImplementing the Template Method Pattern in Java
1. Overview In this quick tutorial, we’ll see how to leverage the template method pattern – one of the most popular GoF patterns. It makes it easier to implement complex algorithms by encapsulating...
View ArticleConvert Date to LocalDate or LocalDateTime and Back
1. Overview Starting with Java 8, we have a new Date API – java.time. However, sometimes we still need to perform conversions between the new and the old APIs, and work with date representations from...
View ArticleIntroduction to the JSON Binding API (JSR 367) in Java
1. Overview For a long time, there was no standard for JSON processing in Java. The most common libraries used for JSON processing are Jackson and Gson. Recently, Java EE7 came with an API for parsing...
View ArticleGuide to java.util.Formatter
1. Overview In this article, we’ll discuss the String formatting in Java using the java.util.Formatter class, which provides support for the layout justification and alignment. 2. How to Use the...
View ArticleJava Weekly, Issue 205
Here we go… 1. Spring and Java >> JUnit 5 Meets AssertJ [blog.codeleak.pl] Although JUnit5 is much more flexible than the previous version, AssertJ is still a must. >> Binding...
View Article