3caa864d5f77c4a5a422f3fb83b2b0b075dd841d
[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.mountpointregistrar.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.mountpointregistrar.impl.FaultConfig;
30
31 public class TestFaultConfig {
32
33     // @formatter:off
34     private static final String TESTCONFIG_CONTENT = "[fault]\n"
35             + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer\n"
36             + "TransportType=HTTPNOAUTH\n"
37             + "Protocol=http\n"
38             + "username=username\n"
39             + "password=password\n"
40             + "host=onap-dmap:3904\n"
41             + "topic=unauthenticated.SEC_FAULT_OUTPUT\n"
42             + "contenttype=application/json\n"
43             + "group=myG\n"
44             + "id=C1\n"
45             + "timeout=20000\n"
46             + "limit=10000\n"
47             + "fetchPause=5000\n"
48             + "jersey.config.client.readTimeout=25000\n"
49             + "jersey.config.client.connectTimeout=25000\n"
50             + "\n"
51             + "";
52     // @formatter:on
53
54     private ConfigurationFileRepresentation cfg;
55     private static final String CONFIGURATIONFILE = "test2.properties";
56     @Test
57     public void test() {
58         try {
59             Files.asCharSink(new File(CONFIGURATIONFILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
60             cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
61             FaultConfig faultCfg = new FaultConfig(cfg);
62             assertEquals("fault", faultCfg.getSectionName());
63             assertEquals("org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer",
64                     faultCfg.getConsumerClass());
65             assertEquals("HTTPNOAUTH", faultCfg.getTransportType());
66             assertEquals("onap-dmap:3904", faultCfg.getHostPort());
67             assertEquals("unauthenticated.SEC_FAULT_OUTPUT", faultCfg.getTopic());
68             assertEquals("application/json", faultCfg.getContenttype());
69             assertEquals("myG", faultCfg.getConsumerGroup());
70             assertEquals("C1", faultCfg.getConsumerId());
71             assertEquals("20000", faultCfg.getTimeout());
72             assertEquals("10000", faultCfg.getLimit());
73             assertEquals("5000", faultCfg.getFetchPause());
74             assertEquals("http", faultCfg.getProtocol());
75             assertEquals("username", faultCfg.getUsername());
76             assertEquals("password", faultCfg.getPassword());
77             assertEquals("25000", faultCfg.getClientReadTimeout());
78             assertEquals("25000", faultCfg.getClientConnectTimeout());
79
80         } catch (IOException e) {
81             e.printStackTrace();
82         }
83     }
84
85     @After
86     public void cleanUp() {
87         File file = new File(CONFIGURATIONFILE);
88         if (file.exists()) {
89             System.out.println("File exists, Deleting it");
90             file.delete();
91         }
92
93     }
94
95 }