Tag: java

  • Log Message Validation with JUnit 5

    Log Message Validation with JUnit 5

    Introduction In your unittests it is important to check whether the code under test has been executed correctly. Sometimes, all you can check is log statements. In this guide, we will leverage the JUnit 5 Extension Model to intercept and verify logging. We will asume Logback is used in the application. Capture logging statements The first thing…

  • Elevate Your Web Content: Adding Image Support with Spring Boot, Thymeleaf, and CKEditor

    Elevate Your Web Content: Adding Image Support with Spring Boot, Thymeleaf, and CKEditor

    Introduction In this guide, we will walk you through the process of integrating image support into your online text editor using a stack that includes Spring Boot, Thymeleaf, and CKEditor. Whether you’re building a wiki, a recipe site, or any application where visual content matters, this tutorial will help you take the next step in…

  • Spring Boot – Load users from database

    This is the third article in a series on authentication with Spring Boot. In the first article we authenticated using social networks, and allowed any user to access our application. In the second article we used inMemoryAuthentication for users that used the login form. In essence, we hardcoded our users. This article is about adding…

  • Apache HttpClient

    For a hackaton I wanted to read some files from our BitBucket server. I knew the URLs of the files, but there were some complications. First, you need to be authenticated. According to the documentation, the preferred way of authentication is HTTP Basic Authentication when authenticating over SSL. We are using an SSL connection, but…

  • Multiple Full-Screens in Java

    Working with Java’s Full-Screen Exclusive Mode is a bit different than working with AWT, Swing or JavaFX. The tutorial describes how, and why, this works. The information, however, is a bit spread out. Also, it doesn’t mention how to work with multiple full screens at the same time. Not that it’s very different from working…

  • Java XML Api

    Who uses XML in 2021? We all use JSON these days, aren’t we? Well, it turns out XML is still being used. These code fragments could help get you up to speed when you’re new to the Java XML API. Create an empty XML document To start from scratch, you’ll need to create an empty…

  • Leveraging Lucene

    Imagine a catalog of a few hundred thousand items. These items have been labeled into a few hundred categories. Each item can be linked to up to three categories. New categories need to be added in order to make things easier to find. However, categories without content are useless. So some content needs to be…

  • Spring Boot, MongoDB and raw JSON

    Sometimes you want to store and retrieve raw JSON in MongoDB. With Spring Boot storing the JSON isn’t very hard, but retrieving can be a bit more challenging. Setting up To start using MongoDB from Spring Boot, you add the dependency to spring-boot-starter-data-mongodb And then you inject MongoTemplate into your class Inserting into MongoDB Inserting…

  • Java: Remove an element from a List

    One of the more common tasks in programming is removing a specific element from a list. Although this seems to be straight-forward in Java, it’s a bit more tricky. Before we start, we should build our list: Let’s say we want to remove the String “String 2”. The first thing that comes to mind is…

  • The Pomodoro Technique

    One of my favorite time management methods is the Pomodoro Technique. The method is basically as follows: Pick a task. Work on it for 25 minutes. This is called a Pomodoro. Take a 5 minute break. Do something totally unrelated to your work. Work for another Pomodoro, or 25 minutes. This can be on the…