Suvrat1629 commented on code in PR #3394:
URL: https://github.com/apache/logging-log4j2/pull/3394#discussion_r1935727549


##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/AbstractConfigurationTest.java:
##########
@@ -79,17 +79,30 @@ public void setup() {
             rootLogger.getAttributes().put("level", "INFO");
             loggers.getChildren().add(rootLogger);
 
-            if (map != null) {
+            // Add Properties Node only if the map is not null and has entries
+            if (map != null && !map.isEmpty()) {
                 final Node properties = newNode(rootNode, "Properties");
                 rootNode.getChildren().add(properties);
 
                 for (final Entry<String, String> entry : map.entrySet()) {
+                    // Create Property node with "name" and "value" attributes
                     final Node property = newNode(properties, "Property");
                     property.getAttributes().put("name", entry.getKey());
                     property.getAttributes().put("value", entry.getValue());
                     properties.getChildren().add(property);
                 }
             }
+
+            // Add a Scripts Node if required (Example for flexibility in 
testing)
+            final Node scripts = newNode(rootNode, "Scripts");
+            rootNode.getChildren().add(scripts);
+
+            // Add sample script node for testing purposes
+            final Node script = newNode(scripts, "Script");
+            script.getAttributes().put("name", "TestScript");
+            script.getAttributes().put("language", "JavaScript");
+            script.getAttributes().put("scriptText", "print('Hello, 
Log4j!');");
+            scripts.getChildren().add(script);

Review Comment:
   Well I followed what you said and made a log4j-script-ref-test.xml file and 
wrote a ScriptConfigurationTest.java file, used a bit of ai for help and this 
is the best i could come up with based on my understanding.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to