Project

General

Profile

6237-219-14370.diff

Vladimir Tsichevski, 11/18/2022 12:21 PM

Download (238 KB)

View differences:

build.gradle 2022-11-03 20:33:22 +0000
105 105
**     TW  20221007 Upgraded junixsocket to 2.5.2.
106 106
**     TJD 20220413 Upgrade to Java 11
107 107
**     TJD 20220804 Make it compatible with both Java 8 and Java 11
108
**     VVT 2022xxxx JUnit5 dependencies updated to support both existing tests and custom test engine.
109
**                  See #6237.
108 110
*/
109 111

  
110 112
/*
......
598 600
       aspectjCompile group: 'org.aspectj', name: 'aspectjweaver', version: aspectjVersion
599 601
    }
600 602

  
601
    fwdAllTest group: 'org.junit.platform', name: 'junit-platform-console-standalone', version: '1.7.1'
603
    // Adding JUnit5 jar both to client and server, so it will be also deployed to converted projects
604
    fwdClientServer group: 'org.junit.platform',
605
                    name: 'junit-platform-engine',
606
                    version: '1.9.0'
607

  
608
    fwdClientServer group: 'org.junit.jupiter',
609
                    name: 'junit-jupiter-api',
610
                    version: '5.9.0'
611

  
612
    fwdClientServer group: 'org.junit.platform',
613
                    name: 'junit-platform-suite-engine',
614
                    version: '1.9.0'
615
    fwdAllTest group: 'org.junit.platform',
616
                    name: 'junit-platform-console',
617
                    version: '1.9.0'
618
    fwdAllTest group: 'org.junit.platform',
619
                    name: 'junit-platform-engine',
620
                    version: '1.9.0'
602 621
}
603 622

  
604 623
// inject ant-optional dependencies to ant, this is needed for the antlr ant target
build.xml 2022-11-14 14:33:39 +0000
239 239
**     TJD 20220413          Upgrade to Java 11 
240 240
**     TJD 20220502          Fix antlr generated files for Java 11 warnings 
241 241
**     TJD 20220804          Make it compatible with both Java 8 and Java 11
242
**     VVT 2022xxxx          Copy org.junit.platform.engine.TestEngine file to META-INF/services. See #6237.
242 243
-->
243 244

  
244 245
<!--
......
894 895
    <!-- Copy SPI descriptors to META-INF/services directory -->
895 896
    <copy todir="${build.home}/classes/META-INF/services">
896 897
      <fileset dir="${manifest.src}" includes="*Provider" />
898
      <fileset dir="${manifest.src}" includes="*TestEngine" />
897 899
    </copy>
898 900

  
899 901
    <!-- Copy aop.xml to META-INF directory for LTW-specific AOP jar -->
......
1640 1642
          basedir="${build.home}/classes.aop"
1641 1643
          includes="com/goldencode/**
1642 1644
                    rules/**
1645
                    META-INF/services/org.junit.platform.engine.TestEngine
1643 1646
                    fonts/**
1644 1647
                    *.dtd
1645 1648
                    *.xml
manifest/org.junit.platform.engine.TestEngine 2022-09-19 20:26:43 +0000
1
com.goldencode.p2j.testengine.FWDTestEngine
rules/annotations/annotations.xml 2022-11-03 20:33:22 +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-11-03 20:33:22 +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-11-18 16:17:15 +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.
14
**                  Both test classes and procedures are now supported.
12 15
*/
13 16
 -->
14 17
<!--
......
65 68
-->
66 69
<rule-set>
67 70
   <worker class="com.goldencode.p2j.uast.ProgressPatternWorker" namespace="prog" />
71
   <worker class="com.goldencode.p2j.uast.UastHintsWorker"       namespace="hints" />
72
   <worker class="com.goldencode.p2j.convert.ExpressionConversionWorker" namespace="ecw" />
73

  
74
   <!-- There can be more than one @TestSuite annotation for the same
75
        legacy class or procedure, the following two variables will
76
        collect the corresponding values -->
77
   <variable name="test_suite_classes" type="java.util.List" />
78
   <variable name="test_suite_procedures" type="java.util.List" />
79

  
80
   <init-rules>
81
      <rule>test_suite_classes = create("java.util.ArrayList")</rule>
