[ 
https://issues.apache.org/jira/browse/NIFI-1974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15322213#comment-15322213
 ] 

ASF GitHub Bot commented on NIFI-1974:
--------------------------------------

Github user YolandaMDavis commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/501#discussion_r66407532
  
    --- Diff: 
nifi-api/src/test/java/org/apache/nifi/registry/TestVariableRegistry.java ---
    @@ -0,0 +1,126 @@
    +/*
    + * 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.registry;
    +
    +import java.nio.file.Path;
    +import java.nio.file.Paths;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.Properties;
    +
    +import org.junit.Test;
    +
    +import static org.junit.Assert.assertTrue;
    +
    +public class TestVariableRegistry {
    +
    +    @Test
    +    public void testReadMap(){
    +        Map<String,String> variables1 = new HashMap<>();
    +        variables1.put("fake.property.1","fake test value");
    +
    +        Map<String,String> variables2 = new HashMap<>();
    +        variables1.put("fake.property.2","fake test value");
    +
    +        VariableRegistry registry = 
VariableRegistryFactory.getInstance(variables1,variables2);
    +
    +        Map<String,String> variables = registry.getVariables();
    +        assertTrue(variables.size() == 2);
    +        assertTrue(variables.get("fake.property.1").equals("fake test 
value"));
    +        
assertTrue(registry.getVariableValue("fake.property.2").equals("fake test 
value"));
    +    }
    +
    +    @Test
    +    public void testReadProperties(){
    +        Properties properties = new Properties();
    +        properties.setProperty("fake.property.1","fake test value");
    +        VariableRegistry registry = 
VariableRegistryFactory.getInstance(properties);
    +        Map<String,String> variables = registry.getVariables();
    +        assertTrue(variables.get("fake.property.1").equals("fake test 
value"));
    +    }
    +
    +    @Test
    +    public void testReadFiles(){
    +        final Path fooPath = 
Paths.get("src/test/resources/TestVariableRegistry/foobar.properties");
    +        final Path testPath = 
Paths.get("src/test/resources/TestVariableRegistry/test.properties");
    +        VariableRegistry registry = 
VariableRegistryFactory.getInstance(fooPath.toFile(),testPath.toFile());
    +        Map<String,String> variables = registry.getVariables();
    +        assertTrue(variables.size() == 3);
    +        assertTrue(variables.get("fake.property.1").equals("test me out 
1"));
    +        assertTrue(variables.get("fake.property.3").equals("test me out 3, 
test me out 4"));
    +    }
    +
    +    @Test
    +    public void testReadPaths(){
    +        final Path fooPath = 
Paths.get("src/test/resources/TestVariableRegistry/foobar.properties");
    +        final Path testPath = 
Paths.get("src/test/resources/TestVariableRegistry/test.properties");
    +        VariableRegistry registry = 
VariableRegistryFactory.getInstance(fooPath,testPath);
    +        Map<String,String> variables = registry.getVariables();
    +        assertTrue(variables.size() == 3);
    +        assertTrue(variables.get("fake.property.1").equals("test me out 
1"));
    +        assertTrue(variables.get("fake.property.3").equals("test me out 3, 
test me out 4"));
    +    }
    +
    +    @Test
    +    public void testAddRegistry(){
    +
    +        final Map<String,String> variables1 = new HashMap<>();
    +        variables1.put("fake.property.1","fake test value");
    +
    +
    +        final Path fooPath = 
Paths.get("src/test/resources/TestVariableRegistry/foobar.properties");
    +        VariableRegistry pathRegistry = 
VariableRegistryFactory.getInstance(fooPath);
    +
    +        final Path testPath = 
Paths.get("src/test/resources/TestVariableRegistry/test.properties");
    +        VariableRegistry fileRegistry = 
VariableRegistryFactory.getInstance(testPath.toFile());
    +
    +        Properties properties = new Properties();
    +        properties.setProperty("fake.property.5","test me out 5");
    +        VariableRegistry propRegistry = 
VariableRegistryFactory.getInstance(properties);
    +
    +        propRegistry.addRegistry(pathRegistry);
    +        propRegistry.addRegistry(fileRegistry);
    +
    +        Map<String,String> variables = propRegistry.getVariables();
    +        assertTrue(variables.size() == 4);
    --- End diff --
    
    This is partially covered in testNoOverwriteRegistry but will create 
additional assertion that property values for duplicate entries  are in tact


> Support Custom Properties in Expression Language
> ------------------------------------------------
>
>                 Key: NIFI-1974
>                 URL: https://issues.apache.org/jira/browse/NIFI-1974
>             Project: Apache NiFi
>          Issue Type: New Feature
>            Reporter: Yolanda M. Davis
>            Assignee: Yolanda M. Davis
>             Fix For: 1.0.0
>
>
> Add a property in "nifi.properties" config file to allows users to specify a 
> list of custom properties files (containing data such as environmental 
> specific values, or sensitive values, etc.). The key/value pairs should be 
> loaded upon NIFI startup and availbale to processors for use in expression 
> languages. 
> Optimally this will lay the groundwork for a UI driven Variable Registry.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to