Repository: nifi Updated Branches: refs/heads/master 7f45251bb -> 05a99a93c
http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java index 33327eb..1504ed0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java @@ -29,19 +29,16 @@ import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.ControllerServiceLookup; import org.apache.nifi.controller.repository.StandardFlowFileRecord; import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.registry.VariableRegistryUtils; import org.junit.Test; public class TestStandardPropertyValue { private final ControllerServiceLookup lookup = new TestControllerServiceLookup(); - private final VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); @Test public void testSubstituteAttributesWithOneMatchingArg() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}!", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, World!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -49,7 +46,7 @@ public class TestStandardPropertyValue { @Test public void testMissingEndBraceEvaluatesToStringLiteral() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience!", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, ${audience!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -57,7 +54,7 @@ public class TestStandardPropertyValue { @Test public void testEscaped() { - final PropertyValue value = new StandardPropertyValue("Hello, $${audience}!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, $${audience}!", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, ${audience}!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -65,7 +62,7 @@ public class TestStandardPropertyValue { @Test public void testSubstituteAttributesWithMultipleMatchingArgs() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question}!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question}!", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); attributes.put("comma", ","); @@ -75,14 +72,14 @@ public class TestStandardPropertyValue { @Test public void testSubstituteAttributesWithNoMatch() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question:replaceNull('')}!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question:replaceNull('')}!", lookup); final Map<String, String> attributes = new HashMap<>(); assertEquals("Hello, !", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); } @Test public void testSubstituteAttributesRecursively() { - final PropertyValue value = new StandardPropertyValue("Hello, ${'${a}${b}'}!", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("Hello, ${'${a}${b}'}!", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("a", "b"); attributes.put("b", "World"); @@ -92,7 +89,7 @@ public class TestStandardPropertyValue { @Test public void testGetValueAsIntegerAfterSubstitute() { - final PropertyValue value = new StandardPropertyValue("1${value}", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("1${value}", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("value", "39"); assertEquals(139, value.evaluateAttributeExpressions(createFlowFile(attributes)).asInteger().intValue()); @@ -100,7 +97,7 @@ public class TestStandardPropertyValue { @Test(expected = NumberFormatException.class) public void testGetValueAsIntegerAfterSubstitutingWithNonInteger() { - final PropertyValue value = new StandardPropertyValue("1${value}", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("1${value}", lookup); final Map<String, String> attributes = new HashMap<>(); attributes.put("value", "Yes"); final PropertyValue substituted = value.evaluateAttributeExpressions(createFlowFile(attributes)); @@ -109,7 +106,7 @@ public class TestStandardPropertyValue { @Test public void testFileSize() { - final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup); final FlowFile flowFile = new StandardFlowFileRecord.Builder().size(1024 * 1024L).build(); final long val = value.evaluateAttributeExpressions(flowFile).asLong().longValue(); assertEquals(1024 * 1024L, val); @@ -119,25 +116,12 @@ public class TestStandardPropertyValue { public void testFlowFileEntryYear() { final Calendar now = Calendar.getInstance(); final int year = now.get(Calendar.YEAR); - final PropertyValue value = new StandardPropertyValue("${entryDate:toNumber():toDate():format('yyyy')}", lookup, variableRegistry); + final PropertyValue value = new StandardPropertyValue("${entryDate:toNumber():toDate():format('yyyy')}", lookup); final FlowFile flowFile = new StandardFlowFileRecord.Builder().entryDate(now.getTimeInMillis()).build(); final int val = value.evaluateAttributeExpressions(flowFile).asInteger().intValue(); assertEquals(year, val); } - @Test - public void testSystemProperty() { - System.setProperty("Prop1", "Foo"); - System.setProperty("Prop2", "Bar"); - final PropertyValue value = new StandardPropertyValue("${Prop1}${Prop2}${abc}", lookup, VariableRegistryUtils.createSystemVariableRegistry()); - final Map<String, String> attributes = new HashMap<>(); - attributes.put("abc", "Baz"); - final FlowFile flowFile = createFlowFile(attributes); - final String val = value.evaluateAttributeExpressions(flowFile).getValue(); - assertEquals("FooBarBaz", val); - - } - private FlowFile createFlowFile(final Map<String, String> attributes) { return new StandardFlowFileRecord.Builder().addAttributes(attributes).build(); } http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java new file mode 100644 index 0000000..cf44435 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/util/TestFileBasedVariableRegistry.java @@ -0,0 +1,45 @@ +/* + * 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. + */ +package org.apache.nifi.util; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; +import org.apache.nifi.registry.VariableDescriptor; +import org.apache.nifi.registry.VariableRegistry; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * + */ +public class TestFileBasedVariableRegistry { + + @Test + public void testCreateCustomVariableRegistry() { + final Path fooPath = Paths.get("src/test/resources/TestVariableRegistry/foobar.properties"); + final Path testPath = Paths.get("src/test/resources/TestVariableRegistry/test.properties"); + Path[] paths = {fooPath, testPath}; + final String vendorUrl = System.getProperty("java.vendor.url"); + VariableRegistry variableRegistry = new FileBasedVariableRegistry(paths); + final Map<VariableDescriptor, String> variables = variableRegistry.getVariableMap(); + assertTrue(variables.containsKey(new VariableDescriptor("fake.property.3"))); + assertEquals(vendorUrl, variableRegistry.getVariableValue("java.vendor.url")); + assertEquals("test me out 3, test me out 4", variableRegistry.getVariableValue("fake.property.3")); + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/foobar.properties ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/foobar.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/foobar.properties new file mode 100644 index 0000000..1094e1b --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/foobar.properties @@ -0,0 +1,16 @@ +# 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. + +fake.property.3=test me out 3, test me out 4 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/test.properties ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/test.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/test.properties new file mode 100644 index 0000000..6191449 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/TestVariableRegistry/test.properties @@ -0,0 +1,17 @@ +# 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. + +fake.property.1=test me out 1 +fake.property.2=test me out 2 http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java index d5a1f83..3800161 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java @@ -288,12 +288,6 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration return componentFacade.updateComponent(requestContext, annotationData, properties); } - - @Override - public VariableRegistry getVariableRegistry() { - return this.variableRegistry; - } - private NodeResponse replicate(final String method, final URI uri, final Object entity, final Map<String, String> headers) throws InterruptedException { final NodeIdentifier coordinatorNode = clusterCoordinator.getElectedActiveCoordinatorNode(); if (coordinatorNode == null) { http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java b/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java index 8768348..af50125 100644 --- a/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java +++ b/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java @@ -29,8 +29,6 @@ import org.apache.nifi.authorization.RequestAction; import org.apache.nifi.authorization.Resource; import org.apache.nifi.authorization.UserContextKeys; import org.apache.nifi.authorization.exception.AuthorizerCreationException; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.MockPropertyValue; import org.apache.nifi.util.NiFiProperties; import org.apache.ranger.plugin.policyengine.RangerAccessRequest; @@ -66,10 +64,9 @@ public class TestRangerNiFiAuthorizer { private RangerBasePluginWithPolicies rangerBasePlugin; private AuthorizerConfigurationContext configurationContext; private NiFiProperties nifiProperties; - private VariableRegistry variableRegistry; - private String serviceType = "nifiService"; - private String appId = "nifiAppId"; + private final String serviceType = "nifiService"; + private final String appId = "nifiAppId"; private RangerAccessResult allowedResult; private RangerAccessResult notAllowedResult; @@ -98,23 +95,22 @@ public class TestRangerNiFiAuthorizer { notAllowedResult = Mockito.mock(RangerAccessResult.class); when(notAllowedResult.getIsAllowed()).thenReturn(false); - variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } private AuthorizerConfigurationContext createMockConfigContext() { AuthorizerConfigurationContext configurationContext = Mockito.mock(AuthorizerConfigurationContext.class); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SECURITY_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null,variableRegistry)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml")); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_AUDIT_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null,variableRegistry)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml")); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_APP_ID_PROP))) - .thenReturn(new MockPropertyValue(appId, null,variableRegistry)); + .thenReturn(new MockPropertyValue(appId)); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SERVICE_TYPE_PROP))) - .thenReturn(new MockPropertyValue(serviceType, null,variableRegistry)); + .thenReturn(new MockPropertyValue(serviceType)); return configurationContext; } @@ -130,7 +126,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutKeytab() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null,variableRegistry)); + .thenReturn(new MockPropertyValue("true")); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosServicePrincipal()).thenReturn(""); @@ -150,7 +146,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutPrincipal() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null,variableRegistry)); + .thenReturn(new MockPropertyValue("true")); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn(""); @@ -170,7 +166,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutKeytabOrPrincipal() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null,variableRegistry)); + .thenReturn(new MockPropertyValue("true")); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn(""); @@ -204,7 +200,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabled() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null,variableRegistry)); + .thenReturn(new MockPropertyValue("true")); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn("test"); @@ -402,7 +398,7 @@ public class TestRangerNiFiAuthorizer { final String rangerAdminIdentity = "ranger-admin"; when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_ADMIN_IDENTITY_PROP))) - .thenReturn(new MockPropertyValue(rangerAdminIdentity, null,variableRegistry)); + .thenReturn(new MockPropertyValue(rangerAdminIdentity)); rangerBasePlugin = Mockito.mock(RangerBasePluginWithPolicies.class); authorizer = new MockRangerNiFiAuthorizer(rangerBasePlugin); @@ -450,10 +446,10 @@ public class TestRangerNiFiAuthorizer { final AuthorizerConfigurationContext configurationContext = Mockito.mock(AuthorizerConfigurationContext.class); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SECURITY_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null,variableRegistry)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml")); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_AUDIT_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null,variableRegistry)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml")); Authorizer authorizer = new RangerNiFiAuthorizer(); try { @@ -513,8 +509,8 @@ public class TestRangerNiFiAuthorizer { */ private static class MockResource implements Resource { - private String identifier; - private String name; + private final String identifier; + private final String name; public MockResource(String identifier, String name) { this.identifier = identifier; http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java index e4e18f7..5f5359d 100644 --- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java +++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java @@ -18,8 +18,6 @@ package org.apache.nifi.processors.script; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.processor.Relationship; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.MockFlowFile; import org.apache.nifi.util.MockProcessContext; import org.apache.nifi.util.MockProcessorInitializationContext; @@ -39,12 +37,9 @@ import static org.junit.Assert.assertTrue; public class TestInvokeGroovy extends BaseScriptTest { - private VariableRegistry variableRegistry; - @Before public void setup() throws Exception { super.setupInvokeScriptProcessor(); - variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } /** @@ -77,7 +72,7 @@ public class TestInvokeGroovy extends BaseScriptTest { @Test public void testScriptDefinedAttribute() throws Exception { InvokeScriptedProcessor processor = new InvokeScriptedProcessor(); - MockProcessContext context = new MockProcessContext(processor, variableRegistry); + MockProcessContext context = new MockProcessContext(processor); MockProcessorInitializationContext initContext = new MockProcessorInitializationContext(processor, context); processor.initialize(initContext); @@ -86,7 +81,7 @@ public class TestInvokeGroovy extends BaseScriptTest { context.setProperty(InvokeScriptedProcessor.SCRIPT_FILE, "target/test/resources/groovy/test_reader.groovy"); context.setProperty(InvokeScriptedProcessor.MODULES, "target/test/resources/groovy"); // State Manger is unused, and a null reference is specified - processor.customValidate(new MockValidationContext(context, null, variableRegistry)); + processor.customValidate(new MockValidationContext(context)); processor.setup(context); List<PropertyDescriptor> descriptors = processor.getSupportedPropertyDescriptors(); @@ -111,7 +106,7 @@ public class TestInvokeGroovy extends BaseScriptTest { @Test public void testScriptDefinedRelationship() throws Exception { InvokeScriptedProcessor processor = new InvokeScriptedProcessor(); - MockProcessContext context = new MockProcessContext(processor, variableRegistry); + MockProcessContext context = new MockProcessContext(processor); MockProcessorInitializationContext initContext = new MockProcessorInitializationContext(processor, context); processor.initialize(initContext); @@ -119,7 +114,7 @@ public class TestInvokeGroovy extends BaseScriptTest { context.setProperty(InvokeScriptedProcessor.SCRIPT_ENGINE, "Groovy"); context.setProperty(InvokeScriptedProcessor.SCRIPT_FILE, "target/test/resources/groovy/test_reader.groovy"); // State Manger is unused, and a null reference is specified - processor.customValidate(new MockValidationContext(context, null, variableRegistry)); + processor.customValidate(new MockValidationContext(context)); processor.setup(context); Set<Relationship> relationships = processor.getRelationships(); http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java index 0e8851c..9dce30b 100644 --- a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java +++ b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java @@ -28,7 +28,6 @@ import org.apache.nifi.provenance.ProvenanceEventRecord; import org.apache.nifi.provenance.ProvenanceEventRepository; import org.apache.nifi.provenance.ProvenanceEventType; import org.apache.nifi.provenance.StandardProvenanceEventRecord; -import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.remote.Transaction; import org.apache.nifi.remote.TransferDirection; import org.apache.nifi.remote.client.SiteToSiteClient; @@ -95,7 +94,7 @@ public class TestSiteToSiteProvenanceReportingTask { @Override public PropertyValue answer(final InvocationOnMock invocation) throws Throwable { final PropertyDescriptor descriptor = invocation.getArgumentAt(0, PropertyDescriptor.class); - return new MockPropertyValue(properties.get(descriptor), null, VariableRegistryUtils.createSystemVariableRegistry()); + return new MockPropertyValue(properties.get(descriptor)); } }).when(context).getProperty(Mockito.any(PropertyDescriptor.class)); http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java index 13bfe61..2eac3f2 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java @@ -26,9 +26,6 @@ import java.util.Map; import org.apache.nifi.components.ValidationResult; import org.apache.nifi.processor.Relationship; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.registry.VariableRegistryUtils; -import org.apache.nifi.state.MockStateManager; import org.apache.nifi.util.MockFlowFile; import org.apache.nifi.util.MockProcessContext; import org.apache.nifi.util.TestRunner; @@ -38,12 +35,10 @@ import org.junit.Test; public class TestRouteOnAttribute { - private VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); - @Test public void testInvalidOnMisconfiguredProperty() { final RouteOnAttribute proc = new RouteOnAttribute(); - final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc), variableRegistry); + final MockProcessContext ctx = new MockProcessContext(proc); final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:equals('b')"); // Missing closing brace assertFalse(validationResult.isValid()); } @@ -51,7 +46,7 @@ public class TestRouteOnAttribute { @Test public void testInvalidOnNonBooleanProperty() { final RouteOnAttribute proc = new RouteOnAttribute(); - final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc), variableRegistry); + final MockProcessContext ctx = new MockProcessContext(proc); final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:length()"); // Should be boolean assertFalse(validationResult.isValid()); } http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java index 488891c..db8f394 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java @@ -21,7 +21,6 @@ import org.apache.nifi.admin.service.AuditService; import org.apache.nifi.authorization.Authorizer; import org.apache.nifi.controller.repository.FlowFileEventRepository; import org.apache.nifi.provenance.MockProvenanceRepository; -import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.CapturingLogger; import org.apache.nifi.util.NiFiProperties; import org.junit.After; @@ -67,8 +66,8 @@ public class MonitorMemoryTest { @Test @Ignore // temporarily ignoring it since it fails intermittently due to - // unpredictability during full build - // still keeping it for local testing + // unpredictability during full build + // still keeping it for local testing public void validateWarnWhenPercentThresholdReached() throws Exception { this.doValidate("10%"); } @@ -136,7 +135,13 @@ public class MonitorMemoryTest { properties.setProperty("nifi.remote.input.socket.port", ""); properties.setProperty("nifi.remote.input.secure", ""); - return FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), properties, - mock(Authorizer.class), mock(AuditService.class), null, null, VariableRegistryUtils.createCustomVariableRegistry(properties.getVariableRegistryPropertiesPaths())); + return FlowController.createStandaloneInstance( + mock(FlowFileEventRepository.class), + properties, + mock(Authorizer.class), + mock(AuditService.class), + null, + null, + null); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java b/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java index 078bd6b..82e4a99 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java @@ -41,8 +41,6 @@ import org.apache.nifi.distributed.cache.client.exception.DeserializationExcepti import org.apache.nifi.distributed.cache.server.map.DistributedMapCacheServer; import org.apache.nifi.processor.Processor; import org.apache.nifi.processor.util.StandardValidators; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.util.MockConfigurationContext; import org.apache.nifi.util.MockControllerServiceInitializationContext; @@ -57,7 +55,6 @@ import org.slf4j.LoggerFactory; public class TestServerAndClient { private static Logger LOGGER; - private static VariableRegistry variableRegistry; static { System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info"); @@ -67,7 +64,6 @@ public class TestServerAndClient { System.setProperty("org.slf4j.simpleLogger.log.nifi.distributed.cache.server.TestServerAndClient", "debug"); System.setProperty("org.slf4j.simpleLogger.log.nifi.remote.io.socket.ssl.SSLSocketChannel", "trace"); LOGGER = LoggerFactory.getLogger(TestServerAndClient.class); - variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } @Test @@ -333,7 +329,7 @@ public class TestServerAndClient { clientProperties.put(DistributedMapCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedMapCacheClientService.PORT, String.valueOf(server.getPort())); clientProperties.put(DistributedMapCacheClientService.COMMUNICATIONS_TIMEOUT, "360 secs"); - MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); + MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); client.cacheConfig(clientContext); final Serializer<String> valueSerializer = new StringSerializer(); final Serializer<String> keySerializer = new StringSerializer(); @@ -379,7 +375,7 @@ public class TestServerAndClient { client2.initialize(clientInitContext2); MockConfigurationContext clientContext2 = new MockConfigurationContext(clientProperties, - clientInitContext2.getControllerServiceLookup(), variableRegistry); + clientInitContext2.getControllerServiceLookup()); client2.cacheConfig(clientContext2); assertFalse(client2.putIfAbsent("testKey", "test", keySerializer, valueSerializer)); assertTrue(client2.containsKey("testKey", keySerializer)); @@ -412,7 +408,7 @@ public class TestServerAndClient { server.initialize(serverInitContext); final Map<PropertyDescriptor, String> serverProperties = new HashMap<>(); - final MockConfigurationContext serverContext = new MockConfigurationContext(serverProperties, serverInitContext.getControllerServiceLookup(), variableRegistry); + final MockConfigurationContext serverContext = new MockConfigurationContext(serverProperties, serverInitContext.getControllerServiceLookup()); server.startServer(serverContext); DistributedMapCacheClientService client = new DistributedMapCacheClientService(); @@ -422,7 +418,7 @@ public class TestServerAndClient { final Map<PropertyDescriptor, String> clientProperties = new HashMap<>(); clientProperties.put(DistributedMapCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedMapCacheClientService.COMMUNICATIONS_TIMEOUT, "360 secs"); - MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); + MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); client.cacheConfig(clientContext); final Serializer<String> valueSerializer = new StringSerializer(); final Serializer<String> keySerializer = new StringSerializer(); @@ -469,7 +465,7 @@ public class TestServerAndClient { final Map<PropertyDescriptor, String> clientProperties = new HashMap<>(); clientProperties.put(DistributedSetCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedSetCacheClientService.PORT, String.valueOf(port)); - final MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); + final MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); client.onConfigured(clientContext); return client; http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java index 6102e82..f4b8b07 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java @@ -23,7 +23,6 @@ import org.apache.nifi.attribute.expression.language.Query; import org.apache.nifi.attribute.expression.language.StandardExpressionLanguageCompiler; import org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException; import org.apache.nifi.expression.AttributeExpression.ResultType; -import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.update.attributes.dto.ActionDTO; import org.apache.nifi.update.attributes.dto.ConditionDTO; import org.apache.nifi.update.attributes.dto.RuleDTO; @@ -33,10 +32,7 @@ import org.apache.nifi.update.attributes.dto.RuleDTO; */ public class UpdateAttributeModelFactory { - private final VariableRegistry variableRegistry; - - public UpdateAttributeModelFactory(VariableRegistry variableRegistry) { - this.variableRegistry = variableRegistry; + public UpdateAttributeModelFactory() { } public Rule createRule(final RuleDTO dto) { @@ -79,7 +75,7 @@ public class UpdateAttributeModelFactory { } // validate the condition's expression - final StandardExpressionLanguageCompiler elCompiler = new StandardExpressionLanguageCompiler(variableRegistry); + final StandardExpressionLanguageCompiler elCompiler = new StandardExpressionLanguageCompiler(); final String syntaxError = elCompiler.validateExpression(dto.getExpression(), false); if (syntaxError != null) { throw new IllegalArgumentException(syntaxError); http://git-wip-us.apache.org/repos/asf/nifi/blob/05a99a93/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java index 99c34cd..4158218 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java @@ -46,7 +46,6 @@ import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; -import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.update.attributes.Action; import org.apache.nifi.update.attributes.Condition; import org.apache.nifi.update.attributes.Criteria; @@ -188,7 +187,6 @@ public class RuleResource { // get the web context final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); - final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); // ensure the rule has been specified if (requestEntity == null || requestEntity.getRule() == null) { @@ -221,7 +219,7 @@ public class RuleResource { // load the criteria final Criteria criteria = getCriteria(configurationContext, requestContext); - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); // create the new rule final Rule rule; @@ -263,14 +261,10 @@ public class RuleResource { // generate a new id final String uuid = UUID.randomUUID().toString(); - // get the variable registry - final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); - final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); - final Condition condition; try { // create the condition object - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); condition = factory.createCondition(requestEntity.getCondition()); condition.setId(uuid); } catch (final IllegalArgumentException iae) { @@ -301,14 +295,10 @@ public class RuleResource { // generate a new id final String uuid = UUID.randomUUID().toString(); - // get the variable registry - final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); - final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); - final Action action; try { // create the condition object - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); action = factory.createAction(requestEntity.getAction()); action.setId(uuid); } catch (final IllegalArgumentException iae) { @@ -471,8 +461,6 @@ public class RuleResource { // get the web context final NiFiWebConfigurationContext nifiWebContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); - // get the variable registry - final VariableRegistry variableRegistry = nifiWebContext.getVariableRegistry(); // ensure the rule has been specified if (requestEntity == null || requestEntity.getRule() == null) { @@ -509,7 +497,7 @@ public class RuleResource { requestEntity.getProcessorId(), requestEntity.getRevision(), requestEntity.getClientId()); // load the criteria - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); final Criteria criteria = getCriteria(nifiWebContext, requestContext); // attempt to locate the rule