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 java.io.IOException;
20 import java.util.ArrayList;
21 import java.util.List;
22 import org.junit.After;
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.config.api.Configuration;
27 import org.onap.config.api.ConfigurationManager;
28 import org.onap.config.util.ConfigTestConstant;
29 import org.onap.config.util.TestUtil;
32 * Scenario 8 Validate configuration with mode specified as a configuration property.
34 public class ModeAsConfigPropTest {
36 private static final String NAMESPACE = "ModeAsConfigProp";
39 public void setUp() throws IOException {
40 String data = "{name:\"SCM\"}";
41 TestUtil.writeFile(data);
45 public void testMergeStrategyInConfig() {
46 Configuration config = ConfigurationManager.lookup();
48 Assert.assertEquals("14", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
50 Assert.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 Assert.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 Assert.assertEquals(expectedEncList, encList);
68 Assert.assertEquals("{name:\"SCM\"}", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_JSON_SCHEMA));
70 Assert.assertEquals("a-zA-Z_0-9", config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_UPPER));
72 Assert.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 Assert.assertEquals(expectedLocList, locList);
80 Assert.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 Assert.assertEquals(config.getAsStringValues(NAMESPACE, ConfigTestConstant.ARTIFACT_CONSUMER_APPC),
87 Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_MANDATORY_NAME), true);
89 Assert.assertEquals(config.getAsString(NAMESPACE, ConfigTestConstant.ARTIFACT_NAME_MINLENGTH), "6");
91 Assert.assertEquals(config.getAsBooleanValue(NAMESPACE, ConfigTestConstant.ARTIFACT_ENCODED), true);
95 public void tearDown() throws Exception {