4eb5ba17bc6d1fded124880d46cd9f6dac95be86
[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.GeneralConfig;
31
32 import com.google.common.io.Files;
33
34 public class TestGeneralConfig {
35
36         private static final String TESTCONFIG_CONTENT="[general]\n" +
37                         "dmaapEnabled=false\n" +
38                         "baseUrl=http://localhost:8181\n" +
39                         "sdnrUser=admin\n" +
40                         "sdnrPasswd=admin\n" +
41                         "";
42
43         private ConfigurationFileRepresentation globalCfg;
44
45         @Test
46         public void test() {
47                 try {
48                         Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
49                         globalCfg = new ConfigurationFileRepresentation("test.properties");
50                         GeneralConfig cfg = new GeneralConfig(globalCfg);
51                         assertEquals(false, cfg.getEnabled());
52                         assertEquals("http://localhost:8181", GeneralConfig.getBaseUrl());
53                         assertEquals("admin", GeneralConfig.getSDNRUser());
54                         assertEquals("admin", GeneralConfig.getSDNRPasswd());
55                         assertEquals("general", cfg.getSectionName());
56                 } catch (IOException e) {
57                         // TODO Auto-generated catch block
58                         e.printStackTrace();
59                 }
60         }
61         
62         @After
63         public void cleanUp() {
64                 File file = new File("test.properties");
65                 if (file.exists()) {
66                         System.out.println("File exists, Deleting it");
67                         file.delete();
68                 }
69                 
70         }
71 }