Search in sources :

Example 61 with SignalMast

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"));
}
Also used : SignalMast(jmri.SignalMast) SignalSystem(jmri.SignalSystem) Test(org.junit.Test)

Example 62 with SignalMast

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());
}
Also used : SignalMast(jmri.SignalMast) Test(org.junit.Test)

Example 63 with SignalMast

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());
}
Also used : SignalMast(jmri.SignalMast) Test(org.junit.Test)

Example 64 with SignalMast

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());
}
Also used : SignalMast(jmri.SignalMast) Test(org.junit.Test)

Example 65 with SignalMast

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();
}
Also used : JFrame(javax.swing.JFrame) JLabel(javax.swing.JLabel) SignalMast(jmri.SignalMast) DefaultSignalHead(jmri.implementation.DefaultSignalHead)

Aggregations

SignalMast (jmri.SignalMast)80 Test (org.junit.Test)19 NamedBean (jmri.NamedBean)11 Sensor (jmri.Sensor)11 SignalHead (jmri.SignalHead)11 Turnout (jmri.Turnout)10 SignalMastManager (jmri.SignalMastManager)9 JsonException (jmri.server.json.JsonException)9 ArrayList (java.util.ArrayList)8 JmriException (jmri.JmriException)8 Block (jmri.Block)7 SignalMastLogic (jmri.SignalMastLogic)7 Hashtable (java.util.Hashtable)6 Element (org.jdom2.Element)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 IOException (java.io.IOException)4 NamedBeanHandle (jmri.NamedBeanHandle)4 Section (jmri.Section)4 LayoutTurnout (jmri.jmrit.display.layoutEditor.LayoutTurnout)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3