Class PduTest

java.lang.Object
edu.nps.moves.dis7.test.PduTest
Direct Known Subclasses:
DetonationPduTest, EntityStatePduTest, FirePduTest, IFFPduTest

public abstract class PduTest extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    protected static final long
    default thread sleep interval milliseconds
  • Constructor Summary

    Constructors
    Constructor
    Description
    default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    compare(Pdu pdu1, Pdu pdu2)
    Compare all values of these two objects and report if identical
    int
    Accessor to get value
    int
    Accessor to set maximum retry attempts
    static long
    Get preferred sleep interval
    int
    Accessor that first increments current value
    static boolean
    Utility accessor whether verbose mode is set
    static void
    preparation
    protected void
    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
    Accessor to set value
    void
    Accessor to get maximum retry attempts
    static void
    Set preferred sleep interval
    void
    Ensure network connections, listener and handler are prepared
    void
    setVerbose(boolean value)
    Utility accessor to set verbose mode
    protected static void
    sleep(long msec)
    Convenience method to wrap Thread.sleep with exception handling
    protected static void
    sleep(long msec, String message)
    Convenience method to wrap Thread.sleep with exception handling
    protected static void
    sleep(String message)
    Convenience method to wrap Thread.sleep with exception handling, using
    void
    Ensure network connections are removed
    static void
    housekeeping
    abstract 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 type
    protected void
    Test common PDU characteristics, independent of PDU type.
    protected void
    Initial common tests for fields in PDU header.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • THREAD_SLEEP_INTERVAL_MSEC_DEFAULT

      protected static final long THREAD_SLEEP_INTERVAL_MSEC_DEFAULT
      default 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

      protected 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.
      Parameters:
      createdPdu - new PDU of interest
    • compare

      protected boolean compare(Pdu pdu1, Pdu pdu2)
      Compare all values of these two objects and report if identical
      Parameters:
      pdu1 - first pdu
      pdu2 - second pdu
      Returns:
      true if identical values found
    • testPduSendReceiveHeaderMatch

      protected void testPduSendReceiveHeaderMatch(Pdu createdPdu)
      Initial common tests for fields in PDU header. See https://en.wikipedia.org/wiki/Marshalling_(computer_science)
      Parameters:
      createdPdu - separate PDU for comparison
    • testPduCommonFields

      protected void testPduCommonFields(Pdu createdPdu)
      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

      protected abstract void testOnePdu(Pdu createdPdu)
      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

      protected static void sleep(long msec, String message)
      Convenience method to wrap Thread.sleep with exception handling
      Parameters:
      msec - milliseconds
      message - name of invoking class, method
    • sleep

      protected static void sleep(String message)
      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