The Difference Between mockito-core and mockito-all
1. Overview Mockito is a popular mocking framework for Java. But, before we start, we have some different artifacts to choose from. In this quick tutorial, we'll explore the difference between...
View ArticleGuide to AtomicStampedReference in Java
1. Overview In this tutorial, we'll review details of theĀ AtomicStampedReference class from the java.util.concurrent.atomic package. After that, we'll explore the AtomicStampedReference classesĀ atomic...
View ArticleMocking the ObjectMapper readValue() Method
1. Overview When unit testing code that involves deserializing JSON with Jackson, we might find it easier to mock the ObjectMapper#readValueĀ method. By doing so, we don't need to specify long JSON...
View ArticleEncode a String to UTF-8 in Java
1. Overview When dealing with Strings in Java, sometimes we need to encode them into a specific charset. This tutorial is a practical guide showing different ways to encode a String to the UTF-8...
View ArticleIntroduction to Transactions
1. Introduction In this tutorial, we'll understand the concept of transactions. We'll go through the types of transactions and different guarantees they provide. We'll also explore different protocols...
View ArticleSpring Security: Check If a User Has a Role in Java
1. Introduction In Spring Security, sometimes it is necessary to check if an authenticated user has a specific role. This can be useful to enable or disable particular features in our applications. In...
View ArticleCreating Spring Beans Through Factory Methods
1. Introduction Factory methods can be a useful technique for hiding complex creation logic within a single method call. While we commonly create beans in Spring using constructor or field injection,...
View ArticleBuilding a Simple Web Application with Spring Boot and Groovy
1. Overview Groovy has a number of capabilities we might want to use in our Spring web applications. So, in this tutorial, we'll build a simple todo application with Spring Boot and Groovy. Also, we'll...
View ArticleAn Introduction to Kaniko
1. Introduction In this tutorial, we'll take a look at building container images using Kaniko. 2. Kaniko Kaniko is a tool to build container images from a Dockerfile. Unlike Docker, Kaniko doesn't...
View ArticleSpring Security Custom Logout Handler
1. Overview The Spring Security framework provides very flexible and powerful support for authentication. Together with user identification, we'll typically want to handle user logout events and, in...
View ArticleJava-R Integration
1. Overview R is a popular programming language used for statistics. Since it has a wide variety of functions and packages available, it's not an uncommon requirement to embed R code into other...
View ArticleConstructing a JPA Query Between Unrelated Entities
1. Overview In this tutorial, we'll see how we can construct a JPA query between unrelated entities. 2. Maven Dependencies Let's start by adding the necessary dependencies to our pom.xml. First of all,...
View ArticleInvoking a SOAP Web Service in Java
1. Overview In this tutorial, we'll learn how to build a SOAP client in Java with JAX-WS RI. First, we'll generate the client code using the wsimport utility, and then test it using a JUnit. For those...
View ArticleUsing Multiple Cache Managers in Spring
1. Overview In this tutorial, we'll learn how we can configure multiple cache managersĀ in a Spring application. 2. Caching Spring applies caching to methods so that our application doesn't execute the...
View ArticleInvoking a SOAP Web Service in Spring
1. Overview Previously, we saw how to create a SOAP web service with Spring. In this tutorial, we'll learn how to create a Spring-based client to consume this web service. In invoking a SOAP web...
View ArticleJava Weekly, Issue 331
1. Spring and Java >> Spring Tips: Configuration [spring.io] Handy tips from the experts on getting the most out of Spring's Environment abstraction through application.properties. >> An...
View ArticleMapping Lists with ModelMapper
1. Overview In this tutorial, we'll explain how to map lists of different element types using the ModelMapper framework. This involves using generic types in Java as a solution to convert different...
View ArticleMemcached vs Redis
1. Overview In this article, we'll examine the similarities and differences of two popular in-memory databases, Memcached and Redis. 2. Memcached and Redis Often, we think about caching to improve...
View ArticleBest Practices When Using Terraform
1. Overview Previously, we've covered Terraform's basic concepts and usage. Now, let's dig deeper and cover some of the best practices when using this popular DevOps tool. 2. Resource Files...
View ArticleDisable Security for a Profile in Spring Boot
1. Overview In this tutorial, we're going to take a look at how we can disable Spring Security for a given profile. 2. Configuration First of all, let's define a security configuration that simply...
View Article