Streamlining Java Unit Testing with Mockito, MockServer, and Cobertura
Mock objects isolate unit tests from external dependencies, ensuring consistent execution regardless of network availability or database state. The goal is truly portable, self-contained validation logic.
After evaluating several tools, Mockito and MockServer were selected for Java projects. Other candidates were set aside for various reasons:
...
Posted on Wed, 05 Aug 2026 17:07:34 +0000 by cyberRobot
Understanding System.currentTimeMillis() in Java: Time Units and Practical Applications
What is System.currentTimeMillis()?
The System.currentTimeMillis() method returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. The return type is long. This method is often overlooked in favor of new Date(), but they serve different purposes.
Performance Comparison
Many developers default ...
Posted on Wed, 05 Aug 2026 17:00:42 +0000 by MrCreeky
Java Server-Side Template Injection Vulnerability Analysis
Java Server-Side Template Injection Vulnerability Analysis
FreeMarker
FreeMarker template files consist of four main components:
(1) Text: Directly output portions
(2) Comments: Using <#-- ... --> format for comments, content inside won't be output
(3) Interpolation: ${...} or #{...} formatted sections, similar to placeholders that will b ...
Posted on Wed, 05 Aug 2026 16:55:40 +0000 by firmolari
Popular LeetCode Problems and Solutions
Two Sum
Given an array of integers nums and a target value target, find the indices of two numbers that add up to target. Return the indices as a pair.
Solution 1: Brute Force
class Solution {
public int[] twoSum(int[] nums, int target) {
for (int i = 0; i < nums.length; i++) {
for (int j = i + 1; j < nums.lengt ...
Posted on Wed, 05 Aug 2026 16:23:22 +0000 by Banacek
Practical MyBatis Integration and Advanced Configuration Guide
Core Concepts of MyBatis
MyBatis is a lightweight, flexible persistence framework that bridges Java objects and relational databases. It eliminates boilerplate JDBC code—such as resource management, parameter binding, and result set handling—while retaining full control over SQL. Developers define mappings using XML files or annotations, enabli ...
Posted on Wed, 05 Aug 2026 16:01:02 +0000 by cityboy101
Implementing a Delayed Task Scheduler in Java
Java provides multiple mechanisms for executing a task after a certain delay. One robust modern approach is to use ScheduledExecutorService, which offfers better thread management and flexibility than the traditional Timer class. This article demonstrates how to schedule a one‑shot delayed task using this executor.
Overview: Scheduling a One‑Ti ...
Posted on Tue, 04 Aug 2026 17:01:08 +0000 by Adeus
Data Extraction from HTML Using Java and Regular Expressions
Regular expressions (regex) serve as a powerful mechanism for identifying and extracting specific patterns within large blocks of text. In the context of web scraping, regex allows developers to parse HTML source code to retrieve specific data points such as URLs, email addresses, or meta tags without the overhead of a full DOM parser.
Core Com ...
Posted on Tue, 04 Aug 2026 16:53:23 +0000 by laurajohn89
Essential Eclipse Shortcuts and Object-Oriented Java Implementation
Essential Eclipse Development Shortcuts
Optimizing your workflow in Eclipse requires mastering specific keyboard combinations. Below is a categorized list of the most impactful shortcuts for Java development:
Action
Shortcut
Editing & Refactoring
Content Assist / Completion
Alt + /
Quick Fix
Ctrl + 1
Format Code
Ctrl + Shift + ...
Posted on Tue, 04 Aug 2026 16:48:59 +0000 by andreea115
Bootstrapping a Lightweight Java Servlet Application with Maven and JDBC
Initializing the Maven Build Environment
Configure the build lifecycle and compiler settings within pom.xml. Specify Java compatibility, encoding, and essential plugins for compilation and test execution.
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId ...
Posted on Tue, 04 Aug 2026 16:24:11 +0000 by zipp
Implementing the Decorator Design Pattern for Dynamic Behavior Extension
The Decorator pattern enables the dynamic addition of behaviors to an individual object without altering its underlying structure or inheritance hierarchy. It provides a flexible alternative to subclassing by wrapping objects with decorator classes that perform additional tasks before or after delegating to the wrapped component.
Architectural ...
Posted on Tue, 04 Aug 2026 16:19:57 +0000 by MLJJ