2bc41490d8d56a67a234da4f2e06be5b016b7882
[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.Test;
28 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
29 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFRegistrationConfig;
30
31 import com.google.common.io.Files;
32
33 public class PNFRegistrationConfigTest {
34
35         private static final String TESTCONFIG_CONTENT="[pnfRegistration]\n" +
36                         "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer\n" +
37                         "TransportType=HTTPNOAUTH\n" +
38                         "host=onap-dmap:3904\n" +
39                         "topic=unauthenticated.VES_PNFREG_OUTPUT\n" +
40                         "contenttype=application/json\n" +
41                         "group=myG\n" +
42                         "id=C1\n" +
43                         "timeout=20000\n" +
44                         "limit=10000\n" +
45                         "fetchPause=5000\n" +
46                         "";
47
48         private ConfigurationFileRepresentation cfg;
49
50         @Test
51         public void test() {
52                 try {
53                         Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
54                         cfg = new ConfigurationFileRepresentation("test.properties");
55                         PNFRegistrationConfig pnfCfg = new PNFRegistrationConfig(cfg);
56                         assertEquals("pnfRegistration", pnfCfg.getSectionName());
57                         assertEquals("org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer", pnfCfg.getConsumerClass());
58                         assertEquals("HTTPNOAUTH", pnfCfg.getTransportType());
59                         assertEquals("onap-dmap:3904", pnfCfg.getHostPort());
60                         assertEquals("unauthenticated.VES_PNFREG_OUTPUT", pnfCfg.getTopic());
61                         assertEquals("application/json", pnfCfg.getContenttype());
62                         assertEquals("myG", pnfCfg.getConsumerGroup());
63                         assertEquals("C1", pnfCfg.getConsumerId());
64                         assertEquals("20000", pnfCfg.getTimeout());
65                         assertEquals("10000", pnfCfg.getLimit());
66                         assertEquals("5000", pnfCfg.getFetchPause());
67
68                 } catch (IOException e) {
69                         // TODO Auto-generated catch block
70                 }
71
72         }
73
74 }