6237-remote.diff
build.gradle 2022-10-09 08:30:26 +0000 | ||
---|---|---|
103 | 103 |
** OM 20220812 Upgraded mariadb JDBC driver from 2.7.3 to 3.0.7 GA. |
104 | 104 |
** TW 20220928 Changed junixsocket dependency to official repository, and upped its version to latest. |
105 | 105 |
** TW 20221007 Upgraded junixsocket to 2.5.2. |
106 |
** VVT 2022xxxx JUnit5 dependencies updated to support both existing tests and custom test engine. |
|
107 |
** See #6237. |
|
106 | 108 |
*/ |
107 | 109 | |
108 | 110 |
/* |
... | ... | |
582 | 584 |
aspectjCompile group: 'org.aspectj', name: 'aspectjweaver', version: aspectjVersion |
583 | 585 |
} |
584 | 586 | |
585 |
fwdAllTest group: 'org.junit.platform', name: 'junit-platform-console-standalone', version: '1.7.1' |
|
587 |
// Adding JUnit5 jar both to client and server, so it will be also deployed to converted projects |
|
588 |
fwdClientServer group: 'org.junit.platform', |
|
589 |
name: 'junit-platform-engine', |
|
590 |
version: '1.9.0' |
|
591 | ||
592 |
fwdClientServer group: 'org.junit.platform', |
|
593 |
name: 'junit-platform-suite-engine', |
|
594 |
version: '1.9.0' |
|
595 |
fwdAllTest group: 'org.junit.platform', |
|
596 |
name: 'junit-platform-console', |
|
597 |
version: '1.9.0' |
|
598 |
fwdAllTest group: 'org.junit.platform', |
|
599 |
name: 'junit-platform-engine', |
|
600 |
version: '1.9.0' |
|
586 | 601 |
} |
587 | 602 | |
588 | 603 |
// inject ant-optional dependencies to ant, this is needed for the antlr ant target |
build.xml 2022-10-03 13:11:18 +0000 | ||
---|---|---|
233 | 233 |
** in a more natural manner. |
234 | 234 |
** RFB 20220908 The convert configuration needs to also have the lib.gwt library included, and building |
235 | 235 |
** projects that include admin need the src/com/goldencode tree to be in place. Ref #6214. |
236 |
** VVT 2022xxxx Copy org.junit.platform.engine.TestEngine file to META-INF/services. See #6237. |
|
236 | 237 |
--> |
237 | 238 | |
238 | 239 |
<!-- |
... | ... | |
870 | 871 |
<!-- Copy SPI descriptors to META-INF/services directory --> |
871 | 872 |
<copy todir="${build.home}/classes/META-INF/services"> |
872 | 873 |
<fileset dir="${manifest.src}" includes="*Provider" /> |
874 |
<fileset dir="${manifest.src}" includes="*TestEngine" /> |
|
873 | 875 |
</copy> |
874 | 876 | |
875 | 877 |
<!-- 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/record_scoping.rules 2022-10-11 11:40:27 +0000 | ||
---|---|---|
455 | 455 |
<action>scope.putAnnotation("is_dynamic_table", true)</action> |
456 | 456 |
</rule> |
457 | 457 |
<action>scope.putAnnotation("schemaname", master.schemaName)</action> |
458 |
<action>scope.putAnnotation("dbname", master.dbName)</action> |
|
458 |
<action>scope.putAnnotation("dbname", master.dbName())</action>
|
|
459 | 459 |
<action>scope.putAnnotation("scopetype", #(long) bufscope.type)</action> |
460 | 460 |
<action>scope.putAnnotation("implicit", master.implicit and !master.inSuper)</action> |
461 | 461 |
<action>scope.putAnnotation("readOnly", master.readOnly)</action> |
rules/annotations/unit_test_support.rules 2022-09-30 11:57:33 +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" /> |
|
68 | 71 |
<walk-rules> |
69 | 72 |
<rule>this.type == prog.annotation |
70 | 73 |
and parent.type == prog.method_def |
74 |
|
|
75 |
<!-- Get required unit test legacy type configuration (hints) --> |
|
76 |
<variable name="unitTestType" type="java.lang.String" /> |
|
77 |
<action>unitTestType = hints.getUnitTestType()</action> |
|
78 |
<rule>unitTestType == null |
|
79 |
<action>compileError(223, "No unit test legacy type is configured")</action> |
|
80 |
</rule> |
|
81 |
|
|
82 |
<variable name="isABLUnit" type="java.lang.Boolean" /> |
|
83 |
<action>isABLUnit = unitTestType.equals("ABLUnit")</action> |
|
84 | ||
85 |
<variable name="methodNode" type="com.goldencode.ast.Aast" /> |
|
86 |
<action>methodNode = parent.firstChild</action> |
|
87 | ||
88 |
<!-- FIXME: Add similar support for procedures --> |
|
71 | 89 | |
72 | 90 |
<!-- Get initial annotation name --> |
73 | 91 |
<variable name="annoName" type="java.lang.String" /> |
74 | 92 |
<action>annoName = this.getAnnotation("javaname")</action> |
75 | 93 | |
94 |
<action>printfln("method %s is ABL unit test type %s annoName @%s", methodNode.getAnnotation("name"), isABLUnit, annoName)</action> |
|
95 | ||
76 | 96 |
<variable name="newName" type="java.lang.String" /> |
77 | 97 |
<action>newName = null</action> |
78 | 98 | |
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> |
|
99 |
<!-- Replace OEUnit/ABLUnit annotation names by corresponding JUnit5 names --> |
|
100 |
<rule>annoName.equalsIgnoreCase("Test") |
|
101 |
<action>newName = "com.goldencode.p2j.testengine.api.Test"</action> |
|
102 | ||
103 |
<!-- Note: the meaning of @Before and @After is opposite in ABLUnit and OEUnit --> |
|
104 |
<rule on="false">annoName.equalsIgnoreCase("Before") |
|
105 |
<rule>isABLUnit |
|
106 |
<action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action> |
|
107 |
<action on="false">newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action> |
|
108 |
</rule> |
|
109 |
<rule on="false">annoName.equalsIgnoreCase("After") |
|
110 |
<rule>isABLUnit |
|
111 |
<action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action> |
|
112 |
<action on="false">newName = "com.goldencode.p2j.testengine.api.AfterEach"</action> |
|
113 |
</rule> |
|
114 |
<rule on="false">annoName.equalsIgnoreCase("BeforeClass") |
|
115 |
<action>newName = "com.goldencode.p2j.testengine.api.BeforeAll"</action> |
|
116 |
<rule on="false">annoName.equalsIgnoreCase("AfterClass") |
|
117 |
<action>newName = "com.goldencode.p2j.testengine.api.AfterAll"</action> |
|
118 |
<rule on="false">annoName.equalsIgnoreCase("Ignore") |
|
119 |
<action>newName = "com.goldencode.p2j.testengine.api.Disabled"</action> |
|
120 |
</rule> |
|
121 |
<rule on="false">annoName.equalsIgnoreCase("Setup") |
|
122 |
<action>newName = "com.goldencode.p2j.testengine.api.BeforeEach"</action> |
|
123 |
<rule on="false">annoName.equalsIgnoreCase("TearDown") |
|
124 |
<action>newName = "com.goldencode.p2j.testengine.api.AfterEach"</action> |
|
125 |
</rule> |
|
92 | 126 |
</rule> |
93 | 127 |
</rule> |
94 | 128 |
</rule> |
... | ... | |
97 | 131 |
</rule> |
98 | 132 | |
99 | 133 |
<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> |
|
134 |
<action>printfln("newName %s", newName)</action> |
|
135 |
<!-- Write it back... --> |
|
136 |
<action>copy.putAnnotation("javaname", newName)</action> |
|
137 |
<!-- ...and mark "our" annotations as preserved --> |
|
138 |
<action>copy.putAnnotation("fwd", true)</action> |
|
103 | 139 |
</rule> |
104 | 140 |
</rule> |
105 | 141 |
|
rules/convert/builtin_functions.rules 2022-10-11 11:44:45 +0000 | ||
---|---|---|
187 | 187 |
** RFB 20210713 Added support for LIST-EVENTS (HandleOps.listEvents). Ref #5536. |
188 | 188 |
** CA 20220930 Dynamic invocation of functions or RUN statements are now tracked via an |
189 | 189 |
** InvokeConfig call-site, to allow the runtime to cache the target of the call-site. |
190 |
** VVT 2022yyyy Method(s) renamed to avoid method name clashes. See #6767. |
|
190 | 191 |
*/ |
191 | 192 |
--> |
192 | 193 |
|
... | ... | |
578 | 579 |
|
579 | 580 |
<!-- DATA-SOURCE-MODIFIED function --> |
580 | 581 |
<rule>ftype == prog.kw_data_sm |
581 |
<action>methodText = "DataSourceModifiable.isDataSourceModified"</action>
|
|
582 |
<action>methodText = "DataSourceModifiable.dataSourceModified()"</action>
|
|
582 | 583 |
<action>dbimport = true</action> |
583 | 584 |
</rule> |
584 | 585 |
|
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-09-30 12:00:04 +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 |
<!-- |
... | ... | |
75 | 77 |
<variable name="annoName" type="java.lang.String" /> |
76 | 78 |
<action>annoName = this.getAnnotation("javaname")</action> |
77 | 79 |
<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")
|
|
80 |
annoName.equals("com.goldencode.p2j.testengine.api.Test") or
|
|
81 |
annoName.equals("com.goldencode.p2j.testengine.api.BeforeEach") or
|
|
82 |
annoName.equals("com.goldencode.p2j.testengine.api.AfterEach") or
|
|
83 |
annoName.equals("com.goldencode.p2j.testengine.api.BeforeAll") or
|
|
84 |
annoName.equals("com.goldencode.p2j.testengine.api.AfterAll") or
|
|
85 |
annoName.equals("com.goldencode.p2j.testengine.api.Disabled")
|
|
84 | 86 |
<!-- Replace fully-qualified name by simple name --> |
85 |
<action>copy.putAnnotation("javaname", annoName.substring(22))</action>
|
|
87 |
<action>copy.putAnnotation("javaname", annoName.substring(34))</action>
|
|
86 | 88 |
<action>hasJUnit5Annotations = true</action> |
87 | 89 |
</rule> |
88 | 90 |
</rule> |
89 | 91 |
</walk-rules> |
90 | 92 |
<post-rules> |
91 | 93 |
<rule>hasJUnit5Annotations == true |
92 |
<action>help.createImport("org.junit.jupiter.api.*")</action>
|
|
94 |
<action>help.createImport("com.goldencode.p2j.testengine.api.*")</action>
|
|
93 | 95 |
<action>hasJUnit5Annotations = false</action> |
94 | 96 |
</rule> |
95 | 97 |
</post-rules> |
src/com/goldencode/p2j/cfg/Configuration.java 2022-09-30 11:47:48 +0000 | ||
---|---|---|
75 | 75 |
** CA 20220412 Added file-set support (either -Z command-line option or p2j.cfg.xml |
76 | 76 |
** configuration). |
77 | 77 |
** OM 20220421 Restored the ability to load the configuration file relative to P2J_HOME folder. |
78 |
** VVT 2022xxxx Constant added: default legacy unit test framework type. See #6237. |
|
78 | 79 |
*/ |
79 | 80 | |
80 | 81 |
/* |
... | ... | |
268 | 269 |
/** Default configuration filename */ |
269 | 270 |
public static final String DEF_CFG_FILE = "p2j.cfg.xml"; |
270 | 271 |
|
272 |
/** Default legacy unit test type */ |
|
273 |
public static final String DEF_UNIT_TEST_TYPE = "ABLUnit"; |
|
274 |
|
|
271 | 275 |
/** Singleton instance. */ |
272 | 276 |
private static volatile Configuration instance; |
273 | 277 |
|
src/com/goldencode/p2j/main/ClientCore.java 2022-10-12 22:01:49 +0000 | ||
---|---|---|
60 | 60 |
** CA 20220208 Added -errorstack command-line option (client:cmd-line-option:error-stack). |
61 | 61 |
** SVL 20220620 "ininame" parameter handling moved earlier to TC.initializePost. |
62 | 62 |
** CA 20220918 Added socket trust store filename and password to the ClientParameters. |
63 |
** VVT 2022xxxx Native methods processInit and getPid made public to be accessible from |
|
64 |
** FWD test engine. See #6237. |
|
63 | 65 |
*/ |
64 | 66 |
/* |
65 | 67 |
** This program is free software: you can redistribute it and/or modify |
... | ... | |
121 | 123 |
import java.util.logging.*; |
122 | 124 | |
123 | 125 |
import com.goldencode.p2j.cfg.*; |
126 |
import com.goldencode.p2j.directory.*; |
|
124 | 127 |
import com.goldencode.p2j.net.*; |
125 |
import com.goldencode.p2j.directory.*;
|
|
128 |
import com.goldencode.p2j.net.Session;
|
|
126 | 129 |
import com.goldencode.p2j.security.SecurityManager; |
130 |
import com.goldencode.p2j.ui.chui.*; |
|
127 | 131 |
import com.goldencode.p2j.ui.client.*; |
128 | 132 |
import com.goldencode.p2j.ui.client.driver.*; |
129 |
import com.goldencode.p2j.ui.chui.ThinClient; |
|
130 | 133 |
import com.goldencode.p2j.util.*; |
131 | 134 | |
132 | 135 |
/** |
... | ... | |
172 | 175 |
* <code>false</code> for the normal client JVM startup. |
173 | 176 |
* @param diag |
174 | 177 |
* Details about the driver state that can help diagnose server startup issues. |
175 |
* |
|
176 | 178 |
* @throws Exception |
177 | 179 |
*/ |
178 | 180 |
public static void start(BootstrapConfig config, boolean file, boolean single, Supplier<String> diag) |
... | ... | |
357 | 359 |
// set up current user name for client session |
358 | 360 |
ThinClient.getInstance().setUserName(params.osUserName); |
359 | 361 | |
362 |
|
|
360 | 363 |
// call the application |
361 | 364 |
running = main.standardEntry(); |
362 | 365 |
|
... | ... | |
438 | 441 |
/** |
439 | 442 |
* Native call to set up and redefine signal processing handlers. |
440 | 443 |
*/ |
441 |
private static native void processInit();
|
|
444 |
public static native void processInit();
|
|
442 | 445 |
|
443 | 446 |
/** |
444 | 447 |
* Native call to read the operating system pid for the current JVM process. |
448 |
* |
|
449 |
* @return see above |
|
445 | 450 |
*/ |
446 |
private static native long getPid();
|
|
451 |
public static native long getPid();
|
|
447 | 452 |
|
448 | 453 |
/** |
449 | 454 |
* Native call to read the operating system user name for the current JVM process. |
455 |
* |
|
456 |
* @return see above |
|
450 | 457 |
*/ |
451 |
private static native String getUserName();
|
|
458 |
public static native String getUserName();
|
|
452 | 459 |
|
453 | 460 |
/** |
454 | 461 |
* Initialize the logger if needed. |
src/com/goldencode/p2j/main/StandardServer.java 2022-10-12 21:57:10 +0000 | ||
---|---|---|
203 | 203 |
** allows a lazy registration of scopeables, to avoid the unnecessary overhead of |
204 | 204 |
** processing all the scopeables for each and every block. |
205 | 205 |
** CA 20220906 Moved the interactive client cleaner to LogicalTerminal.registerCleaner(). |
206 |
** VVT 2022xxxx UnitTestEngine static network server registration added. See #6237. |
|
206 | 207 |
*/ |
207 | 208 | |
208 | 209 |
/* |
... | ... | |
264 | 265 |
import java.lang.reflect.*; |
265 | 266 |
import java.util.*; |
266 | 267 |
import java.util.concurrent.*; |
267 |
import java.util.function.Supplier;
|
|
268 |
import java.util.function.*;
|
|
268 | 269 |
import java.util.logging.*; |
270 | ||
269 | 271 |
import javax.servlet.*; |
272 | ||
270 | 273 |
import org.eclipse.jetty.server.handler.*; |
271 | 274 |
import org.eclipse.jetty.util.resource.Resource; |
272 | 275 |
import org.eclipse.jetty.webapp.*; |
276 | ||
273 | 277 |
import com.goldencode.ast.*; |
274 | 278 |
import com.goldencode.p2j.*; |
275 | 279 |
import com.goldencode.p2j.admin.*; |
... | ... | |
287 | 291 |
import com.goldencode.p2j.security.*; |
288 | 292 |
import com.goldencode.p2j.security.SecurityManager; |
289 | 293 |
import com.goldencode.p2j.soap.*; |
294 |
import com.goldencode.p2j.testengine.*; |
|
290 | 295 |
import com.goldencode.p2j.ui.*; |
291 | 296 |
import com.goldencode.p2j.util.*; |
292 | 297 |
import com.goldencode.p2j.util.ErrorManager; |
... | ... | |
992 | 997 |
|
993 | 998 |
ifaces = new Class[] { ServerPropertiesInspector.class }; |
994 | 999 |
RemoteObject.registerStaticNetworkServer(ifaces, ServerPropertiesDaemon.class); |
995 |
|
|
1000 |
|
|
1001 |
RemoteObject.registerStaticNetworkServer(new Class[] { UnitTestEngine.class }, UnitTestServer.class); |
|
1002 | ||
996 | 1003 |
AdminServerImpl.initialize(); |
997 | 1004 |
|
998 | 1005 |
DirectoryManager.initServer(); |
... | ... | |
1114 | 1121 |
* @param ds |
1115 | 1122 |
* The directory service. |
1116 | 1123 |
*/ |
1117 |
private void initClassLoaders(DirectoryService ds) |
|
1124 |
private static void initClassLoaders(DirectoryService ds)
|
|
1118 | 1125 |
{ |
1119 | 1126 |
// initialize the class loaders for the jars defined in the directory |
1120 | 1127 |
String path = Utils.findDirectoryNodePath(ds, |
src/com/goldencode/p2j/main/UnitTestDriver.java 2022-10-12 21:44:30 +0000 | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package com.goldencode.p2j.main; |
|
5 | ||
6 |
import com.goldencode.p2j.cfg.*; |
|
7 | ||
8 |
/** |
|
9 |
* The purpose of this class is to explore how to start client with no command line. |
|
10 |
*/ |
|
11 |
public class UnitTestDriver |
|
12 |
{ |
|
13 | ||
14 |
/** |
|
15 |
* The main entry |
|
16 |
* |
|
17 |
* @param args |
|
18 |
* for now unused |
|
19 |
*/ |
|
20 |
public static void main(String[] args) |
|
21 |
{ |
|
22 |
// process arguments: either config files of overrides |
|
23 |
// try standard configuration file if none is given |
|
24 |
BootstrapConfig bc = null; |
|
25 | ||
26 |
try |
|
27 |
{ |
|
28 |
bc = new BootstrapConfig(null, null, null, null); |
|
29 |
} |
|
30 |
catch (ConfigurationException e) |
|
31 |
{ |
|
32 |
e.printStackTrace(); |
|
33 |
System.exit(1); |
|
34 |
} |
|
35 | ||
36 |
bc.setServer(false); |
|
37 | ||
38 |
String convo = null; |
|
39 | ||
40 |
try |
|
41 |
{ |
|
42 |
convo = bc.getConfigItem("net", "queue", "conversation"); |
|
43 |
} |
|
44 |
catch (ConfigurationException ce) |
|
45 |
{ |
|
46 |
// ignore |
|
47 |
} |
|
48 | ||
49 |
// default to conversation mode if not specified |
|
50 |
if (convo == null) |
|
51 |
{ |
|
52 |
bc.setConfigItem("net", "queue", "conversation", "true"); |
|
53 |
} |
|
54 | ||
55 |
// either way, force start thread to false (this client is going to |
|
56 |
// use its main thread as the conversation thread so we don't need |
|
57 |
// to start one |
|
58 |
bc.setConfigItem("net", "queue", "start_thread", "false"); |
|
59 | ||
60 |
bc.setConfigItem("net", "server", "host", "localhost"); |
|
61 |
bc.setConfigItem("net", "connection", "secure", "false"); |
|
62 |
bc.setConfigItem("net", "server", "secure_port", "4434"); |
|
63 |
bc.setConfigItem("net", "server", "insecure_port", "4534"); |
|
64 |
bc.setConfigItem("client", "driver", "type", "gui_swing"); |
|
65 |
bc.setConfigItem("client", "driver", "theme", |
|
66 |
"com.goldencode.p2j.ui.client.gui.theme.Windows10Theme"); |
|
67 | ||
68 |
// run the application |
|
69 |
try |
|
70 |
{ |
|
71 |
// if (config.getBoolean("net", "http_client", "disable_ssl_certificate_validation", false)) |
|
72 |
// { |
|
73 |
// Utils.disableClientSSLCertificateValidation(); |
|
74 |
// } |
|
75 | ||
76 |
// if (config.getBoolean("client", "mode", "broker", false)) |
|
77 |
// { |
|
78 |
// setClientLog("broker"); |
|
79 |
// BrokerCore.start(config); |
|
80 |
// } |
|
81 |
// else |
|
82 |
// { |
|
83 |
// ClientCore.start(config, true, false, this::printDriverDetails); |
|
84 |
// } |
|
85 | ||
86 |
ClientCore.start(bc, true, false, () -> ""); |
|
87 |
// ensure that remaining non-daemon threads don't stop us from closing |
|
88 |
System.exit(0); |
|
89 |
} |
|
90 |
catch (Throwable thr) |
|
91 |
{ |
|
92 |
// STOP conditions don't need to be reported, they are an expected |
|
93 |
// mechanism to terminate |
|
94 |
if (ClientCore.isCauseStop(thr)) |
|
95 |
{ |
|
96 |
System.exit(0); |
|
97 |
} |
|
98 | ||
99 |
thr.printStackTrace(System.err); |
|
100 |
System.err.flush(); |
|
101 |
System.exit(-13); |
|
102 |
} |
|
103 | ||
104 |
} |
|
105 |
} |
src/com/goldencode/p2j/testengine/AbstractBranchTestDescriptor.java 2022-10-12 21:04:57 +0000 | ||
---|---|---|
1 |
/* |
|
2 |
** Module : AbstractBranchTestDescriptor.java |
|
3 |
** Abstract : Common accessor for non-terminal test descriptors |
|
4 |
** |
|
5 |
** Copyright (c) 2022, Golden Code Development Corporation. |
|
6 |
** |
|
7 |
** -#- -I- --Date-- ----------------Description---------------------- |
|
8 |
** 001 VVT 2022xxxx Created initial version. |
|
9 |
*/ |
|
10 |
/* |
|
11 |
** This program is free software: you can redistribute it and/or modify |
|
12 |
** it under the terms of the GNU Affero General Public License as |
|
13 |
** published by the Free Software Foundation, either version 3 of the |
|
14 |
** License, or (at your option) any later version. |
|
15 |
** |
|
16 |
** This program is distributed in the hope that it will be useful, |
|
17 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
** GNU Affero General Public License for more details. |
|
20 |
** |
|
21 |
** You may find a copy of the GNU Affero GPL version 3 at the following |
|
22 |
** location: https://www.gnu.org/licenses/agpl-3.0.en.html |
|
23 |
** |
|
24 |
** Additional terms under GNU Affero GPL version 3 section 7: |
|
25 |
** |
|
26 |
** Under Section 7 of the GNU Affero GPL version 3, the following additional |
|
27 |
** terms apply to the works covered under the License. These additional terms |
|
28 |
** are non-permissive additional terms allowed under Section 7 of the GNU |
|
29 |
** Affero GPL version 3 and may not be removed by you. |
|
30 |
** |
|
31 |
** 0. Attribution Requirement. |
|
32 |
** |
|
33 |
** You must preserve all legal notices or author attributions in the covered |
|
34 |
** work or Appropriate Legal Notices displayed by works containing the covered |
|
35 |
** work. You may not remove from the covered work any author or developer |
|
36 |
** credit already included within the covered work. |
|
37 |
** |
|
38 |
** 1. No License To Use Trademarks. |
|
39 |
** |
|
40 |
** This license does not grant any license or rights to use the trademarks |
|
41 |
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks |
|
42 |
** of Golden Code Development Corporation. You are not authorized to use the |
|
43 |
** name Golden Code, FWD, or the names of any author or contributor, for |
|
44 |
** publicity purposes without written authorization. |
|
45 |
** |
|
46 |
** 2. No Misrepresentation of Affiliation. |
|
47 |
** |
|
48 |
** You may not represent yourself as Golden Code Development Corporation or FWD. |
|
49 |
** |
|
50 |
** You may not represent yourself for publicity purposes as associated with |
|
51 |
** Golden Code Development Corporation, FWD, or any author or contributor to |
|
52 |
** the covered work, without written authorization. |
|
53 |
** |
|
54 |
** 3. No Misrepresentation of Source or Origin. |
|
55 |
** |
|
56 |
** You may not represent the covered work as solely your work. All modified |
|
57 |
** versions of the covered work must be marked in a reasonable way to make it |
|
58 |
** clear that the modified work is not originating from Golden Code Development |
|
59 |
** Corporation or FWD. All modified versions must contain the notices of |
|
60 |
** attribution required in this license. |
|
61 |
*/ |
|
62 |
package com.goldencode.p2j.testengine; |
|
63 | ||
64 |
import java.io.*; |
|
65 |
import java.util.*; |
|
66 | ||
67 |
import org.junit.platform.commons.util.*; |
|
68 |
import org.junit.platform.engine.*; |
|
69 | ||
70 |
/** |
|
71 |
* This class provides common functions for branch test descriptors |
|
72 |
*/ |
|
73 |
public abstract class AbstractBranchTestDescriptor |
|
74 |
extends AbstractFWDTestDescriptor |
|
75 |
{ |
|
76 |
/** Child descriptors */ |
|
77 |
private Set<TestDescriptor> children = Collections.synchronizedSet(new LinkedHashSet<>(16)); |
|
78 | ||
79 |
/** |
|
80 |
* The constructor. |
|
81 |
* |
|
82 |
* @param uniqueId |
|
83 |
* this descriptor unique ID |
|
84 |
* @param displayName |
|
85 |
* this descriptor display name |
|
86 |
*/ |
|
87 |
public AbstractBranchTestDescriptor(final UniqueId uniqueId, final String displayName) |
|
88 |
{ |
|
89 |
super(uniqueId, displayName); |
|
90 |
} |
|
91 | ||
92 |
/** |
|
93 |
* Add a <em>child</em> to this descriptor. |
|
94 |
* |
|
95 |
* @param descriptor the child to add to this descriptor; never {@code null} |
|
96 |
*/ |
|
97 |
@Override |
|
98 |
public void addChild(final TestDescriptor descriptor) |
|
99 |
{ |
|
100 |
Preconditions.notNull(descriptor, "child must not be null"); |
|
101 | ||
102 |
descriptor.setParent(this); |
|
103 |
children.add(descriptor); |
|
104 |
} |
|
105 | ||
106 |
/** |
|
107 |
* Find the descriptor with the supplied unique ID. |
|
108 |
* |
|
109 |
* <p>The search algorithm begins with this descriptor and then searches |
|
110 |
* through its descendants. |
|
111 |
* |
|
112 |
* @param uniqueId the {@code UniqueId} to search for; never {@code null} |
|
113 |
*/ |
|
114 |
@Override |
|
115 |
public Optional<? extends TestDescriptor> findByUniqueId(final UniqueId uniqueId) |
|
116 |
{ |
|
117 |
if (getUniqueId().equals(uniqueId)) |
|
118 |
{ |
|
119 |
return Optional.of(this); |
|
120 |
} |
|
121 | ||
122 |
return children.stream().map(child -> child.findByUniqueId(uniqueId)) |
|
123 |
.filter(Optional::isPresent).findAny().orElse(Optional.empty()); |
|
124 |
} |
|
125 | ||
126 |
/** |
|
127 |
* Get the immutable set of <em>children</em> of this descriptor. |
|
128 |
* |
|
129 |
* @return the set of children of this descriptor; neither {@code null} |
|
130 |
* nor mutable, but potentially empty |
|
131 |
* @see #getDescendants() |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
public final Set<? extends TestDescriptor> getChildren() |
|
135 |
{ |
|
136 |
return Collections.unmodifiableSet(children); |
|
137 |
} |
|
138 | ||
139 |
/** |
|
140 |
* Determine the {@link org.junit.platform.engine.TestDescriptor.Type} of this descriptor. |
|
141 |
* |
|
142 |
* @return the descriptor type; never {@code null}. |
|
143 |
* @see #isContainer() |
|
144 |
* @see #isTest() |
|
145 |
*/ |
|
146 |
@Override |
|
147 |
public Type getType() |
|
148 |
{ |
|
149 |
return Type.CONTAINER; |
|
150 |
} |
|
151 | ||
152 |
/** |
|
153 |
* The object implements the readExternal method to restore its |
|
154 |
* contents by calling the methods of DataInput for primitive |
|
155 |
* types and readObject for objects, strings and arrays. The |
|
156 |
* readExternal method must read the values in the same sequence |
|
157 |
* and with the same types as were written by writeExternal. |
|
158 |
* |
|
159 |
* @param in the stream to read data from in order to restore the object |
|
160 |
* @exception IOException if I/O errors occur |
|
161 |
* @exception ClassNotFoundException If the class for an object being |
|
162 |
* restored cannot be found. |
|
163 |
*/ |
|
164 |
@Override |
|
165 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException |
|
166 |
{ |
|
167 |
super.readExternal(in); |
|
168 |
|
|
169 |
children = (Set<TestDescriptor>) in.readObject(); |
|
170 |
|
|
171 |
for(final TestDescriptor child : children) |
|
172 |
{ |
|
173 |
child.setParent(this); |
|
174 |
} |
|
175 |
} |
|
176 | ||
177 |
/** |
|
178 |
* Remove a <em>child</em> from this descriptor. |
|
179 |
* |
|
180 |
* @param descriptor the child to remove from this descriptor; never |
|
181 |
* {@code null} |
|
182 |
*/ |
|
183 |
@Override |
|
184 |
public void removeChild(TestDescriptor descriptor) |
|
185 |
{ |
|
186 |
Preconditions.notNull(descriptor, "child must not be null"); |
|
187 | ||
188 |
children.remove(descriptor); |
|
189 |
descriptor.setParent(null); |
|
190 |
} |
|
191 | ||
192 |
/** |
|
193 |
* The object implements the writeExternal method to save its contents |
|
194 |
* by calling the methods of DataOutput for its primitive values or |
|
195 |
* calling the writeObject method of ObjectOutput for objects, strings, |
|
196 |
* and arrays. |
|
197 |
* |
|
198 |
* @serialData Overriding methods should use this tag to describe |
|
199 |
* the data layout of this Externalizable object. |
|
200 |
* List the sequence of element types and, if possible, |
|
201 |
* relate the element to a public/protected field and/or |
|
202 |
* method of this Externalizable class. |
|
203 |
* |
|
204 |
* @param out the stream to write the object to |
|
205 |
* @exception IOException Includes any I/O exceptions that may occur |
|
206 |
*/ |
|
207 |
@Override |
|
208 |
public void writeExternal(ObjectOutput out) throws IOException |
|
209 |
{ |
|
210 |
super.writeExternal(out); |
|
211 |
|
|
212 |
out.writeObject(children); |
|
213 |
} |
|
214 | ||
215 |
} |
src/com/goldencode/p2j/testengine/AbstractFWDTestDescriptor.java 2022-10-12 21:15:48 +0000 | ||
---|---|---|
1 |
/* |
|
2 |
** Module : AbstractDWDTestDescriptor.java |
|
3 |
** Abstract : Common accessor for all test descriptors |
|
4 |
** |
|
5 |
** Copyright (c) 2022, Golden Code Development Corporation. |
|
6 |
** |
|
7 |
** -#- -I- --Date-- ----------------Description---------------------- |
|
8 |
** 001 VVT 2022xxxx Created initial version. |
|
9 |
*/ |
|
10 |
/* |
|
11 |
** This program is free software: you can redistribute it and/or modify |
|
12 |
** it under the terms of the GNU Affero General Public License as |
|
13 |
** published by the Free Software Foundation, either version 3 of the |
|
14 |
** License, or (at your option) any later version. |
|
15 |
** |
|
16 |
** This program is distributed in the hope that it will be useful, |
|
17 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
** GNU Affero General Public License for more details. |
|
20 |
** |
|
21 |
** You may find a copy of the GNU Affero GPL version 3 at the following |
|
22 |
** location: https://www.gnu.org/licenses/agpl-3.0.en.html |
|
23 |
** |
|
24 |
** Additional terms under GNU Affero GPL version 3 section 7: |
|
25 |
** |
|
26 |
** Under Section 7 of the GNU Affero GPL version 3, the following additional |
|
27 |
** terms apply to the works covered under the License. These additional terms |
|
28 |
** are non-permissive additional terms allowed under Section 7 of the GNU |
|
29 |
** Affero GPL version 3 and may not be removed by you. |
|
30 |
** |
|
31 |
** 0. Attribution Requirement. |
|
32 |
** |
|
33 |
** You must preserve all legal notices or author attributions in the covered |
|
34 |
** work or Appropriate Legal Notices displayed by works containing the covered |
|
35 |
** work. You may not remove from the covered work any author or developer |
|
36 |
** credit already included within the covered work. |
|
37 |
** |
|
38 |
** 1. No License To Use Trademarks. |
|
39 |
** |
|
40 |
** This license does not grant any license or rights to use the trademarks |
|
41 |
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks |
|
42 |
** of Golden Code Development Corporation. You are not authorized to use the |
|
43 |
** name Golden Code, FWD, or the names of any author or contributor, for |
|
44 |
** publicity purposes without written authorization. |
|
45 |
** |
|
46 |
** 2. No Misrepresentation of Affiliation. |
|
47 |
** |
|
48 |
** You may not represent yourself as Golden Code Development Corporation or FWD. |
|
49 |
** |
|
50 |
** You may not represent yourself for publicity purposes as associated with |
|
51 |
** Golden Code Development Corporation, FWD, or any author or contributor to |
|
52 |
** the covered work, without written authorization. |
|
53 |
** |
|
54 |
** 3. No Misrepresentation of Source or Origin. |
|
55 |
** |
|
56 |
** You may not represent the covered work as solely your work. All modified |
|
57 |
** versions of the covered work must be marked in a reasonable way to make it |
|
58 |
** clear that the modified work is not originating from Golden Code Development |
|
59 |
** Corporation or FWD. All modified versions must contain the notices of |
|
60 |
** attribution required in this license. |
|
61 |
*/ |
|
62 |
package com.goldencode.p2j.testengine; |
|
63 | ||
64 |
import java.io.*; |
|
65 |
import java.util.*; |
|
66 | ||
67 |
import org.junit.platform.engine.*; |
|
68 |
import org.junit.platform.engine.TestDescriptor.*; |
|
69 |
import org.junit.platform.engine.support.hierarchical.*; |
|
70 | ||
71 |
/** |
|
72 |
* This class provides common functions for all FWD test descriptors: |
|
73 |
* |
|
74 |
* <li>Stores unique ID, display name and parent reference. |
|
75 |
* <li>Serialization: FWD test descriptors travel over network, so they must be serializable. |
|
76 |
* <li>Implements {@link Node} interface: all methods are passed to a proxy to be executed on the server. |
|
77 |
*/ |
|
78 |
public abstract class AbstractFWDTestDescriptor |
|
79 |
implements Externalizable, TestDescriptor, Node<FWDEngineExecutionContext> |
|
80 |
{ |
|
81 | ||
82 |
/** This descriptor display name */ |
|
83 |
private String displayName; |
|
84 | ||
85 |
/** The parent descriptor or {@code null} if this is the root (test engine) descriptor */ |
|
86 |
private TestDescriptor parent; |
|
87 |
|
|
88 |
/** The descriptor unique ID */ |
|
89 |
private UniqueId uniqueId; |
|
90 | ||
91 |
/** |
|
92 |
* The constructor. |
|
93 |
* |
|
94 |
* @param uniqueId |
|
95 |
* the descriptor unique ID |
|
96 |
* @param displayName |
|
97 |
* the descriptor display name |
|
98 |
*/ |
|
99 |
public AbstractFWDTestDescriptor(final UniqueId uniqueId, final String displayName) |
|
100 |
{ |
|
101 |
this.uniqueId = uniqueId; |
|
102 |
this.displayName = displayName; |
|
103 |
} |
|
104 | ||
105 |
/** |
|
106 |
* Default constructor. Must be used internally for serialization only. |
|
107 |
*/ |
|
108 |
protected AbstractFWDTestDescriptor() |
|
109 |
{ |
|
110 |
this(null, null); |
|
111 |
} |
|
112 | ||
113 |
/** |
|
114 |
* Add a <em>child</em> to this descriptor. |
|
115 |
* |
|
116 |
* @param descriptor the child to add to this descriptor; never {@code null} |
|
117 |
*/ |
|
118 |
@Override |
|
119 |
public void addChild(TestDescriptor descriptor) |
|
120 |
{ |
|
121 |
// Terminal node implementation, re-defined for branches |
|
122 |
throw new RuntimeException("Not supported"); |
|
123 |
} |
|
124 | ||
125 |
/** |
|
126 |
* Execute the <em>after</em> behavior of this node. |
|
127 |
* |
|
128 |
* <p>This method will be called once <em>after</em> {@linkplain #execute |
|
129 |
* execution} of this node. |
|
130 |
* |
|
131 |
* @param context |
|
132 |
* the context to execute in |
|
133 |
* |
|
134 |
*/ |
|
135 |
@Override |
|
136 |
public void after(final FWDEngineExecutionContext context) throws Exception |
|
137 |
{ |
|
138 |
context.unitTestSupport.after(getUniqueId()); |
|
139 |
} |
|
140 | ||
141 |
/** |
|
142 |
* Execute the <em>before</em> behavior of this node. |
|
143 |
* |
|
144 |
* <p>This method will be called once <em>before</em> {@linkplain #execute |
|
145 |
* execution} of this node. |
|
146 |
* |
|
147 |
* @param context |
|
148 |
* the context to execute in |
|
149 |
* @return the new context to be used for children of this node; never |
|
150 |
* {@code null} |
|
151 |
*/ |
|
152 |
@Override |
|
153 |
public FWDEngineExecutionContext before(FWDEngineExecutionContext context) throws Exception |
|
154 |
{ |
|
155 |
context.unitTestSupport.before(getUniqueId()); |
|
156 |
|
|
157 |
return context; |
|
158 |
} |
|
159 | ||
160 |
/** |
|
161 |
* Clean up the supplied {@code context} after execution. |
|
162 |
* |
|
163 |
* Reset the test class instance. |
|
164 |
* |
|
165 |
* @param context |
|
166 |
* the context to execute in |
|
167 |
|
|
168 |
* @see #prepare |
|
169 |
*/ |
|
170 |
@Override |
|
171 |
public void cleanUp(final FWDEngineExecutionContext context) throws Exception |
|
172 |
{ |
|
173 |
context.unitTestSupport.cleanUp(getUniqueId()); |
|
174 |
} |
|
175 | ||
176 |
@Override |
|
177 |
public final boolean equals(Object other) |
|
178 |
{ |
|
179 |
if (other == null) |
|
180 |
{ |
|
181 |
return false; |
|
182 |
} |
|
183 | ||
184 |
if (this.getClass() != other.getClass()) |
|
185 |
{ |
|
186 |
return false; |
|
187 |
} |
|
188 | ||
189 |
final TestDescriptor that = (TestDescriptor) other; |
|
190 |
return uniqueId.equals(that.getUniqueId()); |
|
191 |
} |
|
192 | ||
193 |
/** |
|
194 |
* Execute the <em>behavior</em> of this node. |
|
195 |
* |
|
196 |
* <p>Containers typically do not implement this method since the |
|
197 |
* {@link HierarchicalTestEngine} handles execution of their children. |
|
198 |
* |
|
199 |
* <p>The supplied {@code dynamicTestExecutor} may be used to submit |
|
200 |
* additional dynamic tests for immediate execution. |
|
201 |
* |
|
202 |
* @param context |
|
203 |
* the context to execute in |
|
204 |
* @param dynamicTestExecutor |
|
205 |
* the executor to submit dynamic tests to |
|
206 |
* |
|
207 |
* @return the new context to be used for children of this node and for the |
|
208 |
* <em>after</em> behavior of the parent of this node, if any |
|
209 |
*/ |
|
210 |
@Override |
|
211 |
public FWDEngineExecutionContext execute(final FWDEngineExecutionContext context, |
|
212 |
DynamicTestExecutor dynamicTestExecutor) throws Exception |
|
213 |
{ |
|
214 |
context.unitTestSupport.execute(getUniqueId()); |
|
215 | ||
216 |
return context; |
|
217 |
} |
|
218 | ||
219 |
/** |
|
220 |
* Find the descriptor with the supplied unique ID. |
|
221 |
* |
|
222 |
* <p>The search algorithm begins with this descriptor and then searches |
|
223 |
* through its descendants. |
|
224 |
* |
|
225 |
* @param uniqueId the {@code UniqueId} to search for; never {@code null} |
|
226 |
*/ |
|
227 |
@Override |
|
228 |
public Optional<? extends TestDescriptor> findByUniqueId(final UniqueId uniqueId) |
|
229 |
{ |
|
230 |
return Optional.of(this.uniqueId.equals(uniqueId) ? this : null); |
|
231 |
} |
|
232 | ||
233 |
/** |
|
234 |
* Get the immutable set of <em>children</em> of this descriptor. |
|
235 |
* |
|
236 |
* @return the set of children of this descriptor; neither {@code null} |
|
237 |
* nor mutable, but potentially empty |
|
238 |
* @see #getDescendants() |
|
239 |
*/ |
|
240 |
@Override |
|
241 |
public Set<? extends TestDescriptor> getChildren() |
|
242 |
{ |
|
243 |
return Collections.emptySet(); |
|
244 |
} |
|
245 | ||
246 |
/** |
|
247 |
* Get the display name for this descriptor. |
|
248 |
* |
|
249 |
* <p>A <em>display name</em> is a human-readable name for a test or |
|
250 |
* container that is typically used for test reporting in IDEs and build |
|
251 |
* tools. Display names may contain spaces, special characters, and emoji, |
|
252 |
* and the format may be customized by {@link TestEngine TestEngines} or |
|
253 |
* potentially by end users as well. Consequently, display names should |
|
254 |
* never be parsed; rather, they should be used for display purposes only. |
|
255 |
* |
|
256 |
* @return the display name for this descriptor; never {@code null} or blank |
|
257 |
* @see #getSource() |
|
258 |
*/ |
|
259 |
@Override |
|
260 |
public String getDisplayName() |
|
261 |
{ |
|
262 |
return displayName; |
|
263 |
} |
|
264 | ||
265 |
/** |
|
266 |
* Get the <em>parent</em> of this descriptor, if available. |
|
267 |
*/ |
|
268 |
@Override |
|
269 |
public Optional<TestDescriptor> getParent() |
|
270 |
{ |
|
271 |
return Optional.ofNullable(parent); |
|
272 |
} |
|
273 | ||
274 |
/** |
|
275 |
* Get the {@linkplain TestSource source} of the test or container described |
|
276 |
* by this descriptor, if available. |
|
277 |
* |
|
278 |
* @see TestSource |
|
279 |
*/ |
|
280 |
@Override |
|
281 |
public Optional<TestSource> getSource() |
|
282 |
{ |
|
283 |
// test sources are not used in FWD test engine |
|
284 |
return Optional.empty(); |
|
285 |
} |
|
286 | ||
287 |
/** |
|
288 |
* Get the set of {@linkplain TestTag tags} associated with this descriptor. |
|
289 |
* |
|
290 |
* @return the set of tags associated with this descriptor; never {@code null} |
|
291 |
* but potentially empty |
|
292 |
* @see TestTag |
|
293 |
*/ |
|
294 |
@Override |
|
295 |
public Set<TestTag> getTags() |
|
296 |
{ |
|
297 |
// tags are not used in FWD test engine currently |
|
298 |
return Collections.emptySet(); |
|
299 |
} |
|
300 | ||
301 |
/** |
|
302 |
* Determine the {@link Type} of this descriptor. |
|
303 |
* |
|
304 |
* @return the descriptor type; never {@code null}. |
|
305 |
* @see #isContainer() |
|
306 |
* @see #isTest() |
|
307 |
*/ |
|
308 |
@Override |
|
309 |
public Type getType() |
|
310 |
{ |
|
311 |
// Default value, test containers must re-define this method |
|
312 |
return Type.TEST; |
|
313 |
} |
|
314 | ||
315 |
/** |
|
316 |
* Get the unique identifier (UID) for this descriptor. |
|
317 |
* |
|
318 |
* <p>Uniqueness must be guaranteed across an entire test plan, |
|
319 |
* regardless of how many engines are used behind the scenes. |
|
320 |
* |
|
321 |
* @return the {@code UniqueId} for this descriptor; never {@code null} |
|
322 |
*/ |
|
323 |
@Override |
|
324 |
public final UniqueId getUniqueId() |
|
325 |
{ |
|
326 |
return this.uniqueId; |
|
327 |
} |
|
328 | ||
329 |
/** |
|
330 |
* Returns a hash code value for the object. This method is |
|
331 |
* supported for the benefit of hash tables such as those provided by |
|
332 |
* {@link java.util.HashMap}. |
|
333 |
* <p> |
|
334 |
* The general contract of {@code hashCode} is: |
|
335 |
* <ul> |
|
336 |
* <li>Whenever it is invoked on the same object more than once during |
|
337 |
* an execution of a Java application, the {@code hashCode} method |
|
338 |
* must consistently return the same integer, provided no information |
|
339 |
* used in {@code equals} comparisons on the object is modified. |
|
340 |
* This integer need not remain consistent from one execution of an |
|
341 |
* application to another execution of the same application. |
|
342 |
* <li>If two objects are equal according to the {@code equals(Object)} |
|
343 |
* method, then calling the {@code hashCode} method on each of |
|
344 |
* the two objects must produce the same integer result. |
|
345 |
* <li>It is <em>not</em> required that if two objects are unequal |
|
346 |
* according to the {@link java.lang.Object#equals(java.lang.Object)} |
|
347 |
* method, then calling the {@code hashCode} method on each of the |
|
348 |
* two objects must produce distinct integer results. However, the |
|
349 |
* programmer should be aware that producing distinct integer results |
|
350 |
* for unequal objects may improve the performance of hash tables. |
|
351 |
* </ul> |
|
352 |
* <p> |
|
353 |
* As much as is reasonably practical, the hashCode method defined by |
|
354 |
* class {@code Object} does return distinct integers for distinct |
|
355 |
* objects. (This is typically implemented by converting the internal |
|
356 |
* address of the object into an integer, but this implementation |
|
357 |
* technique is not required by the |
|
358 |
* Java™ programming language.) |
|
359 |
* |
|
360 |
* @return a hash code value for this object. |
|
361 |
* @see java.lang.Object#equals(java.lang.Object) |
|
362 |
* @see java.lang.System#identityHashCode |
|
363 |
*/ |
|
364 |
@Override |
|
365 |
public final int hashCode() |
|
366 |
{ |
|
367 |
return uniqueId.hashCode(); |
|
368 |
} |
|
369 | ||
370 |
/** |
|
371 |
* Prepare the supplied {@code context} prior to execution. |
|
372 |
* |
|
373 |
* Create test class instance. |
|
374 |
* |
|
375 |
* @see #cleanUp |
|
376 |
*/ |
|
377 |
@Override |
|
378 |
public FWDEngineExecutionContext prepare(FWDEngineExecutionContext context) throws Exception |
|
379 |
{ |
|
380 |
context.unitTestSupport.prepare(getUniqueId()); |
|
381 | ||
382 |
return context; |
|
383 |
} |
|
384 | ||
385 |
/** |
|
386 |
* The object implements the readExternal method to restore its |
|
387 |
* contents by calling the methods of DataInput for primitive |
|
388 |
* types and readObject for objects, strings and arrays. The |
|
389 |
* readExternal method must read the values in the same sequence |
|
390 |
* and with the same types as were written by writeExternal. |
|
391 |
* |
|
392 |
* @param in the stream to read data from in order to restore the object |
|
393 |
* @exception IOException if I/O errors occur |
|
394 |
* @exception ClassNotFoundException If the class for an object being |
|
395 |
* restored cannot be found. |
|
396 |
*/ |
|
397 |
@Override |
|
398 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException |
|
399 |
{ |
|
400 |
uniqueId = (UniqueId) in.readObject(); |
|
401 |
displayName = (String) in.readObject(); |
|
402 |
} |
|
403 | ||
404 |
/** |
|
405 |
* Remove a <em>child</em> from this descriptor. |
|
406 |
* |
|
407 |
* @param descriptor the child to remove from this descriptor; never |
|
408 |
* {@code null} |
|
409 |
*/ |
|
410 |
@Override |
|
411 |
public void removeChild(TestDescriptor descriptor) |
|
412 |
{ |
|
413 |
throw new RuntimeException("Not supported"); |
|
414 |
} |
|
415 | ||
416 |
/** |
|
417 |
* Remove this non-root descriptor from its parent and remove all the |
|
418 |
* children from this descriptor. |
|
419 |
* |
|
420 |
* <p>If this method is invoked on a {@linkplain #isRoot root} descriptor, |
|
421 |
* this method must throw a {@link org.junit.platform.commons.JUnitException |
|
422 |
* JUnitException} explaining that a root cannot be removed from the |
|
423 |
* hierarchy. |
|
424 |
*/ |
|
425 |
@Override |
|
426 |
public void removeFromHierarchy() |
|
427 |
{ |
|
428 |
parent.removeChild(this); |
|
429 |
parent = null; |
|
430 |
} |
|
431 | ||
432 |
/** |
|
433 |
* Set the <em>parent</em> of this descriptor. |
|
434 |
* |
|
435 |
* @param parent the new parent of this descriptor; may be {@code null}. |
|
436 |
*/ |
|
437 |
@Override |
|
438 |
public void setParent(TestDescriptor parent) |
|
439 |
{ |
|
440 |
this.parent = parent; |
|
441 |
} |
|
442 | ||
443 |
/** |
|
444 |
* The object implements the writeExternal method to save its contents |
|
445 |
* by calling the methods of DataOutput for its primitive values or |
|
446 |
* calling the writeObject method of ObjectOutput for objects, strings, |
|
447 |
* and arrays. |
|
448 |
* |
|
449 |
* @serialData Overriding methods should use this tag to describe |
|
450 |
* the data layout of this Externalizable object. |
|
451 |
* List the sequence of element types and, if possible, |
|
452 |
* relate the element to a public/protected field and/or |
|
453 |
* method of this Externalizable class. |
|
454 |
* |
|
455 |
* @param out the stream to write the object to |
|
456 |
* @exception IOException Includes any I/O exceptions that may occur |
|
457 |
*/ |
|
458 |
@Override |
|
459 |
public void writeExternal(ObjectOutput out) throws IOException |
|
460 |
{ |
|
461 |
out.writeObject(uniqueId); |
|
462 |
out.writeObject(displayName); |
|
463 |
} |
|
464 | ||
465 |
} |
src/com/goldencode/p2j/testengine/FWDClassTestDescriptor.java 2022-10-12 21:05:50 +0000 | ||
---|---|---|
1 |
/* |
|
2 |
** Module : FWDClassTestDescriptor.java |
|
3 |
** Abstract : Test descriptor for a Java class. |
|
4 |
** |
|
5 |
** Copyright (c) 2022, Golden Code Development Corporation. |
|
6 |
** |
|
7 |
** -#- -I- --Date-- ----------------Description---------------------- |
|
8 |
** 001 VVT 2022xxxx Created initial version. |
|
9 |
*/ |
|
10 |
/* |
|
11 |
** This program is free software: you can redistribute it and/or modify |
|
12 |
** it under the terms of the GNU Affero General Public License as |
|
13 |
** published by the Free Software Foundation, either version 3 of the |
|
14 |
** License, or (at your option) any later version. |
|
15 |
** |
|
16 |
** This program is distributed in the hope that it will be useful, |
|
17 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
** GNU Affero General Public License for more details. |
|
20 |
** |
|
21 |
** You may find a copy of the GNU Affero GPL version 3 at the following |
|
22 |
** location: https://www.gnu.org/licenses/agpl-3.0.en.html |
|
23 |
** |
|
24 |
** Additional terms under GNU Affero GPL version 3 section 7: |
|
25 |
** |
|
26 |
** Under Section 7 of the GNU Affero GPL version 3, the following additional |
|
27 |
** terms apply to the works covered under the License. These additional terms |
|
28 |
** are non-permissive additional terms allowed under Section 7 of the GNU |
|
29 |
** Affero GPL version 3 and may not be removed by you. |
|
30 |
** |
|
31 |
** 0. Attribution Requirement. |
|
32 |
** |
|
33 |
** You must preserve all legal notices or author attributions in the covered |
|
34 |
** work or Appropriate Legal Notices displayed by works containing the covered |
|
35 |
** work. You may not remove from the covered work any author or developer |
|
36 |
** credit already included within the covered work. |
|
37 |
** |
|
38 |
** 1. No License To Use Trademarks. |
|
39 |
** |
|
40 |
** This license does not grant any license or rights to use the trademarks |
|
41 |
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks |
|
42 |
** of Golden Code Development Corporation. You are not authorized to use the |
|
43 |
** name Golden Code, FWD, or the names of any author or contributor, for |
|
44 |
** publicity purposes without written authorization. |
|
45 |
** |
|
46 |
** 2. No Misrepresentation of Affiliation. |
|
47 |
** |
|
48 |
** You may not represent yourself as Golden Code Development Corporation or FWD. |
|
49 |
** |
|
50 |
** You may not represent yourself for publicity purposes as associated with |
|
51 |
** Golden Code Development Corporation, FWD, or any author or contributor to |
|
52 |
** the covered work, without written authorization. |
|
53 |
** |
|
54 |
** 3. No Misrepresentation of Source or Origin. |
|
55 |
** |
|
56 |
** You may not represent the covered work as solely your work. All modified |
|
57 |
** versions of the covered work must be marked in a reasonable way to make it |
|
58 |
** clear that the modified work is not originating from Golden Code Development |
|
59 |
** Corporation or FWD. All modified versions must contain the notices of |
|
60 |
** attribution required in this license. |
|
61 |
*/ |
|
62 |
package com.goldencode.p2j.testengine; |
|
63 | ||
64 |
import java.io.*; |
|
65 |
import java.lang.reflect.*; |
|
66 |
import java.util.*; |
|
67 | ||
68 |
import org.junit.platform.engine.*; |
|
69 | ||
70 |
import com.goldencode.p2j.testengine.api.*; |
|
71 | ||
72 |
/** |
|
73 |
* Test descriptor for a Java class. |
|
74 |
*/ |
|
75 |
public class FWDClassTestDescriptor extends AbstractBranchTestDescriptor |
|
76 |
{ |
|
77 | ||
78 |
/** |
|
79 |
* The methods marked as {@link AfterAll}. |
|
80 |
*/ |
|
81 |
List<Method> afterAll; |
|
82 | ||
83 |
/** |
|
84 |
* The methods marked as {@link BeforeAll}. |
|
85 |
*/ |
|
86 |
List<Method> beforeAll; |
|
87 | ||
88 |
/** |
|
89 |
* The Java class, referenced by child descriptors. |
|
90 |
*/ |
|
91 |
Class<?> clazz; |
|
92 | ||
93 |
/** |
|
94 |
* Default constructor. Required for serialization. Do not use in applications. |
|
95 |
*/ |
|
96 |
public FWDClassTestDescriptor() |
|
97 |
{ |
|
98 |
super(null, null); |
|
99 | ||
100 |
this.clazz = null; |
|
101 |
this.beforeAll = null; |
|
102 |
this.afterAll = null; |
|
103 |
} |
|
104 | ||
105 |
/** |
|
106 |
* Private constructor. |
|
107 |
* |
|
108 |
* @param clazz |
|
109 |
* the Java class |
|
110 |
* @param parent |
|
111 |
* the parent descriptor |
|
112 |
* @param test |
|
113 |
* class methods marked as tests |
|
114 |
* @param beforeEach |
|
115 |
* class methods marked to execute before each test |
|
116 |
* @param afterEach |
|
117 |
* class methods marked to execute after each test |
|
118 |
* @param beforeAll |
|
119 |
* class methods marked to execute before all tests |
|
120 |
* @param afterAll |
|
121 |
* class methods marked to execute after all tests |
|
122 |
*/ |
|
123 |
FWDClassTestDescriptor(final Class<?> clazz, final TestDescriptor parent, |
|
124 |
final List<Method> test, final List<Method> beforeEach, final List<Method> afterEach, |
|
125 |
final List<Method> beforeAll, final List<Method> afterAll) |
|
126 |
{ |
|
127 |
super(parent.getUniqueId().append("class", clazz.getName()), clazz.getSimpleName()); |
|
128 | ||
129 |
this.clazz = clazz; |
|
130 |
this.beforeAll = beforeAll; |
|
131 |
this.afterAll = afterAll; |
|
132 |
|
|
133 |
test.stream().map(m -> new FWDMethodTestDescriptor(this, clazz, m, beforeEach, afterEach)) |
|
134 |
.forEach(this::addChild); |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* The object implements the readExternal method to restore its |
|
139 |
* contents by calling the methods of DataInput for primitive |
|
140 |
* types and readObject for objects, strings and arrays. The |
|
141 |
* readExternal method must read the values in the same sequence |
|
142 |
* and with the same types as were written by writeExternal. |
|
143 |
* |
|
144 |
* @param in the stream to read data from in order to restore the object |
|
145 |
* @exception IOException if I/O errors occur |
|
146 |
* @exception ClassNotFoundException If the class for an object being |
|
147 |
* restored cannot be found. |
|
148 |
*/ |
|
149 |
@Override |
|
150 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException |
|
151 |
{ |
|
152 |
super.readExternal(in); |
|
153 |
|
|
154 |
clazz = (Class<?>) in.readObject(); |
|
155 |
beforeAll = SerializationSupport.readMethods(in); |
|
156 |
afterAll = SerializationSupport.readMethods(in); |
|
157 |
} |
|
158 | ||
159 |
/** |
|
160 |
* The object implements the writeExternal method to save its contents |
|
161 |
* by calling the methods of DataOutput for its primitive values or |
|
162 |
* calling the writeObject method of ObjectOutput for objects, strings, |
|
163 |
* and arrays. |
|
164 |
* |
|
165 |
* @serialData Overriding methods should use this tag to describe |
|
166 |
* the data layout of this Externalizable object. |
|
167 |
* List the sequence of element types and, if possible, |
|
168 |
* relate the element to a public/protected field and/or |
|
169 |
* method of this Externalizable class. |
|
170 |
* |
|
171 |
* @param out the stream to write the object to |
|
172 |
* @exception IOException Includes any I/O exceptions that may occur |
|
173 |
*/ |
|
174 |
@Override |
|
175 |
public void writeExternal(ObjectOutput out) throws IOException |
|
176 |
{ |