Backend Development 4 min read

Using IntelliJ IDEA Scratch Files and Buffers for Quick Code Testing and MQ Simulation

IntelliJ IDEA provides two temporary editing environments—Scratch files and Scratch buffers—that enable developers to quickly write and run code snippets or HTTP requests, test APIs, simulate MQ messages, and perform white‑box testing without leaving the IDE.

转转QA
转转QA
转转QA
Using IntelliJ IDEA Scratch Files and Buffers for Quick Code Testing and MQ Simulation

Background : IntelliJ IDEA offers two temporary editing environments—Scratch files and Scratch buffers—that allow writing text or code snippets. Scratch files support full run and debug features and require a language type and file extension, while Scratch buffers are simple text files limited to five instances.

Purpose : These tools are used to test small code fragments or API calls directly in IDEA (e.g., GET requests without Postman), simulate external integrations such as MQ messages, and detect code errors for white‑box testing.

Usage Scenario 1 – MQ Simulation

1. Create a new Scratch File (Ctrl + Shift + Alt + Insert).

2. Choose “New Scratch File” and select the “HTTP Request” type.

3. Fill in the request details (URL, headers, body, etc.).

Example request:

POST https://app.zhuanzhuan.com/zzopen/c2b_offline_aggregator/mockProduceRocketMqMsg
Accept: */*
Cache-Control: no-cache
Content-Type: application/json
Cookie: t=998; zljRetrieveToken=2be3688124fc8b04bcaf465bfd00fff5

{
  "mockSourceIp": "192.168.153.109",
  "topic": "zzsc_oms_inbound",
  "tag": "3012_of_30300_0",
  "msgKey": "30120000003",
  "mockMsgContent": "{\"bizOrderId\":1451171680155353093,\"sn\":10602868,\"sku\":10602868}"
}

4. Execute the request and view the response (as shown in the original screenshots).

Usage Scenario 2 – Quick Java Code Error Check

Rotate a Java code snippet, press Ctrl + Shift + Alt + Insert, and IDEA creates a Scratch File containing the selected code, which can be run immediately to verify errors.

Summary

Learn middleware usage.

Understand MQ push and consumption mechanisms.

Gain deeper insight into development frameworks through code experimentation.

Improve white‑box testing skills.

IntelliJ IDEAHTTP requestCode TestingMQ SimulationScratch Files
转转QA
Written by

转转QA

In the era of knowledge sharing, discover 转转QA from a new perspective.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.