Update of /cvsroot/jmri/test/jmri/jmrix/easydcc
In directory usw-pr-cvs1:/tmp/cvs-serv5085/jmri/jmrix/easydcc
Modified Files:
EasyDccMessageTest.java EasyDccProgrammerTest.java
EasyDccReplyTest.java EasyDccTrafficControllerTest.java
EasyDccTurnoutManagerTest.java
Log Message:
more intermediate work on EasyDCC. Not yet passing all tests
Index: EasyDccMessageTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrix/easydcc/EasyDccMessageTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** EasyDccMessageTest.java 25 Mar 2002 03:46:45 -0000 1.1
--- EasyDccMessageTest.java 30 Mar 2002 19:23:32 -0000 1.2
***************
*** 1,8 ****
! /**
* EasyDccMessageTest.java
*
* Description: JUnit tests for the EasyDccMessage class
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* EasyDccMessageTest.java
*
* Description: JUnit tests for the EasyDccMessage class
* @author Bob Jacobsen
! * @version
*/
***************
*** 22,35 ****
}
- public void testToBinaryString() {
- EasyDccMessage m = new EasyDccMessage(4);
- m.setOpCode(0x81);
- m.setElement(1, 0x02);
- m.setElement(2, 0xA2);
- m.setElement(3, 0x00);
- m.setBinary(true);
- Assert.assertEquals("string compare ", "81 02 a2 00", m.toString());
- }
-
public void testToASCIIString() {
EasyDccMessage m = new EasyDccMessage(5);
--- 22,25 ----
***************
*** 39,46 ****
m.setElement(3, 0x36);
m.setElement(4, 0x31);
- m.setBinary(false);
Assert.assertEquals("string compare ", "P 261", m.toString());
}
!
public void testGetEnable() {
EasyDccMessage m = EasyDccMessage.getEnableMain();
--- 29,35 ----
m.setElement(3, 0x36);
m.setElement(4, 0x31);
Assert.assertEquals("string compare ", "P 261", m.toString());
}
!
public void testGetEnable() {
EasyDccMessage m = EasyDccMessage.getEnableMain();
***************
*** 54,58 ****
Assert.assertEquals("isKillMain", false, m.isKillMain());
}
!
public void testReadPagedCV() {
EasyDccMessage m = EasyDccMessage.getReadPagedCV(12);
--- 43,47 ----
Assert.assertEquals("isKillMain", false, m.isKillMain());
}
!
public void testReadPagedCV() {
EasyDccMessage m = EasyDccMessage.getReadPagedCV(12);
***************
*** 64,68 ****
Assert.assertEquals("string compare ", "P012 251", m.toString());
}
!
public void testReadRegister() {
EasyDccMessage m = EasyDccMessage.getReadRegister(2);
--- 53,57 ----
Assert.assertEquals("string compare ", "P012 251", m.toString());
}
!
public void testReadRegister() {
EasyDccMessage m = EasyDccMessage.getReadRegister(2);
***************
*** 74,80 ****
Assert.assertEquals("string compare ", "S2 251", m.toString());
}
!
// from here down is testing infrastructure
!
public EasyDccMessageTest(String s) {
super(s);
--- 63,69 ----
Assert.assertEquals("string compare ", "S2 251", m.toString());
}
!
// from here down is testing infrastructure
!
public EasyDccMessageTest(String s) {
super(s);
***************
*** 86,90 ****
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
--- 75,79 ----
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
***************
*** 92,95 ****
return suite;
}
!
}
--- 81,84 ----
return suite;
}
!
}
Index: EasyDccProgrammerTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrix/easydcc/EasyDccProgrammerTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** EasyDccProgrammerTest.java 25 Mar 2002 03:46:45 -0000 1.1
--- EasyDccProgrammerTest.java 30 Mar 2002 19:23:32 -0000 1.2
***************
*** 36,40 ****
((EasyDccMessage)(t.outbound.elementAt(0))).toString());
// reply from programmer arrives
! EasyDccReply r = new EasyDccReply("**** PROGRAMMING MODE - MAIN TRACK NOW DISCONNECTED ****");
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
--- 36,40 ----
((EasyDccMessage)(t.outbound.elementAt(0))).toString());
// reply from programmer arrives
! EasyDccReply r = new EasyDccReply("P");
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
***************
*** 42,46 ****
// check write message sent
Assert.assertEquals("write message sent", 2, t.outbound.size());
! Assert.assertEquals("write message contents", "P010 020",
((EasyDccMessage)(t.outbound.elementAt(1))).toString());
// reply from programmer arrives
--- 42,46 ----
// check write message sent
Assert.assertEquals("write message sent", 2, t.outbound.size());
! Assert.assertEquals("write message contents", "P 010 020",
((EasyDccMessage)(t.outbound.elementAt(1))).toString());
// reply from programmer arrives
***************
*** 75,79 ****
((EasyDccMessage)(t.outbound.elementAt(0))).toString());
// reply from programmer arrives
! EasyDccReply r = new EasyDccReply("**** PROGRAMMING MODE - MAIN TRACK NOW DISCONNECTED ****");
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
--- 75,79 ----
((EasyDccMessage)(t.outbound.elementAt(0))).toString());
// reply from programmer arrives
! EasyDccReply r = new EasyDccReply("P");
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
***************
*** 82,92 ****
// check "read command" message sent
Assert.assertEquals("read message sent", 2, t.outbound.size());
! Assert.assertEquals("read message contents", "R010",
((EasyDccMessage)(t.outbound.elementAt(1))).toString());
// reply from programmer arrives
r = new EasyDccReply();
! r.setElement(0, '0');
! r.setElement(1, '2');
! r.setElement(2, '0');
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
--- 82,98 ----
// check "read command" message sent
Assert.assertEquals("read message sent", 2, t.outbound.size());
! Assert.assertEquals("read message contents", "R 010",
((EasyDccMessage)(t.outbound.elementAt(1))).toString());
// reply from programmer arrives
r = new EasyDccReply();
! r.setElement(0, 'C');
! r.setElement(1, 'V');
! r.setElement(2, ' ');
! r.setElement(3, '0');
! r.setElement(4, '1');
! r.setElement(5, '0');
! r.setElement(6, ' ');
! r.setElement(7, '1');
! r.setElement(8, '4');
t.sendTestReply(r);
Assert.assertEquals(" programmer listener not invoked", 0, rcvdInvoked);
Index: EasyDccReplyTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrix/easydcc/EasyDccReplyTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** EasyDccReplyTest.java 25 Mar 2002 03:46:45 -0000 1.1
--- EasyDccReplyTest.java 30 Mar 2002 19:23:32 -0000 1.2
***************
*** 1,8 ****
! /**
* EasyDccReplyTest.java
*
* Description: JUnit tests for the EasyDccReplyclass
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* EasyDccReplyTest.java
*
* Description: JUnit tests for the EasyDccReplyclass
* @author Bob Jacobsen
! * @version
*/
***************
*** 33,52 ****
m.setElement(5, 'A');
Assert.assertEquals("expected length ", 6, m.getNumDataElements());
-
- }
- public void testBinaryToString() {
- EasyDccReply m = new EasyDccReply();
- m.setBinary(true);
- m.setOpCode(0x81);
- m.setElement(1, 0x02);
- m.setElement(2, 0xA2);
- m.setElement(3, 0x00);
- Assert.assertEquals("string compare ", "81 02 a2 00", m.toString());
}
!
public void testAsciiToString() {
EasyDccReply m = new EasyDccReply();
- m.setBinary(false);
m.setOpCode('C');
m.setElement(1, 'o');
--- 33,41 ----
m.setElement(5, 'A');
Assert.assertEquals("expected length ", 6, m.getNumDataElements());
}
!
public void testAsciiToString() {
EasyDccReply m = new EasyDccReply();
m.setOpCode('C');
m.setElement(1, 'o');
***************
*** 58,62 ****
public void testSkipWhiteSpace() {
EasyDccReply m = new EasyDccReply();
- m.setBinary(false);
m.setElement(0, '0');
m.setElement(1, ' ');
--- 47,50 ----
***************
*** 73,77 ****
public void testSkipCOMMAND() {
EasyDccReply m = new EasyDccReply();
- m.setBinary(false);
m.setElement(0, ' ');
m.setElement(1, ' ');
--- 61,64 ----
***************
*** 95,99 ****
Assert.assertEquals(" not found", 0, m.skipCOMMAND(0));
m = new EasyDccReply();
- m.setBinary(false);
m.setElement(0, 'C');
m.setElement(1, 'O');
--- 82,85 ----
***************
*** 110,118 ****
Assert.assertEquals(" start of reply ", 9, m.skipCOMMAND(0));
}
!
public void testValue1() {
// value when just the string comes back
EasyDccReply m = new EasyDccReply();
- m.setBinary(false);
m.setElement(0, '0');
m.setElement(1, '2');
--- 96,103 ----
Assert.assertEquals(" start of reply ", 9, m.skipCOMMAND(0));
}
!
public void testValue1() {
// value when just the string comes back
EasyDccReply m = new EasyDccReply();
m.setElement(0, '0');
m.setElement(1, '2');
***************
*** 121,129 ****
Assert.assertEquals("value ", 27, m.value());
}
!
public void testValue2() {
// value with a "Command:" prefix
EasyDccReply m = new EasyDccReply();
- m.setBinary(false);
m.setElement(0, 'C');
m.setElement(1, 'O');
--- 106,113 ----
Assert.assertEquals("value ", 27, m.value());
}
!
public void testValue2() {
// value with a "Command:" prefix
EasyDccReply m = new EasyDccReply();
m.setElement(0, 'C');
m.setElement(1, 'O');
***************
*** 146,152 ****
Assert.assertEquals("not find ", -1, m.match("foo"));
}
!
// from here down is testing infrastructure
!
public EasyDccReplyTest(String s) {
super(s);
--- 130,136 ----
Assert.assertEquals("not find ", -1, m.match("foo"));
}
!
// from here down is testing infrastructure
!
public EasyDccReplyTest(String s) {
super(s);
***************
*** 158,162 ****
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
--- 142,146 ----
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
***************
*** 164,167 ****
return suite;
}
!
}
--- 148,151 ----
return suite;
}
!
}
Index: EasyDccTrafficControllerTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrix/easydcc/EasyDccTrafficControllerTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** EasyDccTrafficControllerTest.java 25 Mar 2002 03:46:45 -0000 1.1
--- EasyDccTrafficControllerTest.java 30 Mar 2002 19:23:32 -0000 1.2
***************
*** 38,42 ****
// send a message
EasyDccMessage m = new EasyDccMessage(3);
- m.setBinary(false);
m.setOpCode('0');
m.setElement(1, '1');
--- 38,41 ----
***************
*** 51,75 ****
}
- public void testSendBinary() throws Exception {
- EasyDccTrafficController c = new EasyDccTrafficController();
-
- // connect to iostream via port controller
- EasyDccPortControllerScaffold p = new EasyDccPortControllerScaffold();
- c.connectPort(p);
-
- // send a message
- EasyDccMessage m = new EasyDccMessage(3);
- m.setBinary(true);
- m.setOpCode(0x81);
- m.setElement(1, 0x12);
- m.setElement(2, 0x34);
- c.sendEasyDccMessage(m, new EasyDccListenerScaffold());
- Assert.assertEquals("total length ", 3, tostream.available());
- Assert.assertEquals("Char 0", 0x81, 0xFF & tostream.readByte());
- Assert.assertEquals("Char 1", 0x12, tostream.readByte());
- Assert.assertEquals("Char 2", 0x34, tostream.readByte());
- Assert.assertEquals("remaining ", 0, tostream.available());
- }
-
public void testMonitor() throws Exception {
EasyDccTrafficController c = new EasyDccTrafficController();
--- 50,53 ----
***************
*** 121,140 ****
// now send reply
! tistream.write('R');
tistream.write(0x0d);
- tistream.write('C');
- tistream.write('O');
- tistream.write('M');
- tistream.write('M');
- tistream.write('A');
- tistream.write('N');
- tistream.write('D');
- tistream.write(':');
- tistream.write(' ');
// drive the mechanism
c.handleOneIncomingReply();
Assert.assertTrue("reply received ", waitForReply());
! Assert.assertEquals("first char of reply ", 'R', rcvdReply.getOpCode());
}
--- 99,109 ----
// now send reply
! tistream.write('P');
tistream.write(0x0d);
// drive the mechanism
c.handleOneIncomingReply();
Assert.assertTrue("reply received ", waitForReply());
! Assert.assertEquals("first char of reply ", 'P', rcvdReply.getOpCode());
}
Index: EasyDccTurnoutManagerTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrix/easydcc/EasyDccTurnoutManagerTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** EasyDccTurnoutManagerTest.java 25 Mar 2002 03:46:45 -0000 1.1
--- EasyDccTurnoutManagerTest.java 30 Mar 2002 19:23:33 -0000 1.2
***************
*** 27,36 ****
public String getSystemName(int n) {
! return "NT"+n;
}
public void testAsAbstractFactory () {
// ask for a Turnout, and check type
! Turnout o = l.newTurnout("NT21", "my name");
--- 27,36 ----
public String getSystemName(int n) {
! return "ET"+n;
}
public void testAsAbstractFactory () {
// ask for a Turnout, and check type
! Turnout o = l.newTurnout("ET21", "my name");
***************
*** 42,46 ****
if (log.isDebugEnabled()) log.debug("by user name: "+l.getByUserName("my name"));
! assertTrue(null != l.getBySystemName("NT21"));
assertTrue(null != l.getByUserName("my name"));
--- 42,46 ----
if (log.isDebugEnabled()) log.debug("by user name: "+l.getByUserName("my name"));
! assertTrue(null != l.getBySystemName("ET21"));
assertTrue(null != l.getByUserName("my name"));
|