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 org.junit.jupiter.api.Assertions.assertEquals;
21 import java.io.IOException;
22 import java.util.HashMap;
24 import org.junit.jupiter.api.AfterEach;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Disabled;
27 import org.junit.jupiter.api.Test;
28 import org.onap.config.api.ConfigurationManager;
29 import org.onap.config.impl.CliConfigurationImpl;
30 import org.onap.config.util.ConfigTestConstant;
31 import org.onap.config.util.TestUtil;
34 * Created by sheetalm on 10/18/2016.
35 * Scenario 21, Scenario 23
36 * 21 - Verify the CLI fetches only the current value unless the fallback option is specified
37 * 23 - Fetch value using CLI for a key with underlying resource
39 @Disabled("Investigate instability (random failures)"
40 + "[ERROR] CliFallbackAndLookupTest.testCliFallbackAndLookup:71 expected:<[{name:\"SCM\"}]> but was:<[@/home/jenkins/TestResources/GeneratorsList.json]>")
41 class CliFallbackAndLookupTest {
43 private static final String NAMESPACE = "CLIFallback";
44 private static final String TENANT = "OPENECOMP";
47 public void setUp() throws Exception {
52 void testCliFallbackAndLookup() throws Exception {
54 //Verify without fallback
55 Map<String, Object> input = new HashMap<>();
56 input.put("ImplClass", "org.onap.config.type.ConfigurationQuery");
57 input.put("tenant", TENANT);
58 input.put("namespace", NAMESPACE);
59 input.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE);
61 ConfigurationManager conf = new CliConfigurationImpl();
62 String maxSizeWithNoFallback = conf.getConfigurationValue(input);
63 assertEquals("", maxSizeWithNoFallback);
65 //Verify underlying resource without lookup switch
66 input.put("key", ConfigTestConstant.ARTIFACT_JSON_SCHEMA);
67 String jsonSchema = conf.getConfigurationValue(input);
68 assertEquals("@" + System.getProperty("user.home") + "/TestResources/GeneratorsList.json", jsonSchema);
70 //Verify underlying resource with lookup switch
71 input.put("externalLookup", true);
72 jsonSchema = conf.getConfigurationValue(input);
73 assertEquals("{name:\"SCM\"}", jsonSchema);
75 //Verify with fallback
76 Map<String, Object> fallbackInput = new HashMap<>();
77 fallbackInput.put("ImplClass", "org.onap.config.type.ConfigurationQuery");
78 fallbackInput.put("fallback", true);
79 fallbackInput.put("tenant", TENANT);
80 fallbackInput.put("namespace", NAMESPACE);
81 fallbackInput.put("key", ConfigTestConstant.ARTIFACT_MAXSIZE);
83 String maxSizeWithFallback = conf.getConfigurationValue(fallbackInput);
84 assertEquals("1024", maxSizeWithFallback);
88 public void tearDown() throws Exception {