A quick and practical guide to Mockito’s MockedConstruction.
Baeldung Author
Jonathan Cook
Jonathan has more than 10 years of experience as a Senior Software Engineer with a focus on Java. He is particularly passionate about testing and ensuring the quality of the systems he is responsible for. He has contributed to several open source projects and can now be found in Spain looking after the ESA science archives.
Here's what I've written (so far):
Baeldung on Java
- All
- Testing (18)
- Spring Boot (5)
- Jakarta EE (3)
- Data (3)
- Java Dates (2)
- Java (2)
- Jackson (2)
- HTTP Client-Side (2)
- Core Java (2)
- Spring (1)
- REST (1)
- NoSQL (1)
- Java Numbers (1)
- JVM (1)
- JSON (1)
Mock a URL Connection in Java
Filed under Testing
Explore several ways of mocking a URL connection to write stand-alone unit tests that don’t rely on external services.
Jackson’s Deserialization With Lombok
Filed under Jackson
Explore two simple approaches to configure our Lombok builder classes to work seamlessly with Jackson.
Apache Camel Exception Handling
Filed under Data
Learn how to handle exceptions in our routes using Apache Camel.
Apache Camel Conditional Routing
Filed under Spring
Learn how we can route messages based on conditions in our routes using Apache Camel.
Apache Camel Routes Testing in Spring Boot
Filed under Spring Boot, Testing
Learn how to test Apache Camel routes in Spring Boot.
Connecting to a NoSQL Database with Spring Boot
Filed under NoSQL, Spring Boot
Learn how to set up and connect to a hosted Cassandra Astra Database.
CassandraUnit Test Tutorial
Write reliable, self-contained unit tests using CassandraUnit.
A Guide to Events in OkHTTP
Filed under HTTP Client-Side
Learn how to capture events using OkHttp.
Mocking Static Methods With Mockito
Filed under Testing
Explore a couple of examples of how we can use Mockito to mock static methods.
Adding Interceptors in OkHTTP
Filed under HTTP Client-Side
Learn how to create interceptors using OkHttp.
Overview of Mockito MockSettings
Filed under Testing
A quick and practical overview of Mockito MockSettings.
Unmarshalling a JSON Array Using camel-jackson
Filed under Jackson, JSON, Spring Boot
Learn two simple approaches for unmarshalling JSON arrays using camel message routing and the camel-jackson component.
Spring Boot With Spring Batch
Filed under Spring Boot
Learn how to create a simple Spring Batch job using Spring Boot.
Testing Kafka and Spring Boot
Filed under Data, Spring Boot, Testing
Learn about a couple of approaches for testing Kafka applications with Spring Boot.
Guide to the System Rules Library
Filed under Testing
Explore the System Rules library in detail.
Unit Testing of System.out.println() with JUnit
Filed under Testing
Learn about approaches for testing System.out.println.
Taking Screenshots With Selenium WebDriver
Filed under Testing
Explore two approaches to capturing screenshots using Selenium WebDriver.
Getting the Week Number From Any Date
Filed under Java Dates
Learn how to get the week number for a given date in Java.
How to Call Python From Java
Filed under Java
Learn the most common ways of calling Python code from Java.
Pattern Matching for instanceof in Java 14
Filed under Core Java
Learn about the Pattern Matching with instanceof in Java 14.
Check for null Before Calling Parse in Double.parseDouble
Filed under Java Numbers
Learn how to check for null before converting a string to a double using Double.parseDouble.
Mockito and Fluent APIs
Filed under Testing
Learn how we can use Mockito to mock a simple fluent API.
Guide to JUnit 4 Rules
Filed under Testing
Learn how to use the JUnit 4 Rules Model to extend the behavior of JUnit tests
JUnit 5 TestWatcher API
Filed under Testing
Learn how you can process the results of test method executions using the JUnit TestWatcher.
JUnit 5 Temporary Directory Support
Filed under Testing
Learn how to use a temporary directory for JUnit tests, with the @TempDir annotation
Mockito Strict Stubbing and The UnnecessaryStubbingException
Filed under Testing
Understand the reasons behind the Mockito UnnecessaryStubbingException and how to avoid it.
Guide to java.lang.ProcessBuilder API
Filed under Core Java
An in-depth look at using the ProcessBuilder API to manipulate OS processes
Verbose Garbage Collection in Java
Filed under JVM
Learn how to enable verbose GC in Java and how to interpret the resulting logs.
Merging java.util.Properties Objects
Filed under Java
A quick and practical guide to merging Properties objects.
Exploring the Jersey Test Framework
Filed under Jakarta EE, Testing
Learn how to make use of the test support in Jersey.
Warning: “The type MockitoJUnitRunner is deprecated”
Filed under Testing
Learn how to handle the MockitoJUnitRunner class deprecation warning.
Bean Validation in Jersey
Filed under Jakarta EE, REST
Learn how to use Bean Validation with the Jersey library
Jersey MVC Support
Filed under Jakarta EE
A quick tutorial to understanding MVC in Jersey using Freemarker.
Testing Callbacks with Mockito
Filed under Testing
Explore two different ways of testing callbacks when using Mockito.
Convert String to Date in Java
Filed under Java Dates
Learn how to get an object representing a Date from a String in Java
Baeldung on Linux
- All
- Scripting (2)
- Files (2)
- File Editing (2)
- Web (1)
- File Conversion (1)
- File Compression (1)
How to Exit a Shell Script From a Subshell
Filed under Scripting
Learn various methods to exit a shell script from within a subshell on Linux.
Manipulating Images With ImageMagick Command-Line Tools
Filed under File Conversion, File Editing
Learn some of the basic capabilities that ImageMagick provides for manipulating images via the command line.
Extracting a WAR File in Linux
Filed under File Compression, Files
Explore several alternatives for extracting and viewing the contents of WAR files on the Linux platform.
Linux Commands – Remove All Text After X
Filed under File Editing, Files
A quick and practical overview of trimming strings after sequence occurrences on Linux.
Guide to Linux jq Command for JSON Processing
Filed under Web
Explore the capabilities that jq provides for processing and manipulating JSON via the command line.
Linux Commands – Looping Through Directories
Filed under Scripting
Learn strategies for looping through directories in Linux
Baeldung on Scala
- All
- Testing (1)
Introduction to Testing With ScalaTest
Filed under Testing
Learn about ScalaTest, a comprehensive testing framework for Scala.