Search in sources :

Example 56 with XNetReply

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

the class XNetSimulatorAdapterTest method testEmergencyStopLocoReplyV1V2.

@Test
public void testEmergencyStopLocoReplyV1V2() {
    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("91 02 93"));
        Assert.assertEquals("CS Emergency Specific Loco (XNetV1,V2) Reply ", new XNetReply("01 04 05"), 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 57 with XNetReply

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

the class XNetSimulatorAdapterTest method testEmergencyStopAllReply.

@Test
public void testEmergencyStopAllReply() {
    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("80 80"));
        Assert.assertEquals("CS Emergency Stop All Reply ", new XNetReply("81 00 81"), 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)

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