Skip to content

Commit

Permalink
Fix test cases
Browse files Browse the repository at this point in the history
Add code to catch log.error("...")'s added to replaceTrackConnection.
  • Loading branch information
geowar1 committed Oct 28, 2017
1 parent 19d6172 commit 4623fda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Expand Up @@ -680,7 +680,7 @@ public boolean replaceTrackConnection(@Nullable TrackSegment oldTrack, @Nullable
result = false; // can't replace null with null
}
if (!result) {
log.error("Attempt to remove non-existant track connection: {}", oldTrack.getName());
log.error("Attempt to remove non-existant track connection: {}", oldTrack);
}
} else // already connected to newTrack?
if ((connect1 != newTrack) && (connect2 != newTrack)) {
Expand All @@ -705,7 +705,7 @@ public boolean replaceTrackConnection(@Nullable TrackSegment oldTrack, @Nullable
result = false;
}
return result;
}
} // replaceTrackConnection

void removeSML(SignalMast signalMast) {
if (signalMast == null) {
Expand Down
Expand Up @@ -345,8 +345,9 @@ public void testSetTrackConnection() {
// test null track segment
Assert.assertFalse("pp.setTrackConnection(null) is false",
pp.setTrackConnection(null));
jmri.util.JUnitAppender.assertErrorMessage("Attempt to remove non-existant track connection: null");

PositionablePoint ppA = new PositionablePoint("A", PositionablePoint.ANCHOR, new Point2D.Double( 0.0, 0.0), le);
PositionablePoint ppA = new PositionablePoint("A", PositionablePoint.ANCHOR, new Point2D.Double(0.0, 0.0), le);
PositionablePoint ppB = new PositionablePoint("B", PositionablePoint.ANCHOR, new Point2D.Double(10.0, 10.0), le);
PositionablePoint ppC = new PositionablePoint("C", PositionablePoint.ANCHOR, new Point2D.Double(20.0, 20.0), le);
PositionablePoint ppD = new PositionablePoint("D", PositionablePoint.ANCHOR, new Point2D.Double(30.0, 30.0), le);
Expand All @@ -361,20 +362,22 @@ public void testSetTrackConnection() {
Assert.assertTrue("pp.setTrackConnection(tsAB) is true",
pp.setTrackConnection(tsAB));

// test already connected is true
Assert.assertTrue("pp.setTrackConnection(tsAB) is true",
// test already connected
Assert.assertFalse("pp.setTrackConnection(tsAB) is false",
pp.setTrackConnection(tsAB));
jmri.util.JUnitAppender.assertErrorMessage("Already connected to testAB");

// test 2nd non-null track segment
Assert.assertTrue("pp.setTrackConnection(tsBC) is true",
pp.setTrackConnection(tsBC));

// test already connected is true
Assert.assertTrue("pp.setTrackConnection(tsBC) is true",
// test already connected
Assert.assertFalse("pp.setTrackConnection(tsBC) is false",
pp.setTrackConnection(tsBC));
jmri.util.JUnitAppender.assertErrorMessage("Already connected to testBC");

// test 3rd non-null track segment
Assert.assertFalse("pp.setTrackConnection(tsCD) is true",
Assert.assertFalse("pp.setTrackConnection(tsCD) is false",
pp.setTrackConnection(tsCD));
jmri.util.JUnitAppender.assertErrorMessage("Attempt to assign more than allowed number of connections");
}
Expand Down

0 comments on commit 4623fda

Please sign in to comment.