Testing NiFi Expression Language with Groovy
- October 5, 2026 at 8:50 AM
- 5 replies
- 15104 views
- Translate All
Some NiFi Expression Language (EL) expressions can be fairly complex, or used in a large flow, or both. These can make it difficult to test an EL expression on a running NiFi system. Although an excellent feature of NiFi is being able to adapt the flow while the system is running, it may not be prudent to stop a downstream processor, reroute a connection to something like UpdateAttribute, then list the queue in order to see attributes, content, etc.
To make EL testing easier, I wrote a Groovy script called testEL.groovy that uses the same EL library that NiFi does, so all functions present in the specified NiFi version are available to the test tool. The following is the usage:
usage: groovy testEL.groovy [options] [expressions]
Options:
-D <attribute=value> set value for given attribute
-help print this message
As an example, the following tests an expression that appends "_world" to the "filename" attribute:
> groovy testEL.groovy -D filename=hello '${filename:append("_world")}'
hello_world
Note that it accepts multiple attribute definitions and multiple expressions, so you can test more than one expression using a single set of attributes:
> groovy testEL.groovy -D filename=hello -D size=10 '${filename:append("_world")}' '${filename:prepend("I say "):append(" ${size} times")}'
hello_world
I say hello 10 times
In order to attach testelgroovy.txt to this post, I had to add a .txt extension (and it lowercased the name), simply rename it before running the above.
Hopefully you find this script helpful, if you try it please let me know how/if it works for you, and as always I welcome any questions, comments and suggestions on how to make things better 🙂
Cheers!

