Keep par0dy with a3270
Build and Test j3270 / Build JAR & Run Tests (push) Failing after 1m3s

This commit is contained in:
2026-08-25 01:12:50 +00:00
parent b5a4978b24
commit dbe0cdaa89
5 changed files with 167 additions and 76 deletions
@@ -66,4 +66,20 @@ public class DataStreamProcessorTest {
assertEquals('A', screen.getCell(i).ucs4, "Cell " + i + " should be 'A'");
}
}
@Test
public void testReadBufferPropagatesLastAid() {
org.lib3270j.input.InputProcessor input = new org.lib3270j.input.InputProcessor(screen, translator, null);
processor.setInputProcessor(input);
input.setLastAid(AID_ENTER);
java.util.concurrent.atomic.AtomicReference<byte[]> sentData = new java.util.concurrent.atomic.AtomicReference<>();
processor.setOutputCallback(sentData::set);
byte[] rbRecord = new byte[] { (byte) CMD_RB };
processor.processRecord(rbRecord, 0, rbRecord.length, true);
assertNotNull(sentData.get());
assertEquals((byte) AID_ENTER, sentData.get()[0], "ReadBuffer must transmit operator's stored AID");
}
}
@@ -153,4 +153,50 @@ public class InputProcessorTest {
assertEquals((byte) 0xFF, sf[34]);
assertEquals((byte) AID_ENTER, sf[35]);
}
@Test
public void testSendAidSuppressesNullsInModifiedField() {
java.util.concurrent.atomic.AtomicReference<byte[]> sent = new java.util.concurrent.atomic.AtomicReference<>();
InputProcessor input = new InputProcessor(screen, translator, null) {
@Override
public void sendAid(int aidCode) {
// Call super logic by hooking via fake FSM or overriding sendAid
super.sendAid(aidCode);
}
};
// Setup screen: field attribute at 0 (unprotected, modified)
screen.erase(false);
screen.setCellFA(0, (byte) (FA_PRINTABLE | FA_MODIFY));
// Pos 1 = null (0x00)
screen.getCell(1).ec = 0x00;
// Pos 2 = 'Q' (0xD8)
screen.getCell(2).ec = (byte) 0xD8;
// Pos 3 = 'U' (0xE4)
screen.getCell(3).ec = (byte) 0xE4;
// Pos 4 = 'I' (0xC9)
screen.getCell(4).ec = (byte) 0xC9;
// Pos 5 = 'T' (0xE3)
screen.getCell(5).ec = (byte) 0xE3;
// Next field at 10 (protected)
screen.setCellFA(10, (byte) (FA_PRINTABLE | FA_PROTECT));
// Use custom callback or inspection
// Let's verify DataStreamProcessor ReadModified behavior with the same buffer
DataStreamProcessor dsp = new DataStreamProcessor(screen, translator);
dsp.setInputProcessor(input);
dsp.setOutputCallback(sent::set);
byte[] rmRecord = new byte[] { (byte) CMD_RM };
dsp.processRecord(rmRecord, 0, rmRecord.length, true);
byte[] result = sent.get();
assertNotNull(result);
// Result format: AID (1 byte), Cursor (2 bytes), SBA (1 byte), Addr (2 bytes), Data ('Q', 'U', 'I', 'T' - 4 bytes)
assertEquals(10, result.length, "Result should be AID(1) + Cursor(2) + SBA(1) + Addr(2) + Data(4)");
assertEquals((byte) ORDER_SBA, result[3]);
assertEquals((byte) 0xD8, result[6]); // 'Q'
assertEquals((byte) 0xE4, result[7]); // 'U'
assertEquals((byte) 0xC9, result[8]); // 'I'
assertEquals((byte) 0xE3, result[9]); // 'T'
}
}