Journal

Mocking Java InputStream and OutputStream in Unit Tests
File-processing code often sits at the boundary between your application and the outside world. It reads uploads, transforms CSV records, writes reports, or…
Testcontainers for PostgreSQL, MySQL and Oracle testing
Testcontainers gives an integration test a real database engine without asking teams to maintain a permanent server. A Docker image starts PostgreSQL, MySQL or…
Testing Java functional interfaces with lambdas and method references
Lambda expressions and method references let a program pass behaviour through an interface rather than hiding it inside a named class. In a functional…
Writing Tests for Java Serialization with Custom ObjectStreams
Java serialization can look deceptively simple. An object goes into an ObjectOutputStream, bytes travel somewhere, and an ObjectInputStream reconstructs the…
How to test Java enum behavior and switch expressions
An enum may look like a harmless list of names, yet its constants can control pricing, order fulfilment, approval workflows and access decisions. A single…
Proving Java generic contracts with reflection after erasure
Java generics give compile-time protection, but the JVM does not preserve every generic detail in the same way. Type erasure removes type arguments from…
Benchmarking Java strings and regex with JMH
String handling often looks trivial until a service starts parsing large payloads, rewriting identifiers or validating thousands of records. A regex may save…
Stubbing external HTTP APIs with WireMock in Java tests
External APIs are often the slowest and least predictable part of a Java test suite. A provider sandbox may be slow, rate-limited, unavailable outside business…
Testing Java Command-Line Applications with Picocli
Picocli makes it practical to build Java command-line applications with typed options, positional parameters, subcommands and generated help. Its annotations…
Testing Java NIO channels and selectors with unit tests
Java NIO makes it possible to handle many network connections with a small number of threads. Channels provide the I/O boundary, while selectors let an event…