Enhancement
Critical
Major
Detail
Detail
Detail
#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, e.g..
<editExecutability> <reference rule-id="ImportedObjectDisabled"/> </editExecutability>.
So far so good. The application starts without errors in the log, the rule is loaded and evaluated, scripted tests are green both manually and in the build.
Due to the change, the testComponentConfigurations test fails with the following stack:
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/en.ascon_systems.dreso/en.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, via the TL script call the ExecutabilityManager is now implicitly dependent on the PersistencyLayer and possibly other model services. At "normal" runtime this is probably not noticeable, because the services have already been started elsewhere before the ExecutabilityRuleManager.
On the other hand, there is a clear comment in TestComponentConfiguration#suite() that persistent objects must not be specified in the config. Does that mean that, the above mentioned application of TL script in the ExecutabilityRuleManager or in the application configuration in general is not allowed?
Solution
TL-Script is only compiled if the model service and the persistence layer are active. Otherwise it is only parsed and translated on 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.