87bd85fa397e0efcc1918a7489ec35103dc0f1e5
[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
23 import java.io.File;
24 import java.io.IOException;
25 import java.nio.charset.StandardCharsets;
26
27 import org.junit.After;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
30 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.GeneralConfig;
31
32 import com.google.common.io.Files;
33
34 public class GeneralConfigTest {
35
36         private static final String TESTCONFIG_CONTENT="[general]\n" +
37                         "dmaapEnabled=false\n" +
38                         "TransportType=HTTPNOAUTH\n" +
39             "host=onap-dmap:3904\n" +
40                         "topic=unauthenticated.SDNR_MOUNTPOINT_STATE_INFO\n" +
41             "contenttype=application/json\n" +
42             "timeout=20000\n" +
43             "limit=10000\n" +
44             "maxBatchSize=100\n" +
45             "maxAgeMs=250\n" +
46             "MessageSentThreadOccurance=50\n";
47
48         private ConfigurationFileRepresentation globalCfg;
49
50         @Test
51         public void test() {
52                 try {
53                         Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
54                         globalCfg = new ConfigurationFileRepresentation("test.properties");
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                 } catch (IOException e) {
69                         // TODO Auto-generated catch block
70                         e.printStackTrace();
71                 }
72         }
73         
74         @After
75         public void cleanUp() {
76                 File file = new File("test.properties");
77                 if (file.exists()) {
78                         System.out.println("File exists, Deleting it");
79                         file.delete();
80                 }
81                 
82         }
83 }