Project

General

Profile

6237-188-r14306.diff

Vladimir Tsichevski, 10/28/2022 05:04 PM

Download (209 KB)

View differences:

build.gradle 2022-10-27 21:14:39 +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.jupiter',
593
                    name: 'junit-jupiter-api',
594
                    version: '5.9.0'
595

  
596
    fwdClientServer group: 'org.junit.platform',
597
                    name: 'junit-platform-suite-engine',
598
                    version: '1.9.0'
599
    fwdAllTest group: 'org.junit.platform',
600
                    name: 'junit-platform-console',
601
                    version: '1.9.0'
602
    fwdAllTest group: 'org.junit.platform',
603
                    name: 'junit-platform-engine',
604
                    version: '1.9.0'
586 605
}
587 606

  
588 607
// inject ant-optional dependencies to ant, this is needed for the antlr ant target
build.xml 2022-10-25 16:19:33 +0000
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 238
**     RFB 20221024          Tighten up the p2jpl build to not include extras that aren't needed.
239
**     VVT 2022xxxx          Copy org.junit.platform.engine.TestEngine file to META-INF/services. See #6237.
239 240
-->
240 241

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

  
891 893
    <!-- 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-28 17:54:02 +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
      <!--
75
          Create an assignment <attName>=
76
      -->
77
      <function name="create_attribute_assignment_right">
78
         <!-- The parent node -->
79
         <parameter name="parent" type="com.goldencode.ast.Aast" />
80
         <!-- the left part attribute name -->
81
         <parameter name="attName" type="java.lang.String" />
82
         
83
         <return name="tref" type="com.goldencode.ast.Aast" />
84
         
85
         <variable name="chref" type="com.goldencode.ast.Aast" />
86
         
87
         <rule>tref = createProgressAst(prog.assign, "=", parent)</rule>
88
         
89
         <rule>chref = createProgressAst(prog.symbol, attName, tref)</rule>
90
         <rule>chref.putAnnotation("javaname", attName)</rule>
91
      </function>
92
   
93
      <!--
