Journal

Testing REST API rate limiting with Bucket4j and Spring
Rate limiting is easy to implement and surprisingly difficult to verify. A token-bucket policy can accept a burst, refill over time, and assign separate…
How to mock Java records and sealed classes in tests
Java records and sealed classes make backend models compact, explicit, and hard to extend. Records package immutable values, while sealed types restrict…
Running JUnit 4 Tests with the JUnit Vintage Engine
JUnit 5 is a collection of components rather than one runner. JUnit Jupiter provides the modern annotation model, while the JUnit Vintage Engine acts as an…
Testing custom Spring validators without guesswork
Validation often looks like a small guardrail until a business rule must survive a REST request, an event consumer and a batch job. Testing custom Spring…
Testing Java dynamic proxies and invocation handlers
A Java dynamic proxy implements one or more interfaces at runtime, giving tests control over calls that would otherwise reach a database, payment gateway, or…
Performance testing HTTP APIs with wrk and wrk2
HTTP APIs can look healthy in functional tests while slowing down under concurrent traffic. A few successful requests from Postman or a Java integration test…
Testing Java streams parallel processing with ForkJoinPool
Parallel streams can turn a concise collection pipeline into concurrent execution, but they do not make the underlying business logic concurrent by itself.…
How to test Java enums and custom enum methods
Java enums often look too simple to deserve dedicated tests. A few constants and a switch expression can appear self-explanatory, especially when the type…
Using Spring Test For Database Transactions And Rollback
Database integration tests are most useful when they exercise the same persistence rules as production code. A test that saves an order, updates an account, or…
Testing WebJars and static resources in Spring Boot
Packaging browser assets as WebJars can hide a surprisingly broad failure surface. A JavaScript file may be present in the dependency tree, resolve through…