Project

General

Profile

6237-173-r14306.diff

Vladimir Tsichevski, 10/19/2022 08:45 AM

Download (179 KB)

View differences:

build.gradle 2022-10-09 08:30:26 +0000
103 103
**     OM  20220812 Upgraded mariadb JDBC driver from 2.7.3 to 3.0.7 GA.
104 104
**     TW  20220928 Changed junixsocket dependency to official repository, and upped its version to latest.
105 105
**     TW  20221007 Upgraded junixsocket to 2.5.2.
106
**     VVT 2022xxxx JUnit5 dependencies updated to support both existing tests and custom test engine.
107
**                  See #6237.
106 108
*/
107 109

  
108 110
/*
......
582 584
       aspectjCompile group: 'org.aspectj', name: 'aspectjweaver', version: aspectjVersion
583 585
    }
584 586

  
585
    fwdAllTest group: 'org.junit.platform', name: 'junit-platform-console-standalone', version: '1.7.1'
587
    // Adding JUnit5 jar both to client and server, so it will be also deployed to converted projects
588
    fwdClientServer group: 'org.junit.platform',
589
                    name: 'junit-platform-engine',
590
                    version: '1.9.0'
591

  
592
    fwdClientServer group: 'org.junit.platform',
593
                    name: 'junit-platform-suite-engine',
594
                    version: '1.9.0'
595
    fwdAllTest group: 'org.junit.platform',
596
                    name: 'junit-platform-console',
597
                    version: '1.9.0'
598
    fwdAllTest group: 'org.junit.platform',
599
                    name: 'junit-platform-engine',
600
                    version: '1.9.0'
586 601
}
587 602

  
588 603
// inject ant-optional dependencies to ant, this is needed for the antlr ant target
build.xml 2022-10-19 10:03:52 +0000
235 235
**                           projects that include admin need the src/com/goldencode tree to be in place. Ref #6214.
236 236
**     RFB 20221017          Move the p2jpl.jar out of the standard build, and into its own "p2jpl" target. This is
237 237
**                           the first step in that jar's deprecation. Remove the FontTable class, too. Ref #6664.
238
**     VVT 2022xxxx          Copy org.junit.platform.engine.TestEngine file to META-INF/services. See #6237.
238 239
-->
239 240

  
240 241
<!--
......
885 886
    <!-- Copy SPI descriptors to META-INF/services directory -->
886 887
    <copy todir="${build.home}/classes/META-INF/services">
887 888
      <fileset dir="${manifest.src}" includes="*Provider" />
889
      <fileset dir="${manifest.src}" includes="*TestEngine" />
888 890
    </copy>
889 891

  
890 892
    <!-- Copy aop.xml to META-INF directory for LTW-specific AOP jar -->
manifest/org.junit.platform.engine.TestEngine 2022-09-19 20:26:43 +0000
1
com.goldencode.p2j.testengine.FWDTestEngine
rules/annotations/annotations.xml 2022-09-30 11:50:03 +0000
263 263
**                           element.
264 264
**     VVT 20220913          OEUnit support: annotations/unit_test_support added. See #6237.
265 265
**     VVT 20220913          Prevent unsupported legacy annotations from going to Java code. See #6237.
266
**     VVT 20220914          Changes in revs. 14243,14241,14239 temporarily reverted until JUnit runtime
267
**                           support is added to client projects.
266
**     VVT 2022xxxx          Two more rulesets processed: unit_test_support and legacy_annotations_post.
267
**                           See #6237.
268 268
*/
269 269
 -->
270 270
 
......
678 678
   <rule-set name="annotations/method_defs" />
679 679
   <rule-set name="annotations/procedures" />
680 680
   <rule-set name="annotations/legacy_services" />
681
   <!-- <rule-set name="annotations/unit_test_support" /> -->
682
   <!-- <rule-set name="annotations/legacy_annotations_post" /> -->
681
   <rule-set name="annotations/unit_test_support" />
682
   <rule-set name="annotations/legacy_annotations_post" />
683 683
   <rule-set name="annotations/case_statements" />
684 684
   <rule-set name="annotations/input_output" />
685 685
   <rule-set name="annotations/assignment_style_stmt_rewriting" />
rules/annotations/legacy_services.rules 2022-09-30 11:51:48 +0000
21 21
** 005 VVT 20220913 OEUnit support: code removing all annotations removed. See #6237.
22 22
**     VVT 20220913 Prevent unsupported legacy annotations from going to Java code. See #6237.
23 23
**                  Use new create_java_annotation() function to create Java annotation nodes.
24
**     VVT 20220914 Changes in revs. 14243,14241,14239 temporarily reverted until JUnit runtime
25
**                  support is added to client projects.
24
**     VVT 2022xxxx Changes in revs. 14243,14241,14239 restored. See #6237.
26 25
*/
27 26
 -->
28 27
 
......
212 211
            <while>iter.hasNext()
213 212
               <action>prest = iter.next()</action>
214 213
               
215
               <action>ref = createProgressAst(prog.annotation, "@", pref)</action>
216
               <action>ref.putAnnotation("javaname", "LegacyServiceParameter")</action>
217
               <action>ref.putAnnotation("name", "LegacyServiceParameter")</action>
214
               
215
               <action>ref = execLib("create_java_annotation", pref, "LegacyServiceParameter", -1)</action>
218 216
               
219 217
               <rule>execLib("assign_field_int", ref, "ordinal", prest.ordinal())</rule>
220 218
               
......
308 306
            <rule>keep
309 307
               <action>hasSrvs = true</action>
310 308
               
311
               <action on="false">ref.remove()</action>
309
               <!-- Do NOT remove unsupported annotations here, they will be removed in legacy_annotations_post.rules -->
310
               <!-- <action on="false">ref.remove()</action> -->
312 311
            </rule>
313 312
         </while>
314 313
      </function>
......
343 342
         
344 343
         <action>hasSrvs = true</action>
345 344
         
346
         <action>ref = createProgressAst(prog.annotation, "@", copy, 1)</action>
347
         <action>ref.putAnnotation("javaname", "LegacyService")</action>
348
         <action>ref.putAnnotation("name", "LegacyService")</action>
345
         <action>ref = execLib("create_java_annotation", copy, "LegacyService", 1)</action>
349 346
         
350 347
         <action>execLib("assign_field", ref, "type", "SOAP")</action>
351 348
         <action>execLib("assign_field", ref, "namespace", soapOp.getNamespace())</action>
......
401 398
            <action>soapOp = iter.next()</action>
402 399
            <action>hasSrvs = true</action>
403 400

  
404
            <action>ref = createProgressAst(prog.annotation, "@", copy, 1)</action>
405
            <action>ref.putAnnotation("javaname", "LegacyService")</action>
406
            <action>ref.putAnnotation("name", "LegacyService")</action>
401
            <action>ref = execLib("create_java_annotation", copy, "LegacyService", 1)</action>
407 402
            
408 403
            <action>execLib("assign_field", ref, "type", "SOAP")</action>
409 404
            <action>execLib("assign_field", ref, "namespace", soapOp.getNamespace())</action>
......
419 414
      <rule>this.type == prog.class_def and srv.isWebHandler(oname)
420 415
         <action>hasSrvs = true</action>
421 416
         
422
         <action>ref = createProgressAst(prog.annotation, "@", copy, 1)</action>
