diff options
author | 2021-04-19 12:46:16 +0200 | |
---|---|---|
committer | 2021-04-20 08:01:27 +0200 | |
commit | 05fe114a5969727c32cd9f1051cd7b9fde0344d5 (patch) | |
tree | 4cb505cd98ddb5b9c6f188f9febe93b07cf743db /sdnr/wt/devicemanager/provider/src/test | |
parent | 6ae7e8a1bae83d407b22d8b066dd0bcca730e1bb (diff) |
Reorganization of devicemanager directory structure
Organized into core, onap and o-ran-sc directories
Issue-ID: CCSDK-3242
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I3c23710f990a2d96ba01104c97315fc8c6b1921b
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test')
17 files changed, 0 insertions, 2113 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java deleted file mode 100644 index cc49ea9bf..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import com.google.common.io.Files; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config.AaiConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; - -public class TestAai { - - private static final String CONFIGURATIONTESTFILE = "test.properties"; // for - private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties"; - private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME); - private static final int AAI_SERVER_PORT = 45454; - private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n" - + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" - + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" - + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n" - + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n" - + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" - + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" - + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n" - + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" - + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" - + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" - + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" - + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" - + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; - - private static final String EXT_TEST_URL = "https://testaai.onap.org:8443"; - private static final String EXT_TEST_KEY = "test.key"; - private static final String EXT_TEST_PASSWD = "test123"; - private static final String EXT_TEST_APPLICATIONID = "SDNC"; - private static final long EXT_TEST_CONN_TIMEOUT = 6000; - - - private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n" - + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n" - + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" - + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + - // "aaiApplicationId=SDNR\n" + - // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + - // "aaiPcks12ClientCertPassphrase=adminadmin\n" + - // "aaiClientConnectionTimeout=30000\n" + - "\n"; - private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key=" - + EXT_TEST_KEY + "\n" + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=" + EXT_TEST_PASSWD + "\n" - + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n" - + "org.onap.ccsdk.sli.adaptors.aai.application=" + EXT_TEST_APPLICATIONID + "\n" - + "org.onap.ccsdk.sli.adaptors.aai.uri=" + EXT_TEST_URL + "\n" + "connection.timeout=" - + EXT_TEST_CONN_TIMEOUT + "\n"; - private static HttpServer server; - private static ExecutorService httpThreadPool; - private static ConfigurationFileRepresentation globalCfg; - - @Test - public void test() { - - String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath(); - ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); - - AaiProviderClient provider = new AaiProviderClient(cfg, null); - - String mountPointName = "testDevice 01"; - String type = "Unit"; - String model = "Horizon Compact+"; - String vendor = "DragonWave-X"; - String ipv4 = "127.0.0.1"; - String ipv6 = "::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName, ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void test2() { - try { - Thread.sleep(3000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - AaiProviderClient provider = new AaiProviderClient(globalCfg, null); - - String mountPointName = "testDevice 01"; - String type = "Unit"; - String model = "Horizon Compact+"; - String vendor = "DragonWave-X"; - String ipv4 = "127.0.0.1"; - String ipv6 = "::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - provider.onDeviceRegistered(mountPointName); - provider.onDeviceRegistered(mountPointName, ii); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("unregistering device"); - provider.onDeviceUnregistered(mountPointName); - System.out.println("finished"); - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testExtendedProperties() { - File testConfigurationFileName = new File("abbsads.properties"); - File extfile = new File("aaiclient.properties"); - if (testConfigurationFileName.exists()) { - testConfigurationFileName.delete(); - } - if (extfile.exists()) { - extfile.delete(); - } - try { - Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT); - } catch (IOException e) { - e.printStackTrace(); - fail("problem writing a test config file: " + e.getMessage()); - } - try { - Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2); - } catch (IOException e) { - e.printStackTrace(); - fail("problem writing a second test config file: " + e.getMessage()); - } - - ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName); - AaiConfig config = new AaiConfig(cfg); - System.out.println(config.toString()); - - assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL)); - assertEquals(EXT_TEST_KEY, config.getPcks12CertificateFilename()); - assertEquals(EXT_TEST_PASSWD, config.getPcks12CertificatePassphrase()); - assertEquals(EXT_TEST_APPLICATIONID, config.getHeaders().get("X-FromAppId")); - assertEquals(EXT_TEST_CONN_TIMEOUT, config.getConnectionTimeout()); - - if (testConfigurationFileName.exists()) { - testConfigurationFileName.delete(); - } - if (extfile.exists()) { - extfile.delete(); - } - - } - - @BeforeClass - public static void initAaiTestWebserver() throws IOException { - try { - Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - } catch (IOException e1) { - fail(e1.getMessage()); - } - //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); - globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME); - server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); - httpThreadPool = Executors.newFixedThreadPool(5); - server.setExecutor(httpThreadPool); - AaiConfig config = new AaiConfig(globalCfg); - server.createContext(config.getBaseUri(), new MyHandler()); - //server.createContext("/", new MyRootHandler()); - server.setExecutor(null); // creates a default executor - server.start(); - System.out.println("http server started"); - } - - @AfterClass - public static void stopTestWebserver() { - if (server != null) { - server.stop(0); - httpThreadPool.shutdownNow(); - System.out.println("http server stopped"); - } - if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { - ENABLEDAAI_TESTCONFIG_FILE.delete(); - } - - } - - static class MyHandler implements HttpHandler { - @Override - public void handle(HttpExchange t) throws IOException { - String method = t.getRequestMethod(); - System.out.println("req method: " + method); - OutputStream os = null; - try { - String res = ""; - if (method.equals("GET")) { - t.sendResponseHeaders(404, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("DELETE")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else if (method.equals("PUT")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else { - t.sendResponseHeaders(404, 0); - } - System.out.println("req handled successful"); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } finally { - if (os != null) { - os.close(); - } - } - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java deleted file mode 100644 index ff01f9a2b..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae; -import com.google.common.io.Files; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; - -@SuppressWarnings("restriction") -public class TestDcae { - - private static final String ENABLEDDCAE_TESTCONFIG_FILENAME = "test2.properties"; - private static final File ENABLEDDCAE_TESTCONFIG_FILE = new File(ENABLEDDCAE_TESTCONFIG_FILENAME); - private static final int DCAE_SERVER_PORT = 45451; - private static final String URI = "/abc"; - private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" - + "dcaeUrl=http://localhost:" + DCAE_SERVER_PORT + URI + "\n" + "dcaeHeartbeatPeriodSeconds=120\n" - + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" + "userPassword=passwd\n" + "soapurladd=off\n" - + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" - + "assignedto=userid\n" + "addtemplate=addreq.tmpl.xml\n" - + "severitypassthrough=critical,major,minor,warning\n" + "systemuser=user\n" + "prt-offset=1200\n" - + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" + "#smtpUsername=\n" + "#smtpPassword=\n" - + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" - + "#keep comment\n" + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=off\n" - + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n" - + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n" - + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" - + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n" - + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + ""; - private HttpServer server; - private ExecutorService httpThreadPool; - private ConfigurationFileRepresentation cfg; - - @Test - public void test2() { - try { - Thread.sleep(3000); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - DcaeProviderClient provider = new DcaeProviderClient(cfg, "mountpoint", null); - - String mountPointName = "testDevice 01"; - String type = "Unit"; - String model = "Horizon Compact+"; - String vendor = "DragonWave-X"; - String ipv4 = "127.0.0.1"; - String ipv6 = "::1"; - List<String> ifInfos = new ArrayList<>(); - ifInfos.add("LP-MWPS-RADIO"); - new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos); - System.out.println("registering device"); - boolean neDeviceAlarm = false; - ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element", - "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern()); - provider.sendProblemNotification(mountPointName, notification, neDeviceAlarm); - - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - try { - provider.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Before - public void initDcaeTestWebserver() throws IOException { - try { - Files.asCharSink(ENABLEDDCAE_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); - } catch (IOException e1) { - fail(e1.getMessage()); - } - cfg = new ConfigurationFileRepresentation(ENABLEDDCAE_TESTCONFIG_FILENAME); - // cfg.reload(ENABLEDDCAE_TESTCONFIG_FILENAME); - /* - * cfg = new HtDevicemanagerConfiguration(ENABLEDDCAE_TESTCONFIG_FILENAME); - * DcaeConfig.reload(); - */ - try { - this.server = HttpServer.create(new InetSocketAddress(DCAE_SERVER_PORT), 0); - } catch (Exception e) { - fail(e.getMessage()); - } - this.httpThreadPool = Executors.newFixedThreadPool(5); - this.server.setExecutor(this.httpThreadPool); - this.server.createContext(URI, new MyHandler()); - // server.createContext("/", new MyRootHandler()); - this.server.setExecutor(null); // creates a default executor - this.server.start(); - System.out.println("http server started"); - } - - @After - public void stopTestWebserver() { - if (this.server != null) { - this.server.stop(0); - this.httpThreadPool.shutdownNow(); - System.out.println("http server stopped"); - } - if (ENABLEDDCAE_TESTCONFIG_FILE.exists()) { - ENABLEDDCAE_TESTCONFIG_FILE.delete(); - } - } - - static class MyHandler implements HttpHandler { - @Override - public void handle(HttpExchange t) throws IOException { - String method = t.getRequestMethod(); - System.out.println("req method: " + method); - OutputStream os = null; - try { - String res = ""; - if (method.equals("POST")) { - t.sendResponseHeaders(200, res.length()); - os = t.getResponseBody(); - os.write(res.getBytes()); - } else { - t.sendResponseHeaders(404, 0); - } - System.out.println("req handled successful"); - - } catch (Exception e) { - System.out.println(e.getMessage()); - } finally { - if (os != null) { - os.close(); - } - } - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java deleted file mode 100644 index 9b533b554..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import com.google.common.io.Files; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config.AaiConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.config.DcaeConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.config.PmConfig; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.ToggleAlarmConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestDevMgrPropertiesFile { - - private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class); - - private static final File FILENAME = new File("testdevmgrpropertiesfile.properties"); - private static final File AAIPROP_FILE = new File("testdevmgrpropertiesfileaaiclient.properties"); - private int hasChanged; - - @Before - public void init() { - delete(FILENAME); - delete(AAIPROP_FILE); - } - - @After - public void deinit() { - this.init(); - } - - @Test - public void testBasicConfiguration() { - - writeFile(FILENAME, this.getContent1()); - writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); - - LOG.info("Read and verify"); - ConfigurationFileRepresentation cfg2 = new ConfigurationFileRepresentation(FILENAME.getPath()); - - AaiConfig aaiConfig = new AaiConfig(cfg2); - assertNotNull(aaiConfig); - DcaeConfig dcaeConfig = new DcaeConfig(cfg2); - assertNotNull(dcaeConfig); - PmConfig pmConfig = new PmConfig(cfg2); - assertNotNull(pmConfig); - ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2); - assertNotNull(toggleAlarmConfig); - - LOG.info("Verify {} ", aaiConfig); - } - - //-- Observer not working with all testcases, because config does not support different file types. - @Test - public void testChangeConfiguration() { - - LOG.info("Read and verify"); - - writeFile(FILENAME, this.getContent1()); - writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); - - ConfigurationFileRepresentation cfg2 = new ConfigurationFileRepresentation(FILENAME.getPath()); - hasChanged = 0; - cfg2.registerConfigChangedListener(() -> { - hasChanged++; - LOG.info("file changed listener triggered: {}", hasChanged); - }); - - AaiConfig aaiConfig = new AaiConfig(cfg2); - assertNotNull(aaiConfig); - DcaeConfig dcaeConfig = new DcaeConfig(cfg2); - assertNotNull(dcaeConfig); - PmConfig pmConfig = new PmConfig(cfg2); - assertNotNull(pmConfig); - ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2); - assertNotNull(toggleAlarmConfig); - - LOG.info("Write new content. Changes {}", hasChanged); - writeFile(FILENAME, this.getContent2()); - - int i = 10; - while (hasChanged == 0 && i-- > 0) { - LOG.info("Wait for Change indication."); - sleep(1000); - } - LOG.info("Changes {}", hasChanged); - - assertTrue("fileChanged counter " + hasChanged, hasChanged > 0); - LOG.info("Test done"); - - } - - - private static void sleep(int milliseconds) { - try { - Thread.sleep(milliseconds); - } catch (InterruptedException e) { - } - } - - public static void writeFile(File f, String content) { - try { - Files.asCharSink(f, StandardCharsets.UTF_8).write(content); - } catch (IOException e) { - fail(e.getMessage()); - } ; - sleep(500); - } - - private void delete(File f) { - if (f.exists()) { - f.delete(); - } - } - - - private String getContent2() { - // @formatter:off - return "[dcae]\n" + - "dcaeUserCredentials=admin:admin\n" + - "dcaeUrl=http://localhost:45451/abc\n" + - "dcaeHeartbeatPeriodSeconds=120\n" + - "dcaeTestCollector=no\n" + - "\n" + - "[aots]\n" + - "userPassword=passwd\n" + - "soapurladd=off\n" + - "soapaddtimeout=10\n" + - "soapinqtimeout=20\n" + - "userName=user\n" + - "inqtemplate=inqreq.tmpl.xml\n" + - "assignedto=userid\n" + - "addtemplate=addreq.tmpl.xml\n" + - "severitypassthrough=critical,major,minor,warning\n" + - "systemuser=user\n" + - "prt-offset=1200\n" + - "soapurlinq=off\n" + - "#smtpHost=\n" + - "#smtpPort=\n" + - "#smtpUsername=\n" + - "#smtpPassword=\n" + - "#smtpSender=\n" + - "#smtpReceivers=\n" + - "\n" + - "[es]\n" + - "esCluster=sendateodl5\n" + - "\n" + - "[aai]\n" + - "#keep comment\n" + - "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + - "aaiUrl=off\n" + - "aaiUserCredentials=AAI:AAI\n" + - "aaiDeleteOnMountpointRemove=true\n" + - "aaiTrustAllCerts=false\n" + - "aaiApiVersion=aai/v13\n" + - "aaiPropertiesFile=aaiclient.properties\n" + - "aaiApplicationId=SDNR\n" + - "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" + - "aaiPcks12ClientCertPassphrase=adminadmin\n" + - "aaiClientConnectionTimeout=30000\n" + - "\n" + - "[pm]\n" + - "pmCluster=sendateodl5\n" + - "pmEnabled=true\n" + - "[toggleAlarmFilter]\n" + - "taEnabled=true\n" + - "taDelay=5555\n" + - ""; - // @formatter:on - } - - private String getContent1() { - // @formatter:off - return "[dcae]\n" + - "dcaeUserCredentials=admin:admin\n" + - "dcaeUrl=http://localhost:45/abc\n" + - "dcaeHeartbeatPeriodSeconds=120\n" + - "dcaeTestCollector=no\n" + - "\n" + - "[aots]\n" + - "userPassword=passwd\n" + - "soapurladd=off\n" + - "soapaddtimeout=10\n" + - "soapinqtimeout=20\n" + - "userName=user\n" + - "inqtemplate=inqreq.tmpl.xml\n" + - "assignedto=userid\n" + - "addtemplate=addreq.tmpl.xml\n" + - "severitypassthrough=critical,major,minor,warning\n" + - "systemuser=user\n" + - "prt-offset=1200\n" + - "soapurlinq=off\n" + - "#smtpHost=\n" + - "#smtpPort=\n" + - "#smtpUsername=\n" + - "#smtpPassword=\n" + - "#smtpSender=\n" + - "#smtpReceivers=\n" + - "\n" + - "[es]\n" + - "esCluster=sendateodl5\n" + - "\n" + - "[aai]\n" + - "#keep comment\n" + - "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + - "aaiUrl=off\n" + - "aaiUserCredentials=AAI:AAI\n" + - "aaiDeleteOnMountpointRemove=true\n" + - "aaiTrustAllCerts=false\n" + - "aaiApiVersion=aai/v13\n" + - "aaiPropertiesFile=aaiclient.properties\n" + - "\n" + - "[pm]\n" + - "pmCluster=sendateodl5\n" + - "pmEnabled=true\n" + - "[toggleAlarmFilter]\n" + - "taEnabled=false\n" + - "taDelay=5555\n" + - ""; - // @formatter:on - } - - private String getAaiPropertiesConfig() { - // @formatter:off - return "org.onap.ccsdk.sli.adaptors.aai.ssl.key=keykey\"\"\n" + - "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=psswdpsswd\"\"\n" + - "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=\"false\"\n" + - "org.onap.ccsdk.sli.adaptors.aai.application=appxyz\"\"\n" + - "org.onap.ccsdk.sli.adaptors.aai.uri=uriu\"\"\n" + - "connection.timeout=60000\n" + - "read.timeout=60000"; - // @formatter:on - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java deleted file mode 100644 index 0dbac340b..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import java.io.File; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler; -import org.opendaylight.mdsal.binding.api.DataBroker; - -public class TestDeviceMonitor extends Mockito { - - private static final String CONFIGURATIONTESTFILE = "test.properties"; // for - private static final String mountPointNodeName = "TestMountpoint"; - - private static DeviceMonitorImpl deviceMonitor; - - @BeforeClass - public static void before() { - - DataBroker dataBroker = mock(DataBroker.class); - ODLEventListenerHandler odlEventListenerHandler = mock(ODLEventListenerHandler.class); - ConfigurationFileRepresentation config = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE); - - deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config); - - } - - @Test - public void testDeviceMonitor() { - - deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName); - deviceMonitor.refreshAlarmsInDb(); - deviceMonitor.taskTestRun(); - deviceMonitor.deviceDisconnectIndication(mountPointNodeName); - deviceMonitor.removeMountpointIndication(mountPointNodeName); - } - - @Test - public void testDeviceMonitorTask() { - - - } - - @AfterClass - public static void after() throws Exception { - deviceMonitor.close(); - File f = new File(CONFIGURATIONTESTFILE); - if (f.exists()) - f.delete(); - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java deleted file mode 100644 index ed7f56f4b..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertTrue; -import java.util.Arrays; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock.RpcProviderServiceMock; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.MountPointService; -import org.opendaylight.mdsal.binding.api.NotificationPublishService; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInputBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("deprecation") -public class TestDevicemanager extends Mockito { - - private static final Logger log = LoggerFactory.getLogger(TestDevicemanager.class); - - private static DeviceManagerImpl deviceManager = new DeviceManagerImpl(); - private static DevicemanagerService apiService; - private static HtDatabaseMaintenance htDataBaseMaintenance = mock(HtDatabaseMaintenance.class); - - @BeforeClass - public static void before() throws Exception { - - DataBroker dataBroker = mock(DataBroker.class); - RpcProviderServiceMock rpcProviderRegistry = new RpcProviderServiceMock(); - NotificationPublishService notificationPublishService = mock(NotificationPublishService.class); - MountPointService mountPointService = mock(MountPointService.class); - ClusterSingletonServiceProvider clusterSingletonService = mock(ClusterSingletonServiceProvider.class); - NetconfNodeStateService netconfNodeStateService = mock(NetconfNodeStateService.class); - - @SuppressWarnings("unchecked") - ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class); - //doNothing().when(lr1).close(); - when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))) - .thenReturn(lr1); - - @SuppressWarnings("unchecked") - ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class); - //doNothing().when(lr2).close(); - when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))) - .thenReturn(lr2); - - WebsocketManagerService websocketmanagerService = mock(WebsocketManagerService.class); - - IEntityDataProvider iEntityDataProvider = mock(IEntityDataProvider.class); - doNothing().when(iEntityDataProvider).setReadyStatus(isA(Boolean.class)); - - DataProvider dataProvider = mock(DataProvider.class); - when(iEntityDataProvider.getDataProvider()).thenReturn(dataProvider); - - when(iEntityDataProvider.getHtDatabaseMaintenance()).thenReturn(htDataBaseMaintenance); - - - IEsConfig esConfig = mock(IEsConfig.class); - when(iEntityDataProvider.getEsConfig()).thenReturn(esConfig); - - - deviceManager.setDataBroker(dataBroker); - deviceManager.setRpcProviderRegistry(rpcProviderRegistry); - deviceManager.setNotificationPublishService(notificationPublishService); - deviceManager.setMountPointService(mountPointService); - deviceManager.setClusterSingletonService(clusterSingletonService); - deviceManager.setNetconfNodeStateService(netconfNodeStateService); - deviceManager.setWebsocketmanagerService(websocketmanagerService); - deviceManager.setEntityDataProvider(iEntityDataProvider); - - deviceManager.init(); - - apiService = rpcProviderRegistry.getDeviceManagerApiService(); - - } - - - @Test - public void testInit() { - assertTrue(deviceManager.isDevicemanagerInitializationOk()); - } - - @Test - public void testMapping() { - - } - - @Test - public void testChangeNotification() { - NotificationService n = deviceManager.getNotificationService(); - - n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); - - n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", - "AtrributeTest1", "NewTest1"); - - n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1"); - - } - - @Test - public void testFaultNotification() { - log.info("testFaultNotification"); - - MaintenanceBuilder mb = new MaintenanceBuilder(); - when(htDataBaseMaintenance.getMaintenance("")).thenReturn(mb.build()); - - FaultService n = deviceManager.getFaultService(); - FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder(); - n.faultNotification(faultLogEntityBuilder.setNodeId("node1").setSeverity(SeverityType.Critical) - .setTimestamp(NetconfTimeStampImpl.getTestpatternDateAndTime()).build()); - - } - - @Test - public void testGet() { - log.info("testGet"); - GetRequiredNetworkElementKeysInputBuilder inputBuilder = new GetRequiredNetworkElementKeysInputBuilder(); - apiService.getRequiredNetworkElementKeys(inputBuilder.build()); - - } - - @Test - public void testShow() { - log.info("testShow"); - ShowRequiredNetworkElementInputBuilder inputBuilder = new ShowRequiredNetworkElementInputBuilder(); - inputBuilder.setMountpointName("test"); - apiService.showRequiredNetworkElement(inputBuilder.build()); - - } - - @Test - public void testResync() { - log.info("testResync"); - - ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder(); - inputBuilder.setNodenames(Arrays.asList("test1", "test2")); - apiService.clearCurrentFaultByNodename(inputBuilder.build()); - - } - - @Test - public void testPushFault() { - log.info("testPushFault"); - - PushFaultNotificationInputBuilder inputBuilder = new PushFaultNotificationInputBuilder(); - inputBuilder.setNodeId("NodeTest23"); - inputBuilder.setTimestamp(new DateAndTime("2020-01-01T01:02:03.4Z")); - apiService.pushFaultNotification(inputBuilder.build()); - - } - - @Test - public void testPushChange() { - log.info("testPushChange"); - - PushAttributeChangeNotificationInputBuilder inputBuilder = new PushAttributeChangeNotificationInputBuilder(); - inputBuilder.setNodeId("NodeTest24"); - apiService.pushAttributeChangeNotification(inputBuilder.build()); - - } - - - @AfterClass - public static void after() { - deviceManager.close(); - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java deleted file mode 100644 index 094be8221..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import java.time.ZonedDateTime; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceCalculator; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceBuilder; - -public class TestMaintenanceTimeFilter { - - private static String DEFAULT1 = - "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=1970-01-01T00:00Z[UTC], definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; - private static String DEFAULT2 = - "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]"; - - @Test - public void testBasic() { - - boolean res; - - DateAndTime start = new DateAndTime("2018-01-01T10:00:00+05:00"); - DateAndTime end = new DateAndTime("2019-01-01T10:00:00+05:00"); - ZonedDateTime now; - - now = ZonedDateTime.parse("2017-05-01T10:00:00+05:00"); - res = MaintenanceCalculator.isInPeriod(start, end, now); - System.out.println("Before: " + res); - assertFalse("before period", res); - - now = ZonedDateTime.parse("2018-05-01T10:00:00+05:00"); - res = MaintenanceCalculator.isInPeriod(start, end, now); - System.out.println("Within: " + res); - assertTrue("within period", res); - - now = ZonedDateTime.parse("2019-05-01T10:00:00+05:00"); - res = MaintenanceCalculator.isInPeriod(start, end, now); - System.out.println("After: " + res); - assertFalse("after period", res); - - } - - @Test - public void testBasic2() { - - MaintenanceBuilder mb = new MaintenanceBuilder(); - - mb.setActive(true); - mb.setStart(new DateAndTime("1999-01-01T00:00:00Z")); - mb.setEnd(new DateAndTime("2001-01-01T00:00:00Z")); - mb.setId("id1"); - mb.setObjectIdRef("Interface1"); - mb.setProblem("Problem1"); - - boolean res; - ZonedDateTime now; - - now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z"); - res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "Interface1", "Problem1", now); - assertTrue("within period", res); - - now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z"); - res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now); - assertFalse("outside period", res); - - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java deleted file mode 100644 index bee1acaa4..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertEquals; -import java.net.URISyntaxException; -import org.junit.Test; -import org.opendaylight.yangtools.yang.common.QName; - -public class TestNameSpace { - - private static final String QNAME_COREMODEL_NAMESPACE = "urn:onf:params:xml:ns:yang:core-model"; - private static final QName QNAME_COREMODEL = - QName.create(QNAME_COREMODEL_NAMESPACE, "2017-03-20", "core-model").intern(); - - @Test - public void test() throws URISyntaxException { - - QName qname = QName.create("(urn:o-ran:hardware:1.0?revision=2019-03-28)o-ran-hardware"); - - System.out.println("QName getNamespace" + qname.getNamespace()); - assertEquals(qname.getNamespace().toString(), "urn:o-ran:hardware:1.0"); - - System.out.println("QName getRevision" + qname.getRevision()); - assertEquals(qname.getRevision().get().toString(), "2019-03-28"); - - System.out.println(QNAME_COREMODEL.getNamespace().toString()); - assertEquals(QNAME_COREMODEL.getNamespace().toString(), QNAME_COREMODEL_NAMESPACE); - - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java deleted file mode 100644 index 71f5a1d96..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationWithServerTimeStamp; - -public class TestToggleAlarmFilter { - - @Test - public void testNotification() { - - NotificationWithServerTimeStamp<Integer> test = new NotificationWithServerTimeStamp<>(1000); - - test.refresh(1000); - test.getStartTime(); - - System.out.println(test); - - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java deleted file mode 100644 index 1ff8efafb..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestVESCollectorClient.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import com.google.common.io.Files; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import org.junit.After; -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESMessage; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.vescollectorconnector.impl.VESCollectorServiceImpl; - -public class TestVESCollectorClient { - - private static final String TESTCONFIG_CONTENT_NO_AUTH = "[VESCollector]\n" + "VES_COLLECTOR_IP=127.0.0.1\n" - + "VES_COLLECTOR_PORT=8080\n" + "VES_COLLECTOR_TLS_ENABLED=false\n" + "VES_COLLECTOR_USERNAME=sample1\n" - + "VES_COLLECTOR_PASSWORD=sample1\n" + "VES_COLLECTOR_VERSION=v7\n" + "REPORTING_ENTITY_NAME=ONAP SDN-R\n" + ""; - - private static final String TESTCONFIG_CONTENT_AUTH = "[VESCollector]\n" + "VES_COLLECTOR_IP=127.0.0.1\n" - + "VES_COLLECTOR_PORT=8080\n" + "VES_COLLECTOR_TLS_ENABLED=true\n" + "VES_COLLECTOR_USERNAME=sample1\n" - + "VES_COLLECTOR_PASSWORD=sample1\n" + "VES_COLLECTOR_VERSION=v7\n" + "REPORTING_ENTITY_NAME=ONAP SDN-R\n" + ""; - - private static final VESMessage message = new VESMessage("Test Message"); - private static final String CONFIG_FILE = "test.properties"; - - @Test - public void testNoAuth() throws Exception { - ConfigurationFileRepresentation vesCfg; - VESCollectorServiceImpl vesClient; - - Files.asCharSink(new File(CONFIG_FILE), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_NO_AUTH); - vesCfg = new ConfigurationFileRepresentation(CONFIG_FILE); - vesClient = new VESCollectorServiceImpl(vesCfg); - - vesClient.publishVESMessage(message); - vesClient.close(); - - } - - @Test - public void testAuth() throws Exception { - ConfigurationFileRepresentation vesCfg; - VESCollectorServiceImpl vesClient; - - Files.asCharSink(new File("test.properties"), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_AUTH); - vesCfg = new ConfigurationFileRepresentation("test.properties"); - - vesClient = new VESCollectorServiceImpl(vesCfg); - vesClient.publishVESMessage(message); - vesClient.close(); - } - - @After - public void after() throws InterruptedException, IOException { - - delete(new File(CONFIG_FILE)); - - } - - private static void delete(File f) throws IOException { - if (f.isDirectory()) { - for (File c : f.listFiles()) { - delete(c); - } - } - if (!f.delete()) { - throw new FileNotFoundException("Failed to delete file: " + f); - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java deleted file mode 100644 index 579f90069..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; - -import static org.junit.Assert.assertTrue; - -import java.util.Date; - -import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util.NetconfTimeStampOld; - -public class TestsNectconfDateTime { - - private static String[] testPatterPostive = {"2017-01-18T11:44:49.482-0500", "2017-01-18T11:44:49.482-05:00", - "20170118114449.123Z", "20170118114449.1Z", "20170118114449.1-0500", "2017-01-23T13:32:38-05:00", - "2017-01-23T13:32-05:00", "2017-01-18T11:44:49Z"}; - private static String[] testPatterProblem = {"2017-01-18T11:44:4" - //"2017-01-18T11:44:49" Excluded Test Ok in J8 and false in J11 .. impact low .. so excluded. - }; - - - private final static NetconfTimeStampOld netconfTimeConverterOld = NetconfTimeStampOld.getConverter(); - private final static NetconfTimeStamp netconfTimeConverterNew = NetconfTimeStampImpl.getConverter(); - - @Test - public void test1() { - - int t = 1; - String timeNew, timeOld; - for (String testTime : testPatterPostive) { - timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime); - timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime); - - System.out.println("No " + t++ + " Pattern: " + testTime); - System.out.println(" to old " + timeOld); - System.out.println(" to new " + timeNew); - System.out.println(); - - assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); - } - - for (String testTime : testPatterProblem) { - timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime); - timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime); - - System.out.println("No " + t++ + " Pattern: " + testTime); - System.out.println(" to old " + timeOld); - System.out.println(" to new " + timeNew); - System.out.println(); - assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); - } - } - - @Test - public void test2() { - - int t = 1; - Long timeNew, timeOld; - for (String testTime : testPatterPostive) { - timeNew = netconfTimeConverterNew.getTimeStampFromNetconfAsMilliseconds(testTime); - timeOld = netconfTimeConverterOld.getTimeStampFromNetconfAsMilliseconds(testTime); - - System.out.println("No " + t++ + " Pattern: " + testTime); - System.out.println(" to old " + timeOld); - System.out.println(" to new " + timeNew); - System.out.println(); - - assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); - } - - } - - - @Test - public void test3() { - - Date now = new Date(); - String timeNew = netconfTimeConverterNew.getTimeStampAsNetconfString(now); - String timeOld = netconfTimeConverterOld.getTimeStampAsNetconfString(now); - - System.out.println("Old/New: " + timeOld + "/" + timeNew); - - assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew)); - - - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java deleted file mode 100644 index 14484d08b..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk feature sdnr wt - * ================================================================================ - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; - -import java.util.Set; -import org.opendaylight.mdsal.binding.api.RpcProviderService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService; -import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.RpcService; - -public class RpcProviderServiceMock implements RpcProviderService { - - private DevicemanagerService deviceManagerApi; - - @Override - public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, - T implementation) { - System.out.println("Register class " + implementation); - if (implementation instanceof DevicemanagerService) { - deviceManagerApi = (DevicemanagerService) implementation; - } - return null; - } - - @Override - public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type, - T implementation, Set<InstanceIdentifier<?>> paths) { - return null; - } - - public DevicemanagerService getDeviceManagerApiService() { - return deviceManagerApi; - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java deleted file mode 100644 index 104ad0364..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved. - * ================================================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * ============LICENSE_END========================================================================== - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Function is handling the NETCONF and the format used by database and restconf communication. - * - * Input supported for the formats used in NETCONF messages: - * - * Format1 ISO 8601 2017-01-18T11:44:49.482-05:00 - * - * Format2 NETCONF - pattern from ietf-yang-types "2013-07-15" Pattern: - * "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-](\d{2}):(\d{2}))" - * - * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom 2016-07-01 Example1: 20170118114449.1Z - * Example2: 20170118114449.1-0500 Pattern: "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef - * DateAndTime { description "This primitive type defines the date and time according to the following structure: - * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31' day hh '00'..'23' - * hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second (set to '.0' if EMS or NE cannot support - * this granularity) Z 'Z' indicates UTC (rather than local time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time - * zone difference in hours Mm '00'..'59' time zone difference in minutes."; type string; } Format4 E/// specific - * Example1: 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00 - * - * Input formats netconfTime as String according the formats given above - * - * Return format is String in ISO8601 Format for database and presentation. - * - * Example formats: 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00 2) Microwave ONF. Examples 20170118114449.1Z, - * 20170118114449.1-0500 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00 3.2) Ericson. Example: 2017-01-23T13:32-05:00 - * Always 10 Groups, 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset - * signedhour 10:min - * - * Template: private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter(); - */ - -public class NetconfTimeStampOld { - private static final Logger LOG = LoggerFactory.getLogger(NetconfTimeStampOld.class); - - private static final NetconfTimeStampOld CONVERTER = new NetconfTimeStampOld(); - - private final SimpleDateFormat dateFormatResult = init("yyyy-MM-dd'T'HH:mm:ss.S'Z'", TimeZone.getTimeZone("GMT")); - private final SimpleDateFormat dateFormatConvert = init("yyyy-MM-dd HH:mm:ss.S", TimeZone.getTimeZone("GMT")); - private static int MILLISECONDSDIGITS = 3; // Digits of milliseconds in dateFormatResult - private static String MILLISECONDZEROS = "000"; // String with zeros for milliseconds in dateFormatResult - private static final Pattern dateNetconfPatter = Pattern.compile( - "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))"); - - /* - * ------------------------------------ Public function - */ - - /** - * Use static access - */ - private NetconfTimeStampOld() {} - - /** - * Use this function to get the converter - * - * @return global converter - */ - public static NetconfTimeStampOld getConverter() { - return CONVERTER; - } - - /** - * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format - * - * @return String with Date in NETCONF/YANG Format Version 1.0. - */ - public String getTimeStampAsNetconfString() { - return this.getRightFormattedDate(new Date().getTime()); - } - - /** - * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format - * - * @return String with Date in NETCONF/YANG Format Version 1.0. - */ - public String getTimeStampAsNetconfString(Date date) { - return getRightFormattedDate(date.getTime()); - } - - /** - * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * - * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. - */ - public DateAndTime getTimeStamp() { - return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString()); - } - - /** - * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT - * - * @param date specifying the date and time - * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0. - */ - public DateAndTime getTimeStamp(Date date) { - return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString(date)); - } - - - /** - * Return the String with a NETCONF time converted to long - * - * @param netconfTime as String according the formats given above - * @return Epoch milliseconds - * @throws IllegalArgumentException In case of no compliant time format definition for the string - * @throws ParseException Time parsing failed - */ - public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException { - Matcher m = dateNetconfPatter.matcher(netconfTime); - // According to specified matches there have to be 10 parameter - if (m.matches() && m.groupCount() == 10) { - // Convert now - synchronized (dateFormatConvert) { - long utcMillis; - try { - utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return utcMillis; - } catch (ParseException e) { - throw new IllegalArgumentException("Parse problem for NETCONF data string: " + netconfTime); - } - } - } else { - throw new IllegalArgumentException("No pattern for NETCONF data string: " + netconfTime); - } - } - - /** - * Deliver String result. - * - * @param netconfTime as String according the formats given above - * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed input" the Input - * string with the prefix "Mailformed date" is delivered back. - */ - public String getTimeStampFromNetconf(String netconfTime) { - Matcher m = dateNetconfPatter.matcher(netconfTime); - // According to spezified matches there have to be 10 parameter - if (m.matches() && m.groupCount() == 10) { - // Convert now - try { - synchronized (dateFormatConvert) { - long utcMillis = - dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime() - - getTimezoneOffsetMilliseconds(m.group(9), m.group(10)); - return getRightFormattedDate(utcMillis); - } - } catch (ParseException e) { - LOG.info(e.getMessage()); - } catch (IllegalArgumentException e) { - LOG.info(e.getMessage()); - } - } - LOG.debug("No pattern for NETCONF data string: {}", netconfTime); - return "Malformed date: " + netconfTime; // Error handling - } - - /*------------------------------------------- - * Private and static functions - */ - /** - * Convert timeZone parameter in format [+-]/d/d:/d/d into milliseconds - * - * @param m Index 9 with "+/-" and hour string or null for UTZ, Index 10 with minutes - * @return long milliseconds of TimeZoneOffset - * @throws IllegalArgumentException If parameters are wrong - */ - private static long getTimezoneOffsetMilliseconds(String timeZoneHour, String timeZoneMinute) - throws IllegalArgumentException { - // -- Calculate timezone specific offset - long timeZoneOffsetMilliseconds = 0; - if (timeZoneHour != null) { - // Time zone offset in hours and minutes - int tzHour = 0; - int tzMinutes = 0; - tzHour = Integer.valueOf(timeZoneHour); - if (timeZoneMinute != null) { - tzMinutes = Integer.valueOf(timeZoneMinute); - } else { - throw new IllegalArgumentException("Problem in Netconf Time format timeZone minutes parameter."); - } - timeZoneOffsetMilliseconds = (tzHour * 60 + (tzHour > 0 ? tzMinutes : -tzMinutes)) * 60000L; - } - return timeZoneOffsetMilliseconds; - } - - /** - * Convert parameters to String with year .. minutes and optional Seconds and .. milliseconds - * - * @param m Matcher with parsed date - * @param secString Seconds as String or null - * @param msString Milliseconds as String or null - * @return Normalized time string - */ - private static String getTimeAsNormalizedString(Matcher m, String secString, String msString) { - // -- Create time as normalized string - StringBuffer sb = new StringBuffer(); - sb.append(m.group(1)); // year - sb.append('-'); - sb.append(m.group(2)); // Month - sb.append('-'); - sb.append(m.group(3)); // Day - sb.append(' '); - sb.append(m.group(4)); // Hour 0-23 - sb.append(':'); - sb.append(m.group(5)); // Minute - sb.append(':'); - sb.append(secString != null ? secString : "00"); // Seconds (optional) - sb.append('.'); - if (msString == null) { // Milliseconds optional - sb.append(MILLISECONDZEROS); - } else if (msString.length() <= MILLISECONDSDIGITS) { - sb.append(msString); // Millisecond - sb.append(MILLISECONDZEROS.substring(0, MILLISECONDSDIGITS - msString.length())); - } else { - sb.append(msString.substring(0, MILLISECONDSDIGITS)); // Only first Three - } - return sb.toString(); - } - - /** - * Deliver format in a way that milliseconds are correct. - * - * @param dateMillis Date as milliseconds in Java definition - * @return String - */ - private String getRightFormattedDate(long dateMillis) { - long tenthOfSeconds = dateMillis % 1000 / 100L; // Extract 100 milliseconds - long base = dateMillis / 1000L * 1000L; // Cut milliseconds to 000 - Date newDate = new Date(base + tenthOfSeconds); - synchronized (dateFormatResult) { - return dateFormatResult.format(newDate); - } - } - - /** - * Static initialization - */ - private static SimpleDateFormat init(String format, TimeZone zone) { - if (zone == null) { - throw new ExceptionInInitializerError(); - } else { - SimpleDateFormat dateFormat; - dateFormat = new SimpleDateFormat(format); - dateFormat.setTimeZone(zone); - return dateFormat; - } - } - - - -} diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/aaiclient.properties b/sdnr/wt/devicemanager/provider/src/test/resources/aaiclient.properties deleted file mode 100644 index 3e4da05b0..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/resources/aaiclient.properties +++ /dev/null @@ -1,165 +0,0 @@ -###
-
-# ============LICENSE_START=======================================================
-
-# openECOMP : SDN-C
-
-# ================================================================================
-
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
-
-# reserved.
-
-# ================================================================================
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-
-# you may not use this file except in compliance with the License.
-
-# You may obtain a copy of the License at
-
-#
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-#
-
-# Unless required by applicable law or agreed to in writing, software
-
-# distributed under the License is distributed on an "AS IS" BASIS,
-
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
-# See the License for the specific language governing permissions and
-
-# limitations under the License.
-
-# ============LICENSE_END=========================================================
-
-###
-
-
-
-#
-
-# Configuration file for A&AI Client
-
-#
-
-
-
-#
-
-# Certificate keystore and truststore
-
-#
-
-org.onap.ccsdk.sli.adaptors.aai.ssl.trust=/opt/logs/externals/data/stores/truststore.client.jks
-
-org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=adminadmin
-
-
-
-org.onap.ccsdk.sli.adaptors.aai.ssl.key=/opt/logs/externals/data/stores/keystore.client.p12
-
-org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=adminadmin
-
-org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=true
-
-
-
-org.onap.ccsdk.sli.adaptors.aai.application=SDNC
-
-
-
-#org.onap.ccsdk.sli.adaptors.aai.uri=https://aai-int1.test.att.com:8443
-
-org.onap.ccsdk.sli.adaptors.aai.uri=https://aai-pwt3.ecomp.cci.att.com:8443
-
-
-
-connection.timeout=60000
-
-read.timeout=60000
-
-
-
-# query
-
-org.onap.ccsdk.sli.adaptors.aai.path.query=/aai/v13/search/sdn-zone-query
-
-org.onap.ccsdk.sli.adaptors.aai.query.nodes=/aai/v13/search/nodes-query?search-node-type={node-type}&filter={entity-identifier}:EQUALS:{entity-name}
-
-org.onap.ccsdk.sli.adaptors.aai.query.generic=/aai/v13/search/generic-query?key={identifier}:{value}&start-node-type={start-node-type}&include=complex&depth=3
-
-
-
-# named query
-
-org.onap.ccsdk.sli.adaptors.aai.query.named=/aai/search/named-query
-
-
-
-#update
-
-org.onap.ccsdk.sli.adaptors.aai.update=/aai/v13/actions/update
-
-
-
-# UBB Notify
-
-org.onap.ccsdk.sli.adaptors.aai.path.notify=/aai/v13/actions/notify
-
-org.onap.ccsdk.sli.adaptors.aai.notify.selflink.fqdn=/restconf/config/L3SDN-API:services/layer3-service-list/{service-instance-id}
-
-org.onap.ccsdk.sli.adaptors.aai.notify.selflink.avpn=/restconf/config/L3AVPN-EVC-API:services/service-list/{service-instance-id}/service-data/avpn-logicalchannel-information
-
-
-
-# P-Interfaces
-
-org.onap.ccsdk.sli.adaptors.aai.path.pserver.pinterfaces=/aai/v13/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces
-
-org.onap.ccsdk.sli.adaptors.aai.path.pserver.pinterface=/aai/v13/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces/p-interface/{interface-name}
-
-
-
-# VNF IMAGES
-
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.images=/aai/v13/service-design-and-creation/vnf-images
-
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image=/aai/v13/service-design-and-creation/vnf-images/vnf-image/{att-uuid}
-
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image.query=/aai/v13/service-design-and-creation/vnf-images/vnf-image?application={application_model}&application-vendor={application_vendor}
-
-
-
-# service instance
-
-org.onap.ccsdk.sli.adaptors.aai.path.svcinst.query=/aai/v13/search/generic-query?key=service-instance.service-instance-id:{svc-instance-id}&start-node-type=service-instance&include=service-instance
-
-org.onap.ccsdk.sli.adaptors.aai.path.service.instance=/aai/v13/business/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{service-instance-id}
-
-
-
-# VNF IMAGES QUERY
-
-org.onap.ccsdk.sli.adaptors.aai.path.vnf.image.query=/aai/v13/service-design-and-creation/vnf-images/vnf-image?application={application_model}&application-vendor={application_vendor}
-
-
-
-#
-
-# Formatting
-
-#
-
-org.onap.ccsdk.sli.adaptors.aai.param.format=filter=%s:%s
-
-org.onap.ccsdk.sli.adaptors.aai.param.vnf_type=vnf-type
-
-org.onap.ccsdk.sli.adaptors.aai.param.physical.location.id=physical-location-id
-
-org.onap.ccsdk.sli.adaptors.aai.param.service.type=service-type
-
-
\ No newline at end of file diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/captured-akka.conf b/sdnr/wt/devicemanager/provider/src/test/resources/captured-akka.conf deleted file mode 100644 index 8489f0905..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/resources/captured-akka.conf +++ /dev/null @@ -1,72 +0,0 @@ - -odl-cluster-data { - - akka { - loglevel = "" - remote { - netty.tcp { - hostname = "zltcdyh1arbc02.2f0377.dyh1a.tci.att.com" - port = 2550 - } - } - actor { - debug{ - autoreceive = on - lifecycle = on - unhandled = on - fsm = on - event-stream = on - } - } - cluster { - seed-nodes = ["akka.tcp://opendaylight-cluster-data@zltcdyh1arbc01.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1arbc02.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1arbc03.2f0377.dyh1a.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc01.f84e7a.dyh1b.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc02.f84e7a.dyh1b.tci.att.com:2550", "akka.tcp://opendaylight-cluster-data@zltcdyh1brbc03.f84e7a.dyh1b.tci.att.com:2550"] - seed-node-timeout = 15s - roles = ["member-2"] - - } - persistence { - journal-plugin-fallback { - circuit-breaker { - max-failures = 10 - call-timeout = 60s - reset-timeout = 30s - } - } - } - } -} - -odl-cluster-rpc { - - akka { - loglevel = "" - remote { - netty.tcp { - hostname = "zltcdyh1arbc02.2f0377.dyh1a.tci.att.com" - port = 2551 - } - } - actor { - debug{ - autoreceive = on - lifecycle = on - unhandled = on - fsm = on - event-stream = on - } - } - cluster { - seed-nodes = ["akka.tcp://odl-cluster-rpc@zltcdyh1arbc01.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1arbc02.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1arbc03.2f0377.dyh1a.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc01.f84e7a.dyh1b.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc02.f84e7a.dyh1b.tci.att.com:2551", "akka.tcp://odl-cluster-rpc@zltcdyh1brbc03.f84e7a.dyh1b.tci.att.com:2551"] - seed-node-timeout = 15s - } - persistence { - journal-plugin-fallback { - circuit-breaker { - max-failures = 10 - call-timeout = 60s - reset-timeout = 30s - } - } - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/mediator-server.json b/sdnr/wt/devicemanager/provider/src/test/resources/mediator-server.json deleted file mode 100644 index c7db70121..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/resources/mediator-server.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "uri":"/mwtn/mediator-server/_query", - "method":"DELETE", - "body":{"query":{"match_all":{}}} - }, - - { - "uri":"/mwtn/mediator-server/1", - "method":"POST", - "body":{ - "id": 1, - "name": "internal mediatorserver", - "url": "http://192.168.178.89:7070" - - } - } -] diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties deleted file mode 100644 index 1c2f131c5..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties +++ /dev/null @@ -1,61 +0,0 @@ -# -# ============LICENSE_START======================================================= -# ONAP : ccsdk features -# ================================================================================ -# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END======================================================= -# -# - -# SLF4J's SimpleLogger configuration file -# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. - -# Default logging detail level for all instances of SimpleLogger. -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, defaults to "info". -org.slf4j.simpleLogger.defaultLogLevel=debug - -# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz". -# Must be one of ("trace", "debug", "info", "warn", or "error"). -# If not specified, the default logging detail level is used. -# org.slf4j.simpleLogger.log.xxx.yyy=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.test=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.database=debug -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources=info -org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container=info - -# Set to true if you want the current date and time to be included in output messages. -# Default is false, and will output the number of milliseconds elapsed since startup. -#org.slf4j.simpleLogger.showDateTime=false - -# The date and time format to be used in the output messages. -# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. -# If the format is not specified or is invalid, the default format is used. -# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. -#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z - -# Set to true if you want to output the current thread name. -# Defaults to true. -#org.slf4j.simpleLogger.showThreadName=true - -# Set to true if you want the Logger instance name to be included in output messages. -# Defaults to true. -#org.slf4j.simpleLogger.showLogName=true - -# Set to true if you want the last component of the name to be included in output messages. -# Defaults to false. -#org.slf4j.simpleLogger.showShortLogName=false diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/test.properties b/sdnr/wt/devicemanager/provider/src/test/resources/test.properties deleted file mode 100644 index 9290a88ba..000000000 --- a/sdnr/wt/devicemanager/provider/src/test/resources/test.properties +++ /dev/null @@ -1,76 +0,0 @@ -# -# ============LICENSE_START======================================================= -# ONAP : ccsdk features -# ================================================================================ -# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END======================================================= -# -# - -[dcae] -dcaeUserCredentials=admin:admin -dcaeUrl=off -dcaeHeartbeatPeriodSeconds=120 -dcaeTestCollector=no - -[aots] -userPassword=passwd -soapurladd=off -soapaddtimeout=10 -soapinqtimeout=20 -userName=user -inqtemplate=inqreq.tmpl.xml -assignedto=userid -addtemplate=addreq.tmpl.xml -severitypassthrough=critical,major,minor,warning -systemuser=user -prt-offset=1200 -soapurlinq=off -#smtpHost= -#smtpPort= -#smtpUsername= -#smtpPassword= -#smtpSender= -#smtpReceivers= - -[es] -esCluster=sendateodl5 -#time limit to keep increasing data in database [in seconds] -#60*60*24*30 (30days) -esArchiveLimit=2592000 -#folder where removed data will be stored -esArchiveFolder=./backup -#interval to archive database [in seconds] -#60*60*24 (1day) -esArchiveInterval=86400 - -[aai] -#keep comment -aaiHeaders=["X-TransactionId: 9999"] -aaiUrl=http://localhost:81 -aaiUserCredentials=AAI:AAI -aaiDeleteOnMountpointRemove=false -aaiTrustAllCerts=false -aaiApiVersion=aai/v13 -aaiPropertiesFile=aaiclient.properties -aaiApplicationId=SDNR -aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12 -aaiPcks12ClientCertPassphrase=adminadmin -aaiClientConnectionTimeout=30000 - -[pm] -pmCluster=sendateodl5 -pmEnabled=true - |