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