Posts for: #Java

Writing parameterized tests for Junit 5?

As a software engineer, I often encounter situations where I need to run the same test logic with different input values. Repeating the same test with minor variations not only clutters your test classes but also violates the DRY (Don't Repeat Yourself) principle.

That’s where parameterized tests come into play. Since JUnit 5, writing these tests has become much easier and cleaner. In this post, I’ll walk you through how to use parameterized tests effectively with JUnit 5.

Read more

How to logging SOAP requests and responses in Spring Boot?

When working with SOAP web services in a Spring Boot application, it’s often necessary to log incoming and outgoing SOAP messages for debugging, auditing, or monitoring purposes. Unlike REST APIs, where logging can be handled easily with filters and interceptors, SOAP requires a specialized approach.

Why Log SOAP Messages?

  • Debugging: Helps developers diagnose issues by capturing full request and response messages.
  • Auditing: Ensures compliance by keeping a record of exchanged messages.
  • Monitoring: Allows tracking of service interactions in production.

Implementing a SOAP Logging Handler

Spring Boot provides integration with SOAP web services using JAX-WS. To log SOAP requests and responses, we can implement a custom SOAPHandler. Here’s a simple SoapLoggingHandler that captures both inbound (responses) and outbound (requests) SOAP messages:

Read more