|
From: Bob J. <jac...@us...> - 2002-03-31 19:07:10
|
Update of /cvsroot/jmri/test/jmri/jmrit/symbolicprog
In directory usw-pr-cvs1:/tmp/cvs-serv5843/jmrit/symbolicprog
Modified Files:
CvValueTest.java LongAddrVariableValueTest.java
VariableTableModelTest.java VariableValueTest.java
Log Message:
remove a bunch of assert deprecation wanrings
Index: CvValueTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrit/symbolicprog/CvValueTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** CvValueTest.java 2 Mar 2002 20:13:24 -0000 1.1.1.1
--- CvValueTest.java 31 Mar 2002 19:07:03 -0000 1.2
***************
*** 1,8 ****
! /**
* CvValueTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* CvValueTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
***************
*** 25,35 ****
new CvValue(12);
}
!
// can we create one and manipulate info?
public void testCvValCreate() {
CvValue cv = new CvValue(19);
! assert(cv.number() == 19);
cv.setValue(23);
! assert(cv.getValue() == 23);
}
--- 25,35 ----
new CvValue(12);
}
!
// can we create one and manipulate info?
public void testCvValCreate() {
CvValue cv = new CvValue(19);
! Assert.assertTrue(cv.number() == 19);
cv.setValue(23);
! Assert.assertTrue(cv.getValue() == 23);
}
***************
*** 39,43 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(91);
--- 39,43 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(91);
***************
*** 54,62 ****
if (i==0) log.warn("textCvValRead saw an immediate return from isBusy");
! assert(i<100);
! assert(cv.getValue() == 123);
! assert(cv.getState() == CvValue.READ);
}
!
// check a confirm operation
public void testCvValConfirmFail() {
--- 54,62 ----
if (i==0) log.warn("textCvValRead saw an immediate return from isBusy");
! Assert.assertTrue(i<100);
! Assert.assertTrue(cv.getValue() == 123);
! Assert.assertTrue(cv.getState() == CvValue.READ);
}
!
// check a confirm operation
public void testCvValConfirmFail() {
***************
*** 65,69 ****
InstanceManager.setProgrammer(p);
p._confirmOK = false;
!
// create the CV value
CvValue cv = new CvValue(66);
--- 65,69 ----
InstanceManager.setProgrammer(p);
p._confirmOK = false;
!
// create the CV value
CvValue cv = new CvValue(66);
***************
*** 86,90 ****
Assert.assertEquals("CV state ", CvValue.UNKNOWN, cv.getState());
}
!
// check a confirm operation
public void testCvValConfirmPass() {
--- 86,90 ----
Assert.assertEquals("CV state ", CvValue.UNKNOWN, cv.getState());
}
!
// check a confirm operation
public void testCvValConfirmPass() {
***************
*** 93,97 ****
p._confirmOK = true;
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(66);
--- 93,97 ----
p._confirmOK = true;
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(66);
***************
*** 114,118 ****
Assert.assertEquals("CV state ", CvValue.READ, cv.getState());
}
!
// check a write operation
public void testCvValWrite() {
--- 114,118 ----
Assert.assertEquals("CV state ", CvValue.READ, cv.getState());
}
!
// check a write operation
public void testCvValWrite() {
***************
*** 120,128 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(91);
cv.setValue(12);
! cv.write(null);
// wait for reply (normally, done by callback; will check that later)
int i = 0;
--- 120,128 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
// create the CV value
CvValue cv = new CvValue(91);
cv.setValue(12);
! cv.write(null);
// wait for reply (normally, done by callback; will check that later)
int i = 0;
***************
*** 141,153 ****
Assert.assertEquals("last value written ", 12, p.lastWrite());
}
!
// check the state diagram
public void testCvValStates() {
CvValue cv = new CvValue(21);
! assert(cv.getState() == CvValue.UNKNOWN);
cv.setValue(23);
! assert(cv.getState() == CvValue.EDITTED);
}
!
// check the initial color
public void testInitialColor() {
--- 141,153 ----
Assert.assertEquals("last value written ", 12, p.lastWrite());
}
!
// check the state diagram
public void testCvValStates() {
CvValue cv = new CvValue(21);
! Assert.assertTrue(cv.getState() == CvValue.UNKNOWN);
cv.setValue(23);
! Assert.assertTrue(cv.getState() == CvValue.EDITTED);
}
!
// check the initial color
public void testInitialColor() {
***************
*** 155,159 ****
Assert.assertEquals("initial color", CvValue.COLOR_UNKNOWN, cv.getTableEntry().getBackground());
}
!
// check color update for EDITTED
public void testEdittedColor() {
--- 155,159 ----
Assert.assertEquals("initial color", CvValue.COLOR_UNKNOWN, cv.getTableEntry().getBackground());
}
!
// check color update for EDITTED
public void testEdittedColor() {
***************
*** 162,169 ****
Assert.assertEquals("editted color", CvValue.COLOR_EDITTED, cv.getTableEntry().getBackground());
}
!
// from here down is testing infrastructure
!
public CvValueTest(String s) {
super(s);
--- 162,169 ----
Assert.assertEquals("editted color", CvValue.COLOR_EDITTED, cv.getTableEntry().getBackground());
}
!
// from here down is testing infrastructure
!
public CvValueTest(String s) {
super(s);
***************
*** 175,179 ****
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
--- 175,179 ----
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
***************
*** 181,185 ****
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(CvValue.class.getName());
--- 181,185 ----
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(CvValue.class.getName());
Index: LongAddrVariableValueTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrit/symbolicprog/LongAddrVariableValueTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** LongAddrVariableValueTest.java 2 Mar 2002 20:13:24 -0000 1.1.1.1
--- LongAddrVariableValueTest.java 31 Mar 2002 19:07:03 -0000 1.2
***************
*** 1,8 ****
! /**
* LongAddrVariableValueTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* LongAddrVariableValueTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
***************
*** 40,62 ****
void setValue(VariableValue var, String val) {
((JTextField)var.getValue()).setText(val);
! ((JTextField)var.getValue()).postActionEvent();
}
!
void setReadOnlyValue(VariableValue var, String val) {
((LongAddrVariableValue)var).setValue(Integer.valueOf(val).intValue());
}
!
void checkValue(VariableValue var, String comment, String val) {
Assert.assertEquals(comment, val, ((JTextField)var.getValue()).getText() );
}
!
void checkReadOnlyValue(VariableValue var, String comment, String val) {
Assert.assertEquals(comment, val, ((JLabel)var.getValue()).getText() );
}
!
// end of abstract members
!
// some of the premade tests don't quite make sense; override them here.
!
public void testVariableValueCreate() {}// mask is ignored by LongAddr
public void testVariableFromCV() {} // low CV is upper part of address
--- 40,62 ----
void setValue(VariableValue var, String val) {
((JTextField)var.getValue()).setText(val);
! ((JTextField)var.getValue()).postActionEvent();
}
!
void setReadOnlyValue(VariableValue var, String val) {
((LongAddrVariableValue)var).setValue(Integer.valueOf(val).intValue());
}
!
void checkValue(VariableValue var, String comment, String val) {
Assert.assertEquals(comment, val, ((JTextField)var.getValue()).getText() );
}
!
void checkReadOnlyValue(VariableValue var, String comment, String val) {
Assert.assertEquals(comment, val, ((JLabel)var.getValue()).getText() );
}
!
// end of abstract members
!
// some of the premade tests don't quite make sense; override them here.
!
public void testVariableValueCreate() {}// mask is ignored by LongAddr
public void testVariableFromCV() {} // low CV is upper part of address
***************
*** 76,90 ****
// create a variable pointed at CV 17&18, check name
LongAddrVariableValue var = new LongAddrVariableValue("label", "comment", false, 17, "VVVVVVVV", 0, 255, v, null, null);
! assert(var.label() == "label");
// pretend you've editted the value, check its in same object
((JTextField)var.getValue()).setText("4797");
! assert( ((JTextField)var.getValue()).getText().equals("4797") );
// manually notify
var.actionPerformed(new java.awt.event.ActionEvent(var, 0, ""));
// see if the CV was updated
! assert(cv17.getValue() == 210);
! assert(cv18.getValue() == 189);
}
!
// can we change both CVs and see the result in the Variable?
public void testLongAddressFromCV() {
--- 76,90 ----
// create a variable pointed at CV 17&18, check name
LongAddrVariableValue var = new LongAddrVariableValue("label", "comment", false, 17, "VVVVVVVV", 0, 255, v, null, null);
! Assert.assertTrue(var.label() == "label");
// pretend you've editted the value, check its in same object
((JTextField)var.getValue()).setText("4797");
! Assert.assertTrue( ((JTextField)var.getValue()).getText().equals("4797") );
// manually notify
var.actionPerformed(new java.awt.event.ActionEvent(var, 0, ""));
// see if the CV was updated
! Assert.assertTrue(cv17.getValue() == 210);
! Assert.assertTrue(cv18.getValue() == 189);
}
!
// can we change both CVs and see the result in the Variable?
public void testLongAddressFromCV() {
***************
*** 103,114 ****
// change the CV, expect to see a change in the variable value
cv17.setValue(210);
! assert(cv17.getValue() == 210);
cv18.setValue(189);
! assert( ((JTextField)var.getValue()).getText().equals("4797") );
! assert(cv18.getValue() == 189);
}
!
List evtList = null; // holds a list of ParameterChange events
!
// check a long address read operation
public void testLongAddressRead() {
--- 103,114 ----
// change the CV, expect to see a change in the variable value
cv17.setValue(210);
! Assert.assertTrue(cv17.getValue() == 210);
cv18.setValue(189);
! Assert.assertTrue( ((JTextField)var.getValue()).getText().equals("4797") );
! Assert.assertTrue(cv18.getValue() == 189);
}
!
List evtList = null; // holds a list of ParameterChange events
!
// check a long address read operation
public void testLongAddressRead() {
***************
*** 117,121 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv17 = new CvValue(17);
--- 117,121 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv17 = new CvValue(17);
***************
*** 135,139 ****
evtList = new ArrayList();
var.addPropertyChangeListener(listen);
!
// set to specific value
((JTextField)var.getValue()).setText("5");
--- 135,139 ----
evtList = new ArrayList();
var.addPropertyChangeListener(listen);
!
// set to specific value
((JTextField)var.getValue()).setText("5");
***************
*** 152,159 ****
if (i==0) log.warn("testLongAddressRead saw an immediate return from isBusy");
Assert.assertTrue("wait satisfied ", i<100);
!
int nBusyFalse = 0;
for (int k = 0; k < evtList.size(); k++) {
! java.beans.PropertyChangeEvent e = (java.beans.PropertyChangeEvent) evtList.get(k);
// System.out.println("name: "+e.getPropertyName()+" new value: "+e.getNewValue());
if (e.getPropertyName().equals("Busy") && ((Boolean)e.getNewValue()).equals(Boolean.FALSE))
--- 152,159 ----
if (i==0) log.warn("testLongAddressRead saw an immediate return from isBusy");
Assert.assertTrue("wait satisfied ", i<100);
!
int nBusyFalse = 0;
for (int k = 0; k < evtList.size(); k++) {
! java.beans.PropertyChangeEvent e = (java.beans.PropertyChangeEvent) evtList.get(k);
// System.out.println("name: "+e.getPropertyName()+" new value: "+e.getNewValue());
if (e.getPropertyName().equals("Busy") && ((Boolean)e.getNewValue()).equals(Boolean.FALSE))
***************
*** 161,169 ****
}
Assert.assertEquals("only one Busy -> false transition ", 1, nBusyFalse);
!
Assert.assertEquals("text value ", "15227", ((JTextField)var.getValue()).getText() ); // 15227 = (1230x3f)*256+123
Assert.assertEquals("Var state", AbstractValue.READ, var.getState() );
Assert.assertEquals("CV 17 value ", 251, cv17.getValue()); // 123 with 128 bit set
! Assert.assertEquals("CV 18 value ", 123, cv18.getValue());
}
--- 161,169 ----
}
Assert.assertEquals("only one Busy -> false transition ", 1, nBusyFalse);
!
Assert.assertEquals("text value ", "15227", ((JTextField)var.getValue()).getText() ); // 15227 = (1230x3f)*256+123
Assert.assertEquals("Var state", AbstractValue.READ, var.getState() );
Assert.assertEquals("CV 17 value ", 251, cv17.getValue()); // 123 with 128 bit set
! Assert.assertEquals("CV 18 value ", 123, cv18.getValue());
}
***************
*** 173,177 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv17 = new CvValue(17);
--- 173,177 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv17 = new CvValue(17);
***************
*** 184,188 ****
var.actionPerformed(new java.awt.event.ActionEvent(var, 0, ""));
! var.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
--- 184,188 ----
var.actionPerformed(new java.awt.event.ActionEvent(var, 0, ""));
! var.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
***************
*** 202,208 ****
Assert.assertEquals("CV 17 value ", 210, cv17.getValue());
Assert.assertEquals("CV 18 value ", 189, cv18.getValue());
! assert( ((JTextField)var.getValue()).getText().equals("4797") );
Assert.assertEquals("Var state", AbstractValue.STORED, var.getState() );
! assert(p.lastWrite() == 189);
// how do you check separation of the two writes? State model?
}
--- 202,208 ----
Assert.assertEquals("CV 17 value ", 210, cv17.getValue());
Assert.assertEquals("CV 18 value ", 189, cv18.getValue());
! Assert.assertTrue( ((JTextField)var.getValue()).getText().equals("4797") );
Assert.assertEquals("Var state", AbstractValue.STORED, var.getState() );
! Assert.assertTrue(p.lastWrite() == 189);
// how do you check separation of the two writes? State model?
}
***************
*** 215,219 ****
// from here down is testing infrastructure
!
public LongAddrVariableValueTest(String s) {
super(s);
--- 215,219 ----
// from here down is testing infrastructure
!
public LongAddrVariableValueTest(String s) {
super(s);
***************
*** 225,229 ****
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
--- 225,229 ----
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
***************
*** 231,235 ****
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance( LongAddrVariableValueTest.class.getName());
--- 231,235 ----
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance( LongAddrVariableValueTest.class.getName());
Index: VariableTableModelTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrit/symbolicprog/VariableTableModelTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** VariableTableModelTest.java 2 Mar 2002 20:13:24 -0000 1.1.1.1
--- VariableTableModelTest.java 31 Mar 2002 19:07:03 -0000 1.2
***************
*** 1,8 ****
! /**
* VariableTableModelTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* VariableTableModelTest.java
*
! * Description:
* @author Bob Jacobsen
! * @version
*/
***************
*** 32,37 ****
);
}
!
!
// Can we create a table?
public void testVarTableCreate() {
--- 32,37 ----
);
}
!
!
// Can we create a table?
public void testVarTableCreate() {
***************
*** 44,49 ****
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, null);
! assert(t.getColumnCount() == 2);
! assert(t.getColumnName(1) == "Name");
}
--- 44,49 ----
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, null);
! Assert.assertTrue(t.getColumnCount() == 2);
! Assert.assertTrue(t.getColumnName(1) == "Name");
}
***************
*** 52,61 ****
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
--- 52,61 ----
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
***************
*** 82,86 ****
)
)
! ) // variables element
) // decoder element
; // end of adding contents
--- 82,86 ----
)
)
! ) // variables element
) // decoder element
; // end of adding contents
***************
*** 93,104 ****
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
log.warn("expect next message: WARN jmri.symbolicprog.VariableTableModel - Element missing mask attribute: one");
// and test reading this
t.setRow(0, el0);
! assert(t.getValueAt(0,0).equals("1"));
! assert(t.getValueAt(0,1).equals("one"));
!
// check that the variable names were set right
Assert.assertEquals("check loaded label ", "one", t.getLabel(0));
--- 93,104 ----
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
log.warn("expect next message: WARN jmri.symbolicprog.VariableTableModel - Element missing mask attribute: one");
// and test reading this
t.setRow(0, el0);
! Assert.assertTrue(t.getValueAt(0,0).equals("1"));
! Assert.assertTrue(t.getValueAt(0,1).equals("one"));
!
// check that the variable names were set right
Assert.assertEquals("check loaded label ", "one", t.getLabel(0));
***************
*** 106,118 ****
t.setRow(1, el1);
! assert(t.getValueAt(1,0).equals("4"));
! assert(t.getValueAt(1,1).equals("two"));
- assert(t.getRowCount() == 2);
-
// check finding
! Assert.assertEquals("find variable two ",1, t.findVarIndex("two"));
! Assert.assertEquals("find nonexistant variable ",-1, t.findVarIndex("not there, eh?"));
!
}
--- 106,118 ----
t.setRow(1, el1);
! Assert.assertTrue(t.getValueAt(1,0).equals("4"));
! Assert.assertTrue(t.getValueAt(1,1).equals("two"));
!
! Assert.assertTrue(t.getRowCount() == 2);
// check finding
! Assert.assertEquals("find variable two ",1, t.findVarIndex("two"));
! Assert.assertEquals("find nonexistant variable ",-1, t.findVarIndex("not there, eh?"));
!
}
***************
*** 121,130 ****
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
--- 121,130 ----
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
***************
*** 139,143 ****
)
)
! ) // variables element
) // decoder element
; // end of adding contents
--- 139,143 ----
)
)
! ) // variables element
) // decoder element
; // end of adding contents
***************
*** 150,174 ****
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
// and test reading this
t.setRow(0, el0);
! assert(t.getValueAt(0,0).equals("17"));
! assert(t.getValueAt(0,1).equals("long"));
- assert(t.getRowCount() == 1);
-
}
!
// Check creating a speed table, then finding it by name
public void testVarSpeedTable() {
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0;
--- 150,174 ----
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
// and test reading this
t.setRow(0, el0);
! Assert.assertTrue(t.getValueAt(0,0).equals("17"));
! Assert.assertTrue(t.getValueAt(0,1).equals("long"));
!
! Assert.assertTrue(t.getRowCount() == 1);
}
!
// Check creating a speed table, then finding it by name
public void testVarSpeedTable() {
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0;
***************
*** 181,185 ****
)
)
! ) // variables element
) // decoder element
; // end of adding contents
--- 181,185 ----
)
)
! ) // variables element
) // decoder element
; // end of adding contents
***************
*** 191,209 ****
Assert.assertEquals("length of variable list ", 1, t.getRowCount());
Assert.assertEquals("name of 1st variable ", "Speed Table", t.getLabel(0));
! Assert.assertEquals("find Speed Table ",0, t.findVarIndex("Speed Table"));
! Assert.assertEquals("find nonexistant variable ",-1, t.findVarIndex("not there, eh?"));
!
}
!
// Check creating bogus XML (unknown variable type)
public void testVarTableLoadBogus() {
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
--- 191,209 ----
Assert.assertEquals("length of variable list ", 1, t.getRowCount());
Assert.assertEquals("name of 1st variable ", "Speed Table", t.getLabel(0));
! Assert.assertEquals("find Speed Table ",0, t.findVarIndex("Speed Table"));
! Assert.assertEquals("find nonexistant variable ",-1, t.findVarIndex("not there, eh?"));
!
}
!
// Check creating bogus XML (unknown variable type)
public void testVarTableLoadBogus() {
String[] args = {"CV", "Name"};
VariableTableModel t = new VariableTableModel(null, args, new CvTableModel(null));
!
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config","decoder-config.dtd"));
!
// add some elements
Element el0, el1;
***************
*** 218,222 ****
)
)
! ) // variables element
) // decoder element
; // end of adding contents
--- 218,222 ----
)
)
! ) // variables element
) // decoder element
; // end of adding contents
***************
*** 229,243 ****
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
// and test reading this
log.warn("expect next message: ERROR jmri.symbolicprog.VariableTableModel - Did not find a valid variable type");
t.setRow(0, el0);
! assert(t.getRowCount() == 0);
!
}
// from here down is testing infrastructure
!
public VariableTableModelTest(String s) {
super(s);
--- 229,243 ----
//try {
// fmt.output(doc, o);
! //} catch (Exception e) { System.out.println("error writing XML: "+e);}
// and test reading this
log.warn("expect next message: ERROR jmri.symbolicprog.VariableTableModel - Did not find a valid variable type");
t.setRow(0, el0);
! Assert.assertTrue(t.getRowCount() == 0);
!
}
// from here down is testing infrastructure
!
public VariableTableModelTest(String s) {
super(s);
***************
*** 249,253 ****
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
--- 249,253 ----
junit.swingui.TestRunner.main(testCaseName);
}
!
// test suite from all defined tests
public static Test suite() {
***************
*** 255,259 ****
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(VariableTableModelTest.class.getName());
--- 255,259 ----
return suite;
}
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(VariableTableModelTest.class.getName());
Index: VariableValueTest.java
===================================================================
RCS file: /cvsroot/jmri/test/jmri/jmrit/symbolicprog/VariableValueTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** VariableValueTest.java 2 Mar 2002 20:13:25 -0000 1.1.1.1
--- VariableValueTest.java 31 Mar 2002 19:07:03 -0000 1.2
***************
*** 1,8 ****
! /**
* VariableValueTest.java
*
* Description: base for tests of classes inheriting from VariableValue abstract class
* @author Bob Jacobsen
! * @version
*/
--- 1,8 ----
! /**
* VariableValueTest.java
*
* Description: base for tests of classes inheriting from VariableValue abstract class
* @author Bob Jacobsen
! * @version
*/
***************
*** 13,16 ****
--- 13,17 ----
import javax.swing.*;
import java.awt.Component;
+ import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
***************
*** 26,39 ****
int cvNum, String mask, int minVal, int maxVal,
Vector v, JLabel status, String item);
!
abstract void setValue(VariableValue var, String value);
abstract void checkValue(VariableValue var, String comment, String value);
!
// we have separate fns for ReadOnly, as they may have different "value" object types
abstract void setReadOnlyValue(VariableValue var, String value);
abstract void checkReadOnlyValue(VariableValue var, String comment, String value);
!
// start of base tests
!
// check label, item from ctor
public void testVariableNaming() {
--- 27,40 ----
int cvNum, String mask, int minVal, int maxVal,
Vector v, JLabel status, String item);
!
abstract void setValue(VariableValue var, String value);
abstract void checkValue(VariableValue var, String comment, String value);
!
// we have separate fns for ReadOnly, as they may have different "value" object types
abstract void setReadOnlyValue(VariableValue var, String value);
abstract void checkReadOnlyValue(VariableValue var, String comment, String value);
!
// start of base tests
!
// check label, item from ctor
public void testVariableNaming() {
***************
*** 61,65 ****
// pretend you've editted the value & manually notify
setValue(variable, "5");
!
// check value
checkValue(variable, "value object contains ", "5");
--- 62,66 ----
// pretend you've editted the value & manually notify
setValue(variable, "5");
!
// check value
checkValue(variable, "value object contains ", "5");
***************
*** 80,84 ****
setValue(variable, "5");
checkValue(variable, "variable value", "5");
!
// change the CV, expect to see a change in the variable value
cv.setValue(7*4+1);
--- 81,85 ----
setValue(variable, "5");
checkValue(variable, "variable value", "5");
!
// change the CV, expect to see a change in the variable value
cv.setValue(7*4+1);
***************
*** 86,90 ****
Assert.assertEquals("cv after CV set ", 7*4+1, cv.getValue());
}
!
// Do we get the right return from a readOnly == true DecVariable?
public void testVariableReadOnly() {
--- 87,91 ----
Assert.assertEquals("cv after CV set ", 7*4+1, cv.getValue());
}
!
// Do we get the right return from a readOnly == true DecVariable?
public void testVariableReadOnly() {
***************
*** 95,103 ****
// create a variable pointed at CV 81, loaded as 5
VariableValue variable = makeVar("label", "comment", true, 81, "XXVVVVXX", 0, 255, v, null, null);
! assert( variable.getValue() != null);
setReadOnlyValue(variable, "5");
checkReadOnlyValue(variable, "value", "5");
}
!
// check a read operation
public void testVariableValueRead() {
--- 96,104 ----
// create a variable pointed at CV 81, loaded as 5
VariableValue variable = makeVar("label", "comment", true, 81, "XXVVVVXX", 0, 255, v, null, null);
! Assert.assertTrue( variable.getValue() != null);
setReadOnlyValue(variable, "5");
checkReadOnlyValue(variable, "value", "5");
}
!
// check a read operation
public void testVariableValueRead() {
***************
*** 106,110 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 107,111 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 139,143 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 140,144 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 147,151 ****
setValue(variable, "5");
! variable.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
--- 148,152 ----
setValue(variable, "5");
! variable.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
***************
*** 165,169 ****
Assert.assertEquals("last program write ", 5*4, p.lastWrite());
}
!
// check synch during a write operation to the CV
public void testVariableCvWrite() {
--- 166,170 ----
Assert.assertEquals("last program write ", 5*4, p.lastWrite());
}
!
// check synch during a write operation to the CV
public void testVariableCvWrite() {
***************
*** 172,176 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 173,177 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 181,185 ****
JLabel statusLabel = new JLabel("nothing");
! cv.write(statusLabel); // JLabel is for reporting status, ignored here
// wait for reply (normally, done by callback; will check that later)
int i = 0;
--- 182,186 ----
JLabel statusLabel = new JLabel("nothing");
! cv.write(statusLabel); // JLabel is for reporting status, ignored here
// wait for reply (normally, done by callback; will check that later)
int i = 0;
***************
*** 201,205 ****
if (log.isDebugEnabled()) log.debug("end testVariableCvWrite test");
}
!
// check the state diagram
public void testVariableValueStates() {
--- 202,206 ----
if (log.isDebugEnabled()) log.debug("end testVariableCvWrite test");
}
!
// check the state diagram
public void testVariableValueStates() {
***************
*** 207,211 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 208,212 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 225,229 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 226,230 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 236,240 ****
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, variable.getValue().getBackground() );
}
!
// check the state <-> color connection for rep when var changes
public void testVariableRepStateColor() {
--- 237,241 ----
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, variable.getValue().getBackground() );
}
!
// check the state <-> color connection for rep when var changes
public void testVariableRepStateColor() {
***************
*** 242,246 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 243,247 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 250,254 ****
// get a representation
JTextField rep = (JTextField)variable.getRep("");
!
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, variable.getValue().getBackground() );
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
--- 251,255 ----
// get a representation
JTextField rep = (JTextField)variable.getRep("");
!
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, variable.getValue().getBackground() );
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
***************
*** 264,268 ****
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
}
!
// check the state <-> color connection for var when rep changes
public void testVariableVarChangeColorRep() {
--- 265,269 ----
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
}
!
// check the state <-> color connection for var when rep changes
public void testVariableVarChangeColorRep() {
***************
*** 270,274 ****
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 271,275 ----
Programmer p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 278,282 ****
// get a representation
JTextField rep = (JTextField)variable.getRep("");
!
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, variable.getValue().getBackground() );
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
--- 279,283 ----
// get a representation
JTextField rep = (JTextField)variable.getRep("");
!
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, variable.getValue().getBackground() );
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
***************
*** 285,289 ****
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, variable.getValue().getBackground() );
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, rep.getBackground() );
!
rep.setText("9");
rep.postActionEvent();
--- 286,290 ----
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, variable.getValue().getBackground() );
Assert.assertEquals("UNKNOWN color", VariableValue.COLOR_UNKNOWN, rep.getBackground() );
!
rep.setText("9");
rep.postActionEvent();
***************
*** 291,295 ****
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
}
!
// check synchonization of value, representations
public void testVariableSynch() {
--- 292,296 ----
Assert.assertEquals("EDITTED color", VariableValue.COLOR_EDITTED, rep.getBackground() );
}
!
// check synchonization of value, representations
public void testVariableSynch() {
***************
*** 297,301 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 298,302 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 311,318 ****
JTextField rep1 = (JTextField) variable.getRep("");
Assert.assertEquals("initial rep ", "5", rep1.getText());
!
// update via value
setValue(variable, "2");
!
// check again with existing reference
Assert.assertEquals("same value object ", val1, variable.getValue());
--- 312,319 ----
JTextField rep1 = (JTextField) variable.getRep("");
Assert.assertEquals("initial rep ", "5", rep1.getText());
!
// update via value
setValue(variable, "2");
!
// check again with existing reference
Assert.assertEquals("same value object ", val1, variable.getValue());
***************
*** 321,329 ****
checkValue(variable, "1 new value ", "2");
Assert.assertEquals("1 new rep ", "2", ((JTextField) variable.getRep("")).getText());
!
// update via rep
rep1.setText("9");
rep1.postActionEvent();
!
// check again with existing references
Assert.assertEquals("2 saved value ", "9", ((JTextField)val1).getText());
--- 322,330 ----
checkValue(variable, "1 new value ", "2");
Assert.assertEquals("1 new rep ", "2", ((JTextField) variable.getRep("")).getText());
!
// update via rep
rep1.setText("9");
rep1.postActionEvent();
!
// check again with existing references
Assert.assertEquals("2 saved value ", "9", ((JTextField)val1).getText());
***************
*** 340,344 ****
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
--- 341,345 ----
ProgDebugger p = new ProgDebugger();
InstanceManager.setProgrammer(p);
!
Vector v = createCvVector();
CvValue cv = new CvValue(81);
***************
*** 349,353 ****
setValue(var1, "5");
! var1.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
--- 350,354 ----
setValue(var1, "5");
! var1.write();
// wait for reply (normally, done by callback; will check that later)
int i = 0;
***************
*** 369,375 ****
if (log.isDebugEnabled()) log.debug("end testWriteSynch2 test");
}
!
// end of common tests
!
// this next is just preserved here; note not being invoked.
// test that you're not using too much space when you call for a value
--- 370,376 ----
if (log.isDebugEnabled()) log.debug("end testWriteSynch2 test");
}
!
// end of common tests
!
// this next is just preserved here; note not being invoked.
// test that you're not using too much space when you call for a value
***************
*** 399,403 ****
+" "+Runtime.getRuntime().totalMemory());
long usedAfter = Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory();
!
Runtime.getRuntime().gc();
long usedAfterGC = Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory();
--- 400,404 ----
+" "+Runtime.getRuntime().totalMemory());
long usedAfter = Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory();
!
Runtime.getRuntime().gc();
long usedAfterGC = Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory();
***************
*** 406,410 ****
System.out.println("used & kept = "+(usedAfterGC-usedStart)+" used before reclaim = "+(usedAfter-usedStart));
}
!
protected Vector createCvVector() {
Vector v = new Vector(512);
--- 407,411 ----
System.out.println("used & kept = "+(usedAfterGC-usedStart)+" used before reclaim = "+(usedAfter-usedStart));
}
!
protected Vector createCvVector() {
Vector v = new Vector(512);
***************
*** 414,418 ****
// from here down is testing infrastructure
!
public VariableValueTest(String s) {
super(s);
--- 415,419 ----
// from here down is testing infrastructure
!
public VariableValueTest(String s) {
super(s);
***************
*** 420,424 ****
// abstract class has no main entry point, test suite
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(VariableValueTest.class.getName());
--- 421,425 ----
// abstract class has no main entry point, test suite
!
static org.apache.log4j.Category log = org.apache.log4j.Category.getInstance(VariableValueTest.class.getName());
|