60 lines
1.6 KiB
Java
60 lines
1.6 KiB
Java
package jmri.jmrix.grapevine;
|
|
|
|
import jmri.implementation.AbstractLightTestBase;
|
|
import jmri.util.JUnitUtil;
|
|
|
|
import org.junit.Assert;
|
|
import org.junit.jupiter.api.*;
|
|
|
|
/**
|
|
* Tests for the jmri.jmrix.grapevine.SerialLight class.
|
|
*
|
|
* @author Bob Jacobsen
|
|
*/
|
|
public class SerialLightTest extends AbstractLightTestBase {
|
|
|
|
private GrapevineSystemConnectionMemo memo = null;
|
|
private SerialTrafficControlScaffold tcis = null;
|
|
|
|
@Override
|
|
@BeforeEach
|
|
public void setUp() {
|
|
jmri.util.JUnitUtil.setUp();
|
|
// prepare an interface
|
|
memo = new GrapevineSystemConnectionMemo();
|
|
tcis = new SerialTrafficControlScaffold(memo);
|
|
memo.setTrafficController(tcis);
|
|
tcis.registerNode(new SerialNode(1, SerialNode.NODE2002V6, tcis));
|
|
|
|
t = new SerialLight("GL1104", "t4", memo);
|
|
}
|
|
|
|
@Override
|
|
public int numListeners() {
|
|
return tcis.numListeners();
|
|
}
|
|
|
|
@Override
|
|
public void checkOffMsgSent() {
|
|
Assert.assertTrue("message sent", tcis.outbound.size() > 0);
|
|
Assert.assertEquals("content", "81 1C 81 04", tcis.outbound.elementAt(tcis.outbound.size() - 1).toString()); // CLOSED message
|
|
}
|
|
|
|
@Override
|
|
public void checkOnMsgSent() {
|
|
Assert.assertTrue("message sent", tcis.outbound.size() > 0);
|
|
Assert.assertEquals("content", "81 18 81 0C", tcis.outbound.elementAt(tcis.outbound.size() - 1).toString()); // THROWN message
|
|
}
|
|
|
|
// reset objects
|
|
@AfterEach
|
|
public void tearDown() {
|
|
tcis.terminateThreads();
|
|
tcis = null;
|
|
memo = null;
|
|
t.dispose();
|
|
JUnitUtil.tearDown();
|
|
}
|
|
|
|
}
|