Journal
Mocking Java InputStream and OutputStream in Unit TestsFile-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 testingTestcontainers 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 referencesLambda 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 ObjectStreamsJava 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 expressionsAn 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 erasureJava 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 JMHString 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 testsExternal 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 PicocliPicocli 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 testsJava 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…