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