Search in sources :

Example 21 with XNetReply

use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.

the class XNetSimulatorAdapterTest method testGenerateResumeOperationsReply.

@Test
public void testGenerateResumeOperationsReply() {
    XNetSimulatorAdapter a = new XNetSimulatorAdapter();
    // NOTE: this test uses reflection to test a private method.
    java.lang.reflect.Method generateReplyMethod = null;
    try {
        generateReplyMethod = a.getClass().getDeclaredMethod("generateReply", XNetMessage.class);
    } catch (java.lang.NoSuchMethodException nsm) {
        Assert.fail("Could not find method generateReply in XNetSimulatorAdapter class: ");
    }
    // override the default permissions.
    Assert.assertNotNull(generateReplyMethod);
    generateReplyMethod.setAccessible(true);
    try {
        XNetReply r = (XNetReply) generateReplyMethod.invoke(a, new XNetMessage("21 81 A0"));
        Assert.assertEquals("CS Resume Operations Reply", new XNetReply("61 82 E3"), r);
    } catch (java.lang.IllegalAccessException ite) {
        Assert.fail("could not access method generateReply in XNetSimulatoradapter class");
    } catch (java.lang.reflect.InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        Assert.fail("generateReply execution failed reason: " + cause.getMessage());
    }
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 22 with XNetReply

use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopAllReply.

@Test
public void testGenerateEmergencyStopAllReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergeny Stop All Reply", new XNetReply("81 00 81"), a.generateReply(new XNetMessage("80 80")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 23 with XNetReply

use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopLocoReplyV1V2.

@Test
public void testGenerateEmergencyStopLocoReplyV1V2() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergeny Stop Specific Loco (XNetV1,V2)", new XNetReply("01 04 05"), a.generateReply(new XNetMessage("91 02 93")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 24 with XNetReply

use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.

the class Z21XNetSimulatorAdapterTest method testGenerateCSVersionReply.

@Test
public void testGenerateCSVersionReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Version Reply", new XNetReply("63 21 30 12 60"), a.generateReply(new XNetMessage("21 21 00")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 25 with XNetReply

use of jmri.jmrix.lenz.XNetReply in project JMRI by JMRI.

the class Z21XNetTurnoutManagerTest method testz21XNetMessages.

@Test
public void testz21XNetMessages() {
    // send messages for 21, 22
    // notify that somebody else changed it...
    XNetReply m1 = new XNetReply();
    m1.setElement(0, 0x42);
    m1.setElement(1, 0x05);
    m1.setElement(2, 0x02);
    m1.setElement(3, 0x45);
    lnis.sendTestMessage(m1);
    // notify that somebody else changed it...
    XNetReply m2 = new XNetReply();
    m2.setElement(0, 0x42);
    m2.setElement(1, 0x05);
    m2.setElement(2, 0x04);
    m2.setElement(3, 0x43);
    lnis.sendTestMessage(m2);
    // try to get turnouts to see if they exist
    Assert.assertTrue(null != l.getBySystemName("XT21"));
    Assert.assertTrue(null != l.getBySystemName("XT22"));
    // check the list
    List<String> testList = new ArrayList<String>(2);
    testList.add("XT21");
    testList.add("XT22");
    Assert.assertEquals("system name list", testList, l.getSystemNameList());
}
Also used : ArrayList(java.util.ArrayList) XNetReply(jmri.jmrix.lenz.XNetReply) Test(org.junit.Test)

Aggregations

XNetReply (jmri.jmrix.lenz.XNetReply)57 XNetInterfaceScaffold (jmri.jmrix.lenz.XNetInterfaceScaffold)18 Test (org.junit.Test)17 XNetMessage (jmri.jmrix.lenz.XNetMessage)14 LenzCommandStation (jmri.jmrix.lenz.LenzCommandStation)10 IOException (java.io.IOException)3 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Z21Reply (jmri.jmrix.roco.z21.Z21Reply)1