2 * ============LICENSE_START======================================================= ONAP : ccsdk
3 * feature sdnr wt ================================================================================
4 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
5 * ================================================================================ Licensed under
6 * the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
7 * with the License. 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 distributed under the License
12 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing permissions and limitations under
14 * the License. ============LICENSE_END=========================================================
16 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.fail;
22 import java.io.FileNotFoundException;
23 import java.io.IOException;
24 import java.io.PrintWriter;
25 import java.io.StringWriter;
26 import java.nio.file.Files;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MountpointRegistrarImpl;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
37 public class TestMountpointRegistrarImpl {
39 private static Path KARAF_ETC = Paths.get("etc");
40 private static MountpointRegistrarImpl mountpointRegistrar;
42 private static final Logger LOG = LoggerFactory.getLogger(TestMountpointRegistrarImpl.class);
47 public void before() throws InterruptedException, IOException {
49 System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
50 // Call System property to get the classpath value
54 System.out.println("Create empty:" + etc.toString());
55 Files.createDirectories(etc);
59 // start using blueprint interface
61 mountpointRegistrar = new MountpointRegistrarImpl();
62 mountpointRegistrar.init();
63 } catch (Exception e) {
64 StringWriter sw = new StringWriter();
65 e.printStackTrace(new PrintWriter(sw));
66 fail("Not initialized" + sw.toString());
68 System.out.println("Initialization status: " + mountpointRegistrar.isInitializationOk());
69 System.out.println("Initialization done");
73 public void after() throws InterruptedException, IOException {
75 System.out.println("Start shutdown");
76 // close using blueprint interface
78 mountpointRegistrar.close();
79 } catch (Exception e) {
80 System.out.println(e);
88 System.out.println("Test1: slave mountpoint");
89 assertNotNull(mountpointRegistrar);
90 System.out.println("Initialization status: " + mountpointRegistrar.isInitializationOk());
91 System.out.println("Test2: Done");
94 // ********************* Private
96 @SuppressWarnings("unused")
97 private static void sleep(int millis) {
100 } catch (InterruptedException e) {
101 LOG.warn(e.getMessage());
102 Thread.currentThread().interrupt();
106 private static void delete(Path etc) throws IOException {
107 if (Files.exists(etc)) {
108 System.out.println("Found and remove:" + etc.toString());
109 delete(etc.toFile());
113 private static void delete(File f) throws IOException {
114 if (f.isDirectory()) {
115 for (File c : f.listFiles()) {
120 throw new FileNotFoundException("Failed to delete file: " + f);