diff --git a/src/com/goldencode/p2j/testengine/FWDEngineDescriptor.java b/src/com/goldencode/p2j/testengine/FWDEngineDescriptor.java index caf38b7..9edbfb0 100644 --- a/src/com/goldencode/p2j/testengine/FWDEngineDescriptor.java +++ b/src/com/goldencode/p2j/testengine/FWDEngineDescriptor.java @@ -11,6 +11,7 @@ ** to program mode for the period legacy code is running. See #3827-435. ** 003 VVT 20240325 Unused import statement removed. ** 004 VVT 20240408 Minor style fixes. See #8406-70. +** 005 ME 20241231 Use the context driver to support both chui/gui modes. */ /* ** This program is free software: you can redistribute it and/or modify @@ -72,7 +73,6 @@ import org.junit.platform.engine.*; import org.opentest4j.*; -import com.goldencode.p2j.ui.client.chui.driver.console.*; import com.goldencode.p2j.util.*; /** @@ -81,11 +81,7 @@ public class FWDEngineDescriptor extends AbstractBranchTestDescriptor { - /** - * Switch between the shell and program terminal modes in ChUI. - */ - private final static ConsoleHelper consoleHelper = ConsoleHelper.getDefaultConsoleHelper(); - + /** * Default constructor for de-serialization only, * must never be used by applications. @@ -124,7 +120,7 @@ super.cleanUp(context); // Assure we are in the program shell mode while FWD is not active - consoleHelper.suspend(); + context.initStruct.driver.suspend(); } /** @@ -156,7 +152,7 @@ AssertionFailedError { // Assure we are in the program terminal mode while FWD is active - consoleHelper.resume(); + context.initStruct.driver.resume(); return super.prepare(context); } diff --git a/src/com/goldencode/p2j/testengine/FWDEngineExecutionContext.java b/src/com/goldencode/p2j/testengine/FWDEngineExecutionContext.java index 241f2ce..5b1e951 100644 --- a/src/com/goldencode/p2j/testengine/FWDEngineExecutionContext.java +++ b/src/com/goldencode/p2j/testengine/FWDEngineExecutionContext.java @@ -7,6 +7,7 @@ ** -#- -I- --Date-- ---------------------------------Description--------------------------------- ** 001 VVT 20230318 Created initial version. ** 002 VVT 20230428 Javadoc fixed. +** 003 ME 20241231 Save the client initialization structure to support both chui/gui modes. */ /* ** This program is free software: you can redistribute it and/or modify @@ -64,6 +65,8 @@ import org.junit.platform.engine.support.hierarchical.*; +import com.goldencode.p2j.main.ClientCore; + /** * Test engine execution context. * @@ -74,14 +77,20 @@ /** Proxy instance to execute remove operations on the server */ final UnitTestEngine unitTestSupport; + /** The client initialization structure to have access to the screen driver */ + final ClientCore.InitStruct initStruct; + /** * The constructor. * * @param unitTestSupport * the remote protocol instance + * @param initStruct + * the client initialization structure */ - FWDEngineExecutionContext(final UnitTestEngine unitTestSupport) + FWDEngineExecutionContext(final UnitTestEngine unitTestSupport, final ClientCore.InitStruct initStruct) { this.unitTestSupport = unitTestSupport; + this.initStruct = initStruct; } } diff --git a/src/com/goldencode/p2j/testengine/FWDTestEngine.java b/src/com/goldencode/p2j/testengine/FWDTestEngine.java index c0397f3..a81bdd7 100644 --- a/src/com/goldencode/p2j/testengine/FWDTestEngine.java +++ b/src/com/goldencode/p2j/testengine/FWDTestEngine.java @@ -12,6 +12,8 @@ ** 004 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus. ** 005 CA 20240311 Allow server:clientConfig:outputToFile to be set for the FWD unit test client, too. ** 006 VVT 20240618 Forced ConsoleHelper.terminate() after test engine initialization failure. See #8529-7. +** 007 ME 20241231 Use the client initialization structure to support both chui/gui modes. +** Allow usage of environment variable to specify the xml configuration file (Eclipse). */ /* ** This program is free software: you can redistribute it and/or modify @@ -82,7 +84,6 @@ import com.goldencode.p2j.cfg.*; import com.goldencode.p2j.main.*; import com.goldencode.p2j.net.*; -import com.goldencode.p2j.ui.client.chui.driver.console.*; import com.goldencode.p2j.ui.client.driver.*; /** @@ -148,6 +149,11 @@ * Unit test support on the server proxy instance. */ private static UnitTestEngine unitTestSupport; + + /** + * Client initialization structure, screen driver supports chui/gui modes. + */ + private static ClientCore.InitStruct is; /** * Initialize the engine. @@ -173,7 +179,7 @@ ScreenDriver driver = (uuid == null) ? null : ClientCore.processTemporaryClient(uuid, bc); ClientCore.loadNativeLibrary(); - final ClientCore.InitStruct is = new ClientCore.InitStruct(); + is = new ClientCore.InitStruct(); ClientCore.setOutputToFile(bc); is.driver = driver; ClientCore.initialize(is, @@ -192,7 +198,7 @@ } catch (Throwable thr) { - ConsoleHelper.terminate(); + is.driver.shutdown(); LOG.warning("Test engine cannot initialize and will be disabled: " + thr); @@ -229,12 +235,12 @@ case NONE: final ConfigurationParameters configurationParameters = discoveryRequest .getConfigurationParameters(); - if (initialize( - configurationParameters.get(CFG_FWD_CONFIG_FILE).orElse(DEFAULT_FWD_CONFIG_FILE))) - { - state = State.INITIALIZED; - break; - } + String configFile = configurationParameters.get(CFG_FWD_CONFIG_FILE).orElse(System.getenv(CFG_FWD_CONFIG_FILE)); + + if (initialize(configFile != null ? configFile : DEFAULT_FWD_CONFIG_FILE)) { + state = State.INITIALIZED; + break; + } //$FALL-THROUGH$ case INOPERABLE: @@ -301,7 +307,7 @@ @Override protected FWDEngineExecutionContext createExecutionContext(ExecutionRequest request) { - return new FWDEngineExecutionContext(unitTestSupport); + return new FWDEngineExecutionContext(unitTestSupport, is); } /**