100 lines
2.7 KiB
Java
100 lines
2.7 KiB
Java
package jmri.jmrix.grapevine;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
import java.beans.PropertyVetoException;
|
|
|
|
import jmri.Light;
|
|
import jmri.util.JUnitUtil;
|
|
|
|
import org.junit.jupiter.api.*;
|
|
|
|
/**
|
|
* Tests for the SerialLightManager class
|
|
*
|
|
* @author Bob Jacobsen Copyright 2004, 2007, 2008
|
|
*/
|
|
public class SerialLightManagerTest extends jmri.managers.AbstractLightMgrTestBase {
|
|
|
|
private GrapevineSystemConnectionMemo memo = null;
|
|
|
|
@Override
|
|
public String getSystemName(int n) {
|
|
return "GL" + n;
|
|
}
|
|
|
|
@Override
|
|
protected String getASystemNameWithNoPrefix() {
|
|
return "1106";
|
|
}
|
|
|
|
@Test
|
|
public void testAsAbstractFactory() {
|
|
// ask for a Light, and check type
|
|
Light o = l.newLight("GL1105", "my name");
|
|
assertNotNull( o);
|
|
assertInstanceOf( SerialLight.class, o);
|
|
|
|
// make sure loaded into tables
|
|
assertNotNull( l.getBySystemName("GL1105"));
|
|
assertNotNull( l.getByUserName("my name"));
|
|
|
|
}
|
|
|
|
@Override
|
|
@Test
|
|
public void testRegisterDuplicateSystemName() throws PropertyVetoException, NoSuchFieldException,
|
|
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
|
testRegisterDuplicateSystemName(l,
|
|
l.makeSystemName("1107"),
|
|
l.makeSystemName("1109"));
|
|
}
|
|
|
|
@Override
|
|
@Test
|
|
public void testMakeSystemName() {
|
|
String s = l.makeSystemName("1107");
|
|
assertNotNull(s);
|
|
assertFalse(s.isEmpty());
|
|
}
|
|
|
|
/**
|
|
* Number of light to test. Use 9th output on node 1.
|
|
*/
|
|
@Override
|
|
protected int getNumToTest1() {
|
|
return 1109;
|
|
}
|
|
|
|
@Override
|
|
protected int getNumToTest2() {
|
|
return 1107;
|
|
}
|
|
|
|
@BeforeEach
|
|
@Override
|
|
public void setUp() {
|
|
JUnitUtil.setUp();
|
|
|
|
// replace the SerialTrafficController
|
|
memo = new GrapevineSystemConnectionMemo();
|
|
SerialTrafficController t = new SerialTrafficControlScaffold(memo);
|
|
memo.setTrafficController(t);
|
|
t.registerNode(new SerialNode(1, SerialNode.NODE2002V6, t));
|
|
// create and register the manager object
|
|
l = new SerialLightManager(memo);
|
|
jmri.InstanceManager.setLightManager(l);
|
|
}
|
|
|
|
@AfterEach
|
|
public void tearDown() {
|
|
JUnitUtil.clearShutDownManager(); // put in place because AbstractMRTrafficController implementing subclass was not terminated properly
|
|
JUnitUtil.tearDown();
|
|
}
|
|
|
|
// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SerialLightManagerTest.class);
|
|
|
|
}
|