df04c388f0c364109a0db5a304451d3829bc0812
[ccsdk/features.git] /
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 package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
19
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.File;
24 import java.io.FileNotFoundException;
25 import java.io.IOException;
26 import java.net.URISyntaxException;
27 import java.nio.file.Files;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.websocketmanager.utils.AkkaConfig;
30
31 public class AkkaConfigTest {
32
33     @Test
34     public void test() throws URISyntaxException, IOException {
35
36         AkkaConfig config = null;
37         try {
38             //config = AkkaConfig.load("akka-singlenode.cfg", true);
39             config = AkkaConfig.loadContent(loadResourceContentAsString("akka-singlenode.cfg"));
40         } catch (Exception e) {
41             e.printStackTrace();
42             fail("error loading singlenode config");
43         }
44         assertEquals("no singlenode config detected", false, config.isCluster());
45         assertEquals("more than one node detected", 1, config.getClusterConfig().getSeedNodes().size());
46
47         try {
48             config = AkkaConfig.loadContent(loadResourceContentAsString("akka-cluster.cfg"));
49         } catch (Exception e) {
50             fail("error loading cluster config");
51         }
52         assertEquals("no cluster config detected", true, config.isCluster());
53         assertTrue("only one node detected", config.getClusterConfig().getSeedNodes().size() > 1);
54     }
55
56     public static String loadResourceContentAsString(String resourceName)
57             throws URISyntaxException, FileNotFoundException, IOException {
58
59         return Files.readString(new File("src/test/resources/"+resourceName).toPath());
60     }
61 }