enhancement
critical
major
minor
minor
minor
#25976
Test Error with TL Script in Executability Rules in Application Configuration
We have extended an application configuration to include a scripted ExecutabilityRule:
<config service-class="com.top_logic.tool.execution.ExecutabilityRuleManager">
<instance class="com.top_logic.tool.execution.ExecutabilityRuleManager">
<definitions>
<definition id="ImportedObjectDisabled">
<executability>
<rule-by-expression>
<decision>x -> if($x.get(`library.common:ImportedObject#imported`) == false, true,#"library.common.ImportedObjectDisabled")</decision>
<show-disabled>true</show-disabled>
</rule-by-expression>
</executability>
</definition>
</definitions>
</instance>
</config>
The rule is then referenced in various *layout.xml files, e.g.,
<editExecutability> <reference rule-id="ImportedObjectDisabled"/> </editExecutability>
So far, so good. The application starts without any errors in the log, the rule is loaded and evaluated, and scripted tests pass both manually and in the build.
Due to the change, the test `testComponentConfigurations` fails with the following stack trace:
java.lang.AssertionError: Setup failed for test 'Test suite: test.com.top_logic.layout.component.TestComponentConfiguration'. Cause: Unable to instantiate service 'com.top_logic.tool.execution.ExecutabilityRuleManager'.
at test.com.top_logic.basic.NestableTestSetup.setUp(NestableTestSetup.java:146)
…
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: com.top_logic.basic.module.ModuleException: Unable to instantiate service 'com.top_logic.tool.execution.ExecutabilityRuleManager'.
at com.top_logic.basic.module.TypedRuntimeModule.newImplementationInstance(TypedRuntimeModule.java:508)
... 46 more
Caused by: com.top_logic.basic.AbortExecutionException: Aborting execution due to previous errors
at com.top_logic.basic.LogProtocol.createAbort(LogProtocol.java:92)
... 62 more
Caused by: com.top_logic.basic.config.ConfigurationException: Instantiation of configured class 'com.top_logic.model.search.providers.ExecutabilityByExpression' failed: file:D:/Development/GIT/de.ascon_systems.dreso/de.ascon_systems.dreso.common/webapp/WEB-INF/conf/dreso-common.conf.config.xml line 20 column 28
at com.top_logic.basic.config.DefaultConfigConstructorScheme.toConfigurationException(DefaultConfigConstructorScheme.java:1179)
at com.top_logic.basic.module.TypedRuntimeModule.newImplementationInstance(TypedRuntimeModule.java:502)
... 62 more
Caused by: java.lang.IllegalStateException: com.top_logic.knowledge.service.PersistencyLayer module not started.
at com.top_logic.basic.module.ModuleUtil.invalidStateNotStarted(ModuleUtil.java:1899)
at com.top_logic.basic.config.DefaultConfigConstructorScheme$ConfiguredObjectFactory.createInstance(DefaultConfigConstructorScheme.java:1142)
... 85 more
I’m afraid that, due to the TL-Script call, the ExecutabilityManager is now implicitly dependent on the PersistencyLayer and, possibly, other model services. This likely won’t be noticeable during “normal” runtime because the services were already started elsewhere before the ExecutabilityRuleManager.
On the other hand, there is a clear comment in `TestComponentConfiguration#suite()` stating that persistent objects must not be specified in the configuration. Does this mean that the above-mentioned use of TL-Script in the `ExecutabilityRuleManager`—or in the application configuration in general—is not permitted?
Solution
TL-Script is only compiled when the model service and the persistence layer are active. Otherwise, it is only parsed and compiled upon first use.
Test
- /com.top_logic.demo/src/test/com/top_logic/demo/scripted/layout/executability/TestCommandApprovalService.script.xml - some rules are now registered in the application configuration.