Search in sources :

Example 31 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class ProxyTurnoutManagerTest method testDefaultSystemName.

public void testDefaultSystemName() {
    // create
    Turnout t = l.provideTurnout("" + getNumToTest1());
    // check
    Assert.assertTrue("real object returned ", t != null);
    Assert.assertTrue("system name correct ", t == l.getBySystemName(getSystemName(getNumToTest1())));
}
Also used : Turnout(jmri.Turnout)

Example 32 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class ProxyTurnoutManagerTest method testProvideUser.

public void testProvideUser() {
    Turnout l1 = l.provideTurnout("211");
    l1.setUserName("user 1");
    Turnout l2 = l.provideTurnout("user 1");
    Turnout l3 = l.getTurnout("user 1");
    Assert.assertNotNull(l1);
    Assert.assertNotNull(l2);
    Assert.assertNotNull(l3);
    Assert.assertEquals(l1, l2);
    Assert.assertEquals(l3, l2);
    Assert.assertEquals(l1, l3);
    Turnout l4 = l.getTurnout("JLuser 1");
    Assert.assertNull(l4);
}
Also used : Turnout(jmri.Turnout)

Example 33 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class ProxyTurnoutManagerTest method testProvideFailure.

public void testProvideFailure() {
    boolean correct = false;
    try {
        Turnout t = l.provideTurnout("");
        Assert.fail("didn't throw");
    } catch (IllegalArgumentException ex) {
        correct = true;
    }
    Assert.assertTrue("Exception thrown properly", correct);
    jmri.util.JUnitAppender.assertErrorMessage("Invalid system name for turnout: JT needed JT");
}
Also used : Turnout(jmri.Turnout)

Example 34 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class ProxyTurnoutManagerTest method testRename.

public void testRename() {
    // get 
    Turnout t1 = l.newTurnout(getSystemName(getNumToTest1()), "before");
    Assert.assertNotNull("t1 real object ", t1);
    t1.setUserName("after");
    Turnout t2 = l.getByUserName("after");
    Assert.assertEquals("same object", t1, t2);
    Assert.assertEquals("no old object", null, l.getByUserName("before"));
}
Also used : Turnout(jmri.Turnout)

Example 35 with Turnout

use of jmri.Turnout in project JMRI by JMRI.

the class ProxyTurnoutManagerTest method testUpperLower.

public void testUpperLower() {
    Turnout t = l.provideTurnout("" + getNumToTest2());
    String name = t.getSystemName();
    Assert.assertNull(l.getTurnout(name.toLowerCase()));
}
Also used : Turnout(jmri.Turnout)

Aggregations

Turnout (jmri.Turnout)221 Test (org.junit.Test)63 Sensor (jmri.Sensor)26 SignalHead (jmri.SignalHead)20 Element (org.jdom2.Element)20 TurnoutManager (jmri.TurnoutManager)17 JmriException (jmri.JmriException)11 Light (jmri.Light)10 SignalMast (jmri.SignalMast)10 ActionEvent (java.awt.event.ActionEvent)9 NamedBeanHandle (jmri.NamedBeanHandle)9 JsonException (jmri.server.json.JsonException)9 ActionListener (java.awt.event.ActionListener)8 Block (jmri.Block)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 NamedBean (jmri.NamedBean)6 Route (jmri.Route)6 AbstractTurnout (jmri.implementation.AbstractTurnout)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5