1 package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.test;
2 /*******************************************************************************
3 * ============LICENSE_START========================================================================
4 * ONAP : ccsdk feature sdnr wt
5 * =================================================================================================
6 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
7 * =================================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software distributed under the License
14 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15 * or implied. See the License for the specific language governing permissions and limitations under
17 * ============LICENSE_END==========================================================================
18 ******************************************************************************/
20 import static org.junit.Assert.fail;
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.io.PrintWriter;
26 import java.io.StringWriter;
27 import java.nio.file.Files;
28 import java.nio.file.Path;
29 import java.nio.file.Paths;
31 import org.junit.AfterClass;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
34 import org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl.MountpointStateProviderImpl;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public class TestMountpointStateProviderImpl {
40 private static Path KARAF_ETC = Paths.get("etc");
41 private static MountpointStateProviderImpl mountpointStateProvider;
43 private static final Logger LOG = LoggerFactory.getLogger(TestMountpointStateProviderImpl.class);
48 public static void before() throws InterruptedException, IOException {
50 System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
51 // Call System property to get the classpath value
55 System.out.println("Create empty:" + etc.toString());
56 Files.createDirectories(etc);
60 // start using blueprint interface
62 mountpointStateProvider = new MountpointStateProviderImpl();
64 //mountpointStateProvider.init(); // Can't be tested as this invokes a thread. Mockito doesn't help either
65 } catch (Exception e) {
66 StringWriter sw = new StringWriter();
67 e.printStackTrace(new PrintWriter(sw));
68 fail("Not initialized" +sw.toString());
70 System.out.println("Initialization status: " + mountpointStateProvider.isInitializationOk());
71 System.out.println("Initialization done");
75 public static void after() throws InterruptedException, IOException {
77 System.out.println("Start shutdown");
78 // close using blueprint interface
80 mountpointStateProvider.close();
81 } catch (Exception e) {
82 System.out.println(e);
90 System.out.println("Test1: slave mountpoint");
91 System.out.println("Initialization status: " + mountpointStateProvider.isInitializationOk());
92 System.out.println("Test2: Done");
95 // ********************* Private
97 private static void delete(Path etc) throws IOException {
98 if (Files.exists(etc)) {
99 System.out.println("Found and remove:" + etc.toString());
100 delete(etc.toFile());
104 private static void delete(File f) throws IOException {
105 if (f.isDirectory()) {
106 for (File c : f.listFiles()) {
111 throw new FileNotFoundException("Failed to delete file: " + f);
115 public void testInit() {
120 public void testOnConfigChanged() {
121 //fail("Not yet implemented");