Topics

Recommended way to test two connections

Randall Wood <rhwood@...>
 

I have found that for a piece of code which handled multiple connections, I was passing all tests, and covering all the code, but still having real issues handling multiple connections. (The problem lays in that for physical NamedBeans, there are almost always a manager and a proxy manager, so that all code gets used in a test, but the case of multiple managers in a single proxy is still not get tested).

Is there a recommended way to configure two connections for unit testing?

Randall

Bob Jacobsen
 

Would multiple internal-style connections work? They don’t have all the structure of real connections, but at the Manager level (should) look the same. From java/test/jmri/managers/ProxySensorManagerTest.java

l = new ProxySensorManager();
// initially has three systems: IS, JS, KS
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("J", "Juliet")));
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("I", "India"))); // not in alpha order to make it exciting
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("K", "Kilo")));

If it’s more complicated than that, maybe it’s better to find a way to drop down to more detailed unit testing?

Bob


On Sep 29, 2019, at 9:15 AM, Randall Wood via Groups.Io <rhwood=mac.com@groups.io> wrote:

I have found that for a piece of code which handled multiple connections, I was passing all tests, and covering all the code, but still having real issues handling multiple connections. (The problem lays in that for physical NamedBeans, there are almost always a manager and a proxy manager, so that all code gets used in a test, but the case of multiple managers in a single proxy is still not get tested).

Is there a recommended way to configure two connections for unit testing?

Randall
--
Bob Jacobsen
@BobJacobsen

Randall Wood <rhwood@...>
 

That is perfect, thank you.

On Sep 29, 2019, at 17:04, Bob Jacobsen <@BobJacobsen> wrote:

Would multiple internal-style connections work? They don’t have all the structure of real connections, but at the Manager level (should) look the same. From java/test/jmri/managers/ProxySensorManagerTest.java

l = new ProxySensorManager();
// initially has three systems: IS, JS, KS
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("J", "Juliet")));
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("I", "India"))); // not in alpha order to make it exciting
l.addManager(new InternalSensorManager(new InternalSystemConnectionMemo("K", "Kilo")));

If it’s more complicated than that, maybe it’s better to find a way to drop down to more detailed unit testing?

Bob


On Sep 29, 2019, at 9:15 AM, Randall Wood via Groups.Io <rhwood=mac.com@groups.io> wrote:

I have found that for a piece of code which handled multiple connections, I was passing all tests, and covering all the code, but still having real issues handling multiple connections. (The problem lays in that for physical NamedBeans, there are almost always a manager and a proxy manager, so that all code gets used in a test, but the case of multiple managers in a single proxy is still not get tested).

Is there a recommended way to configure two connections for unit testing?

Randall
--
Bob Jacobsen
@BobJacobsen