2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.datarouter.node;
24 import java.io.IOException;
25 import java.net.InetAddress;
27 import org.apache.commons.io.FileUtils;
28 import org.junit.AfterClass;
29 import org.junit.Assert;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.powermock.core.classloader.annotations.PowerMockIgnore;
34 import org.powermock.core.classloader.annotations.PrepareForTest;
35 import org.powermock.modules.junit4.PowerMockRunner;
37 @RunWith(PowerMockRunner.class)
38 @PowerMockIgnore({"javax.net.ssl.*", "javax.security.auth.x500.X500Principal", "javax.crypto.*"})
39 @PrepareForTest({InetAddress.class, URL.class})
40 public class NodeConfigManagerTest {
42 private NodeConfigManager nodeConfigManager = NodeConfigManager.getInstance();
45 public static void init() {
46 System.setProperty("org.onap.dmaap.datarouter.node.properties", "src/test/resources/node_test.properties");
50 public static void tearDownClass() throws IOException {
51 FileUtils.deleteDirectory(new File(System.getProperty("user.dir") + "/src/test/resources/spool"));
52 FileUtils.deleteDirectory(new File(System.getProperty("user.dir") + "/src/test/resources/logs"));
56 public void Verify_NodeConfigMan_Getters() {
57 Assert.assertEquals("legacy", nodeConfigManager.getAafInstance());
58 Assert.assertEquals("src/test/resources/spool/f", nodeConfigManager.getSpoolDir());
59 Assert.assertEquals("src/test/resources/spool", nodeConfigManager.getSpoolBase());
60 Assert.assertEquals("PKCS12", nodeConfigManager.getKSType());
61 Assert.assertEquals(8080, nodeConfigManager.getHttpPort());
62 Assert.assertEquals(8443, nodeConfigManager.getHttpsPort());
63 Assert.assertEquals(443, nodeConfigManager.getExtHttpsPort());
64 Assert.assertEquals("dmaap-dr-node", nodeConfigManager.getMyName());
65 Assert.assertEquals("https://dmaap-dr-prov:8443/internal/logs", nodeConfigManager.getEventLogUrl());
66 Assert.assertEquals("src/test/resources/logs/events", nodeConfigManager.getEventLogPrefix());
67 Assert.assertEquals(".log", nodeConfigManager.getEventLogSuffix());
68 Assert.assertEquals("src/test/resources/logs", nodeConfigManager.getLogDir());
69 Assert.assertEquals((86400000L * 30), nodeConfigManager.getLogRetention());
70 Assert.assertEquals(new String[] {"TLSv1.1", "TLSv1.2"}, nodeConfigManager.getEnabledprotocols());
71 Assert.assertEquals("org.onap.dmaap-dr.feed", nodeConfigManager.getAafType());
72 Assert.assertEquals("publish", nodeConfigManager.getAafAction());
73 Assert.assertEquals("https://aaf-locate:8095", nodeConfigManager.getAafURL());
74 Assert.assertFalse(nodeConfigManager.getCadiEnabled());
75 Assert.assertFalse(nodeConfigManager.isShutdown());
76 Assert.assertFalse(nodeConfigManager.isConfigured());