423
         <action>ref.putAnnotation("javaname", "LegacyService")</action>
424
         <action>ref.putAnnotation("name", "LegacyService")</action>
417
         <action>ref = execLib("create_java_annotation", copy, "LegacyService", 1)</action>
425 418
         
426 419
         <rule>execLib("assign_field", ref, "name", srv.getSection(oname))</rule>
427 420
         <rule>execLib("assign_field", ref, "type", "WEBHANDLER")</rule>
......
432 425
         <while>iter.hasNext()
433 426
            <action>path = iter.next()</action>
434 427

  
435
            <action>ref = createProgressAst(prog.annotation, "@", pref)</action>
436
            <action>ref.putAnnotation("javaname", "LegacyWebPath")</action>
437
            <action>ref.putAnnotation("name", "LegacyWebPath")</action>
428
            <action>ref = execLib("create_java_annotation", pref, "LegacyWebPath", -1)</action>
438 429

  
439 430
            <action>execLib("assign_field", ref, "path", path.path())</action>
440 431
            <action>execLib("assign_field_int", ref, "order", path.order())</action>
rules/annotations/unit_test_support.rules 2022-10-18 18:52:05 +0000
9 9
** _#_ _I_ __Date__  ___________________________Description____________________________
10 10
** 001 VVT 20220913  Initial version
11 11
**     VVT 20220913  Prevent unsupported legacy annotations from going to Java code. See #6237.
12
**     VVT 2022xxxx Custom test engine annotations are now used instead of that
13
**                  from the Jupiter test engine. See #6237.
12 14
*/
13 15
 -->
14 16
<!--
......
65 67
-->
66 68
<rule-set>
67 69
   <worker class="com.goldencode.p2j.uast.ProgressPatternWorker" namespace="prog" />
70
   <worker class="com.goldencode.p2j.uast.UastHintsWorker"       namespace="hints" />
71
   <worker class="com.goldencode.p2j.convert.ExpressionConversionWorker" namespace="ecw" />
72
   
73
   <func-library access="private">
74
      <!-- FIXME: functions in this library are mostly copied from the legacy_services.rules.
75
           they should probably go to some public library -->
76
      <!--
77
          Create an assignment <attName>=
78
      -->
79
      <function name="assign_field_part">
80
         <!-- The parent node -->
81
         <parameter name="parent" type="com.goldencode.ast.Aast" />
82
         <!-- the left part attribute name -->
83
         <parameter name="attName" type="java.lang.String" />
84
         
85
         <return name="tref" type="com.goldencode.ast.Aast" />
86
         
87
         <variable name="chref" type="com.goldencode.ast.Aast" />
88
         
89
         <rule>tref = createProgressAst(prog.assign, "=", parent)</rule>
90
         
91
         <rule>chref = createProgressAst(prog.symbol, attName, tref)</rule>
92
         <rule>chref.putAnnotation("javaname", attName)</rule>
93
      </function>
94
   
95
      <!--
