Class PduTest
java.lang.Object
edu.nps.moves.dis7.test.PduTest
- Direct Known Subclasses:
DetonationPduTest
,EntityStatePduTest
,FirePduTest
,IFFPduTest
Abstract superclass for PDU testing, containing shared methods.
Originally extracted using Netbeans refactoring feature, further
updated using SignalPdusTest exemplar patterns.
- Author:
- Don Brutzman
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final long
default thread sleep interval milliseconds -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Compare all values of these two objects and report if identicalint
Accessor to get valueint
Accessor to set maximum retry attemptsstatic long
Get preferred sleep intervalint
Accessor that first increments current valuestatic boolean
Utility accessor whether verbose mode is setstatic void
preparationprotected void
sendIeeeStandardPdu
(Pdu createdPdu) Handler that passes PDU to DIS network interface for marshalling (serialization), which then sends IEEE Standard (binary) PDU to self, which is then read separately for unmarshalling (deserialization) further unit testing.void
setMasterEventNumber
(int value) Accessor to set valuevoid
setMaximumRetryAttempts
(int value) Accessor to get maximum retry attemptsstatic void
setThreadSleepInterval
(long value) Set preferred sleep intervalvoid
setUp()
Ensure network connections, listener and handler are preparedvoid
setVerbose
(boolean value) Utility accessor to set verbose modeprotected static void
sleep
(long msec) Convenience method to wrap Thread.sleep with exception handlingprotected static void
Convenience method to wrap Thread.sleep with exception handlingprotected static void
Convenience method to wrap Thread.sleep with exception handling, usingvoid
tearDown()
Ensure network connections are removedstatic void
housekeepingabstract void
Test PDU sending, receiving, marshalling (serialization) and unmarshalling (deserialization)protected abstract void
testOnePdu
(Pdu createdPdu) Test single PDU for correctness according to all contained fields in this PDU typeprotected void
testPduCommonFields
(Pdu createdPdu) Test common PDU characteristics, independent of PDU type.protected void
testPduSendReceiveHeaderMatch
(Pdu createdPdu) Initial common tests for fields in PDU header.
-
Field Details
-
THREAD_SLEEP_INTERVAL_MSEC_DEFAULT
protected static final long THREAD_SLEEP_INTERVAL_MSEC_DEFAULTdefault thread sleep interval milliseconds- See Also:
-
-
Constructor Details
-
PduTest
public PduTest()default constructor
-
-
Method Details
-
prepareClass
@BeforeAll public static void prepareClass()preparation -
tearDownClass
@AfterAll public static void tearDownClass()housekeeping -
setUp
@BeforeEach public void setUp()Ensure network connections, listener and handler are prepared -
tearDown
@AfterEach public void tearDown()Ensure network connections are removed -
sendIeeeStandardPdu
Handler that passes PDU to DIS network interface for marshalling (serialization), which then sends IEEE Standard (binary) PDU to self, which is then read separately for unmarshalling (deserialization) further unit testing.- Parameters:
createdPdu
- new PDU of interest
-
compare
-
testPduSendReceiveHeaderMatch
Initial common tests for fields in PDU header. See https://en.wikipedia.org/wiki/Marshalling_(computer_science)- Parameters:
createdPdu
- separate PDU for comparison
-
testPduCommonFields
Test common PDU characteristics, independent of PDU type. See https://en.wikipedia.org/wiki/Marshalling_(computer_science)- Parameters:
createdPdu
- separate PDU for comparison
-
testMultiplePdus
public abstract void testMultiplePdus()Test PDU sending, receiving, marshalling (serialization) and unmarshalling (deserialization) -
testOnePdu
Test single PDU for correctness according to all contained fields in this PDU type- Parameters:
createdPdu
- separate PDU for comparison
-
getThreadSleepInterval
public static long getThreadSleepInterval()Get preferred sleep interval- Returns:
- the threadSleepInterval
-
setThreadSleepInterval
public static void setThreadSleepInterval(long value) Set preferred sleep interval- Parameters:
value
- the threadSleepInterval to set
-
getMaximumRetryAttempts
public int getMaximumRetryAttempts()Accessor to set maximum retry attempts- Returns:
- the maximumRetryAttempts value
-
setMaximumRetryAttempts
public void setMaximumRetryAttempts(int value) Accessor to get maximum retry attempts- Parameters:
value
- the maximumRetryAttempts value to set
-
isVerbose
public static boolean isVerbose()Utility accessor whether verbose mode is set- Returns:
- whether verbose
-
setVerbose
public void setVerbose(boolean value) Utility accessor to set verbose mode- Parameters:
value
- the verbose value to set
-
sleep
protected static void sleep(long msec) Convenience method to wrap Thread.sleep with exception handling- Parameters:
msec
- milliseconds
-
sleep
Convenience method to wrap Thread.sleep with exception handling- Parameters:
msec
- millisecondsmessage
- name of invoking class, method
-
sleep
Convenience method to wrap Thread.sleep with exception handling, using- Parameters:
message
- name of invoking class, method
-
incrementMasterEventNumber
public int incrementMasterEventNumber()Accessor that first increments current value- Returns:
- the masterEventNumber
-
getMasterEventNumber
public int getMasterEventNumber()Accessor to get value- Returns:
- the masterEventNumber
-
setMasterEventNumber
public void setMasterEventNumber(int value) Accessor to set value- Parameters:
value
- the masterEventNumber to set
-