Skip to content
Permalink
Browse files

use real roster entries for consist tests involving roster IDs

  • Loading branch information...
pabender committed Aug 1, 2019
1 parent dacbfb8 commit f184d14cd673e7096731196cba3f7f99e43f71e3
Showing with 17 additions and 8 deletions.
  1. +17 −8 java/test/jmri/implementation/AbstractConsistTestBase.java
@@ -1,6 +1,11 @@
package jmri.implementation;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import jmri.Consist;
import jmri.jmrit.roster.Roster;
import jmri.jmrit.roster.RosterEntry;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -97,27 +102,31 @@ public void checkDisposeMethod(){
Assert.assertFalse("Direction in Advanced Consist",c.getLocoDirection(B));
}

@Test public void checkGetSetLocoRosterIDAdvanced(){
@Test public void checkGetSetLocoRosterIDAdvanced() throws IOException,FileNotFoundException {
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 = new jmri.DccLocoAddress(200,true);
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,"foo");
Assert.assertEquals("Roster ID A","foo",c.getRosterId(A));
c.setRosterId(A,"ATSF123");
Assert.assertEquals("Roster ID A","ATSF123",c.getRosterId(A));
Assert.assertNull("Roster ID B",c.getRosterId(B));
}

@Test public void checkRemoveWithGetRosterIDAdvanced(){
@Test public void checkRemoveWithGetRosterIDAdvanced() throws IOException,FileNotFoundException {
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 = new jmri.DccLocoAddress(200,true);
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,"foo");
Assert.assertEquals("Roster ID A","foo",c.getRosterId(A));
c.setRosterId(A,"ATSF123");
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));

0 comments on commit f184d14

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