Skip to content
Snippets Groups Projects
Commit 6a42eaf3 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

tuned naming and logic, works well

parent 01db3692
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,8 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -13,8 +13,8 @@ import static org.junit.jupiter.api.Assertions.*;
@DisplayName("Comment Pdus Test") @DisplayName("Comment Pdus Test")
public class CommentPdusTest public class CommentPdusTest
{ {
DisThreadedNetIF disThreadedNetworkInterface; DisThreadedNetIF disThreadedNetworkInterface;
Pdu receivedPdu; Pdu receivedPdu;
DisThreadedNetIF.PduListener pduListener; DisThreadedNetIF.PduListener pduListener;
@BeforeAll @BeforeAll
...@@ -52,32 +52,32 @@ public class CommentPdusTest ...@@ -52,32 +52,32 @@ public class CommentPdusTest
@Test @Test
public void testRoundTrip() public void testRoundTrip()
{ {
PduFactory factory = new PduFactory(); PduFactory pduFactory = new PduFactory();
testOne(factory.makeCommentPdu()); testOne(pduFactory.makeCommentPdu());
testOne(factory.makeCommentPdu("123_test_string")); testOne(pduFactory.makeCommentPdu("123_test_string"));
testOne(factory.makeCommentPdu(VariableRecordType.MODEL_TYPE, "456_test with type = modeltype")); testOne(pduFactory.makeCommentPdu(VariableRecordType.MODEL_TYPE, "456_test with type = modeltype"));
testOne(factory.makeCommentPdu("xyz first message","mno second message", "jkl third message")); testOne(pduFactory.makeCommentPdu("xyz first message","mno second message", "jkl third message"));
testOne(factory.makeCommentReliablePdu()); testOne(pduFactory.makeCommentReliablePdu());
testOne(factory.makeCommentReliablePdu("789_test_string")); testOne(pduFactory.makeCommentReliablePdu("789_test_string"));
testOne(factory.makeCommentReliablePdu(VariableRecordType.ACLS_AIRCRAFT_REPORT, "abc_test with type = acls_aircraft_report")); testOne(pduFactory.makeCommentReliablePdu(VariableRecordType.ACLS_AIRCRAFT_REPORT, "abc_test with type = acls_aircraft_report"));
testOne(factory.makeCommentReliablePdu("xyz R first message","mno R second message", "jkl R third message")); testOne(pduFactory.makeCommentReliablePdu("xyz R first message","mno R second message", "jkl R third message"));
} }
private void testOne(Pdu pdu) private void testOne(Pdu newPdu)
{ {
sendPdu(pdu); // will wait a while sendPdu(newPdu); // will wait a while
assertTrue(receivedPdu != null, "No response from network receive"); assertTrue(receivedPdu != null, "No response from network receiver");
assertTrue(compare(pdu,receivedPdu), "Comparison failed"); assertTrue(compare(newPdu,receivedPdu), "Comparison failed");
receivedPdu = null; receivedPdu = null; // ensure cleared prior to next test
} }
private void sendPdu(Pdu pdu) private void sendPdu(Pdu pdu)
{ {
try { try {
disThreadedNetworkInterface.send(pdu); disThreadedNetworkInterface.send(pdu);
Thread.sleep(100l); Thread.sleep(100); // TODO consider refactoring the wait logic and moving externally
} }
catch (InterruptedException ex) { catch (InterruptedException ex) {
System.err.println("Error sending Multicast: " + ex.getLocalizedMessage()); System.err.println("Error sending Multicast: " + ex.getLocalizedMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment