From b83a5544a6b09fa053d45fbba0c406701a6aa915 Mon Sep 17 00:00:00 2001
From: GwenaelLM <121117824+GwenaelLM@users.noreply.github.com>
Date: Tue, 20 Dec 2022 17:39:04 +0100
Subject: [PATCH 1/2] Update OperationFunction.java
In order to ease the location of functions we have improved importFile() function in OperationFunction.java file.
This modification allows developer to define absolute path instead of relative path based on user HOME directory.
This allows to include a same function from several directories location and no more play with relative path. It improves the robustness in case of code/lib refactoring, improve code re-usage, ease library imports for developers.
Usage example in a scenario:
Then [user_home] parameter must be solved by MTS framework. To allows this parameter resolution please find below modification to apply in the code: highlighted in yellow color.
---
.../xmlloader/core/operations/basic/OperationFunction.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationFunction.java b/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationFunction.java
index a04289246..9a40e483c 100755
--- a/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationFunction.java
+++ b/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationFunction.java
@@ -69,6 +69,13 @@ else if (file != null && name == null) {
}
public static void importFile(String file, URI relativeTo) throws Exception {
+
+ // Solve user_home value
+ if (file.contains("[user_home]")) {
+ String userHome = System.getProperty("user.home");
+ file = file.replace("[user_home]", userHome);
+ }
+
// parse the xml file
XMLDocument scenarioDocument = Cache.getXMLDocument(relativeTo.resolve(file), URIFactory.newURI("../conf/schemas/scenario.xsd"));
From bb8f67942bbd9801ab24cebffc1c404d4f4fcd7d Mon Sep 17 00:00:00 2001
From: GwenaelLM <121117824+GwenaelLM@users.noreply.github.com>
Date: Tue, 20 Dec 2022 17:44:31 +0100
Subject: [PATCH 2/2] Update OperationGroovy.java
This modification allows developer to define absolute path instead of relative path based on user HOME directory.
This allows to include a same function from several directories location and no more play with relative path. It improves the robustness in case of code/lib refactoring, improve code re-usage, ease library imports for developers.
groovy_Functions_Control.control(GroovyCallerControl)
Then [user_home] parameter must be solved by MTS framework. To allows this parameter resolution please find below modification to apply in the code:
---
.../xmlloader/core/operations/basic/OperationGroovy.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationGroovy.java b/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationGroovy.java
index 9432fe180..b886bb4e7 100755
--- a/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationGroovy.java
+++ b/src/main/java/com/devoteam/srit/xmlloader/core/operations/basic/OperationGroovy.java
@@ -91,6 +91,12 @@ public Operation execute(Runner runner) throws Exception {
// retrieve the list of groovy files to load
String groovyFiles = getRootElement().attributeValue("name");
+ // Solve user_home value
+ if (groovyFiles.contains("[user_home]")) {
+ String userHome = System.getProperty("user.home");
+ groovyFiles = groovyFiles.replace("[user_home]", userHome);
+ }
+
// retrieve the groovy operation script source
String scriptSource = getRootElement().getText();