c921e7bcbc4cdf4eaae2a9eeab668df9bc50640e
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18
19 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
20
21 import static org.junit.Assert.assertEquals;
22 import com.google.common.io.Files;
23 import java.io.File;
24 import java.io.IOException;
25 import java.nio.charset.StandardCharsets;
26 import org.junit.After;
27 import org.junit.Test;
28 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
29 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig;
30
31 public class GeneralConfigTest {
32
33     // @formatter:off
34     private static final String TESTCONFIG_CONTENT =
35             "[general]\n"
36             + "dmaapEnabled=false\n"
37             + "TransportType=HTTPNOAUTH\n"
38             + "host=onap-dmap:3904\n"
39             + "topic=unauthenticated.SDNR_MOUNTPOINT_STATE_INFO\n"
40             + "contenttype=application/json\n"
41             + "timeout=20000\n"
42             + "limit=10000\n"
43             + "maxBatchSize=100\n"
44             + "maxAgeMs=250\n"
45             + "MessageSentThreadOccurance=50\n";
46     // @formatter:on
47     private final String fileName = "test.properties";
48     private ConfigurationFileRepresentation globalCfg;
49
50     @Test
51     public void test() throws IOException {
52
53             Files.asCharSink(new File(fileName), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
54             globalCfg = new ConfigurationFileRepresentation(fileName);
55             GeneralConfig cfg = new GeneralConfig(globalCfg);
56             assertEquals("onap-dmap:3904", cfg.getHostPort());
57             assertEquals(false, cfg.getEnabled());
58             assertEquals("unauthenticated.SDNR_MOUNTPOINT_STATE_INFO", cfg.getTopic());
59             assertEquals("application/json", cfg.getContenttype());
60             assertEquals("20000", cfg.getTimeout());
61             assertEquals("10000", cfg.getLimit());
62             assertEquals("100", cfg.getMaxBatchSize());
63             assertEquals("250", cfg.getMaxAgeMs());
64             assertEquals("50", cfg.getMessageSentThreadOccurrence());
65             assertEquals("HTTPNOAUTH", cfg.getTransportType());
66             assertEquals("general", cfg.getSectionName());
67
68
69     }
70
71     @After
72     public void cleanUp() {
73         File file = new File(fileName);
74         if (file.exists()) {
75             System.out.println("File exists, Deleting it");
76             file.delete();
77         }
78
79     }
80 }