82
      <rule>test_suite_procedures = create("java.util.ArrayList")</rule>
83
   </init-rules>
84

  
85
   <func-library access="private">
86
      <!--
87
          Create an assignment <attName>=
88
      -->
89
      <function name="create_attribute_assignment_right">
90
         <!-- The parent node -->
91
         <parameter name="parent" type="com.goldencode.ast.Aast" />
92
         <!-- the left part attribute name -->
93
         <parameter name="attName" type="java.lang.String" />
94
         
95
         <return name="tref" type="com.goldencode.ast.Aast" />
96
         
97
         <variable name="chref" type="com.goldencode.ast.Aast" />
98
         
99
         <rule>tref = createProgressAst(prog.assign, "=", parent)</rule>
100
         
101
         <rule>chref = createProgressAst(prog.symbol, attName, tref)</rule>
102
         <rule>chref.putAnnotation("javaname", attName)</rule>
103
      </function>
104
   
105
      <!--
106
          Create an array assignment <attName>=[
107
      -->
108
      <function name="create_attribute_array_assignment_right">
109
         <parameter name="p" type="com.goldencode.ast.Aast" />
110
         <parameter name="an" type="java.lang.String" />
111
         
112
         <return name="tref" type="com.goldencode.ast.Aast" />
113
         
114
         <rule>tref = execLib("create_attribute_assignment_right", p, an)</rule>
115
         <rule>tref = createProgressAst(prog.lbracket, "[", tref)</rule>
116
      </function>
117

  
118

  
119
      <!--
120
          Lookup legacy annotation attribute value
121

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

  
152
      <function name="create_java_annotation">
153
         <parameter name="parent" type="com.goldencode.ast.Aast" />
154
         <parameter name="className" type="java.lang.String" />
155
         <return name="retval" type="com.goldencode.ast.Aast" />
156
         <rule>retval = createProgressAst(prog.annotation, "@", parent)</rule>
157
         <rule>retval.putAnnotation("javaname", className)</rule>
158
         <!-- ...and mark "our" annotations as preserved -->
159
         <rule>retval.putAnnotation("fwd", true)</rule>
160
      </function>
161

  
162
      <!--
163
          Process ABLUnit @TestSuite annotation:
164
          
165
          1. If the suite includes classes, then create a @SelectClasses(value = {Class1.class, Class2...}) annotation
166
          2. If the suite includes procedures, then create a @SelectProcedures(value = {"procedure1.p", "procedure2.p"...}) annotation
167
          3. Create an empty @Suite annotation
168

  
169
          On entry the current node is the annotation.
170
      -->
171
      <function name="process_ablunit_test_suite">
172
         
173
         <!-- Get the "classes" attribute, convert the quoted comma-separated list of class
174
              names to nodes of prog.symbol type -->
175
         <variable name="classList" type="java.lang.String" />
176
         <rule>classList = execLib("lookup_annotation_attribute_string", "classes")</rule>
177
         
178
         <variable name="lref" type="com.goldencode.ast.Aast" />
179
         <rule>classList != null
180
            <!-- <action>printfln("@TestSuite Classlist %s", classList)</action> -->
181

  
182
            <!-- Convert comma-separated class name list string into an array of class references -->
183
            <!-- Parse and convert the comma-separated list -->
184
            <variable name="classNameList" type="java.util.List" />
185
            <action>classNameList = splitToList(classList, ",")</action>
186
            <variable name="classNames" type="java.util.Iterator" />
187
            <action>classNames = classNameList.iterator()</action>
188
            <while>classNames.hasNext()
189
               <variable name="className" type="java.lang.String" />
190
               <action>className = #(java.lang.String)classNames.next()</action>
191
               <action>test_suite_classes.add(className.trim())</action>
192
            </while>
193
         </rule>
194

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

  
203
            <!-- Convert comma-separated procedure name list string into an array of procedure name strings -->
204
            <!-- Parse and convert the comma-separated list -->
205
            <variable name="procedureNameList" type="java.util.List" />
206
            <action>procedureNameList = splitToList(procedureList, ",")</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()</action>
212
               <action>test_suite_procedures.add(procedureName.trim())</action>
213
            </while>
214
         </rule>
215
         <!-- Drop the original value -->
216
         <rule>copy.remove()</rule>
217
      </function>
218

  
219
      <!-- Get the legacy unit test engine type confugured for this source : OEUnit or ABLUnit.
220
           Throw error if the value is not configured, so call this function only if you really
221
           need to know the value, so the configuration is expected to exist  -->
222
      <function name="is_abl_unit">
223
         <return name="isABLUnit" type="java.lang.Boolean" />
224
         <variable name="unitTestType" type="java.lang.String" />
225
         <rule>unitTestType = hints.getUnitTestType()</rule>
226
         <rule>unitTestType == null
227
            <action>compileError(223, "Cannot convert @Before or @After annotation: unit test legacy type is not configured.")</action>
228
         </rule>
229
         
230
         <rule>isABLUnit = unitTestType.equals("ABLUnit")</rule>
231
      </function>
232
   </func-library>
233

  
68 234
   <walk-rules>
235
      <!-- This is an annotatin in class_def or method_def or procedure toplevel block -->
69 236
      <rule>this.type == prog.annotation
70
            and parent.type == prog.method_def
71

  
237
            and (parent.type == prog.method_def
238
                 or parent.type == prog.procedure
239
                 or parent.type == prog.class_def
240
                 or (parent.type == prog.block and parent.isRoot()))
241
            
242
         <!-- <action>printfln("testing for junit annotations")</action> -->
243
         <!-- Get required unit test legacy type configuration (hints) -->
72 244
         <!-- Get initial annotation name -->
73 245
         <variable name="annoName" type="java.lang.String" />
74 246
         <action>annoName = this.getAnnotation("javaname")</action>
......
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>execLib("is_abl_unit")
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>execLib("is_abl_unit")
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
      
106 298
   </walk-rules>
299

  
300
   <ascent-rules>
301
      <rule>(this.type == prog.class_def or this.type == prog.procedure or this.isRoot())
302
            and (!test_suite_classes.isEmpty() || !test_suite_procedures.isEmpty())
303
         <action>execLib("create_java_annotation", copy, "com.goldencode.p2j.testengine.api.Suite")</action>
304

  
305
         <variable name="lref" type="com.goldencode.ast.Aast" />
306

  
307
         <rule>!test_suite_classes.isEmpty()
308

  
309
            <!-- @SelectClasses annotation -->
310
            <variable name="selectClassesAnno" type="com.goldencode.ast.Aast" />
311
            <action>selectClassesAnno = execLib("create_java_annotation", copy, "com.goldencode.p2j.testengine.api.SelectClasses")</action>
312
            
313
            <!-- <action>printfln("selectClassesAnno.id %s", selectClassesAnno.id)</action> -->
314
            <!-- Convert comma-separated class name list string into an array of class references -->
315
            <!--   Create a node of the array type -->
316
            <action>lref = execLib("create_attribute_array_assignment_right", selectClassesAnno, "value")</action>
317
            <variable name="classNames" type="java.util.Iterator" />
318
            <action>classNames = test_suite_classes.iterator()</action>
319
            <while>classNames.hasNext()
320
               <variable name="className" type="java.lang.String" />
321
               <action>className = #(java.lang.String)classNames.next()</action>
322
               <action>createProgressAst(prog.string, sprintf("'%s'", className), lref)</action>
323
            </while>
324
            <action>test_suite_classes.clear()</action>            
325
         </rule>
326

  
327
         <rule>!test_suite_procedures.isEmpty()
328
            <!-- <action>printfln("test_suite_procedures %s", test_suite_procedures)</action> -->
329
            <!-- Create the @SelectProcedures annotation -->
330
            <variable name="selectProceduresAnno" type="com.goldencode.ast.Aast" />
331
            <action>selectProceduresAnno = execLib("create_java_annotation", copy, "com.goldencode.p2j.testengine.api.SelectProcedures")</action>
332
            <!-- Convert comma-separated procedure name list string into an array of procedure name strings -->
333
            <!--   Create a node of the array type -->
334
            <action>lref = execLib("create_attribute_array_assignment_right", selectProceduresAnno, "value")</action>
335
            <variable name="procedureNames" type="java.util.Iterator" />
336
            <action>procedureNames = test_suite_procedures.iterator()</action>
337
            <while>procedureNames.hasNext()
338
               <variable name="procedureName" type="java.lang.String" />
339
               <action>procedureName = #(java.lang.String)procedureNames.next()</action>
340
               <action>createProgressAst(prog.string, sprintf("'%s'", procedureName), lref)</action>
341
            </while>
342
            <action>test_suite_procedures.clear()</action>            
343
         </rule>
344
      </rule>
345
      
346
   </ascent-rules>
107 347
</rule-set>
rules/convert/core_conversion.xml 2022-11-03 20:33:22 +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-11-18 15:34:24 +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
79
                 or parent.type == prog.class_def
80
                 or (parent.type == prog.block and parent.isRoot()))
