Search in sources :

Example 51 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage 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 52 with XNetMessage

use of jmri.jmrix.lenz.XNetMessage 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)

Example 53 with XNetMessage

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

the class Z21XNetSimulatorAdapterTest method testGenerateResumeOperationsReply.

@Test
public void testGenerateResumeOperationsReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Resume Operations Reply", new XNetReply("61 82 E3"), a.generateReply(new XNetMessage("21 81 A0")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 54 with XNetMessage

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

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopReply.

@Test
public void testGenerateEmergencyStopReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergency Stop Reply", new XNetReply("61 82 E3"), a.generateReply(new XNetMessage("21 80 A1")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Example 55 with XNetMessage

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

the class Z21XNetSimulatorAdapterTest method testGenerateEmergencyStopLocoReply.

@Test
public void testGenerateEmergencyStopLocoReply() {
    Z21XNetSimulatorAdapter a = new Z21XNetSimulatorAdapter();
    Assert.assertEquals("CS Emergeny Stop Specific Loco (XNetV4)", new XNetReply("01 04 05"), a.generateReply(new XNetMessage("92 00 02 90")));
}
Also used : XNetReply(jmri.jmrix.lenz.XNetReply) XNetMessage(jmri.jmrix.lenz.XNetMessage) Test(org.junit.Test)

Aggregations

XNetMessage (jmri.jmrix.lenz.XNetMessage)55 XNetReply (jmri.jmrix.lenz.XNetReply)14 Test (org.junit.Test)14 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 IOException (java.io.IOException)1 XNetListenerScaffold (jmri.jmrix.lenz.XNetListenerScaffold)1 Z21Reply (jmri.jmrix.roco.z21.Z21Reply)1