Quick 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 ArticleThe SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5
1. Introduction In this quick article, we’ll take a look at the new @SpringJUnitConfig and @SpringJUnitWebConfig annotations available in Spring 5. These annotations are a composition of JUnit 5 and...
View ArticleComparator and Comparable in Java
1. Introduction Comparisons in Java are quite easy – until they’re not. When working with custom types, or trying to compare objects that aren’t directly comparable, we need to make use of a...
View ArticleIntroduction to the JDBC RowSet Interface in Java
1. Overview In this article, we’re reviewing the JDBC RowSet interface. A JDBC RowSet object holds tabular data in a style that makes it more adaptable and simpler to use than a result set. Oracle has...
View ArticleNested Classes in Java
1. Introduction This tutorial is a quick and to-the-point introduction to nested classes in the Java language. Simply put, Java allows us to define classes inside other classes. Nested classes enable...
View ArticleWriting Custom Gradle Plugins
1. Introduction Gradle is a very popular build tool, which is often appreciated for the highly-customizable build process. Today we’re going to show how to create custom Gradle plugins, that will...
View ArticleA Guide to Java Loops
1. Overview In this article, we’ll look at a core aspect of the Java language – executing a statement or a group of statements repeatedly – using loops. 2. Intro to Loops In programming languages,...
View ArticleCreating a MS PowerPoint Presentation in Java
1. Introduction In this article, we’ll see how we can create a presentation using Apache POI. This library gives us a possibility to create PowerPoint presentations, read existing ones, and to alter...
View ArticleVarargs in Java
1. Introduction Varargs were introduced in Java 5 and provide a short-hand for methods that support an arbitrary number of parameters of one type. In this article, we’ll see how we can use this core...
View Article