Skip to content
Permalink
Browse files

additional tests

  • Loading branch information...
pabender committed Aug 1, 2019
1 parent e71f748 commit 05b83f0c48c9a6e87841459cf82696b48c1bd1c9
@@ -6,6 +6,11 @@
import jmri.Consist;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterEntry;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterEntry;
import jmri.jmrit.symbolicprog.CvTableModel;
import jmri.jmrit.symbolicprog.CvValue;
import jmri.jmrit.symbolicprog.VariableTableModel;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -132,6 +137,49 @@ public void checkDisposeMethod(){
Assert.assertFalse("Roster A is no longer in consist",c.contains(A));
}

@Test public void checkAddRemoveWithRosterUpdateAdvanced() throws IOException,FileNotFoundException {
// verify the roster update process is active.
jmri.InstanceManager.getDefault(jmri.jmrit.consisttool.ConsistPreferencesManager.class).setUpdateCV19(true);
jmri.util.RosterTestUtil.createTestRoster(new File(Roster.getDefault().getRosterLocation()),"rosterTest.xml");
RosterEntry entry = Roster.getDefault().getEntryForId("ATSF123");
c.setConsistType(jmri.Consist.ADVANCED_CONSIST);
jmri.DccLocoAddress A = entry.getDccLocoAddress();
jmri.DccLocoAddress B = new jmri.DccLocoAddress(250,true);
c.restore(A,true); // use restore here, as it does not send
// any data to the command station
c.restore(B,false); // revese direction.
c.setRosterId(A,"ATSF123");

// verify that roster ATSF123 has CV19 set to the consist address (12)
CvTableModel cvTable = new CvTableModel(null, null); // will hold CV objects
VariableTableModel varTable = new VariableTableModel(null,new String[]{"Name","Value"},cvTable);
entry.readFile(); // read, but don’t yet process

// load from decoder file
jmri.util.RosterTestUtil.loadDecoderFromLoco(entry,varTable);

entry.loadCvModel(varTable, cvTable);
CvValue cv19Value = cvTable.getCvByNumber("19");
Assert.assertEquals("CV19 value after add",12,cv19Value.getValue());

Assert.assertEquals("Roster ID A","ATSF123",c.getRosterId(A));
Assert.assertNull("Roster ID B",c.getRosterId(B));
c.remove(A);
Assert.assertFalse("Roster A is no longer in consist",c.contains(A));

cvTable = new CvTableModel(null, null); // will hold CV objects
varTable = new VariableTableModel(null,new String[]{"Name","Value"},cvTable);
entry.readFile(); // read, but don’t yet process

// load from decoder file
jmri.util.RosterTestUtil.loadDecoderFromLoco(entry,varTable);

entry.loadCvModel(varTable, cvTable);
cv19Value = cvTable.getCvByNumber("19");
Assert.assertEquals("CV19 value after remove",0,cv19Value.getValue());
}


// The minimal setup for log4J

}
@@ -13,8 +13,6 @@
import jmri.jmrit.throttle.ThrottleOperator;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterEntry;
import jmri.jmrit.decoderdefn.DecoderFile;
import jmri.jmrit.decoderdefn.DecoderIndexFile;
import jmri.jmrit.symbolicprog.CvTableModel;
import jmri.jmrit.symbolicprog.CvValue;
import jmri.jmrit.symbolicprog.VariableTableModel;
@@ -97,6 +97,12 @@ public void checkDisposeMethod(){
public void checkRemoveWithGetRosterIDAdvanced(){
}

@Test
@Ignore("Remove requires response from command station")
@ToDo("re-write parent class test here and include simulated command station response")
public void checkAddRemoveWithRosterUpdateAdvanced(){
}

// The minimal setup for log4J
@Before
@Override
@@ -82,6 +82,12 @@ void killConsist(int address, boolean isLong){
public void checkRemoveWithGetRosterIDAdvanced(){
}

@Test
@Ignore("Remove requires response from command station")
@ToDo("re-write parent class test here and include simulated command station response")
public void checkAddRemoveWithRosterUpdateAdvanced(){
}

// The minimal setup for log4J
@Before
@Override

0 comments on commit 05b83f0

Please sign in to comment.
You can’t perform that action at this time.