From b2b4c5f153ba8fb92775bbf62d84a1d6880d7486 Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Mon, 17 Dec 2018 22:18:54 +0100 Subject: [PATCH] Makes the different ConnectioNConfigXmlTestBase be consistent in how they invoke the code under test. Some of these generate ConcurrentModificationExceptions, while others have been fixed. --- .../AbstractConnectionConfigXmlTestBase.java | 9 +++++++-- .../AbstractSerialConnectionConfigXmlTestBase.java | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/java/test/jmri/jmrix/configurexml/AbstractConnectionConfigXmlTestBase.java b/java/test/jmri/jmrix/configurexml/AbstractConnectionConfigXmlTestBase.java index 00c67044b92..bb840ff658d 100644 --- a/java/test/jmri/jmrix/configurexml/AbstractConnectionConfigXmlTestBase.java +++ b/java/test/jmri/jmrix/configurexml/AbstractConnectionConfigXmlTestBase.java @@ -3,6 +3,8 @@ import org.junit.*; import org.jdom2.Element; import jmri.jmrix.ConnectionConfig; +import jmri.util.ThreadingUtil; + import javax.swing.JPanel; /** @@ -39,8 +41,11 @@ public void loadTest() throws jmri.configurexml.JmriConfigureXmlException { jmri.util.JUnitUtil.resetProfileManager(); // This test requires a configure manager. jmri.util.JUnitUtil.initConfigureManager(); - cc.loadDetails(new JPanel()); - cc.setDisabled(true); // so we don't try to start the connection on load. + // Running this on the UI thread fixes some ConcurrentModificationExceptions errors. + ThreadingUtil.runOnGUI(()-> { + cc.loadDetails(new JPanel()); + cc.setDisabled(true); // so we don't try to start the connection on load. + }); Element e = xmlAdapter.store(cc); try { //load what we just produced. diff --git a/java/test/jmri/jmrix/configurexml/AbstractSerialConnectionConfigXmlTestBase.java b/java/test/jmri/jmrix/configurexml/AbstractSerialConnectionConfigXmlTestBase.java index d0434662737..62d8781489c 100644 --- a/java/test/jmri/jmrix/configurexml/AbstractSerialConnectionConfigXmlTestBase.java +++ b/java/test/jmri/jmrix/configurexml/AbstractSerialConnectionConfigXmlTestBase.java @@ -40,10 +40,12 @@ public void loadTest() throws jmri.configurexml.JmriConfigureXmlException { // This test requires a configure manager. jmri.util.JUnitUtil.initConfigureManager(); // Running this on the UI thread fixes some ConcurrentModificationExceptions errors. - ThreadingUtil.runOnGUI(()->{cc.loadDetails(new JPanel());}); + ThreadingUtil.runOnGUI(()->{ + cc.loadDetails(new JPanel()); + cc.setDisabled(true); // so we don't try to start the connection on load. + }); // load details MAY produce an error message if no ports are found. jmri.util.JUnitAppender.suppressErrorMessage("No usable ports returned"); - cc.setDisabled(true); // so we don't try to start the connection on load. Element e = xmlAdapter.store(cc); //load what we just produced. xmlAdapter.load(e,e);