Skip to content
Permalink
Browse files

proper test setup; adjust one test to pass with single LayoutEditor i…

…nstance.
  • Loading branch information...
pabender committed Oct 16, 2018
1 parent c579af0 commit 194299fae00fa418603f0dba2af2c6eb5c83a2d6
Showing with 41 additions and 25 deletions.
  1. +41 −25 java/test/jmri/jmrit/display/layoutEditor/LayoutTurnoutTest.java
@@ -23,12 +23,12 @@
public class LayoutTurnoutTest {

private static LayoutEditor layoutEditor = null;
LayoutTurnout ltRH = null;
LayoutTurnout ltLH = null;
LayoutTurnout ltWY = null;
LayoutTurnout ltDX = null;
LayoutTurnout ltRX = null;
LayoutTurnout ltLX = null;
private LayoutTurnout ltRH = null;
private LayoutTurnout ltLH = null;
private LayoutTurnout ltWY = null;
private LayoutTurnout ltDX = null;
private LayoutTurnout ltRX = null;
private LayoutTurnout ltLX = null;

@Test
public void testNew() {
@@ -471,22 +471,22 @@ public void testGetCoordsForConnectionType() {
public void testGetBounds() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
Assert.assertEquals("ltRH.getBounds() is equal to...",
new Rectangle2D.Double(132.0, 87.0, 36.0, 36.0),
new Rectangle2D.Double(121.0, 80.0, 58.0, 55.0),
ltRH.getBounds());
Assert.assertEquals("ltLH.getBounds() is equal to...",
new Rectangle2D.Double(189.0, 149.0, 33.0, 52.0),
new Rectangle2D.Double(184.0, 135.0, 50.0, 80.0),
ltLH.getBounds());
Assert.assertEquals("ltWY.getBounds() is equal to...",
new Rectangle2D.Double(238.0, 218.5, 16.5, 64.5),
new Rectangle2D.Double(232.0, 201.0, 25.0, 100.0),
ltWY.getBounds());
Assert.assertEquals("ltDX.getBounds() is equal to...",
new Rectangle2D.Double(253.0, 273.0, 94.0, 104.0),
new Rectangle2D.Double(199.0, 213.0, 202.0, 224.0),
ltDX.getBounds());
Assert.assertEquals("ltRX.getBounds() is equal to...",
new Rectangle2D.Double(290.0, 376.0, 120.0, 48.0),
new Rectangle2D.Double(223.0, 345.0, 254.0, 110.0),
ltRX.getBounds());
Assert.assertEquals("ltLX.getBounds() is equal to...",
new Rectangle2D.Double(334.0, 447.0, 132.0, 56.0),
new Rectangle2D.Double(259.0, 413.0, 282.0, 124.0),
ltLX.getBounds());
}

@@ -756,10 +756,8 @@ public static void afterClass() {

@Before
public void setUp() throws Exception {
JUnitUtil.setUp();
JUnitUtil.resetProfileManager();
if (!GraphicsEnvironment.isHeadless()) {
layoutEditor = new LayoutEditor();
Point2D point = new Point2D.Double(150.0, 100.0);
Point2D delta = new Point2D.Double(50.0, 75.0);

@@ -790,18 +788,36 @@ public void setUp() throws Exception {

@After
public void tearDown() throws Exception {
if (layoutEditor != null) {
JUnitUtil.dispose(layoutEditor);
if(ltRH!=null){
ltRH.remove();
ltRH.dispose();
ltRH = null;
}
if(ltLH!=null){
ltLH.remove();
ltLH.dispose();
ltLH = null;
}
if(ltWY!=null){
ltWY.remove();
ltWY.dispose();
ltWY = null;
}
if(ltDX!=null){
ltDX.remove();
ltDX.dispose();
ltDX = null;
}
if(ltRX!=null){
ltRX.remove();
ltRX.dispose();
ltRX = null;
}
if(ltLX!=null){
ltLX.remove();
ltLX.dispose();
ltLX = null;
}
layoutEditor = null;
ltRH = null;
ltLH = null;
ltWY = null;
ltDX = null;
ltRX = null;
ltLX = null;
// reset the instance manager.
JUnitUtil.tearDown();
}
// private final static Logger log = LoggerFactory.getLogger(LayoutSlipTest.class);
}

0 comments on commit 194299f

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