yeg
2026-08-26 f9e7ed27f6ae71f6b2d89c40b422284a7e5411d2
ruoyi-device/src/main/java/com/ruoyi/device/bts/ScriptedBtsTcpSimulator.java
File was renamed from ruoyi-device/src/test/java/com/ruoyi/device/bts/ScriptedBtsTcpSimulator.java
@@ -16,7 +16,10 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
final class ScriptedBtsTcpSimulator implements AutoCloseable
/**
 * 提供可复用的 BTS TCP 脚本设备边界,用于闭环与恢复测试。
 */
public final class ScriptedBtsTcpSimulator implements AutoCloseable
{
    private static final byte[] FRAME_END = "#\r\n".getBytes(StandardCharsets.UTF_8);
@@ -26,7 +29,7 @@
    private final BlockingQueue<ScriptedAction> actions = new LinkedBlockingQueue<>();
    private final List<String> requests = new CopyOnWriteArrayList<>();
    ScriptedBtsTcpSimulator() throws IOException
    public ScriptedBtsTcpSimulator() throws IOException
    {
        this(true);
    }
@@ -41,38 +44,38 @@
            serverSocket.close();
    }
    static ScriptedBtsTcpSimulator refusingConnections() throws IOException
    public static ScriptedBtsTcpSimulator refusingConnections() throws IOException
    {
        return new ScriptedBtsTcpSimulator(false);
    }
    int port()
    public int port()
    {
        return port;
    }
    void enqueue(String response)
    public void enqueue(String response)
    {
        actions.add(new ScriptedAction(Duration.ZERO, response.getBytes(StandardCharsets.UTF_8), false));
    }
    void enqueueDelayed(Duration delay, String response)
    public void enqueueDelayed(Duration delay, String response)
    {
        if (delay.isNegative()) throw new IllegalArgumentException("delay must not be negative");
        actions.add(new ScriptedAction(delay, response.getBytes(StandardCharsets.UTF_8), false));
    }
    void enqueueRaw(byte[] response)
    public void enqueueRaw(byte[] response)
    {
        actions.add(new ScriptedAction(Duration.ZERO, response.clone(), false));
    }
    void enqueueDisconnect()
    public void enqueueDisconnect()
    {
        actions.add(new ScriptedAction(Duration.ZERO, null, true));
    }
    List<String> requests()
    public List<String> requests()
    {
        return List.copyOf(requests);
    }