diff --git a/test/edu/nps/moves/dis7/test/AllPduRoundTripTest.java b/test/edu/nps/moves/dis7/test/AllPduRoundTripTest.java index c7617802d53d780cc92a8cde79470930ad95b3e4..67bfb0e479ec97fd19dc4077fdef207bad73800b 100644 --- a/test/edu/nps/moves/dis7/test/AllPduRoundTripTest.java +++ b/test/edu/nps/moves/dis7/test/AllPduRoundTripTest.java @@ -42,31 +42,36 @@ public class AllPduRoundTripTest PduFactory pduFactory; PduRecorder pduRecorder; + /** Prepare */ @BeforeAll public static void beforeAllTests() { System.out.println("AllPduRoundTripTest"); + File file = new File("./pduLog"); + + for (File subFile : file.listFiles()) { + subFile.delete(); + } } + /** Finish */ @AfterAll public static void afterAllTests() { } - @BeforeEach + /** Setup initialization before each test */ + @BeforeEach public void setUp() { - File file = new File("./pduLog"); - - for (File subFile : file.listFiles()) { - subFile.delete(); - } } + /** Housekeeping after each test */ @AfterEach public void tearDown() { } + /** Check ability to send and receive each DIS PDU */ @Test public void testRoundTripAllPdus() { @@ -77,6 +82,7 @@ public class AllPduRoundTripTest pduFactory = new PduFactory(Country.PHILIPPINES_PHL, (byte) 11, (byte) 22, (short) 33, DisTime.TimestampStyle.IEEE_ABSOLUTE); + // 72 total pdusSent.add(pduFactory.makeAcknowledgePdu()); pdusSent.add(pduFactory.makeAcknowledgeReliablePdu()); pdusSent.add(pduFactory.makeActionRequestPdu()); @@ -176,7 +182,12 @@ public class AllPduRoundTripTest System.out.println ("*** AllPduRoundTripTest testRoundTripAllPdus() complete"); } - private void setupSenderRecorder() throws Exception { + /** setup the common send/receive network interface + * @see PduRecorder + * @see DisNetworkInterface + */ + private void setupSenderRecorder() throws Exception + { pduRecorder = new PduRecorder(); // default network address, port, logfile dir pduRecorder.setDescriptor(this.getClass().getName() + " unit test"); pduRecorder.start(); @@ -197,13 +208,13 @@ public class AllPduRoundTripTest System.out.println("Recorder log at " + pduRecorder.getLogFilePath()); } - /** Will shutdown the common send/receive network interface */ + /** shutdown the common send/receive network interface */ private void shutDownSenderRecorder() throws Exception { disNetworkInterface.removeListener(pduListener); pduRecorder.stop(); } - + /** comparison test */ private void testForEquals() throws Exception { // System.out.println("*** Warning: ensure no prior dislog files are present in pduLog directory or assertion count of replay will fail."); @@ -215,7 +226,8 @@ public class AllPduRoundTripTest assertIterableEquals(pdusSent, pdusReceived, "Sent and received pdus not identical"); System.out.println("... testForEquals() assertIterableEquals() passed"); } - + /** not used, legacy code */ + @Deprecated private void getAllFromRecorder(Semaphore sem) throws Exception { sem.acquire(); @@ -233,6 +245,8 @@ public class AllPduRoundTripTest }); } + /** not used, legacy code */ + @Deprecated private void testRecorderForEquals() throws Exception { // TODO this may fail if prior dislog files are present in pduLog directory, ignore them to make it less brittle @@ -249,7 +263,7 @@ public class AllPduRoundTripTest // TODO is this sufficient? has each PDU value been compared as well? } - + /** being careful during threaded operations, also encourage in-order receipt before next send */ private static void sleep(long ms) { try { Thread.sleep(ms); @@ -258,8 +272,12 @@ public class AllPduRoundTripTest } } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { + System.out.println ("*** AllPduRoundTripTest main() started..."); AllPduRoundTripTest allPduRoundTripTest = new AllPduRoundTripTest(); // create instance allPduRoundTripTest.testRoundTripAllPdus(); System.out.println ("*** AllPduRoundTripTest main() complete"); diff --git a/test/edu/nps/moves/dis7/test/CommentPdusTest.java b/test/edu/nps/moves/dis7/test/CommentPdusTest.java index 40017d44a337f31a807ac1750a0624908ee13097..1e58048446b6c794b95ebb176e8db4fc22c6f0c1 100644 --- a/test/edu/nps/moves/dis7/test/CommentPdusTest.java +++ b/test/edu/nps/moves/dis7/test/CommentPdusTest.java @@ -22,17 +22,20 @@ public class CommentPdusTest Pdu receivedPdu; DisThreadedNetworkInterface.PduListener pduListener; + /** Setup initialization before each test */ @BeforeAll public static void setUpClass() { System.out.println("CommentPdusTest"); } + /** Housekeeping after each test */ @AfterAll public static void tearDownClass() { } + /** Setup initialization before each test */ @BeforeEach public void setUp() { @@ -46,6 +49,7 @@ public class CommentPdusTest disNetworkInterface.addListener(pduListener); } + /** Housekeeping after each test */ @AfterEach public void tearDown() { @@ -91,6 +95,7 @@ public class CommentPdusTest receivedPdu = null; // ensure cleared prior to next test } + /** send the PDU of interest */ private void sendPdu(Pdu pdu) { try { @@ -103,6 +108,7 @@ public class CommentPdusTest } } + /** comparison test */ private boolean compare(Pdu pdu1, Pdu pdu2) { return pdu1.equals(pdu2); @@ -113,6 +119,9 @@ public class CommentPdusTest receivedPdu = newPdu; } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { CommentPdusTest commentPdusTest = new CommentPdusTest(); diff --git a/test/edu/nps/moves/dis7/test/CreateAllObjectTypesTest.java b/test/edu/nps/moves/dis7/test/CreateAllObjectTypesTest.java index 6988152fa5a5272112bb4bc5fd3a17b558b00909..839274ef60d6bc588d31ba3ddaddac4f249552ef 100644 --- a/test/edu/nps/moves/dis7/test/CreateAllObjectTypesTest.java +++ b/test/edu/nps/moves/dis7/test/CreateAllObjectTypesTest.java @@ -19,27 +19,32 @@ import static org.junit.jupiter.api.Assertions.assertNull; @DisplayName("All Object Types Create") public class CreateAllObjectTypesTest { + /** preparation **/ @BeforeAll public static void beforeAllTests() { System.out.println("CreateAllObjectTypesTest"); } + /** housekeeping **/ @AfterAll public static void afterAllTests() { } + /** Setup initialization before each test */ @BeforeEach public void setUp() { } + /** Housekeeping after all tests */ @AfterEach public void tearDown() { } + /** Perform test of interest */ @Test public void testCreateAllObjectTypes() { @@ -276,6 +281,9 @@ public class CreateAllObjectTypesTest System.out.println(String.format(formatString, name, domain, kind, objectType.getCategory(), objectType.getSubCategory())); } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { new CreateAllObjectTypesTest().testCreateAllObjectTypes(); diff --git a/test/edu/nps/moves/dis7/test/CreateAllPduTypesTest.java b/test/edu/nps/moves/dis7/test/CreateAllPduTypesTest.java index 6c16315a1b7a75204462106bd7bfd1629dd52c9c..bc20519e2ecde96ee3afa62282467f8b1b630e1c 100644 --- a/test/edu/nps/moves/dis7/test/CreateAllPduTypesTest.java +++ b/test/edu/nps/moves/dis7/test/CreateAllPduTypesTest.java @@ -94,26 +94,31 @@ import org.junit.jupiter.api.Test; */ public class CreateAllPduTypesTest { + /** constructor */ public CreateAllPduTypesTest() { } + /** preparation **/ @BeforeAll public static void setUpClass() { System.out.println("CreateAllPduTypesTest"); } + /** Housekeeping after all tests */ @AfterAll public static void tearDownClass() { } + /** Setup initialization before each test */ @BeforeEach public void setUp() { } + /** Housekeeping after each test */ @AfterEach public void tearDown() { @@ -124,6 +129,7 @@ public class CreateAllPduTypesTest private Throwable throwable; + /** Perform test of interest */ @Test public void testCreateAll() { @@ -228,6 +234,9 @@ public class CreateAllPduTypesTest assertNull(throwable, "Exception should be null if successful marshal"); } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { new CreateAllPduTypesTest().testCreateAll(); diff --git a/test/edu/nps/moves/dis7/test/DataQueryPduRoundTripTest.java b/test/edu/nps/moves/dis7/test/DataQueryPduRoundTripTest.java index e4999533abe893731299efaa9513a4f81fdc9494..1cf74f92b03b432f43e27bb9f7a23005940b5523 100644 --- a/test/edu/nps/moves/dis7/test/DataQueryPduRoundTripTest.java +++ b/test/edu/nps/moves/dis7/test/DataQueryPduRoundTripTest.java @@ -26,17 +26,20 @@ public class DataQueryPduRoundTripTest DisThreadedNetworkInterface disNetworkInterface; DisThreadedNetworkInterface.PduListener pduListener; + /** preparation **/ @BeforeAll public static void setUpClass() { System.out.println("DataQueryPduRoundTripTest"); } + /** Housekeeping after all tests */ @AfterAll public static void tearDownClass() { } + /** Setup initialization before each test */ @BeforeEach public void setUp() { @@ -50,6 +53,7 @@ public class DataQueryPduRoundTripTest disNetworkInterface.addListener(pduListener); } + /** Housekeeping after each test */ @AfterEach public void tearDown() { @@ -97,6 +101,7 @@ public class DataQueryPduRoundTripTest // variableDatum2.setVariableDatumLength(variableDatum2Value.length); // should be done automatically } + /** Perform test of interest */ @Test public void testRoundTrip() { @@ -132,6 +137,9 @@ public class DataQueryPduRoundTripTest receivedPdu = pdu; } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { DataQueryPduRoundTripTest drt = new DataQueryPduRoundTripTest(); diff --git a/test/edu/nps/moves/dis7/test/DetonationPduTest.java b/test/edu/nps/moves/dis7/test/DetonationPduTest.java index da3748c3830f30d04efa79c3639042b2f1bb909d..1352e0255d2c2fbd6de3d8413ca574a22e433e2d 100644 --- a/test/edu/nps/moves/dis7/test/DetonationPduTest.java +++ b/test/edu/nps/moves/dis7/test/DetonationPduTest.java @@ -47,6 +47,7 @@ import org.junit.jupiter.api.Test; @DisplayName("Detonation Pdu Test") public class DetonationPduTest extends PduTest { + /** constructor **/ public DetonationPduTest() { } @@ -94,6 +95,9 @@ public class DetonationPduTest extends PduTest { testPduFinishingChecks(createdPdu); // shared tests in superclass } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { PduTest detonationPduTest = new DetonationPduTest(); diff --git a/test/edu/nps/moves/dis7/test/EntityStatePduTest.java b/test/edu/nps/moves/dis7/test/EntityStatePduTest.java index 95745c0b3ea2a1d3d925b7a25415eee6b050b10c..c91e50f5d48a2a94b4a704e838371698a18c71cf 100644 --- a/test/edu/nps/moves/dis7/test/EntityStatePduTest.java +++ b/test/edu/nps/moves/dis7/test/EntityStatePduTest.java @@ -93,6 +93,9 @@ public class EntityStatePduTest extends PduTest testPduFinishingChecks(createdPdu); // shared tests in superclass } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { EntityStatePduTest entityStatePduTest = new EntityStatePduTest(); diff --git a/test/edu/nps/moves/dis7/test/MarshalEnumsTest.java b/test/edu/nps/moves/dis7/test/MarshalEnumsTest.java index eb67c3e5a05610f8c45d0846705b13a0cd54b639..0f47e07690a61592a85455c577b2b988720a6d0f 100644 --- a/test/edu/nps/moves/dis7/test/MarshalEnumsTest.java +++ b/test/edu/nps/moves/dis7/test/MarshalEnumsTest.java @@ -18,27 +18,32 @@ import static org.junit.jupiter.api.Assertions.assertNull; @DisplayName("Marshal Enums Test") public class MarshalEnumsTest { + /** preparation **/ @BeforeAll public static void setUpClass() { System.out.println("MarshalEnumsTest"); } + /** Housekeeping after all tests */ @AfterAll public static void tearDownClass() { } + /** Setup initialization before each test */ @BeforeEach public void setUp() { } + /** Housekeeping after each test */ @AfterEach public void tearDown() { } + /** Perform test of interest */ @Test public void testGoodMarshall() { @@ -591,6 +596,9 @@ public class MarshalEnumsTest System.out.println(); } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { new MarshalEnumsTest().testGoodMarshall(); diff --git a/test/edu/nps/moves/dis7/test/NullFieldsEntityMarshallTest.java b/test/edu/nps/moves/dis7/test/NullFieldsEntityMarshallTest.java index 1a6dfdec2b118597c01619b57bbfa3e499789b19..e2208a88ddf794005b4df7c820ffadfb3b4f90b0 100644 --- a/test/edu/nps/moves/dis7/test/NullFieldsEntityMarshallTest.java +++ b/test/edu/nps/moves/dis7/test/NullFieldsEntityMarshallTest.java @@ -21,28 +21,33 @@ public class NullFieldsEntityMarshallTest { LAV105 lav105; + /** preparation **/ @BeforeAll public static void beforeAllTests() { System.out.println("NullFieldsEntityMarshallTest"); } + /** housekeeping **/ @AfterAll public static void afterAllTests() {} + /** Setup initialization before each test */ @BeforeEach public void setUp() { lav105 = new LAV105(); } + /** Housekeeping after each test */ @AfterEach public void tearDown() { lav105 = null; } + /** Perform test of interest */ @Test public void testNoSpecificNoExtraMarshal() { @@ -61,6 +66,7 @@ public class NullFieldsEntityMarshallTest assertEquals(8, byteBuffer.position(), "Marshalled array should be 8 bytes long"); } + /** Perform test of interest */ @Test public void testGoodMarshall() { @@ -100,6 +106,9 @@ public class NullFieldsEntityMarshallTest System.out.println("LAV_105 extra: " + entityType.getExtra()); } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { NullFieldsEntityMarshallTest inst = new NullFieldsEntityMarshallTest(); diff --git a/test/edu/nps/moves/dis7/test/ObjectTypeMarshallTest.java b/test/edu/nps/moves/dis7/test/ObjectTypeMarshallTest.java index b0eef63f35883c98e8d3c3e0e2bed1856d955c0b..c8e62349a505867f6119dfa57015dc11163aab7f 100644 --- a/test/edu/nps/moves/dis7/test/ObjectTypeMarshallTest.java +++ b/test/edu/nps/moves/dis7/test/ObjectTypeMarshallTest.java @@ -18,18 +18,25 @@ import static org.junit.jupiter.api.Assertions.assertNull; @DisplayName("Object Type Marshal Test") public class ObjectTypeMarshallTest { + /** preparation **/ @BeforeAll public static void setUpClass() { System.out.println("ObjectTypeMarshallTest"); } + /** Housekeeping after all tests */ @AfterAll public static void tearDownClass(){} + + /** Setup initialization before each test */ @BeforeEach public void setUp(){} + + /** Housekeeping after each test */ @AfterEach public void tearDown(){} + /** Perform test of interest */ @Test public void testGoodMarshall() { @@ -44,6 +51,7 @@ public class ObjectTypeMarshallTest assertNull(thr, "Exception should be null if successful marshal"); } + /** Perform test of interest */ @Test public void testNoSubCategory() { @@ -85,6 +93,9 @@ public class ObjectTypeMarshallTest System.out.println(String.format(formatStr, nm, dom, kind, ot.getCategory(), ot.getSubCategory())); } + /** Command-line invocation (CLI) of program, execution starts here + * @param args command-line arguments + */ public static void main(String[] args) { ObjectTypeMarshallTest inst = new ObjectTypeMarshallTest(); diff --git a/test/edu/nps/moves/dis7/test/PduTest.java b/test/edu/nps/moves/dis7/test/PduTest.java index 405cc05dd71c836ffd75c0bf79c37737249865ff..6287fcc5e2f6d8229e81f20b901db927ea645b3d 100644 --- a/test/edu/nps/moves/dis7/test/PduTest.java +++ b/test/edu/nps/moves/dis7/test/PduTest.java @@ -50,6 +50,7 @@ import org.junit.jupiter.api.BeforeEach; abstract public class PduTest { + /** default thread sleep interval msec */ protected final long THREAD_SLEEP_INTERVAL_MSEC_DEFAULT = 1000l; // e.g. 100 msec, type long private long threadSleepInterval = THREAD_SLEEP_INTERVAL_MSEC_DEFAULT; private int maximumRetryAttempts = 10; @@ -58,12 +59,14 @@ abstract public class PduTest DisThreadedNetworkInterface disNetworkInterface; DisThreadedNetworkInterface.PduListener pduListener; + /** preparation **/ @BeforeAll public static void setUpClass() { System.out.println("EntityStatePduTest"); } + /** housekeeping **/ @AfterAll public static void tearDownClass() {