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==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.fail;
23 import java.io.BufferedReader;
25 import java.io.FileNotFoundException;
26 import java.io.FileReader;
27 import java.io.IOException;
28 import java.net.URISyntaxException;
29 import java.nio.file.Paths;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.utils.AkkaConfig;
33 public class AkkaConfigTest {
36 public void test() throws URISyntaxException, IOException {
38 AkkaConfig config = null;
40 //config = AkkaConfig.load("akka-singlenode.cfg", true);
41 config = AkkaConfig.loadContent(loadResourceContentAsString("akka-singlenode.cfg"));
42 } catch (Exception e) {
44 fail("error loading singlenode config");
46 assertEquals("no singlenode config detected", false, config.isCluster());
47 assertEquals("more than one node detected", 1, config.getClusterConfig().getSeedNodes().size());
50 config = AkkaConfig.loadContent(loadResourceContentAsString("akka-cluster.cfg"));
51 } catch (Exception e) {
52 fail("error loading cluster config");
54 assertEquals("no cluster config detected", true, config.isCluster());
55 assertTrue("only one node detected", config.getClusterConfig().getSeedNodes().size() > 1);
58 public static String loadResourceContentAsString(String resourceName)
59 throws URISyntaxException, FileNotFoundException, IOException {
61 StringBuilder sb = new StringBuilder();
63 ClassLoader classLoader = AkkaConfigTest.class.getClassLoader();
64 File file = Paths.get(classLoader.getResource(resourceName).toURI()).toFile();
65 try (BufferedReader br = new BufferedReader(new FileReader(file))) {
66 String line = br.readLine();
68 while (line != null) {
70 sb.append(System.lineSeparator());