2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.config.test;
19 import static java.util.concurrent.TimeUnit.SECONDS;
20 import static org.awaitility.Awaitility.await;
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
25 import java.io.FileOutputStream;
26 import java.io.OutputStream;
27 import java.util.HashMap;
29 import java.util.Properties;
30 import org.junit.jupiter.api.AfterAll;
31 import org.junit.jupiter.api.Disabled;
32 import org.junit.jupiter.api.Test;
33 import org.onap.config.api.ConfigurationManager;
34 import org.onap.config.impl.CliConfigurationImpl;
35 import org.onap.config.util.ConfigTestConstant;
36 import org.onap.config.util.TestUtil;
39 * Created by sheetalm on 10/19/2016. Scenario 19 Pre-requisite - set -Dnode.config.location=${"user.home"}/TestResources/ while running test Verify
40 * node specific override using CLI
42 @Disabled("Investigate instability (random failures)"
43 + "[ERROR] NodeSpecificCliTest.testCliApi:73 » FileNotFound /home/jenkins/TestResources/c...")
44 class NodeSpecificCliTest {
46 private static final String NAMESPACE = "NodeCLI";
47 private static final File FILE = new File(TestUtil.jsonSchemaLoc + "config.properties");
50 public static void tearDown() throws Exception {
53 assertTrue(FILE.delete());
58 void testCliApi() throws Exception {
59 //Verify without fallback
60 final Map<String, Object> input = new HashMap<>();
61 input.put("ImplClass", "org.onap.config.type.ConfigurationQuery");
62 input.put("namespace", NAMESPACE);
63 input.put("key", ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH);
65 final ConfigurationManager conf = new CliConfigurationImpl();
66 final String maxLength = conf.getConfigurationValue(input);
68 //Verify Property from Namespace configurations
69 assertEquals("30", maxLength);
71 //Add node specific configurations
72 final Properties props = new Properties();
73 props.setProperty(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH, "50");
74 props.setProperty("_config.namespace", NAMESPACE);
76 await().atMost(30, SECONDS).pollInterval(1, SECONDS).until(() -> FILE.exists());
77 try (final OutputStream out = new FileOutputStream(FILE)) {
78 props.store(out, "Node Config Property");
81 //Verify property from node specific configuration
82 input.put("nodeSpecific", true);
83 final String nodeVal = conf.getConfigurationValue(input);
84 assertEquals("30", nodeVal);
87 assertTrue(FILE.delete());