81

  
75 82
         <variable name="annoName" type="java.lang.String" />
76 83
         <action>annoName = this.getAnnotation("javaname")</action>
84
         <!-- <action>printfln("annoName '%s'", annoName)</action> -->
77 85
         <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")
86
            annoName.startsWith("com.goldencode.p2j.testengine.api.")
84 87
            <!-- Replace fully-qualified name by simple name -->
85
            <action>copy.putAnnotation("javaname", annoName.substring(22))</action>
88
            <action>copy.putAnnotation("javaname", annoName.substring(34))</action>
86 89
            <action>hasJUnit5Annotations = true</action>
87 90
         </rule>
88 91
      </rule>
92
      <rule>upPath("ANNOTATION/ASSIGN/LBRACKET")
93
            and this.type == prog.symbol
94
         <!-- <action>printfln("ANNOTATION/ASSIGN/LBRACKET text '%s'", this.getText())</action> -->
95
         <action>createJavaAst(java.reference, ecw.stripQuotes(this.getText()), getClosestPeerId())</action>
96
      </rule>
89 97
   </walk-rules>
90 98
   <post-rules>
91 99
      <rule>hasJUnit5Annotations == true
92
         <action>help.createImport("org.junit.jupiter.api.*")</action>
100
         <action>help.createImport("com.goldencode.p2j.testengine.api.*")</action>
