5f79d943a8cbc25dcf5ba5e2b5552ec50071caad
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 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.devicemanager.adaptermanager.test;
19
20 import java.io.File;
21 import java.io.FileNotFoundException;
22 import java.io.IOException;
23 import java.nio.file.Files;
24 import java.nio.file.Path;
25 import java.nio.file.Paths;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.DeviceManagerAdapterManagerImpl;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 public class TestDeviceManagerAdapterManagerImpl {
34     private static Path KARAF_ETC = Paths.get("etc");
35     private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerAdapterManagerImpl.class);
36     DeviceManagerAdapterManagerImpl devMgrAdapterManager;
37
38     @Before
39     public void init() throws InterruptedException, IOException {
40         /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
41         Path etc = KARAF_ETC;
42         delete(etc);
43
44         System.out.println("Create empty:" + etc.toString());
45         Files.createDirectories(etc);*/
46     }
47
48     @Test
49     public void test() throws Exception {
50         devMgrAdapterManager = new DeviceManagerAdapterManagerImpl();
51         /*DeviceManagerImpl devMgr = new DeviceManagerImpl();
52
53         try {
54                 devMgr.init();
55                 devMgrOran.setNetconfNetworkElementService(devMgr);
56                 devMgrOran.init();
57         } catch (Exception e) {
58                 // TODO Auto-generated catch block
59                 e.printStackTrace();
60         }*/
61         /*
62          * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init();
63          * NetconfNetworkElementService netConfNetworkElementService =
64          * mock(NetconfNetworkElementService.class); devMgrOran =
65          * mock(DeviceManagerORanImpl.class);
66          * when(netConfNetworkElementService.registerNetworkElementFactory(new
67          * ORanNetworkElementFactory())).thenReturn(null);
68          */
69
70
71     }
72
73     @After
74     public void cleanUp() throws Exception {
75         devMgrAdapterManager.close();
76     }
77
78     private static void delete(Path etc) throws IOException {
79         if (Files.exists(etc)) {
80             System.out.println("Found, removing:" + etc.toString());
81             delete(etc.toFile());
82         }
83     }
84
85     private static void delete(File f) throws IOException {
86         if (f.isDirectory()) {
87             for (File c : f.listFiles()) {
88                 delete(c);
89             }
90         }
91         if (!f.delete()) {
92             throw new FileNotFoundException("Failed to delete file: " + f);
93         }
94     }
95 }