Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f0e8922a7 |
No files matched your search
@@ -133,7 +133,7 @@ class GatewayEndToEndTest {
|
||||
waitFor(() -> controllerWrites().size() == 2);
|
||||
|
||||
assertEquals(List.of(1, 4143, 38), controllerWrites().get(1));
|
||||
assertEquals(1, controller.connections(), "the MK01 drops a client when a second one connects");
|
||||
assertEquals(1, controller.peakOpenConnections(), "the MK01 drops a client when a second one connects");
|
||||
|
||||
gateway.close(); // flushes the audit lines, which otherwise wait for the next flush period
|
||||
var audit = auditLines().toList();
|
||||
|
||||
@@ -30,6 +30,7 @@ public final class MockModbusServer implements Closeable {
|
||||
private final Map<Integer, Integer> input = new ConcurrentHashMap<>();
|
||||
private final AtomicInteger connections = new AtomicInteger();
|
||||
private final AtomicInteger open = new AtomicInteger();
|
||||
private final AtomicInteger peakOpen = new AtomicInteger();
|
||||
private final List<int[]> writes = new CopyOnWriteArrayList<>();
|
||||
private final List<int[]> multipleWrites = new CopyOnWriteArrayList<>();
|
||||
private volatile Duration responseDelay = Duration.ZERO;
|
||||
@@ -68,6 +69,11 @@ public final class MockModbusServer implements Closeable {
|
||||
return open.get();
|
||||
}
|
||||
|
||||
/** The most connections that were open at the same time. */
|
||||
public int peakOpenConnections() {
|
||||
return peakOpen.get();
|
||||
}
|
||||
|
||||
public void holding(int address, int value) {
|
||||
holding.put(address, value);
|
||||
}
|
||||
@@ -135,7 +141,7 @@ public final class MockModbusServer implements Closeable {
|
||||
try {
|
||||
Socket client = server.accept();
|
||||
connections.incrementAndGet();
|
||||
open.incrementAndGet();
|
||||
peakOpen.accumulateAndGet(open.incrementAndGet(), Math::max);
|
||||
Thread.ofVirtual().start(() -> serve(client));
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user