Skip to content
Snippets Groups Projects
Commit cc87bc82 authored by Fisher, Alexander (Alex) (Capt)'s avatar Fisher, Alexander (Alex) (Capt)
Browse files

Delete CommentPDUFisherTest.java

parent 3b81bb10
No related branches found
No related tags found
No related merge requests found
package MV3500Cohort2021JulySeptember.projects.Fisher;
import edu.nps.moves.dis7.enumerations.VariableRecordType;
import edu.nps.moves.dis7.pdus.Pdu;
import edu.nps.moves.dis7.utilities.PduFactory;
/**
*
* @author adfis
*/
public class CommentPDUFisherTest {
//BeforeAll
public static void setUpClass()
{
System.out.println("CommentPdusTest");
}
//AfterAll
public static void tearDownClass()
{
}
//BeforeEach
public void setUp()
{
}
//AfterEach
public void tearDown()
{
}
private Pdu receivedPdu;
//Test
public void testRoundTrip()
{
PduFactory factory = new PduFactory();
setUpReceiver();
testOne(factory.makeCommentPdu());
testOne(factory.makeCommentPdu("123_test_string"));
testOne(factory.makeCommentPdu(VariableRecordType.MODEL_TYPE, "456_test with type = modeltype"));
testOne(factory.makeCommentPdu("xyz first message","mno second message", "jkl third message"));
testOne(factory.makeCommentReliablePdu());
testOne(factory.makeCommentReliablePdu("789_test_string"));
testOne(factory.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"));
}
private void testOne(Pdu pdu)
{
sendPdu(pdu); // will wait a while
assertTrue(receivedPdu != null, "No response from network receive");
assertTrue(compare(pdu,receivedPdu),"Comparison failed");
receivedPdu = null;
}
private void sendPdu(Pdu pdu)
{
try {
Thread.sleep(250l); // make sure receiver is listening
DisNetworking disnet = new DisNetworking();
disnet.sendPdu(pdu);
Thread.sleep(1000l);
}
catch (InterruptedException ex) {
System.err.println("Error sending Multicast: " + ex.getLocalizedMessage());
System.exit(1);
}
}
private boolean compare(Pdu pdu1, Pdu pdu2)
{
return pdu1.equals(pdu2);
}
private void setUpReceiver()
{
Thread rcvThread = new Thread(() -> {
while(true) {
receivedPdu = new DisNetworking().receivePdu(); // blocks
}
});
rcvThread.setPriority(Thread.NORM_PRIORITY);
rcvThread.setDaemon(true);
rcvThread.start();
}
/**
*
* @param args
*/
public static void main(String[] args)
{
//new CommentPdusTest().testRoundTrip();
}
private void assertTrue(boolean b, String no_response_from_network_receive) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private static class CommentPdusTest {
public CommentPdusTest() {
}
//private void testRoundTrip() {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
}
private static class DisNetworking {
public DisNetworking() {
}
private Pdu receivePdu() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private void sendPdu(Pdu pdu) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
}
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