fix oauth code
[ccsdk/features.git] / sdnr / wt / mountpoint-registrar / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / mountpointregistrar / test / config / TestStrimziKafkaConfig.java
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.config;
20
21 import static org.junit.jupiter.api.Assertions.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.config.StrimziKafkaConfig;
30
31 public class TestStrimziKafkaConfig {
32
33     // @formatter:off
34     private static final String TESTCONFIG_CONTENT = "[strimzi-kafka]\n"
35             + "strimziEnabled=false\n"
36             + "bootstrapServers=onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094\n"
37             + "securityProtocol=PLAINTEXT\n"
38             + "saslMechanism=PLAIN\n"
39             + "saslJaasConfig=PLAIN\n"
40             + "";
41      // @formatter:on
42
43     private ConfigurationFileRepresentation cfg;
44     private static final String CONFIGURATIONFILE = "test2.properties";
45
46     @Test
47     public void test() {
48         try {
49             Files.asCharSink(new File(CONFIGURATIONFILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
50             cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
51             StrimziKafkaConfig sKafkaCfg = new StrimziKafkaConfig(cfg);
52             assertEquals("strimzi-kafka", sKafkaCfg.getSectionName());
53             assertEquals("onap-strimzi-kafka-0:9094,onap-strimzi-kafka-1:9094", sKafkaCfg.getBootstrapServers());
54             assertEquals("PLAINTEXT", sKafkaCfg.getSecurityProtocol());
55             assertEquals(false, sKafkaCfg.getEnabled());
56             assertEquals("PLAIN", sKafkaCfg.getSaslJaasConfig());
57             assertEquals("PLAIN", sKafkaCfg.getSaslMechanism());
58         } catch (IOException e) {
59             e.printStackTrace();
60         }
61     }
62
63     @After
64     public void cleanUp() {
65         File file = new File(CONFIGURATIONFILE);
66         if (file.exists()) {
67             System.out.println("File exists, Deleting it");
68             file.delete();
69         }
70
71     }
72
73 }