public void testInvokeNoLock() throws JmriException { OsIndicator os = new OsIndicator("IT12", "IS34", ""); Turnout t1 = InstanceManager.turnoutManagerInstance().provideTurnout("IT12"); t1.setCommandedState(Turnout.CLOSED); Sensor s1 = InstanceManager.sensorManagerInstance().provideSensor("IS34"); s1.setKnownState(Sensor.INACTIVE); Assert.assertEquals("sensor before", Sensor.INACTIVE, s1.getKnownState()); Assert.assertEquals("output before", Turnout.CLOSED, t1.getCommandedState()); os.instantiate(); Assert.assertEquals("sensor after instantiate", Sensor.INACTIVE, s1.getKnownState()); Assert.assertEquals("output after instantiate", Turnout.CLOSED, t1.getCommandedState()); // and change s1.setKnownState(Sensor.ACTIVE); Assert.assertEquals("sensor after activate", Sensor.ACTIVE, s1.getKnownState()); Assert.assertEquals("output after activate", Turnout.THROWN, t1.getCommandedState()); s1.setKnownState(Sensor.INACTIVE); Assert.assertEquals("sensor after inactivate", Sensor.INACTIVE, s1.getKnownState()); Assert.assertEquals("output after inactivate", Turnout.CLOSED, t1.getCommandedState()); }
public void testIntantiateLocked() throws JmriException { OsIndicator os = new OsIndicator("IT12", "IS34", "IS56"); Turnout t1 = InstanceManager.turnoutManagerInstance().provideTurnout("IT12"); t1.setCommandedState(Turnout.CLOSED); Sensor s1 = InstanceManager.sensorManagerInstance().provideSensor("IS34"); s1.setKnownState(Sensor.INACTIVE); Sensor s2 = InstanceManager.sensorManagerInstance().provideSensor("IS56"); s2.setKnownState(Sensor.INACTIVE); Assert.assertEquals("sensor before", Sensor.INACTIVE, s1.getKnownState()); Assert.assertEquals("lock before", Sensor.INACTIVE, s2.getKnownState()); Assert.assertEquals("output before", Turnout.CLOSED, t1.getCommandedState()); os.instantiate(); Assert.assertEquals("sensor after instantiate", Sensor.INACTIVE, s1.getKnownState()); Assert.assertEquals("lock after instantiate", Sensor.INACTIVE, s2.getKnownState()); Assert.assertEquals("output after instantiate", Turnout.CLOSED, t1.getCommandedState()); }