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