2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
24 import static org.junit.Assert.assertEquals;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
32 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section;
33 import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsConfig;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public class TestConfig {
40 private static final Logger LOG = LoggerFactory.getLogger(TestConfig.class);
42 private static final String TESTFILENAME = "testconfig.properties";
43 private static String ENVSDNRDBURL = "SDNRDBURL";
44 private static String SDNRDBURL = "http://sdnrdb:9200";
48 public void afterAndBefore() {
49 File f = new File(TESTFILENAME);
51 LOG.info("Remove {}", f.getAbsolutePath());
58 EnvGetter env = Section.getEnvGetter();
59 Section.setEnvGetter((envname) -> {
60 return envname.equals(ENVSDNRDBURL) ? SDNRDBURL : env.getenv(envname);
62 ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(TESTFILENAME);
63 EsConfig esConfig = new EsConfig(configuration);
64 LOG.info("Defaultconfiguration: {}", esConfig.toString());
65 assertEquals("http", esConfig.getHosts()[0].protocol.getValue());
66 assertEquals(9200, esConfig.getHosts()[0].port);
67 assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);