Project

General

Profile

testengine.patch

Marian Edu, 12/31/2024 09:13 AM

Download (6.21 KB)

View differences:

src/com/goldencode/p2j/testengine/FWDEngineDescriptor.java
11 11
**                  to program mode for the period legacy code is running. See #3827-435.
12 12
** 003 VVT 20240325 Unused import statement removed.
13 13
** 004 VVT 20240408 Minor style fixes. See #8406-70.
14
** 005 ME  20241231 Use the context driver to support both chui/gui modes.
14 15
*/
15 16
/*
16 17
** This program is free software: you can redistribute it and/or modify
......
72 73
import org.junit.platform.engine.*;
73 74
import org.opentest4j.*;
74 75

  
75
import com.goldencode.p2j.ui.client.chui.driver.console.*;
76 76
import com.goldencode.p2j.util.*;
77 77

  
78 78
/**
......
81 81
public class FWDEngineDescriptor
82 82
extends AbstractBranchTestDescriptor
83 83
{
84
   /**
85
    * Switch between the shell and program terminal modes in ChUI.
86
    */
87
   private final static ConsoleHelper consoleHelper = ConsoleHelper.getDefaultConsoleHelper();
88
   
84
     
89 85
   /**
90 86
    * Default constructor for de-serialization only,
91 87
    * must never be used by applications.
......
124 120
      super.cleanUp(context);
125 121

  
126 122
      // Assure we are in the program shell mode while FWD is not active
127
      consoleHelper.suspend();
123
      context.initStruct.driver.suspend();
128 124
   }
129 125

  
130 126
   /**
......
156 152
          AssertionFailedError
157 153
   {
158 154
      // Assure we are in the program terminal mode while FWD is active
159
      consoleHelper.resume();
155
	  context.initStruct.driver.resume();
160 156

  
161 157
      return super.prepare(context);
162 158
   }
src/com/goldencode/p2j/testengine/FWDEngineExecutionContext.java
7 7
** -#- -I- --Date-- ---------------------------------Description---------------------------------
8 8
** 001 VVT 20230318 Created initial version.
9 9
** 002 VVT 20230428 Javadoc fixed.
10
** 003 ME  20241231 Save the client initialization structure to support both chui/gui modes.
10 11
*/
11 12
/*
12 13
** This program is free software: you can redistribute it and/or modify
......
64 65

  
65 66
import org.junit.platform.engine.support.hierarchical.*;
66 67

  
68
import com.goldencode.p2j.main.ClientCore;
69

  
67 70
/**
68 71
 * Test engine execution context.
69 72
 * 
......
74 77
   /** Proxy instance to execute remove operations on the server */
75 78
   final UnitTestEngine unitTestSupport;
76 79

  
80
   /** The client initialization structure to have access to the screen driver */
81
   final ClientCore.InitStruct initStruct;
82
   
77 83
   /**
78 84
    * The constructor.
79 85
    * 
80 86
    * @param unitTestSupport
81 87
    *        the remote protocol instance
88
    * @param initStruct
89
    * 		 the client initialization structure
82 90
    */
83
   FWDEngineExecutionContext(final UnitTestEngine unitTestSupport)
91
   FWDEngineExecutionContext(final UnitTestEngine unitTestSupport, final ClientCore.InitStruct initStruct)
84 92
   {
85 93
      this.unitTestSupport = unitTestSupport;
94
      this.initStruct = initStruct;
86 95
   }
87 96
}
src/com/goldencode/p2j/testengine/FWDTestEngine.java
12 12
** 004 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus.
13 13
** 005 CA  20240311 Allow server:clientConfig:outputToFile to be set for the FWD unit test client, too.
14 14
** 006 VVT 20240618 Forced ConsoleHelper.terminate() after test engine initialization failure. See #8529-7.
15
** 007 ME  20241231 Use the client initialization structure to support both chui/gui modes.
16
**                  Allow usage of environment variable to specify the xml configuration file (Eclipse).
15 17
*/
16 18
/*
17 19
** This program is free software: you can redistribute it and/or modify
......
82 84
import com.goldencode.p2j.cfg.*;
83 85
import com.goldencode.p2j.main.*;
84 86
import com.goldencode.p2j.net.*;
85
import com.goldencode.p2j.ui.client.chui.driver.console.*;
86 87
import com.goldencode.p2j.ui.client.driver.*;
87 88

  
88 89
/**
......
148 149
    * Unit test support on the server proxy instance.
149 150
    */
150 151
   private static UnitTestEngine unitTestSupport;
152
   
153
   /**
154
    * Client initialization structure, screen driver supports chui/gui modes.
155
    */
156
   private static ClientCore.InitStruct is;
151 157

  
152 158
   /**
153 159
    * Initialize the engine.
......
173 179
         ScreenDriver<?> driver = (uuid == null) ? null : ClientCore.processTemporaryClient(uuid, bc);
174 180
         ClientCore.loadNativeLibrary();
175 181

  
176
         final ClientCore.InitStruct is = new ClientCore.InitStruct();
182
         is = new ClientCore.InitStruct();
177 183
         ClientCore.setOutputToFile(bc);
178 184
         is.driver = driver;
179 185
         ClientCore.initialize(is,
......
192 198
      }
193 199
      catch (Throwable thr)
194 200
      {
195
         ConsoleHelper.terminate();
201
    	 is.driver.shutdown();
196 202
         
197 203
         LOG.warning("Test engine cannot initialize and will be disabled: " + thr);
198 204

  
......
229 235
         case NONE:
230 236
            final ConfigurationParameters configurationParameters = discoveryRequest
231 237
                     .getConfigurationParameters();
232
            if (initialize(
233
                     configurationParameters.get(CFG_FWD_CONFIG_FILE).orElse(DEFAULT_FWD_CONFIG_FILE)))
234
            {
235
               state = State.INITIALIZED;
236
               break;
237
            }
238
            String configFile = configurationParameters.get(CFG_FWD_CONFIG_FILE).orElse(System.getenv(CFG_FWD_CONFIG_FILE));
239
            
240
			if (initialize(configFile != null ? configFile : DEFAULT_FWD_CONFIG_FILE)) {
241
				state = State.INITIALIZED;
242
				break;
243
			}
238 244
            //$FALL-THROUGH$
239 245

  
240 246
         case INOPERABLE:
......
301 307
   @Override
302 308
   protected FWDEngineExecutionContext createExecutionContext(ExecutionRequest request)
303 309
   {
304
      return new FWDEngineExecutionContext(unitTestSupport);
310
      return new FWDEngineExecutionContext(unitTestSupport, is);
305 311
   }
306 312

  
307 313
   /**