Community Articles

Find and share helpful community-sourced technical articles.
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.
Labels (1)
Super Guru

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] 
 -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")}' 

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")}'

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 🙂


Not applicable

Hi, i think that testing the expression language using the command line it is a very fast and convenient way to test expressions.

However, trying to run your script i encountered an error caused by a maven dependencies not resolved. This is the error that i'm encountering:

General error during conversion: Error grabbing Grapes -- [download failed: com.fasterxml.jackson.core#jackson-annotations;2.6.0!jackson-annotations.jar(bundle)]


Me too. Similar error.

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: org.apache.commons#commons-lang3;3.5!commons-lang3.jar]


I fixed this by changing the @Grab in the first line of the script to the following;

@Grab(group='org.apache.nifi', module='nifi-expression-language', version='1.11.4')

New Member

Greetings. I tried the provided testelgroovy.txt unchanged and also with nifi-expression-language 1.11.4 to no vail. Here is the error I get no matter what expression I try:

$ groovy testelgroovy.txt -D filename=hello '${filename:append("_world")}'
Caught: org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException: Unexpected token '<EOF>' at line 1, column 0. Query:
org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException: Unexpected token '<EOF>' at line 1, column 0. Query:
at org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.displayRecognitionError(
at org.antlr.runtime.BaseRecognizer.reportError(
at org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.expression(
at org.apache.nifi.attribute.expression.language.antlr.AttributeExpressionParser.query(
at org.apache.nifi.attribute.expression.language.compile.ExpressionCompiler.compile(
at org.apache.nifi.attribute.expression.language.Query.compile(
at org.apache.nifi.attribute.expression.language.Query$ Source)
at testelgroovy$_run_closure2.doCall(testelgroovy.txt:25)
$ groovy --version
Groovy Version: 3.0.4 JVM: 1.8.0_242 Vendor: OS: Windows 10

 P.S.  I run this test under Cygwin.

New Member

cool tool. I updated to work with 1.12.1:

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.
Version history
Last update:
‎10-25-2017 08:57 PM
Updated by:
Top Kudoed Authors