Tagged articles
3 articles
Page 1 of 1
FunTester
FunTester
Apr 28, 2020 · Backend Development

How to Mock System.in and System.out for Java Unit Tests

This guide shows how to replace System.in and System.out with in‑memory streams during unit testing, provides reusable helper classes for setting and restoring these streams, and includes a complete example demonstrating input simulation and output capture in Java.

IO StreamsMockingSystem.in
0 likes · 5 min read
How to Mock System.in and System.out for Java Unit Tests
360 Quality & Efficiency
360 Quality & Efficiency
May 15, 2017 · Fundamentals

Special Cases in Java Resource Closing: Utilities, Return Patterns, Non‑Closeable Streams, Nested Streams, JDBC Statements, and Sockets

This article, the fifth in a static code scanning series, explains six special scenarios—custom close utilities, methods returning resources, streams that need not be closed, nested stream closures, JDBC statement/result set relationships, and socket streams—that complicate determining whether Java resources have been properly closed.

CloseableIO StreamsJDBC
0 likes · 9 min read
Special Cases in Java Resource Closing: Utilities, Return Patterns, Non‑Closeable Streams, Nested Streams, JDBC Statements, and Sockets