Add Read Modified Query from Moshix bug report
Build and Test j3270 / Build JAR & Run Tests (Java 11) (push) Successful in 1m19s
Build and Test j3270 / Build JAR & Run Tests (Java 21) (push) Successful in 1m24s
Build and Test j3270 / Build JAR & Run Tests (Java 17) (push) Successful in 1m43s
Release j3270 / Build & Publish Release (push) Successful in 39s

This commit is contained in:
2026-09-24 15:35:08 +00:00
parent 0d6ab31f0a
commit bd4c1f3040
2 changed files with 136 additions and 11 deletions
@@ -271,4 +271,91 @@ public class DataStreamProcessorTest {
assertEquals('8', screen.getCell(12).ucs4);
assertEquals('9', screen.getCell(13).ucs4);
}
@Test
public void testReadPartitionReadModifiedReturnsAidQreply() {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
processor.setOutputSender(out::writeBytes);
// Send WSF Read Partition with SNA_CMD_RM (0xF6)
byte[] sfRm = new byte[] {
(byte) CMD_WSF, 0x00, 0x05, (byte) SF_READ_PART, 0x00, (byte) SNA_CMD_RM
};
out.reset();
processor.processRecord(sfRm, 0, sfRm.length, true);
byte[] sent = out.toByteArray();
assertTrue(sent.length >= 3, "Inbound data stream must contain at least AID and cursor address");
assertEquals((byte) AID_QREPLY, sent[0], "Read Partition Read Modified AID must be AID_QREPLY (0x61)");
// Send WSF Read Partition with CMD_RM (0x06)
byte[] sfRmNonSna = new byte[] {
(byte) CMD_WSF, 0x00, 0x05, (byte) SF_READ_PART, 0x00, (byte) CMD_RM
};
out.reset();
processor.processRecord(sfRmNonSna, 0, sfRmNonSna.length, true);
sent = out.toByteArray();
assertTrue(sent.length >= 3);
assertEquals((byte) AID_QREPLY, sent[0], "Read Partition Read Modified (non-SNA) AID must be AID_QREPLY (0x61)");
}
@Test
public void testReadPartitionReadModifiedAllReturnsAidQreply() {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
processor.setOutputSender(out::writeBytes);
// Send WSF Read Partition with SNA_CMD_RMA (0x6E)
byte[] sfRma = new byte[] {
(byte) CMD_WSF, 0x00, 0x05, (byte) SF_READ_PART, 0x00, (byte) SNA_CMD_RMA
};
out.reset();
processor.processRecord(sfRma, 0, sfRma.length, true);
byte[] sent = out.toByteArray();
assertTrue(sent.length >= 3);
assertEquals((byte) AID_QREPLY, sent[0], "Read Partition Read Modified All AID must be AID_QREPLY (0x61)");
}
@Test
public void testReadPartitionReadBufferReturnsAidQreply() {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
processor.setOutputSender(out::writeBytes);
// Send WSF Read Partition with SNA_CMD_RB (0xF2)
byte[] sfRb = new byte[] {
(byte) CMD_WSF, 0x00, 0x05, (byte) SF_READ_PART, 0x00, (byte) SNA_CMD_RB
};
out.reset();
processor.processRecord(sfRb, 0, sfRb.length, true);
byte[] sent = out.toByteArray();
assertTrue(sent.length >= 3);
assertEquals((byte) AID_QREPLY, sent[0], "Read Partition Read Buffer AID must be AID_QREPLY (0x61)");
}
@Test
public void testReadModifiedAfterQueryRespondsWithQueryReply() {
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
processor.setOutputSender(out::writeBytes);
// 1. Send WSF Read Partition Query
byte[] sfQuery = new byte[] {
(byte) CMD_WSF, 0x00, 0x05, (byte) SF_READ_PART, (byte) 0xFF, (byte) SF_RP_QUERY
};
out.reset();
processor.processRecord(sfQuery, 0, sfQuery.length, true);
assertTrue(processor.isQreplyPending(), "qreplyPending should be true after query");
// 2. Mainframe issues channel Read Modified command (0x06) to poll the query reply
byte[] rmCmd = new byte[] { (byte) CMD_RM };
out.reset();
processor.processRecord(rmCmd, 0, rmCmd.length, true);
byte[] sent = out.toByteArray();
assertTrue(sent.length > 0, "Should have received query reply data");
assertEquals((byte) AID_SF, sent[0], "Query reply header AID must be AID_SF (0x88)");
assertFalse(processor.isQreplyPending(), "qreplyPending should be cleared after reply is sent");
}
}