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;
20 import static org.junit.jupiter.api.Assertions.assertTrue;
22 import java.util.ArrayList;
23 import java.util.List;
24 import org.junit.jupiter.api.AfterEach;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27 import org.onap.config.api.Configuration;
28 import org.onap.config.api.ConfigurationManager;
29 import org.onap.config.util.ConfigTestConstant;
30 import org.onap.config.util.TestUtil;
33 * Scenario 8 Validate configuration with mode specified as a configuration property.
35 class ModeAsConfigPropTest {
37 private static final String NAMESPACE = "ModeAsConfigProp";
40 public void setUp() throws Exception {
45 void testMergeStrategyInConfig() {
46 Configuration config = ConfigurationManager.lookup();
48 assertEquals("14", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
50 assertEquals("1048", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_MAXSIZE));
52 List<String> expectedExtList = new ArrayList<>();
53 expectedExtList.add("pdf");
54 expectedExtList.add("zip");
55 expectedExtList.add("xml");
56 expectedExtList.add("pdf");
57 expectedExtList.add("tgz");
58 expectedExtList.add("xls");
59 List<String> extList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_EXT);
60 assertEquals(expectedExtList, extList);
62 List<String> expectedEncList = new ArrayList<>();
63 expectedEncList.add("Base64");
64 expectedEncList.add("MD5");
65 List<String> encList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_ENC);
66 assertEquals(expectedEncList, encList);
68 assertEquals("{name:\"SCM\"}", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA));
70 assertEquals("a-zA-Z_0-9", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER));
72 assertEquals("Deleted", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_STATUS));
74 List<String> expectedLocList = new ArrayList<>();
75 expectedLocList.add("/opt/spool");
76 expectedLocList.add(System.getProperty("user.home") + "/asdc");
77 List<String> locList = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_LOC);
78 assertEquals(expectedLocList, locList);
80 assertEquals("@" + TestUtil.getenv(ConfigTestConstant.PATH) + "/myschema.json",
81 config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_XML_SCHEMA));
83 List<String> artifactConsumer = config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER);
84 assertEquals(config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER_APPC),
87 assertTrue(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_MANDATORY_NAME));
89 assertEquals("6", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH));
91 assertTrue(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_ENCODED));
95 public void tearDown() throws Exception {