93 101
         <action>hasJUnit5Annotations = false</action>
94 102
      </rule>
95 103
   </post-rules>
src/com/goldencode/p2j/cfg/Configuration.java 2022-11-03 20:33:22 +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-11-03 20:33:22 +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-11-03 20:33:22 +0000
204 204
**                           processing all the scopeables for each and every block.
205 205
**     CA  20220906          Moved the interactive client cleaner to LogicalTerminal.registerCleaner().
206 206
**     TJD 20220504          Migration to Java 11 minor changes
207
**     VVT 2022xxxx          UnitTestEngine static network server registration added. See #6237.
207 208
*/
208 209

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

  
270 272
import javax.servlet.*;
273

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

  
274 278
import com.goldencode.ast.*;
275 279
import com.goldencode.p2j.*;
276 280
import com.goldencode.p2j.admin.*;
......
288 292
import com.goldencode.p2j.security.*;
289 293
import com.goldencode.p2j.security.SecurityManager;
290 294
import com.goldencode.p2j.soap.*;
295
import com.goldencode.p2j.testengine.*;
291 296
import com.goldencode.p2j.ui.*;
292 297
import com.goldencode.p2j.util.*;
293 298
import com.goldencode.p2j.util.ErrorManager;
......
1009 1014
      
1010 1015
      ifaces = new Class[] { ServerPropertiesInspector.class };
1011 1016
      RemoteObject.registerStaticNetworkServer(ifaces, ServerPropertiesDaemon.class);
1012
      
1017
            
1018
      RemoteObject.registerStaticNetworkServer(new Class[] { UnitTestEngine.class }, UnitTestServer.class);
1019

  
1013 1020
      AdminServerImpl.initialize();
1014 1021
      
1015 1022
      DirectoryManager.initServer();
......
1131 1138
    * @param   ds
1132 1139
    *          The directory service.
1133 1140
    */
1134
   private void initClassLoaders(DirectoryService ds)
1141
   private static void initClassLoaders(DirectoryService ds)
1135 1142
   {
1136 1143
      // initialize the class loaders for the jars defined in the directory
1137 1144
      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-11-05 14:07:19 +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,
... This diff was truncated because it exceeds the maximum size that can be displayed.