578053aa464ad77148e9074d1cb3d021e921f02f
[dmaap/datarouter.git] / datarouter-node / src / test / java / org / onap / dmaap / datarouter / node / NodeConfigManagerTest.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.dmaap.datarouter.node;
22
23 import java.io.File;
24 import java.io.IOException;
25 import java.net.InetAddress;
26 import java.net.URL;
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;
36
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 {
41
42     private NodeConfigManager nodeConfigManager = NodeConfigManager.getInstance();
43
44     @BeforeClass
45     public static void init() {
46         System.setProperty("org.onap.dmaap.datarouter.node.properties", "src/test/resources/node_test.properties");
47     }
48
49     @AfterClass
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"));
53     }
54
55     @Test
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());
77     }
78
79 }