From 8e15392e2fcddc56ef75b333177b0299bbded159 Mon Sep 17 00:00:00 2001 From: dlukyanov Date: Sun, 12 Nov 2017 17:02:34 +0200 Subject: [PATCH] 2916ce1ec80714b886cbed9797bf7874aacb32dd --- .../groovyx/ExecuteGroovyScriptTest.java | 14 +++++++++++ .../groovy/test_ctl_01_access.groovy | 24 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/resources/groovy/test_ctl_01_access.groovy diff --git a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScriptTest.java b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScriptTest.java index e275177325..a49ad8f086 100644 --- a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScriptTest.java +++ b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/java/org/apache/nifi/processors/groovyx/ExecuteGroovyScriptTest.java @@ -225,6 +225,20 @@ public class ExecuteGroovyScriptTest { runner.setProperty(proc.SCRIPT_BODY, " { { "); runner.assertNotValid(); } + //--------------------------------------------------------- + @Test + public void test_ctl_01_access() throws Exception { + runner.setProperty(proc.SCRIPT_FILE, TEST_RESOURCE_LOCATION + "test_ctl_01_access.groovy"); + runner.setProperty("CTL.mydbcp", "dbcp"); //pass dbcp as a service to script + runner.assertValid(); + + runner.run(); + + runner.assertAllFlowFilesTransferred(proc.REL_SUCCESS.getName(), 1); + final List result = runner.getFlowFilesForRelationship(proc.REL_SUCCESS.getName()); + MockFlowFile resultFile = result.get(0); + resultFile.assertContentEquals("OK", "UTF-8"); + } @Test public void test_sql_01_select() throws Exception { diff --git a/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/resources/groovy/test_ctl_01_access.groovy b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/resources/groovy/test_ctl_01_access.groovy new file mode 100644 index 0000000000..f788fbb40c --- /dev/null +++ b/nifi-nar-bundles/nifi-groovyx-bundle/nifi-groovyx-processors/src/test/resources/groovy/test_ctl_01_access.groovy @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//just check that it's possible to access controller services +def ff=session.create() +def con=CTL.mydbcp.getConnection() +assert con instanceof java.sql.Connection +con.close(); +ff.write('UTF-8', 'OK') +REL_SUCCESS<