94
          Create an array assignment <attName>=[
95
      -->
96
      <function name="create_attribute_array_assignment_right">
97
         <parameter name="parent" type="com.goldencode.ast.Aast" />
98
         <parameter name="attName" type="java.lang.String" />
99
         
100
         <return name="tref" type="com.goldencode.ast.Aast" />
101
         
102
         <rule>tref = execLib("create_attribute_assignment_right", parent, attName)</rule>
103
         <rule>tref = createProgressAst(prog.lbracket, "[", tref)</rule>
104
      </function>
105

  
106

  
107
      <!--
108
          Lookup legacy annotation attribute value
109

  
110
          Input conditions:
111
          1. current node is the legacy annotation node
112
          2. The attName parameter contains the name of the attribute to lookup
113
          
114
          Return: attribute value string of null if this annotation has no attribute with the given name.
115
      -->
116
      <function name="lookup_annotation_attribute_string">
117
         <parameter name="attName" type="java.lang.String" />
118
         <return name="result" type="java.lang.String" />
119
         
120
         <rule>result = null</rule>
121
         
122
         <variable name="attAssignment" type="com.goldencode.ast.Aast" />
123
         <!-- Skip the annotation name SYMBOL -->
124
         <rule>attAssignment = copy.firstChild.nextSibling</rule>
125
         <while>attAssignment != null
126
           <!-- Go to the second child, which must be attribute assignment -->
127
           <rule>attAssignment.type == prog.assign
128
              <action on="false">compileError(367, "Annotation children must be ASSIGNMENTs")</action>
129
           </rule>
130
           <variable name="attNameNode" type="com.goldencode.ast.Aast" />
131
           <action>attNameNode = attAssignment.firstChild</action>
132
           <rule>attNameNode.getAnnotation("javaname").equals(attName)
133
              <action>result = ecw.stripQuotes(attNameNode.nextSibling.getText())</action>
134
              <break/>
135
           </rule>
136
           <action>attAssignment = attAssignment.nextSibling</action>
137
         </while>      
138
      </function>
139

  
140
      <function name="create_java_annotation">
141
         <parameter name="parent" type="com.goldencode.ast.Aast" />
142
         <parameter name="className" type="java.lang.String" />
143
         <return name="selectClassesAnno" type="com.goldencode.ast.Aast" />
144
         <rule>selectClassesAnno = createProgressAst(prog.annotation, "@", parent)</rule>
145
         <rule>selectClassesAnno.putAnnotation("javaname", className)</rule>
146
         <!-- ...and mark "our" annotations as preserved -->
147
         <rule>selectClassesAnno.putAnnotation("fwd", true)</rule>
148
      </function>
149
      <!--
150
          Process ABLUnit @TestSuite annotation:
151
          1. If the suite includes classes, then create a @SelectClasses(value = {Class1.class, Class2...}) annotation
152
          2. If the suite includes procedures, then create a @SelectProcedures(value = {"procedure1.p", "procedure2.p"...}) annotation
153
          3. Create an empty @Suite annotation
154

  
155
          On entry the current node is the annotation.
156
      -->
157
      <function name="process_ablunit_test_suite">
158
         <!-- Create a marker @Suite annotation-->
159
         <rule>execLib("create_java_annotation", copy.parent, "com.goldencode.p2j.testengine.api.Suite")</rule>
160
         
161
         <!-- Get the "classes" attribute, convert the quoted comma-separated list of class
162
              names to nodes of prog.symbol type -->
163
         <variable name="classList" type="java.lang.String" />
164
         <rule>classList = execLib("lookup_annotation_attribute_string", "classes")</rule>
165
         
166
         <variable name="lref" type="com.goldencode.ast.Aast" />
167
         <rule>classList != null
168
            <action>printfln("@TestSuite Classlist %s", classList)</action>
169

  
170
            <!-- Create the @SelectClasses annotation -->
171
            <variable name="selectClassesAnno" type="com.goldencode.ast.Aast" />
172
            <action>selectClassesAnno = execLib("create_java_annotation", copy.parent, "com.goldencode.p2j.testengine.api.SelectClasses")</action>
173
            
174
            <!-- Convert comma-separated class name list string into an array of class references -->
175
            <!--   Create a node of the array type -->
176
            <action>lref = execLib("create_attribute_array_assignment_right", selectClassesAnno, "value")</action>
177
            <!-- Parse and convert the comma-separated list -->
178
            <variable name="classNameList" type="java.util.List" />
179
            <action>classNameList = createListFromObject(classList.split(","))</action>
180
            <variable name="classNames" type="java.util.Iterator" />
181
            <action>classNames = classNameList.iterator()</action>
182
            <while>classNames.hasNext()
183
               <variable name="className" type="java.lang.String" />
184
               <action>className = (#(java.lang.String)classNames.next()).trim()</action>
185
               <action>printfln("Class name '%s'", className)</action>                                       
186
               <action>createProgressAst(prog.symbol, sprintf("%s.class", className), lref)</action>
187
            </while>
188
         </rule>
189

  
190
         <!-- Get the "procedures" attribute, convert the quoted comma-separated list of procedure
191
              names to nodes of prog.symbol type -->
192
         <variable name="procedureList" type="java.lang.String" />
193
         <rule>procedureList = execLib("lookup_annotation_attribute_string", "procedures")</rule>
194
         
195
         <rule>procedureList != null
196
            <action>printfln("@TestSuite procedures %s", procedureList)</action>
197

  
198
            <!-- Create the @SelectProcedures annotation -->
199
            <variable name="selectProceduresAnno" type="com.goldencode.ast.Aast" />
200
            <action>selectProceduresAnno = execLib("create_java_annotation", copy.parent, "com.goldencode.p2j.testengine.api.SelectProcedures")</action>
201
            <!-- Convert comma-separated procedure name list string into an array of procedure name strings -->
202
            <!--   Create a node of the array type -->
203
            <action>lref = execLib("create_attribute_array_assignment_right", selectProceduresAnno, "value")</action>
204
            <!-- Parse and convert the comma-separated list -->
205
            <variable name="procedureNameList" type="java.util.List" />
206
            <action>procedureNameList = createListFromObject(procedureList.split(","))</action>
207
            <variable name="procedureNames" type="java.util.Iterator" />
208
            <action>procedureNames = procedureNameList.iterator()</action>
209
            <while>procedureNames.hasNext()
210
               <variable name="procedureName" type="java.lang.String" />
211
               <action>procedureName = (#(java.lang.String)procedureNames.next()).trim()</action>
212
               <action>printfln("Procedure name '%s'", procedureName)</action>                                       
213
               <action>createProgressAst(prog.string, sprintf("'%s'", procedureName), lref)</action>
214
            </while>
215
         </rule>
216
         <!-- Drop the original value -->
217
         <rule>copy.remove()</rule>
218
      </function>
219
   </func-library>
220

  
68 221
   <walk-rules>
69 222
      <rule>this.type == prog.annotation
70
            and parent.type == prog.method_def
223
            and (parent.type == prog.method_def
224
                 or parent.type == prog.procedure
225
                 or parent.type == prog.class_def)
226
            
227
         <!-- Get required unit test legacy type configuration (hints) -->
228
         <variable name="unitTestType" type="java.lang.String" />
229
         <action>unitTestType = hints.getUnitTestType()</action>
230
         <rule>unitTestType == null
231
            <action>compileError(223, "No unit test legacy type is configured")</action>
232
         </rule>
233
         
234
         <variable name="isABLUnit" type="java.lang.Boolean" />
235
         <action>isABLUnit = unitTestType.equals("ABLUnit")</action>
236

  
237
         <variable name="methodNode" type="com.goldencode.ast.Aast" />
238
         <action>methodNode = parent.firstChild</action>
239

  
240
         <!-- FIXME: Add similar support for procedures -->
71 241

  
72 242
         <!-- Get initial annotation name -->
73 243
         <variable name="annoName" type="java.lang.String" />
74 244
         <action>annoName = this.getAnnotation("javaname")</action>
75 245

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

  
76 248
         <variable name="newName" type="java.lang.String" />
77 249
         <action>newName = null</action>
78 250

  
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>
251
         <!-- Replace OEUnit/ABLUnit annotation names by corresponding JUnit5 names -->
252
         <rule>annoName.equalsIgnoreCase("Test")
253
            <action>newName = "com.goldencode.p2j.testengine.api.Test"</action>
254

  
255
            <!-- Note: the meaning of @Before and @After is opposite in ABLUnit and OEUnit -->
256
            <rule on="false">annoName.equalsIgnoreCase("Before")
257
               <rule>isABLUnit
258
                  <action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action>
259
                  <action on="false">newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action>
260
               </rule>
261
               <rule on="false">annoName.equalsIgnoreCase("After")
262
                  <rule>isABLUnit
263
                     <action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action>
264
                     <action on="false">newName = "com.goldencode.p2j.testengine.api.AfterEach"</action>
265
                  </rule>
266
                  <rule on="false">annoName.equalsIgnoreCase("BeforeClass")
267
                     <action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action>
268
                     <rule on="false">annoName.equalsIgnoreCase("AfterClass")
269
                        <action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action>
270
                        <rule on="false">annoName.equalsIgnoreCase("Ignore")
271
                           <action>newName = "com.goldencode.p2j.testengine.api.Disabled"</action>
272
                           <rule on="false">annoName.equalsIgnoreCase("Setup")
273
                              <action>newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action>
274
                              <rule on="false">annoName.equalsIgnoreCase("TearDown")
275
                                 <action>newName = "com.goldencode.p2j.testengine.api.AfterEach"</action>
276
   
277
                                 <!-- ABLUnit @TestSuite(classes="classname1,classname2...", procedures="procedure1.p,procedure2.p...") -->
278
                                 <rule on="false">annoName.equalsIgnoreCase("TestSuite")
279
                                    <action>execLib("process_ablunit_test_suite")</action>
280
                                 </rule>
281
                              </rule>
282
                           </rule>
92 283
                        </rule>
93 284
                     </rule>
94 285
                  </rule>
95 286
               </rule>
96 287
            </rule>
97 288
         </rule>
98

  
99 289
         <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>
290
            <action>printfln("newName %s", newName)</action>
291
            <!-- Write it back... -->
292
            <action>copy.putAnnotation("javaname", newName)</action>
293
            <!-- ...and mark "our" annotations as preserved -->
294
            <action>copy.putAnnotation("fwd", true)</action>
103 295
         </rule>
104 296
      </rule>
105 297
      
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/AbstractClassTestDescriptor.java 2022-10-21 15:15:58 +0000
1
/*
2
** Module   : AbstractClassTestDescriptor.java
3
** Abstract : Common ancestor for legacy class and legacy procedure 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.lang.reflect.*;
66
import java.util.*;
67

  
68
import org.junit.platform.engine.*;
69

  
70
import com.goldencode.util.*;
71

  
72
/**
73
 * Common ancestor for legacy class and legacy procedure test descriptors.
74
 */
75
public abstract class AbstractClassTestDescriptor
76
extends AbstractBranchTestDescriptor
77
{
78

  
79
   /**
80
    * Class methods marked to execute before all tests 
81
    */
82
   List<Method> afterAll;
83

  
84
   /**
85
    * Class methods marked to execute before all tests 
86
    */
87
   List<Method> beforeAll;
88

  
89
   /**
90
    * The Java class.
91
    */
92
   Class clazz;
93

  
94
   /**
95
    * Default constructor. Required for serialization. Not to be used in application code.
96
    */
97
   protected AbstractClassTestDescriptor()
98
   {
99
      super(null, null);
100

  
101
      this.clazz = null;
102
      this.beforeAll = null;
103
      this.afterAll = null;      
104
   }
105

  
106
   /**
107
    * The constructor.
108
    * 
109
    * @param clazz
110
    *        the Java class
111
    * @param parent
112
    *        the parent descriptor
113
    * @param test
114
    *        class methods marked as tests  
115
    * @param beforeEach
116
    *        class methods marked to execute before each test  
117
    * @param afterEach
118
    *        class methods marked to execute after each test  
119
    * @param beforeAll
120
    *        class methods marked to execute before all tests  
121
    * @param afterAll
122
    *        class methods marked to execute after all tests  
123
    */
124
   protected AbstractClassTestDescriptor(final Class<?> clazz, final TestDescriptor parent,
125
            final List<Method> test, final List<Method> beforeEach, final List<Method> afterEach,
126
            final List<Method> beforeAll, final List<Method> afterAll)
127
   {
128
      super(parent.getUniqueId().append("class", clazz.getName()), clazz.getSimpleName());
129

  
130
      this.clazz = clazz;
131
      this.beforeAll = beforeAll;
132
      this.afterAll = afterAll;
133
   }
134
   
135
   /**
136
    * Execute the <em>after</em> behavior of this node implementation.
137
    *
138
    * <p>This method will be called once <em>after</em> {@linkplain #executeImpl()
139
    * execution} of this node.
140
    * 
141
    * @throws Exception 
142
    * 
143
    */
144
   @Override
145
   public void afterImpl() throws Exception
146
   {
147
      callMethodsImpl(afterAll);
148
   }
149

  
150
   /**
151
    * Execute the <em>before</em> behavior of this node implementation.
152
    *
153
    * <p>This method will be called once <em>before</em> {@linkplain #executeImpl()
154
    * execution} of this node.
155
    * 
156
    * @throws Exception 
157
    *
158
    */
159
   @Override
160
   public void beforeImpl() throws Exception
161
   {
162
      callMethodsImpl(beforeAll);
163
   }
164

  
165
   /**
166
    * Print all class-specific fields.
167
    * 
168
    * @param printer
169
    *        the string printer to print into
170
    */
171
   @Override
172
   public void print(PrintHelper printer)
173
   {
174
      printer.print(clazz.getName());
175
   }
176

  
177
   /**
178
    * The object implements the readExternal method to restore its
179
    * contents by calling the methods of DataInput for primitive
180
    * types and readObject for objects, strings and arrays.  The
181
    * readExternal method must read the values in the same sequence
182
    * and with the same types as were written by writeExternal.
183
    *
184
    * @param in the stream to read data from in order to restore the object
185
    * @exception IOException if I/O errors occur
186
    * @exception ClassNotFoundException If the class for an object being
187
    *              restored cannot be found.
188
    */
189
   @Override
190
   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
191
   {
192
      super.readExternal(in);
193
      
194
      clazz = (Class<?>) in.readObject();
195
      beforeAll = SerializationSupport.readMethods(in);
196
      afterAll = SerializationSupport.readMethods(in);
197
   }
198

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

  
224
}
src/com/goldencode/p2j/testengine/AbstractFWDTestDescriptor.java 2022-10-27 14:28:06 +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.lang.reflect.*;
65
import java.util.*;
66

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

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

  
82
   /**
83
    * The constructor.
84
    * 
85
    * @param uniqueId
86
    *        the descriptor unique ID
87
    * @param displayName
88
    *        the descriptor display name
89
    */
90
   public AbstractFWDTestDescriptor(final UniqueId uniqueId, final String displayName)
91
   {
92
      super(uniqueId, displayName);
93
   }
94

  
95
   /**
96
    * Default constructor. Must be used internally for serialization only.
97
    */
98
   protected AbstractFWDTestDescriptor()
99
   {
100
      this(null, null);
101
   }
102

  
103
   /**
104
    * Execute the <em>after</em> behavior of this node.
105
    *
106
    * <p>This method will be called once <em>after</em> {@linkplain #execute
107
    * execution} of this node.
108
    *
109
    * @param context
110
    *        the context to execute in
111
    * 
112
    */
113
   @Override
114
   public void after(final FWDEngineExecutionContext context) throws Exception
115
   {
116
      context.unitTestSupport.after(getUniqueId());
117
   }
118

  
119
   /**
120
    * Execute the <em>after</em> behavior of this node implementation.
121
    *
122
    * <p>This method will be called once <em>after</em> {@linkplain #executeImpl()
123
    * execution} of this node.
124
    * 
125
    * @throws Exception 
126
    * 
127
    */
128
   public void afterImpl() throws Exception
129
   {
130
      // no-op
131
   }
132

  
133
   /**
134
    * Execute the <em>before</em> behavior of this node.
135
    *
136
    * <p>This method will be called once <em>before</em> {@linkplain #execute
137
    * execution} of this node.
138
    *
139
    * @param context
140
    *        the context to execute in
141
    * @return the new context to be used for children of this node; never
142
    * {@code null}
143
    */
144
   @Override
145
   public FWDEngineExecutionContext before(FWDEngineExecutionContext context) throws Exception
146
   {
147
      context.unitTestSupport.before(getUniqueId());
148

  
149
      return context;
150
   }
151

  
152
   /**
153
    * Execute the <em>before</em> behavior of this node implementation.
154
    *
155
    * <p>This method will be called once <em>before</em> {@linkplain #executeImpl()
156
    * execution} of this node.
157
    * 
158
    * @throws Exception 
159
    *
160
    */
161
   public void beforeImpl() throws Exception
162
   {
163
      // no-op
164
   }
165

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

  
182
   /**
183
    * Clean up the supplied {@code context} after execution implementation.
184
    * 
185
    * Reset the test class instance.
186
    * 
187
    * @throws Exception 
188
    *
189
    * @see #prepare
190
    */
191
   public void cleanUpImpl() throws Exception
192
   {
193
      // no-op
194
   }
195

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

  
219
      return context;
220
   }
221

  
222
   /**
223
    * Execute the implementation <em>behavior</em> of this node.
224
    *
225
    * @throws Exception 
226
    *
227
    */
228
   public void executeImpl() throws Exception
229
   {
230
      // no-op
231
   }
232

  
233
   /**
234
    * Prepare the supplied {@code context} prior to execution.
235
    * 
236
    * Create test class instance.
237
    *
238
    * @see #cleanUp
239
    */
240
   @Override
241
   public FWDEngineExecutionContext prepare(FWDEngineExecutionContext context) throws Exception
242
   {
243
      context.unitTestSupport.prepare(getUniqueId());
244

  
245
      return context;
246
   }
247

  
248
   /**
249
    * Prepare the supplied {@code context} prior to execution implementation.
250
    * 
251
    * @throws Exception 
252
    *
253
    * @see #cleanUpImpl
254
    */
255
   public void prepareImpl() throws Exception
256
   {
257
      // no-op
258
   }
259

  
260
   /**
261
   * Returns a string representation of the object. In general, the
262
   * {@code toString} method returns a string that
263
   * "textually represents" this object. The result should
264
   * be a concise but informative representation that is easy for a
265
   * person to read.
266
   * It is recommended that all subclasses override this method.
267
   * <p>
268
   * The {@code toString} method for class {@code Object}
269
   * returns a string consisting of the name of the class of which the
270
   * object is an instance, the at-sign character `{@code @}', and
271
   * the unsigned hexadecimal representation of the hash code of the
272
   * object. In other words, this method returns a string equal to the
273
   * value of:
274
   * <blockquote>
275
   * <pre>
276
   * getClass().getName() + '@' + Integer.toHexString(hashCode())
277
   * </pre></blockquote>
... This diff was truncated because it exceeds the maximum size that can be displayed.