96
          Create an assignment <attName>=[
97
      -->
98
      <function name="assign_field_array">
99
         <parameter name="parent" type="com.goldencode.ast.Aast" />
100
         <parameter name="attName" type="java.lang.String" />
101
         
102
         <return name="tref" type="com.goldencode.ast.Aast" />
103
         
104
         <rule>tref = execLib("assign_field_part", parent, attName)</rule>
105
         <rule>tref = createProgressAst(prog.lbracket, "[", tref)</rule>
106
      </function>
107
   </func-library>
68 108
   <walk-rules>
69 109
      <rule>this.type == prog.annotation
70
            and parent.type == prog.method_def
110
            and (parent.type == prog.method_def or parent.type == prog.class_def)
111
            
112
         <!-- Get required unit test legacy type configuration (hints) -->
113
         <variable name="unitTestType" type="java.lang.String" />
114
         <action>unitTestType = hints.getUnitTestType()</action>
115
         <rule>unitTestType == null
116
            <action>compileError(223, "No unit test legacy type is configured")</action>
117
         </rule>
118
         
119
         <variable name="isABLUnit" type="java.lang.Boolean" />
120
         <action>isABLUnit = unitTestType.equals("ABLUnit")</action>
121

  
122
         <variable name="methodNode" type="com.goldencode.ast.Aast" />
123
         <action>methodNode = parent.firstChild</action>
124

  
125
         <!-- FIXME: Add similar support for procedures -->
71 126

  
72 127
         <!-- Get initial annotation name -->
73 128
         <variable name="annoName" type="java.lang.String" />
74 129
         <action>annoName = this.getAnnotation("javaname")</action>
75 130

  
131
         <action>printfln("method %s is ABL unit test type %s annoName @%s", methodNode.getAnnotation("name"), isABLUnit, annoName)</action>
132

  
76 133
         <variable name="newName" type="java.lang.String" />
77 134
         <action>newName = null</action>
78 135

  
79
         <!-- Replace OEUnit annotation names (made after JUnit 4) by JUnit 5 names -->
80
         <rule>annoName.equals("Test")
81
            <action>newName = "org.junit.jupiter.api.Test"</action>
82
            <rule on="false">annoName.equals("Before")
83
               <action>newName = "org.junit.jupiter.api.BeforeEach"</action>
84
               <rule on="false">annoName.equals("After")
85
                  <action>newName = "org.junit.jupiter.api.AfterEach"</action>
86
                  <rule on="false">annoName.equals("BeforeClass")
87
                     <action>newName = "org.junit.jupiter.api.BeforeAll"</action>
88
                     <rule on="false">annoName.equals("AfterClass")
89
                        <action>newName = "org.junit.jupiter.api.AfterAll"</action>
90
                        <rule on="false">annoName.equals("Ignore")
91
                           <action>newName = "org.junit.jupiter.api.Disabled"</action>
136
         <!-- Replace OEUnit/ABLUnit annotation names by corresponding JUnit5 names -->
137
         <rule>annoName.equalsIgnoreCase("Test")
138
            <action>newName = "com.goldencode.p2j.testengine.api.Test"</action>
139

  
140
            <!-- Note: the meaning of @Before and @After is opposite in ABLUnit and OEUnit -->
141
            <rule on="false">annoName.equalsIgnoreCase("Before")
142
               <rule>isABLUnit
143
                  <action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action>
144
                  <action on="false">newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action>
145
               </rule>
146
               <rule on="false">annoName.equalsIgnoreCase("After")
147
                  <rule>isABLUnit
148
                     <action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action>
149
                     <action on="false">newName = "com.goldencode.p2j.testengine.api.AfterEach"</action>
150
                  </rule>
151
                  <rule on="false">annoName.equalsIgnoreCase("BeforeClass")
152
                     <action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action>
153
                     <rule on="false">annoName.equalsIgnoreCase("AfterClass")
154
                        <action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action>
155
                        <rule on="false">annoName.equalsIgnoreCase("Ignore")
156
                           <action>newName = "com.goldencode.p2j.testengine.api.Disabled"</action>
157
                        </rule>
158
                        <rule on="false">annoName.equalsIgnoreCase("Setup")
159
                           <action>newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action>
160
                           <rule on="false">annoName.equalsIgnoreCase("TearDown")
161
                              <action>newName = "com.goldencode.p2j.testengine.api.AfterEach"</action>
162
                              <rule on="false">annoName.equalsIgnoreCase("Suite")
163
                                 <action>newName = "com.goldencode.p2j.testengine.api.Suite"</action>
164

  
165
                                 <rule on="false">annoName.equalsIgnoreCase("SelectClasses")
166
                                    <!-- Get the "value" attribute, convert the quoted comma-separated list of class
167
                                         names to nodes of prog.symbol type -->
168
                                    <action>newName = "com.goldencode.p2j.testengine.api.SelectClasses"</action>
169
                                    <variable name="ref" type="com.goldencode.ast.Aast" />
170
                                    <!-- Go to the second child, which must be attribute assignment -->
171
                                    <action>ref = copy.getChildAt(1)</action>
172
                                    <rule>ref == null
173
                                       <action>compileError(367, "@SelectClasses annotation must have a child")</action>
174
                                    </rule>
175
                                    <rule>ref.type == prog.assign
176
                                       <action on="false">compileError(367, "@SelectClasses children must have the assignment type")</action>
177
                                    </rule>
178
                                    <action>ref = ref.firstChild</action>
179
                                    <rule>ref.getAnnotation("javaname").equals("value")
180
                                       <action on="false">compileError(367, "@SelectClasses: attribute name must be 'value'")</action>
181
                                    </rule>
182
                                    <!-- Go to second child od ASSIGN, which must be a STRING literal -->
183
                                    <action>ref = ref.nextSibling</action>
184
                                    <rule>ref.type == prog.string and ref.getAnnotation("is-literal").equals("true")
185
                                       <action>compileError(367, "@SelectClasses attribute assignment right part must be a string literal")</action>
186
                                    </rule>
187
                                    <!-- Get the value of the "value" attribute ofthe annotation, strip surrounding quotes -->
188
                                    <variable name="classList" type="java.lang.String" />
189
                                    <action>classList = ecw.stripQuotes(ref.getText())</action>
190

  
191
                                    <!-- Now we can drop the original value -->
192
                                    <action>ref.getParent().remove()</action>
193
                                    
194
                                    <action>printfln("Classlist %s", classList)</action>
195

  
196
                                    <!-- Create a node of the array type -->
197
                                    <action>ref = execLib("assign_field_array", copy, "value")</action>
198
                                    <!-- Parse and convert the comma-separated list -->
199
                                    <variable name="classNameList" type="java.util.List" />
200
                                    <action>classNameList = createListFromObject(classList.split(","))</action>
201
                                    <variable name="classNames" type="java.util.Iterator" />
202
                                    <action>classNames = classNameList.iterator()</action>
203
                                    <while>classNames.hasNext()
204
                                       <variable name="className" type="java.lang.String" />
205
                                       <action>className = (#(java.lang.String)classNames.next()).trim()</action>
206
                                       <action>printfln("Class name '%s'", className)</action>                                       
207
                                       <action>createProgressAst(prog.symbol, sprintf("%s.class", className), ref)</action>
208
                                    </while>            
209
                                 </rule>
210
                              </rule>
211
                           </rule>
92 212
                        </rule>
93 213
                     </rule>
94 214
                  </rule>
95 215
               </rule>
96 216
            </rule>
97 217
         </rule>
98

  
99 218
         <rule>newName != null
100
           <!-- Write it back and mark "our" annotations as preserved -->
101
           <action>copy.putAnnotation("javaname", newName)</action>
102
           <action>copy.putAnnotation("fwd", true)</action>
219
            <action>printfln("newName %s", newName)</action>
220
            <!-- Write it back... -->
221
            <action>copy.putAnnotation("javaname", newName)</action>
222
            <!-- ...and mark "our" annotations as preserved -->
223
            <action>copy.putAnnotation("fwd", true)</action>
103 224
         </rule>
104 225
      </rule>
105 226
      
rules/convert/core_conversion.xml 2022-09-30 11:59:12 +0000
71 71
** 026 VVT 20220913          OEUnit support: convert/unit_test_support added. See #6237.
72 72
**     VVT 20220914          Changes in revs. 14243,14241,14239 temporarily reverted until JUnit runtime
73 73
**                           support is added to client projects.
74
**     VVT 2022xxxx          Changes in revs. 14243,14241,14239 restored. See #6237.
74 75
*/
75 76
 -->
76 77
 
......
184 185
        Progress source constructs into the equivalent Java constructs
185 186
        rooted in the Java AST -->
186 187
   <rule-set honor-hidden="true" input="tree" load-condition="runtime-query">
187
      <!-- <rule-set name="convert/unit_test_support" /> -->
188
      <rule-set name="convert/unit_test_support" />
188 189
      <rule-set name="convert/variable_definitions" />
189 190
      <!-- the order of the following rules is important - method_definitions' ascent-rules will
190 191
           emit the signature's parameter annotations -->
rules/convert/unit_test_support.rules 2022-10-18 18:36:43 +0000
9 9
** _#_ _I_ __Date__  ___________________________Description____________________________
10 10
** 001 VVT 20220913  Initial version
11 11
**     VVT 20220913  Prevent unsupported legacy annotations from going to Java code. See #6237.
12
**     VVT 2022xxxx  Custom test engine annotations are now used instead of that
13
**                   from the Jupiter test engine. See #6237.
12 14
*/
13 15
 -->
14 16
<!--
......
66 68
<rule-set>
67 69
   <worker class="com.goldencode.p2j.convert.ConverterHelper" namespace="help" />
68 70
   <worker class="com.goldencode.p2j.uast.ProgressPatternWorker" namespace="prog" />
71
   <worker class="com.goldencode.p2j.convert.ExpressionConversionWorker" namespace="ecw" />
72
   
69 73
   <variable name="hasJUnit5Annotations" type="java.lang.Boolean"/>
70 74

  
71 75
   <!-- Detect if any of JUnit 5 annotations exist in the tree -->
72 76
   <walk-rules>
73 77
      <rule>this.type == prog.annotation
74
            and parent.type == prog.method_def
78
            and (parent.type == prog.method_def or parent.type == prog.class_def)
75 79
         <variable name="annoName" type="java.lang.String" />
76 80
         <action>annoName = this.getAnnotation("javaname")</action>
77 81
         <rule>
78
            annoName.equals("org.junit.jupiter.api.Test") or
79
            annoName.equals("org.junit.jupiter.api.BeforeEach") or
80
            annoName.equals("org.junit.jupiter.api.AfterEach")  or
81
            annoName.equals("org.junit.jupiter.api.BeforeAll")  or
82
            annoName.equals("org.junit.jupiter.api.AfterAll")   or
83
            annoName.equals("org.junit.jupiter.api.Disabled")
82
            annoName.startsWith("com.goldencode.p2j.testengine.api.")
84 83
            <!-- Replace fully-qualified name by simple name -->
85
            <action>copy.putAnnotation("javaname", annoName.substring(22))</action>
84
            <action>copy.putAnnotation("javaname", annoName.substring(34))</action>
86 85
            <action>hasJUnit5Annotations = true</action>
87 86
         </rule>
88 87
      </rule>
88
      <rule>upPath("ANNOTATION/ASSIGN/LBRACKET")
89
            and this.type == prog.symbol
90
         <action>printfln("ANNOTATION/ASSIGN/LBRACKET text '%s'", this.getText())</action>
91
         <action>createJavaAst(java.reference, ecw.stripQuotes(this.getText()), getClosestPeerId())</action>
92
      </rule>
89 93
   </walk-rules>
90 94
   <post-rules>
91 95
      <rule>hasJUnit5Annotations == true
92
         <action>help.createImport("org.junit.jupiter.api.*")</action>
96
         <action>help.createImport("com.goldencode.p2j.testengine.api.*")</action>
93 97
         <action>hasJUnit5Annotations = false</action>
94 98
      </rule>
95 99
   </post-rules>
src/com/goldencode/p2j/cfg/Configuration.java 2022-09-30 11:47:48 +0000
75 75
**     CA  20220412          Added file-set support (either -Z command-line option or p2j.cfg.xml 
76 76
**                           configuration).
77 77
**     OM  20220421          Restored the ability to load the configuration file relative to P2J_HOME folder.
78
**     VVT 2022xxxx          Constant added: default legacy unit test framework type. See #6237. 
78 79
*/
79 80

  
80 81
/*
......
268 269
   /** Default configuration filename */
269 270
   public static final String DEF_CFG_FILE = "p2j.cfg.xml";
270 271
   
272
   /** Default legacy unit test type */
273
   public static final String DEF_UNIT_TEST_TYPE = "ABLUnit";
274
   
271 275
   /** Singleton instance. */
272 276
   private static volatile Configuration instance;
273 277
   
src/com/goldencode/p2j/main/ClientCore.java 2022-10-12 22:01:49 +0000
60 60
**     CA  20220208 Added -errorstack command-line option (client:cmd-line-option:error-stack).
61 61
**     SVL 20220620 "ininame" parameter handling moved earlier to TC.initializePost.
62 62
**     CA  20220918 Added socket trust store filename and password to the ClientParameters.
63
**     VVT 2022xxxx Native methods processInit and getPid made public to be accessible from
64
**                  FWD test engine. See #6237.
63 65
*/
64 66
/*
65 67
** This program is free software: you can redistribute it and/or modify
......
121 123
import java.util.logging.*;
122 124

  
123 125
import com.goldencode.p2j.cfg.*;
126
import com.goldencode.p2j.directory.*;
124 127
import com.goldencode.p2j.net.*;
125
import com.goldencode.p2j.directory.*;
128
import com.goldencode.p2j.net.Session;
126 129
import com.goldencode.p2j.security.SecurityManager;
130
import com.goldencode.p2j.ui.chui.*;
127 131
import com.goldencode.p2j.ui.client.*;
128 132
import com.goldencode.p2j.ui.client.driver.*;
129
import com.goldencode.p2j.ui.chui.ThinClient;
130 133
import com.goldencode.p2j.util.*;
131 134

  
132 135
/**
......
172 175
    *           <code>false</code> for the normal client JVM startup.
173 176
    * @param    diag
174 177
    *           Details about the driver state that can help diagnose server startup issues.
175
    *           
176 178
    * @throws Exception 
177 179
    */
178 180
   public static void start(BootstrapConfig config, boolean file, boolean single, Supplier<String> diag)
......
357 359
         // set up current user name for client session
358 360
         ThinClient.getInstance().setUserName(params.osUserName);
359 361

  
362
         
360 363
         // call the application
361 364
         running = main.standardEntry();
362 365
         
......
438 441
   /**
439 442
    * Native call to set up and redefine signal processing handlers.
440 443
    */
441
   private static native void processInit();
444
   public static native void processInit();
442 445
   
443 446
   /**
444 447
    * Native call to read the operating system pid for the current JVM process.
448
    * 
449
    * @return see above 
445 450
    */
446
   private static native long getPid();
451
   public static native long getPid();
447 452
   
448 453
   /**
449 454
    * Native call to read the operating system user name for the current JVM process.
455
    * 
456
    * @return see above 
450 457
    */
451
   private static native String getUserName();
458
   public static native String getUserName();
452 459
   
453 460
   /**
454 461
    * Initialize the logger if needed.
src/com/goldencode/p2j/main/StandardServer.java 2022-10-12 21:57:10 +0000
203 203
**                           allows a lazy registration of scopeables, to avoid the unnecessary overhead of
204 204
**                           processing all the scopeables for each and every block.
205 205
**     CA  20220906          Moved the interactive client cleaner to LogicalTerminal.registerCleaner().
206
**     VVT 2022xxxx          UnitTestEngine static network server registration added. See #6237.
206 207
*/
207 208

  
208 209
/*
......
264 265
import java.lang.reflect.*;
265 266
import java.util.*;
266 267
import java.util.concurrent.*;
267
import java.util.function.Supplier;
268
import java.util.function.*;
268 269
import java.util.logging.*;
270

  
269 271
import javax.servlet.*;
272

  
270 273
import org.eclipse.jetty.server.handler.*;
271 274
import org.eclipse.jetty.util.resource.Resource;
272 275
import org.eclipse.jetty.webapp.*;
276

  
273 277
import com.goldencode.ast.*;
274 278
import com.goldencode.p2j.*;
275 279
import com.goldencode.p2j.admin.*;
......
287 291
import com.goldencode.p2j.security.*;
288 292
import com.goldencode.p2j.security.SecurityManager;
289 293
import com.goldencode.p2j.soap.*;
294
import com.goldencode.p2j.testengine.*;
290 295
import com.goldencode.p2j.ui.*;
291 296
import com.goldencode.p2j.util.*;
292 297
import com.goldencode.p2j.util.ErrorManager;
......
992 997
      
993 998
      ifaces = new Class[] { ServerPropertiesInspector.class };
994 999
      RemoteObject.registerStaticNetworkServer(ifaces, ServerPropertiesDaemon.class);
995
      
1000
            
1001
      RemoteObject.registerStaticNetworkServer(new Class[] { UnitTestEngine.class }, UnitTestServer.class);
1002

  
996 1003
      AdminServerImpl.initialize();
997 1004
      
998 1005
      DirectoryManager.initServer();
......
1114 1121
    * @param   ds
1115 1122
    *          The directory service.
1116 1123
    */
1117
   private void initClassLoaders(DirectoryService ds)
1124
   private static void initClassLoaders(DirectoryService ds)
1118 1125
   {
1119 1126
      // initialize the class loaders for the jars defined in the directory
1120 1127
      String path = Utils.findDirectoryNodePath(ds,
src/com/goldencode/p2j/main/UnitTestDriver.java 2022-10-12 21:44:30 +0000
1
/**
2
 * 
3
 */
4
package com.goldencode.p2j.main;
5

  
6
import com.goldencode.p2j.cfg.*;
7

  
8
/**
9
 * The purpose of this class is to explore how to start client with no command line.
10
 */
11
public class UnitTestDriver
12
{
13

  
14
   /**
15
    * The main entry
16
    * 
17
    * @param args
18
    *        for now unused
19
    */
20
   public static void main(String[] args)
21
   {
22
      // process arguments: either config files of overrides
23
      // try standard configuration file if none is given
24
      BootstrapConfig bc = null;
25

  
26
      try
27
      {
28
         bc = new BootstrapConfig(null, null, null, null);
29
      }
30
      catch (ConfigurationException e)
31
      {
32
         e.printStackTrace();
33
         System.exit(1);
34
      }
35

  
36
      bc.setServer(false);
37

  
38
      String convo = null;
39

  
40
      try
41
      {
42
         convo = bc.getConfigItem("net", "queue", "conversation");
43
      }
44
      catch (ConfigurationException ce)
45
      {
46
         // ignore
47
      }
48

  
49
      // default to conversation mode if not specified
50
      if (convo == null)
51
      {
52
         bc.setConfigItem("net", "queue", "conversation", "true");
53
      }
54

  
55
      // either way, force start thread to false (this client is going to
56
      // use its main thread as the conversation thread so we don't need
57
      // to start one
58
      bc.setConfigItem("net", "queue", "start_thread", "false");
59

  
60
      bc.setConfigItem("net", "server", "host", "localhost");
61
      bc.setConfigItem("net", "connection", "secure", "false");
62
      bc.setConfigItem("net", "server", "secure_port", "4434");
63
      bc.setConfigItem("net", "server", "insecure_port", "4534");
64
      bc.setConfigItem("client", "driver", "type", "gui_swing");
65
      bc.setConfigItem("client", "driver", "theme",
66
               "com.goldencode.p2j.ui.client.gui.theme.Windows10Theme");
67

  
68
      // run the application
69
      try
70
      {
71
         //         if (config.getBoolean("net", "http_client", "disable_ssl_certificate_validation", false))
72
         //         {
73
         //            Utils.disableClientSSLCertificateValidation();
74
         //         }
75

  
76
         //         if (config.getBoolean("client", "mode", "broker", false))
77
         //         {
78
         //            setClientLog("broker");
79
         //            BrokerCore.start(config);
80
         //         }
81
         //         else
82
         //         {
83
         //            ClientCore.start(config, true, false, this::printDriverDetails);
84
         //         }
85

  
86
         ClientCore.start(bc, true, false, () -> "");
87
         // ensure that remaining non-daemon threads don't stop us from closing
88
         System.exit(0);
89
      }
90
      catch (Throwable thr)
91
      {
92
         // STOP conditions don't need to be reported, they are an expected
93
         // mechanism to terminate
94
         if (ClientCore.isCauseStop(thr))
95
         {
96
            System.exit(0);
97
         }
98

  
99
         thr.printStackTrace(System.err);
100
         System.err.flush();
101
         System.exit(-13);
102
      }
103

  
104
   }
105
}
src/com/goldencode/p2j/testengine/AbstractBranchTestDescriptor.java 2022-10-12 21:04:57 +0000
1
/*
2
** Module   : AbstractBranchTestDescriptor.java
3
** Abstract : Common accessor for non-terminal test descriptors
4
**
5
** Copyright (c) 2022, Golden Code Development Corporation.
6
**
7
** -#- -I- --Date-- ----------------Description----------------------
8
** 001 VVT 2022xxxx Created initial version.
9
*/
10
/*
11
** This program is free software: you can redistribute it and/or modify
12
** it under the terms of the GNU Affero General Public License as
13
** published by the Free Software Foundation, either version 3 of the
14
** License, or (at your option) any later version.
15
**
16
** This program is distributed in the hope that it will be useful,
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
** GNU Affero General Public License for more details.
20
**
21
** You may find a copy of the GNU Affero GPL version 3 at the following
22
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
23
** 
24
** Additional terms under GNU Affero GPL version 3 section 7:
25
** 
26
**   Under Section 7 of the GNU Affero GPL version 3, the following additional
27
**   terms apply to the works covered under the License.  These additional terms
28
**   are non-permissive additional terms allowed under Section 7 of the GNU
29
**   Affero GPL version 3 and may not be removed by you.
30
** 
31
**   0. Attribution Requirement.
32
** 
33
**     You must preserve all legal notices or author attributions in the covered
34
**     work or Appropriate Legal Notices displayed by works containing the covered
35
**     work.  You may not remove from the covered work any author or developer
36
**     credit already included within the covered work.
37
** 
38
**   1. No License To Use Trademarks.
39
** 
40
**     This license does not grant any license or rights to use the trademarks
41
**     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
42
**     of Golden Code Development Corporation. You are not authorized to use the
43
**     name Golden Code, FWD, or the names of any author or contributor, for
44
**     publicity purposes without written authorization.
45
** 
46
**   2. No Misrepresentation of Affiliation.
47
** 
48
**     You may not represent yourself as Golden Code Development Corporation or FWD.
49
** 
50
**     You may not represent yourself for publicity purposes as associated with
51
**     Golden Code Development Corporation, FWD, or any author or contributor to
52
**     the covered work, without written authorization.
53
** 
54
**   3. No Misrepresentation of Source or Origin.
55
** 
56
**     You may not represent the covered work as solely your work.  All modified
57
**     versions of the covered work must be marked in a reasonable way to make it
58
**     clear that the modified work is not originating from Golden Code Development
59
**     Corporation or FWD.  All modified versions must contain the notices of
60
**     attribution required in this license.
61
*/
62
package com.goldencode.p2j.testengine;
63

  
64
import java.io.*;
65
import java.util.*;
66

  
67
import org.junit.platform.commons.util.*;
68
import org.junit.platform.engine.*;
69

  
70
/**
71
 * This class provides common functions for branch test descriptors
72
 */
73
public abstract class AbstractBranchTestDescriptor
74
extends AbstractFWDTestDescriptor
75
{
76
   /** Child descriptors */
77
   private Set<TestDescriptor> children = Collections.synchronizedSet(new LinkedHashSet<>(16));
78

  
79
   /**
80
    * The constructor.
81
    * 
82
    * @param uniqueId
83
    *        this descriptor unique ID
84
    * @param displayName
85
    *        this descriptor display name
86
    */
87
   public AbstractBranchTestDescriptor(final UniqueId uniqueId, final String displayName)
88
   {
89
      super(uniqueId, displayName);
90
   }
91

  
92
   /**
93
    * Add a <em>child</em> to this descriptor.
94
    *
95
    * @param descriptor the child to add to this descriptor; never {@code null}
96
    */
97
   @Override
98
   public void addChild(final TestDescriptor descriptor)
99
   {
100
      Preconditions.notNull(descriptor, "child must not be null");
101

  
102
      descriptor.setParent(this);
103
      children.add(descriptor);
104
   }
105

  
106
   /**
107
    * Find the descriptor with the supplied unique ID.
108
    *
109
    * <p>The search algorithm begins with this descriptor and then searches
110
    * through its descendants.
111
    *
112
    * @param uniqueId the {@code UniqueId} to search for; never {@code null}
113
    */
114
   @Override
115
   public Optional<? extends TestDescriptor> findByUniqueId(final UniqueId uniqueId)
116
   {
117
      if (getUniqueId().equals(uniqueId))
118
      {
119
         return Optional.of(this);
120
      }
121

  
122
      return children.stream().map(child -> child.findByUniqueId(uniqueId))
123
               .filter(Optional::isPresent).findAny().orElse(Optional.empty());
124
   }
125

  
126
   /**
127
    * Get the immutable set of <em>children</em> of this descriptor.
128
    *
129
    * @return the set of children of this descriptor; neither {@code null}
130
    * nor mutable, but potentially empty
131
    * @see #getDescendants()
132
    */
133
   @Override
134
   public final Set<? extends TestDescriptor> getChildren()
135
   {
136
      return Collections.unmodifiableSet(children);
137
   }
138

  
139
   /**
140
   * Determine the {@link org.junit.platform.engine.TestDescriptor.Type} of this descriptor.
141
   *
142
   * @return the descriptor type; never {@code null}.
143
   * @see #isContainer()
144
   * @see #isTest()
145
   */
146
   @Override
147
   public Type getType()
148
   {
149
      return Type.CONTAINER;
150
   }
151

  
152
   /**
153
    * The object implements the readExternal method to restore its
154
    * contents by calling the methods of DataInput for primitive
155
    * types and readObject for objects, strings and arrays.  The
156
    * readExternal method must read the values in the same sequence
157
    * and with the same types as were written by writeExternal.
158
    *
159
    * @param in the stream to read data from in order to restore the object
160
    * @exception IOException if I/O errors occur
161
    * @exception ClassNotFoundException If the class for an object being
162
    *              restored cannot be found.
163
    */
164
   @Override
165
   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
166
   {
167
      super.readExternal(in);
168
      
169
      children = (Set<TestDescriptor>) in.readObject();
170
      
171
      for(final TestDescriptor child : children)
172
      {
173
         child.setParent(this);
174
      }
175
   }
176

  
177
   /**
178
    * Remove a <em>child</em> from this descriptor.
179
    *
180
    * @param descriptor the child to remove from this descriptor; never
181
    * {@code null}
182
    */
183
   @Override
184
   public void removeChild(TestDescriptor descriptor)
185
   {
186
      Preconditions.notNull(descriptor, "child must not be null");
187

  
188
      children.remove(descriptor);
189
      descriptor.setParent(null);
190
   }
191

  
192
   /**
193
    * The object implements the writeExternal method to save its contents
194
    * by calling the methods of DataOutput for its primitive values or
195
    * calling the writeObject method of ObjectOutput for objects, strings,
196
    * and arrays.
197
    *
198
    * @serialData Overriding methods should use this tag to describe
199
    *             the data layout of this Externalizable object.
200
    *             List the sequence of element types and, if possible,
201
    *             relate the element to a public/protected field and/or
202
    *             method of this Externalizable class.
203
    *
204
    * @param out the stream to write the object to
205
    * @exception IOException Includes any I/O exceptions that may occur
206
    */
207
   @Override
208
   public void writeExternal(ObjectOutput out) throws IOException
209
   {
210
      super.writeExternal(out);
211
      
212
      out.writeObject(children);
213
   }
214

  
215
}
src/com/goldencode/p2j/testengine/AbstractFWDTestDescriptor.java 2022-10-18 20:35:01 +0000
1
/*
2
** Module   : AbstractDWDTestDescriptor.java
3
** Abstract : Common accessor for all test descriptors
4
**
5
** Copyright (c) 2022, Golden Code Development Corporation.
6
**
7
** -#- -I- --Date-- ----------------Description----------------------
8
** 001 VVT 2022xxxx Created initial version.
9
*/
10
/*
11
** This program is free software: you can redistribute it and/or modify
12
** it under the terms of the GNU Affero General Public License as
13
** published by the Free Software Foundation, either version 3 of the
14
** License, or (at your option) any later version.
15
**
16
** This program is distributed in the hope that it will be useful,
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
** GNU Affero General Public License for more details.
20
**
21
** You may find a copy of the GNU Affero GPL version 3 at the following
22
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
23
** 
24
** Additional terms under GNU Affero GPL version 3 section 7:
25
** 
26
**   Under Section 7 of the GNU Affero GPL version 3, the following additional
27
**   terms apply to the works covered under the License.  These additional terms
28
**   are non-permissive additional terms allowed under Section 7 of the GNU
29
**   Affero GPL version 3 and may not be removed by you.
30
** 
31
**   0. Attribution Requirement.
32
** 
33
**     You must preserve all legal notices or author attributions in the covered
34
**     work or Appropriate Legal Notices displayed by works containing the covered
35
**     work.  You may not remove from the covered work any author or developer
36
**     credit already included within the covered work.
37
** 
38
**   1. No License To Use Trademarks.
39
** 
40
**     This license does not grant any license or rights to use the trademarks
41
**     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
42
**     of Golden Code Development Corporation. You are not authorized to use the
43
**     name Golden Code, FWD, or the names of any author or contributor, for
44
**     publicity purposes without written authorization.
45
** 
46
**   2. No Misrepresentation of Affiliation.
47
** 
48
**     You may not represent yourself as Golden Code Development Corporation or FWD.
49
** 
50
**     You may not represent yourself for publicity purposes as associated with
51
**     Golden Code Development Corporation, FWD, or any author or contributor to
52
**     the covered work, without written authorization.
53
** 
54
**   3. No Misrepresentation of Source or Origin.
55
** 
56
**     You may not represent the covered work as solely your work.  All modified
57
**     versions of the covered work must be marked in a reasonable way to make it
58
**     clear that the modified work is not originating from Golden Code Development
59
**     Corporation or FWD.  All modified versions must contain the notices of
60
**     attribution required in this license.
61
*/
62
package com.goldencode.p2j.testengine;
63

  
64
import java.io.*;
65
import java.util.*;
66

  
67
import org.junit.platform.engine.*;
68
import org.junit.platform.engine.TestDescriptor.*;
69
import org.junit.platform.engine.support.hierarchical.*;
70

  
71
import com.goldencode.util.*;
72

  
73
/**
74
 * This class provides common functions for all FWD test descriptors:
75
 * 
76
 * <li>Stores unique ID, display name and parent reference.
77
 * <li>Serialization: FWD test descriptors travel over network, so they must be serializable.
78
 * <li>Implements {@link Node} interface: all methods are passed to a proxy to be executed on the server.
79
 */
80
public abstract class AbstractFWDTestDescriptor
81
         implements Externalizable, TestDescriptor, Node<FWDEngineExecutionContext>, Printable
82
{
83

  
84
   /** This descriptor display name */
85
   private String displayName;
86

  
87
   /** The parent descriptor or {@code null} if this is the root (test engine) descriptor */
88
   private TestDescriptor parent;
89
   
90
   /** The descriptor unique ID */
91
   private UniqueId uniqueId;
92

  
93
   /**
94
    * The constructor.
95
    * 
96
    * @param uniqueId
97
    *        the descriptor unique ID
98
    * @param displayName
99
    *        the descriptor display name
100
    */
101
   public AbstractFWDTestDescriptor(final UniqueId uniqueId, final String displayName)
102
   {
103
      this.uniqueId = uniqueId;
104
      this.displayName = displayName;
105
   }
106

  
107
   /**
108
    * Default constructor. Must be used internally for serialization only.
109
    */
110
   protected AbstractFWDTestDescriptor()
111
   {
112
      this(null, null);
113
   }
114

  
115
   /**
116
    * Add a <em>child</em> to this descriptor.
117
    *
118
    * @param descriptor the child to add to this descriptor; never {@code null}
119
    */
120
   @Override
121
   public void addChild(TestDescriptor descriptor)
122
   {
123
      // Terminal node implementation, re-defined for branches
124
      throw new RuntimeException("Not supported");
125
   }
126

  
127
   /**
128
    * Execute the <em>after</em> behavior of this node.
129
    *
130
    * <p>This method will be called once <em>after</em> {@linkplain #execute
131
    * execution} of this node.
132
    *
133
    * @param context
134
    *        the context to execute in
135
    * 
136
    */
137
   @Override
138
   public void after(final FWDEngineExecutionContext context) throws Exception
139
   {
140
      context.unitTestSupport.after(getUniqueId());
141
   }
142

  
143
   /**
144
    * Execute the <em>before</em> behavior of this node.
145
    *
146
    * <p>This method will be called once <em>before</em> {@linkplain #execute
147
    * execution} of this node.
148
    *
149
    * @param context
150
    *        the context to execute in
151
    * @return the new context to be used for children of this node; never
152
    * {@code null}
153
    */
154
   @Override
155
   public FWDEngineExecutionContext before(FWDEngineExecutionContext context) throws Exception
156
   {
157
      context.unitTestSupport.before(getUniqueId());
158
      
159
      return context;
160
   }
161

  
162
   /**
163
    * Clean up the supplied {@code context} after execution.
164
    * 
165
    * Reset the test class instance.
166
    *
167
    * @param context
168
    *        the context to execute in
169
   
170
    * @see #prepare
171
    */
172
   @Override
173
   public void cleanUp(final FWDEngineExecutionContext context) throws Exception
174
   {
175
      context.unitTestSupport.cleanUp(getUniqueId());
176
   }
177

  
178
   @Override
179
   public final boolean equals(Object other)
180
   {
181
      if (other == null)
182
      {
183
         return false;
184
      }
185

  
186
      if (this.getClass() != other.getClass())
187
      {
188
         return false;
189
      }
190

  
191
      final TestDescriptor that = (TestDescriptor) other;
192
      return uniqueId.equals(that.getUniqueId());
193
   }
194

  
195
   /**
196
    * Execute the <em>behavior</em> of this node.
197
    *
198
    * <p>Containers typically do not implement this method since the
199
    * {@link HierarchicalTestEngine} handles execution of their children.
200
    *
201
    * <p>The supplied {@code dynamicTestExecutor} may be used to submit
202
    * additional dynamic tests for immediate execution.
203
    *
204
    * @param context
205
    *         the context to execute in
206
    * @param dynamicTestExecutor
207
    *        the executor to submit dynamic tests to
208
    *        
209
    * @return the new context to be used for children of this node and for the
210
    * <em>after</em> behavior of the parent of this node, if any
211
    */
212
   @Override
213
   public FWDEngineExecutionContext execute(final FWDEngineExecutionContext context,
214
            DynamicTestExecutor dynamicTestExecutor) throws Exception
215
   {
216
      context.unitTestSupport.execute(getUniqueId());
217

  
218
      return context;
219
   }
220

  
221
   /**
222
    * Find the descriptor with the supplied unique ID.
223
    *
224
    * <p>The search algorithm begins with this descriptor and then searches
225
    * through its descendants.
226
    *
227
    * @param uniqueId the {@code UniqueId} to search for; never {@code null}
228
    */
229
   @Override
230
   public Optional<? extends TestDescriptor> findByUniqueId(final UniqueId uniqueId)
231
   {
232
      return Optional.of(this.uniqueId.equals(uniqueId) ? this : null);
233
   }
234

  
235
   /**
236
    * Get the immutable set of <em>children</em> of this descriptor.
237
    *
238
    * @return the set of children of this descriptor; neither {@code null}
239
    * nor mutable, but potentially empty
240
    * @see #getDescendants()
241
    */
242
   @Override
243
   public Set<? extends TestDescriptor> getChildren()
244
   {
245
      return Collections.emptySet();
246
   }
247

  
248
   /**
249
    * Get the display name for this descriptor.
250
    *
251
    * <p>A <em>display name</em> is a human-readable name for a test or
252
    * container that is typically used for test reporting in IDEs and build
253
    * tools. Display names may contain spaces, special characters, and emoji,
254
    * and the format may be customized by {@link TestEngine TestEngines} or
255
    * potentially by end users as well. Consequently, display names should
256
    * never be parsed; rather, they should be used for display purposes only.
257
    *
258
    * @return the display name for this descriptor; never {@code null} or blank
259
    * @see #getSource()
260
    */
261
   @Override
262
   public String getDisplayName()
263
   {
264
      return displayName;
265
   }
266

  
267
   /**
268
    * Get the <em>parent</em> of this descriptor, if available.
269
    */
270
   @Override
271
   public Optional<TestDescriptor> getParent()
272
   {
273
      return Optional.ofNullable(parent);
274
   }
275

  
276
   /**
277
    * Get the {@linkplain TestSource source} of the test or container described
278
    * by this descriptor, if available.
279
    *
280
    * @see TestSource
281
    */
282
   @Override
283
   public Optional<TestSource> getSource()
284
   {
285
      // test sources are not used in FWD test engine
286
      return Optional.empty();
287
   }
288

  
289
   /**
290
    * Get the set of {@linkplain TestTag tags} associated with this descriptor.
291
    *
292
    * @return the set of tags associated with this descriptor; never {@code null}
293
    * but potentially empty
294
    * @see TestTag
295
    */
296
   @Override
297
   public Set<TestTag> getTags()
298
   {
299
      // tags are not used in FWD test engine currently
300
      return Collections.emptySet();
301
   }
302

  
303
   /**
304
    * Determine the {@link Type} of this descriptor.
305
    *
306
    * @return the descriptor type; never {@code null}.
307
    * @see #isContainer()
308
    * @see #isTest()
309
    */
310
   @Override
311
   public Type getType()
312
   {
313
      // Default value, test containers must re-define this method 
314
      return Type.TEST;
315
   }
316

  
317
   /**
318
    * Get the unique identifier (UID) for this descriptor.
319
    *
320
    * <p>Uniqueness must be guaranteed across an entire test plan,
321
    * regardless of how many engines are used behind the scenes.
322
    *
323
    * @return the {@code UniqueId} for this descriptor; never {@code null}
324
    */
325
   @Override
326
   public final UniqueId getUniqueId()
327
   {
328
      return this.uniqueId;
329
   }
330

  
331
   /**
332
    * Returns a hash code value for the object. This method is
333
    * supported for the benefit of hash tables such as those provided by
334
    * {@link java.util.HashMap}.
335
    * <p>
336
    * The general contract of {@code hashCode} is:
337
    * <ul>
338
    * <li>Whenever it is invoked on the same object more than once during
339
    *     an execution of a Java application, the {@code hashCode} method
340
    *     must consistently return the same integer, provided no information
341
    *     used in {@code equals} comparisons on the object is modified.
342
    *     This integer need not remain consistent from one execution of an
343
    *     application to another execution of the same application.
344
    * <li>If two objects are equal according to the {@code equals(Object)}
345
    *     method, then calling the {@code hashCode} method on each of
346
    *     the two objects must produce the same integer result.
347
    * <li>It is <em>not</em> required that if two objects are unequal
348
    *     according to the {@link java.lang.Object#equals(java.lang.Object)}
349
    *     method, then calling the {@code hashCode} method on each of the
350
    *     two objects must produce distinct integer results.  However, the
351
    *     programmer should be aware that producing distinct integer results
352
    *     for unequal objects may improve the performance of hash tables.
353
    * </ul>
354
    * <p>
355
    * As much as is reasonably practical, the hashCode method defined by
356
    * class {@code Object} does return distinct integers for distinct
357
    * objects. (This is typically implemented by converting the internal
358
    * address of the object into an integer, but this implementation
359
    * technique is not required by the
360
    * Java&trade; programming language.)
361
    *
362
    * @return  a hash code value for this object.
363
    * @see     java.lang.Object#equals(java.lang.Object)
364
    * @see     java.lang.System#identityHashCode
365
    */
366
   @Override
367
   public final int hashCode()
368
   {
369
      return uniqueId.hashCode();
370
   }
371

  
372
   /**
373
    * Prepare the supplied {@code context} prior to execution.
374
    * 
375
    * Create test class instance.
376
    *
377
    * @see #cleanUp
378
    */
379
   @Override
380
   public FWDEngineExecutionContext prepare(FWDEngineExecutionContext context) throws Exception
381
   {
382
      context.unitTestSupport.prepare(getUniqueId());
383

  
384
      return context;
385
   }
386

  
387
   @Override
388
   public void print(PrintHelper printer)
389
   {
390
      printer.print(uniqueId);
391
      printer.print(displayName);
392

  
393
      if (parent != null)
394
      {
395
         printer.print(parent.getDisplayName());
396
      }
397
   }
398

  
399
   /**
400
    * The object implements the readExternal method to restore its
401
    * contents by calling the methods of DataInput for primitive
402
    * types and readObject for objects, strings and arrays.  The
403
    * readExternal method must read the values in the same sequence
404
    * and with the same types as were written by writeExternal.
405
    *
406
    * @param in the stream to read data from in order to restore the object
407
    * @exception IOException if I/O errors occur
408
    * @exception ClassNotFoundException If the class for an object being
409
    *              restored cannot be found.
410
    */
411
   @Override
412
   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
413
   {
414
      uniqueId = (UniqueId) in.readObject();
415
      displayName = (String) in.readObject();
416
   }
417

  
418
   /**
419
    * Remove a <em>child</em> from this descriptor.
420
    *
421
    * @param descriptor the child to remove from this descriptor; never
422
    * {@code null}
423
    */
424
   @Override
425
   public void removeChild(TestDescriptor descriptor)
426
   {
427
      throw new RuntimeException("Not supported");
428
   }
429

  
430
   /**
431
    * Remove this non-root descriptor from its parent and remove all the
432
    * children from this descriptor.
433
    *
434
    * <p>If this method is invoked on a {@linkplain #isRoot root} descriptor,
435
    * this method must throw a {@link org.junit.platform.commons.JUnitException
436
    * JUnitException} explaining that a root cannot be removed from the
437
    * hierarchy.
438
    */
439
   @Override
440
   public void removeFromHierarchy()
441
   {
442
      parent.removeChild(this);
443
      parent = null;
444
   }
445

  
446
   /**
447
    * Set the <em>parent</em> of this descriptor.
448
    *
449
    * @param parent the new parent of this descriptor; may be {@code null}.
450
    */
451
  @Override
452
   public void setParent(TestDescriptor parent)
453
   {
454
      this.parent = parent;
455
   }
456

  
457
  /**
458
 * Returns a string representation of the object. In general, the
459
 * {@code toString} method returns a string that
460
 * "textually represents" this object. The result should
461
 * be a concise but informative representation that is easy for a
462
 * person to read.
463
 * It is recommended that all subclasses override this method.
464
 * <p>
465
 * The {@code toString} method for class {@code Object}
466
 * returns a string consisting of the name of the class of which the
467
 * object is an instance, the at-sign character `{@code @}', and
468
 * the unsigned hexadecimal representation of the hash code of the
469
 * object. In other words, this method returns a string equal to the
470
 * value of:
471
 * <blockquote>
472
 * <pre>
473
 * getClass().getName() + '@' + Integer.toHexString(hashCode())
474
 * </pre></blockquote>
475
 *
476
 * @return  a string representation of the object.
477
 */
478
@SuppressWarnings("null")
479
@Override
480
public String toString()
481
{
482
   return asString();
483
}
484

  
485
/**
486
   * The object implements the writeExternal method to save its contents
487
   * by calling the methods of DataOutput for its primitive values or
488
   * calling the writeObject method of ObjectOutput for objects, strings,
489
   * and arrays.
490
   *
491
   * @serialData Overriding methods should use this tag to describe
492
   *             the data layout of this Externalizable object.
493
   *             List the sequence of element types and, if possible,
494
   *             relate the element to a public/protected field and/or
495
   *             method of this Externalizable class.
496
   *
497
   * @param out the stream to write the object to
498
   * @exception IOException Includes any I/O exceptions that may occur
499
   */
500
   @Override
501
   public void writeExternal(ObjectOutput out) throws IOException
502
   {
503
      out.writeObject(uniqueId);
504
      out.writeObject(displayName);
505
   }
506

  
507
}
src/com/goldencode/p2j/testengine/FWDClassTestDescriptor.java 2022-10-18 20:39:58 +0000
1
/*
2
** Module   : FWDClassTestDescriptor.java
3
** Abstract : Test descriptor for a Java class.
4
**
5
** Copyright (c) 2022, Golden Code Development Corporation.
6
**
7
** -#- -I- --Date-- ----------------Description----------------------
8
** 001 VVT 2022xxxx Created initial version.
9
*/
10
/*
11
** This program is free software: you can redistribute it and/or modify
12
** it under the terms of the GNU Affero General Public License as
13
** published by the Free Software Foundation, either version 3 of the
14
** License, or (at your option) any later version.
15
**
16
** This program is distributed in the hope that it will be useful,
17
** but WITHOUT ANY WARRANTY; without even the implied warranty of
18
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
** GNU Affero General Public License for more details.
20
**
21
** You may find a copy of the GNU Affero GPL version 3 at the following
22
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
23
** 
24
** Additional terms under GNU Affero GPL version 3 section 7:
25
** 
26
**   Under Section 7 of the GNU Affero GPL version 3, the following additional
27
**   terms apply to the works covered under the License.  These additional terms
28
**   are non-permissive additional terms allowed under Section 7 of the GNU
29
**   Affero GPL version 3 and may not be removed by you.
30
** 
31
**   0. Attribution Requirement.
32
** 
33
**     You must preserve all legal notices or author attributions in the covered
34
**     work or Appropriate Legal Notices displayed by works containing the covered
35
**     work.  You may not remove from the covered work any author or developer
36
**     credit already included within the covered work.
37
** 
38
**   1. No License To Use Trademarks.
39
** 
40
**     This license does not grant any license or rights to use the trademarks
41
**     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
42
**     of Golden Code Development Corporation. You are not authorized to use the
43
**     name Golden Code, FWD, or the names of any author or contributor, for
44
**     publicity purposes without written authorization.
45
** 
46
**   2. No Misrepresentation of Affiliation.
47
** 
48
**     You may not represent yourself as Golden Code Development Corporation or FWD.
49
** 
50
**     You may not represent yourself for publicity purposes as associated with
51
**     Golden Code Development Corporation, FWD, or any author or contributor to
52
**     the covered work, without written authorization.
53
** 
54
**   3. No Misrepresentation of Source or Origin.
55
** 
56
**     You may not represent the covered work as solely your work.  All modified
57
**     versions of the covered work must be marked in a reasonable way to make it
58
**     clear that the modified work is not originating from Golden Code Development
59
**     Corporation or FWD.  All modified versions must contain the notices of
60
**     attribution required in this license.
61
*/
62
package com.goldencode.p2j.testengine;
63

  
64
import java.io.*;
65
import java.lang.reflect.*;
66
import java.util.*;
67

  
68
import org.junit.platform.engine.*;
... This diff was truncated because it exceeds the maximum size that can be displayed.