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.*;
22 import java.io.BufferedReader;
24 import java.io.FileNotFoundException;
25 import java.io.FileReader;
26 import java.io.IOException;
27 import java.net.URISyntaxException;
28 import java.nio.file.Paths;
29 import org.junit.Test;
30 import org.onap.ccsdk.features.sdnr.wt.websocketmanager2.utils.AkkaConfig;
32 public class AkkaConfigTest {
35 public void test() throws URISyntaxException, IOException {
37 AkkaConfig config = null;
39 //config = AkkaConfig.load("akka-singlenode.cfg", true);
40 config = AkkaConfig.loadContent(loadResourceContentAsString("akka-singlenode.cfg"));
41 } catch (Exception e) {
43 fail("error loading singlenode config");
45 assertEquals("no singlenode config detected", false, config.isCluster());
46 assertEquals("more than one node detected", 1, config.getClusterConfig().getSeedNodes().size());
49 config = AkkaConfig.loadContent(loadResourceContentAsString("akka-cluster.cfg"));
50 } catch (Exception e) {
51 fail("error loading cluster config");
53 assertEquals("no cluster config detected", true, config.isCluster());
54 assertTrue("only one node detected", config.getClusterConfig().getSeedNodes().size() > 1);
57 public static String loadResourceContentAsString(String resourceName)
58 throws URISyntaxException, FileNotFoundException, IOException {
60 StringBuilder sb = new StringBuilder();
62 ClassLoader classLoader = AkkaConfigTest.class.getClassLoader();
63 File file = Paths.get(classLoader.getResource(resourceName).toURI()).toFile();
64 try (BufferedReader br = new BufferedReader(new FileReader(file))) {
65 String line = br.readLine();
67 while (line != null) {
69 sb.append(System.lineSeparator());