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());
}
}
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());
}
}
Aggregations