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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
19 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test.config;
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import com.google.common.io.Files;
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;
29 public class TestStrimziKafkaConfig {
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"
41 private StrimziKafkaConfig sKafkaCfg;
42 private static final String CONFIGURATIONFILE = "test2.properties";
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);
50 public StrimziKafkaConfig getCfg() {
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());
66 public void cleanUp() {
67 File file = new File(CONFIGURATIONFILE);
69 System.out.println("File exists, Deleting it");