use of jmri.SignalMast in project JMRI by JMRI.
the class SignalHeadSignalMastTest method testSignalSystemLink.
@Test
public void testSignalSystemLink() {
SignalMast s = InstanceManager.getDefault(jmri.SignalMastManager.class).provideSignalMast("IF$shsm:basic:one-searchlight:IH2");
SignalSystem sy = s.getSignalSystem();
Assert.assertNotNull(sy);
Assert.assertEquals("Proceed", s.getSignalSystem().getProperty("Clear", "indication"));
}
use of jmri.SignalMast in project JMRI by JMRI.
the class SignalHeadSignalMastTest method testAspectFail.
@Test
public void testAspectFail() {
SignalMast s = new SignalHeadSignalMast("IF$shsm:basic:one-searchlight:IH1", "user");
s.setAspect("Clear");
try {
s.setAspect("Not An Aspect, I Hope");
Assert.fail("should have thrown exception");
} catch (IllegalArgumentException e1) {
jmri.util.JUnitAppender.assertWarnMessage("attempting to set invalid aspect: Not An Aspect, I Hope on mast: user");
} catch (Exception e2) {
Assert.fail("wrong exception: " + e2);
}
// unchanged after failed request
Assert.assertEquals("check clear", "Clear", s.getAspect());
}
use of jmri.SignalMast in project JMRI by JMRI.
the class SignalHeadSignalMastTest method testConfigureTwoSearchLight.
@Test
public void testConfigureTwoSearchLight() {
SignalMast s = new SignalHeadSignalMast("IF$shsm:basic:two-searchlight:IH1:IH2", "user");
s.setAspect("Clear");
Assert.assertEquals("Clear head 1 green", SignalHead.GREEN, InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH1").getAppearance());
Assert.assertEquals("Clear head 2 red", SignalHead.RED, InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH2").getAppearance());
s.setAspect("Diverging Approach");
Assert.assertEquals("Diverging Approach head 1 red", SignalHead.RED, InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH1").getAppearance());
Assert.assertEquals("Diverging Approach head 2 yellow", SignalHead.YELLOW, InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH2").getAppearance());
}
use of jmri.SignalMast in project JMRI by JMRI.
the class SignalHeadSignalMastTest method testLit.
@Test
public void testLit() {
SignalMast m = new SignalHeadSignalMast("IF$shsm:basic:one-searchlight(IH1)", "user");
Assert.assertTrue(m.getLit());
m.setLit(false);
Assert.assertTrue(!m.getLit());
Assert.assertTrue(!InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH1").getLit());
m.setLit(true);
Assert.assertTrue(m.getLit());
Assert.assertTrue(InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead("IH1").getLit());
}
use of jmri.SignalMast in project JMRI by JMRI.
the class SignalMastIconTest method testShowIcon.
public void testShowIcon() {
if (GraphicsEnvironment.isHeadless()) {
// can't Assume in TestCase
return;
}
JFrame jf = new JFrame("SignalMastIcon Icon Test");
jf.getContentPane().setLayout(new java.awt.FlowLayout());
SignalMastIcon to = new SignalMastIcon(panel);
to.setShowAutoText(false);
jf.getContentPane().add(new JLabel("Should be yellow/red: "));
jf.getContentPane().add(to);
// reset instance manager & create test heads
jmri.util.JUnitUtil.resetInstanceManager();
InstanceManager.getDefault(jmri.SignalHeadManager.class).register(new DefaultSignalHead("IH1") {
@Override
protected void updateOutput() {
}
});
InstanceManager.getDefault(jmri.SignalHeadManager.class).register(new DefaultSignalHead("IH2") {
@Override
protected void updateOutput() {
}
});
InstanceManager.getDefault(jmri.SignalHeadManager.class).register(new DefaultSignalHead("IH3") {
@Override
protected void updateOutput() {
}
});
SignalMast s = InstanceManager.getDefault(jmri.SignalMastManager.class).provideSignalMast("IF$shsm:basic:two-searchlight:IH1:IH2");
s.setAspect("Clear");
to.setSignalMast(s.getSystemName());
s.setAspect("Clear");
s.setAspect("Approach");
jf.pack();
jf.setVisible(true);
// close
jf.dispose();
}
Aggregations