summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main/test
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main/test')
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/AaiTest.java59
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/AkkaConfigTest.java194
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/ClusterConfigTest.java48
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/ConfigTest.java82
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/ESWebAPITest.java37
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/GeoConfigTest.java100
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/ResTest.java76
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/TestFileChangeNotification.java147
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/UntilTest.java38
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/ZonedDateTimeTimesTest.java54
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/test/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/DBPluginExtractTest.java28
11 files changed, 863 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/AaiTest.java b/sdnr/wt/devicemanager/provider/src/main/test/AaiTest.java
new file mode 100644
index 000000000..397239eb6
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/AaiTest.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiConnector.impl.AaiProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.HtDevicemanagerConfiguration;
+
+public class AaiTest {
+
+ public static void main(String[] args)
+ {
+ HtDevicemanagerConfiguration cfg=HtDevicemanagerConfiguration.getTestConfiguration();
+
+ 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");
+ InventoryInformation ii=new InventoryInformation(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName,ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/AkkaConfigTest.java b/sdnr/wt/devicemanager/provider/src/main/test/AkkaConfigTest.java
new file mode 100644
index 000000000..40a19101f
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/AkkaConfigTest.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig.ClusterNodeInfo;
+
+public class AkkaConfigTest {
+
+ private static String getAkkaConfigSingleNodeText()
+ {
+return "\n" +
+ "odl-cluster-data {\n" +
+ " akka {\n" +
+ " remote {\n" +
+ " artery {\n" +
+ " enabled = off\n" +
+ " canonical.hostname = \"127.0.0.1\"\n" +
+ " canonical.port = 2550\n" +
+ " }\n" +
+ " netty.tcp {\n" +
+ " hostname = \"127.0.0.1\"\n" +
+ " port = 2550\n" +
+ " }\n" +
+ " # when under load we might trip a false positive on the failure detector\n" +
+ " # transport-failure-detector {\n" +
+ " # heartbeat-interval = 4 s\n" +
+ " # acceptable-heartbeat-pause = 16s\n" +
+ " # }\n" +
+ " }\n" +
+ "\n" +
+ " cluster {\n" +
+ " # Remove \".tcp\" when using artery.\n" +
+ " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" +
+ "\n" +
+ " roles = [\n" +
+ " \"member-1\"\n" +
+ " ]\n" +
+ "\n" +
+ " }\n" +
+ "\n" +
+ " persistence {\n" +
+ " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n" +
+ " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n" +
+ " # The relative path is always relative to KARAF_HOME.\n" +
+ "\n" +
+ " # snapshot-store.local.dir = \"target/snapshots\"\n" +
+ " # journal.leveldb.dir = \"target/journal\"\n" +
+ "\n" +
+ " journal {\n" +
+ " leveldb {\n" +
+ " # Set native = off to use a Java-only implementation of leveldb.\n" +
+ " # Note that the Java-only version is not currently considered by Akka to be production quality.\n" +
+ "\n" +
+ " # native = off\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }
+ private static String getAkkaConfigClusterNodeText()
+ {
+ return "\n" +
+ "odl-cluster-data {\n" +
+ "\n" +
+ " akka {\n" +
+ " loglevel = \"\"\n" +
+ " remote {\n" +
+ " netty.tcp {\n" +
+ " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" +
+ " port = 2550\n" +
+ " }\n" +
+ " }\n" +
+ " actor {\n" +
+ " debug{\n" +
+ " autoreceive = on\n" +
+ " lifecycle = on\n" +
+ " unhandled = on\n" +
+ " fsm = on\n" +
+ " event-stream = on\n" +
+ " }\n" +
+ " }\n" +
+ " cluster {\n" +
+ " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2550\"]\n" +
+ " seed-node-timeout = 15s\n" +
+ " roles = [\"member-1\"]\n" +
+ "\n" +
+ " }\n" +
+ " persistence {\n" +
+ " journal-plugin-fallback {\n" +
+ " circuit-breaker {\n" +
+ " max-failures = 10\n" +
+ " call-timeout = 60s\n" +
+ " reset-timeout = 30s\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "odl-cluster-rpc {\n" +
+ "\n" +
+ " akka {\n" +
+ " loglevel = \"\"\n" +
+ " remote {\n" +
+ " netty.tcp {\n" +
+ " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" +
+ " port = 2551\n" +
+ " }\n" +
+ " }\n" +
+ " actor {\n" +
+ " debug{\n" +
+ " autoreceive = on\n" +
+ " lifecycle = on\n" +
+ " unhandled = on\n" +
+ " fsm = on\n" +
+ " event-stream = on\n" +
+ " }\n" +
+ " }\n" +
+ " cluster {\n" +
+ " seed-nodes = [\"akka.tcp://odl-cluster-rpc@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2551\"]\n" +
+ " seed-node-timeout = 15s\n" +
+ " }\n" +
+ " persistence {\n" +
+ " journal-plugin-fallback {\n" +
+ " circuit-breaker {\n" +
+ " max-failures = 10\n" +
+ " call-timeout = 60s\n" +
+ " reset-timeout = 30s\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n" +
+ "\n" +
+ "";
+ }
+ public static void main(String[] args)
+ {
+ AkkaConfig cfg;
+ try {
+ System.out.println("testing clusternode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText());
+ System.out.println("succeeded: ");
+ System.out.println(cfg.toString());
+ System.out.println(String.format("found %d cluster nodes",cfg.getClusterConfig().getSeedNodes().size()));
+ for(ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes())
+ {
+ System.out.println(n.toString());
+ }
+ } catch (Exception e) {
+ System.out.println("failed: "+e.getMessage());
+ }
+ try {
+ System.out.println("testing singlenode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText());
+ System.out.println("succeeded: ");
+ System.out.println(cfg.toString());
+ } catch (Exception e) {
+ System.out.println("failed: "+e.getMessage());
+ }
+ try {
+ System.out.println("testing clusternode config1");
+ System.out.println("===========================");
+ cfg = AkkaConfig.load("/home/herbert/Nextcloud/captured-karaf-logs/akka.conf");
+ System.out.println("succeeded: ");
+ System.out.println(cfg.toString());
+ System.out.println(String.format("found %d cluster nodes",cfg.getClusterConfig().getSeedNodes().size()));
+ for(ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes())
+ {
+ System.out.println(n.toString());
+ }
+ } catch (Exception e) {
+ System.out.println("failed: "+e.getMessage());
+ }
+
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/ClusterConfigTest.java b/sdnr/wt/devicemanager/provider/src/main/test/ClusterConfigTest.java
new file mode 100644
index 000000000..1f2f183fd
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/ClusterConfigTest.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.GeoConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.HtDevicemanagerConfiguration;
+
+public class ClusterConfigTest {
+
+ public static void main(String[] args)
+ {
+ final String geoconf="/home/herbert/Nextcloud/captured-karaf-logs/geo.conf";
+ final String akkconf="/home/herbert/Nextcloud/captured-karaf-logs/akka.conf";
+ final String devmgrprop="";
+
+
+ try {
+ GeoConfig geo = geoconf==null?null:GeoConfig.load(geoconf);
+ AkkaConfig akkaConfig = AkkaConfig.load(akkconf);
+ //HtDevicemanagerConfiguration config = HtDevicemanagerConfiguration.getTestConfiguration(devmgrprop);
+ String hostName = "0.0.0.0";
+ hostName=akkaConfig.getClusterConfig().getHostName(hostName);
+ String clusterDBName=akkaConfig.getClusterConfig().getDBClusterName(null);
+ String nodeName=String.format("node%d.%s",akkaConfig.getClusterConfig().getRoleMemberIndex(),clusterDBName);
+
+ System.out.println("hostname="+hostName);
+ System.out.println("clusterdbName="+clusterDBName);
+ System.out.println("nodename="+nodeName);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/ConfigTest.java b/sdnr/wt/devicemanager/provider/src/main/test/ConfigTest.java
new file mode 100644
index 000000000..48cf2db72
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/ConfigTest.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.PmConfig;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.ToggleAlarmConfig;
+
+public class ConfigTest {
+
+ public static void main(String[] args)
+ {
+ HtDevicemanagerConfiguration config;
+ DcaeConfig c;
+ EsConfig c3;
+ AaiConfig c4;
+ PmConfig c5;
+ ToggleAlarmConfig c6;
+ /*config= = HtDevicemanagerConfiguration.getTestConfiguration();
+ c=config.getDcae();
+ c2=AotsMConfig.getAots(config);
+ c3=config.getEs();
+ c4= config.getAai();
+ c5 = config.getPm();
+ System.out.println(c.toString());
+ System.out.println(c2.toString());
+ System.out.println(c3.toString());
+ System.out.println(c4.toString());
+ System.out.println(c5.toString());
+ IConfigChangedListener listener = new IConfigChangedListener() {
+
+ @Override
+ public void onConfigChanged() {
+ System.out.println("sth changed");
+ AaiConfig c=AaiConfig.reload();
+ System.out.println(c.toString());
+ }
+ };
+ System.out.println("start listening for changes");
+
+ config.registerConfigChangedListener(listener );
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ config.unregisterConfigChangedListener(listener);
+ System.out.println("finished");
+ */
+ HtDevicemanagerConfiguration.clear();
+ config = HtDevicemanagerConfiguration.getTestConfiguration("/home/herbert/tmp/devicemanager.properties");
+ c=config.getDcae();
+ c3=config.getEs();
+ c4 = config.getAai();
+ c5 = config.getPm();
+ c6 = config.getToggleAlarm();
+ System.out.println(c.toString());
+ System.out.println(c3.toString());
+ System.out.println(c4.toString());
+ System.out.println(c5.toString());
+ System.out.println(c6.toString());
+
+
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/ESWebAPITest.java b/sdnr/wt/devicemanager/provider/src/main/test/ESWebAPITest.java
new file mode 100644
index 000000000..9f9962a55
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/ESWebAPITest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import java.io.IOException;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseWebAPIClient;
+
+public class ESWebAPITest {
+
+ public static void main(String[] args)
+ {
+ HtDatabaseWebAPIClient client=new HtDatabaseWebAPIClient();
+ try {
+ String response=client.sendRequest("/mwtn/mediator-server/_search", "GET", new JSONObject("{\"match\":{\"id\":id}}"));
+ System.out.println(response);
+ } catch (JSONException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/GeoConfigTest.java b/sdnr/wt/devicemanager/provider/src/main/test/GeoConfigTest.java
new file mode 100644
index 000000000..36e60e177
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/GeoConfigTest.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.GeoConfig;
+
+public class GeoConfigTest {
+
+
+ private static String getClusterGeoConfigContent()
+ {
+return "\n" +
+ "lumina-geo-cluster {\n" +
+ " primary_roles = [\n" +
+ " \"member-1\",\"member-2\",\"member-3\"\n" +
+ " ]\n" +
+ " secondary_roles = [\n" +
+ " \"member-4\",\"member-5\",\"member-6\"\n" +
+ " ]\n" +
+ " ip_roles_table = [\n" +
+ "\n" +
+ " {\n" +
+ "role=\"member-1\"\n" +
+ "ip=\"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" +
+ "},\n" +
+ "{\n" +
+ "role=\"member-2\"\n" +
+ "ip=\"zltcmtn23arbc02.2f0377.mtn23a.tci.att.com\"\n" +
+ "},\n" +
+ "{\n" +
+ "role=\"member-3\"\n" +
+ "ip=\"zltcmtn23arbc03.2f0377.mtn23a.tci.att.com\"\n" +
+ "},\n" +
+ "{\n" +
+ "role=\"member-4\"\n" +
+ "ip=\"zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com\"\n" +
+ "},\n" +
+ "{\n" +
+ "role=\"member-5\"\n" +
+ "ip=\"zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com\"\n" +
+ "},\n" +
+ "{\n" +
+ "role=\"member-6\"\n" +
+ "ip=\"zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com\"\n" +
+ "}\n" +
+ " \n" +
+ " ]\n" +
+ "}\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "";
+ }
+ public static void main(String[] args)
+ {
+ GeoConfig config;
+ try {
+ System.out.println("testing clusternode geo config1");
+ System.out.println("===========================");
+ config = GeoConfig.parse(getClusterGeoConfigContent());
+ System.out.println("succeeded: ");
+ System.out.println(config.toString());
+ System.out.println("primary roles:");
+ System.out.println(config.getPrimaryRoles().toString());
+ System.out.println("secondary roles:");
+ System.out.println(config.getSecondaryRoles().toString());
+
+ } catch (Exception e) {
+ System.out.println("failed: "+e.getMessage());
+ }
+ try {
+ System.out.println("testing clusternode geo config1");
+ System.out.println("===========================");
+ config = GeoConfig.load("/home/herbert/Nextcloud/captured-karaf-logs/geo.conf");
+ System.out.println("succeeded: ");
+ System.out.println(config.toString());
+ System.out.println("primary roles:");
+ System.out.println(config.getPrimaryRoles().toString());
+ System.out.println("secondary roles:");
+ System.out.println(config.getSecondaryRoles().toString());
+
+ } catch (Exception e) {
+ System.out.println("failed: "+e.getMessage());
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/ResTest.java b/sdnr/wt/devicemanager/provider/src/main/test/ResTest.java
new file mode 100644
index 000000000..17e8d3076
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/ResTest.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import java.io.IOException;
+import java.util.List;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources;
+
+public class ResTest {
+
+ private static void testDuplicateKeyJSON()
+ {
+ try
+ {
+ String str=Resources.getFileContent("/elasticsearch/index/mwtn/modelDescription/CoreModel-ForMicrowave.json");
+
+ JSONObject o=new JSONObject(str) {
+
+ @Override
+ public JSONObject putOnce(String key, Object value) throws JSONException {
+
+
+ Object storedValue;
+ if (key != null && value != null) {
+ if ((storedValue = this.opt(key)) != null ) {
+ if(!storedValue.equals(value)) { //Only through Exception for different values with same key
+ //Replace
+ System.out.println("duplicate found");
+ this.remove(key);
+ this.put(key, value);
+
+ } else {
+ return this;
+ }
+ } else {
+ this.put(key, value);
+ }
+ }
+ return this;
+ }
+ };
+ System.out.println(o.toString());
+ }
+ catch(IOException err)
+ {
+ err.printStackTrace();
+ }
+ }
+ public static void main(String[] args)
+ {
+ JSONObject o=Resources.getJSONFile("/elasticsearch/index/sdnevents/sdneventsMapping.json");
+ System.out.println(o==null?"null":o.toString());
+
+ List<JSONObject> list=Resources.getJSONFiles("/elasticsearch/index", true);
+ System.out.println("found "+list.size()+" valid json files");
+
+ testDuplicateKeyJSON();
+
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/TestFileChangeNotification.java b/sdnr/wt/devicemanager/provider/src/main/test/TestFileChangeNotification.java
new file mode 100644
index 000000000..812ce4770
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/TestFileChangeNotification.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import java.io.File;
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class TestFileChangeNotification {
+ /**
+ * Check every now and then that a certain file has not changed. If it has, then
+ * call the {@link #doOnChange} method.
+ *
+ * @author JunHo Yoon
+ * @since 3.1.1
+ */
+ public static abstract class FileWatchdog extends Thread {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileWatchdog.class);
+ /**
+ * The default delay between every file modification check, set to 60
+ * seconds.
+ */
+ public static final long DEFAULT_DELAY = 60000;
+ /**
+ * The name of the file to observe for changes.
+ */
+ private String filename;
+
+ /**
+ * The delay to observe between every check. By default set
+ * {@link #DEFAULT_DELAY}.
+ */
+ private long delay = DEFAULT_DELAY;
+
+ private File file;
+ private long lastModified = 0;
+ private boolean warnedAlready = false;
+ private boolean interrupted = false;
+
+ protected FileWatchdog(String filename) {
+ this.filename = filename;
+ file = new File(filename);
+ setDaemon(true);
+ checkAndConfigure();
+ }
+
+ /**
+ * Set the delay to observe between each check of the file changes.
+ *
+ * @param delay
+ * the frequency of file watch.
+ */
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ /**
+ * abstract method to be run when the file is changed.
+ */
+ protected abstract void doOnChange();
+
+ protected void checkAndConfigure() {
+ boolean fileExists;
+ try {
+ fileExists = file.exists();
+ } catch (SecurityException e) {
+ LOGGER.warn("Was not allowed to read check file existence, file:[" + filename + "].");
+ interrupted = true; // there is no point in continuing
+ return;
+ }
+
+ if (fileExists) {
+ long l = file.lastModified(); // this can also throw a
+ if (lastModified ==0) {
+ lastModified = l; // is very unlikely.
+ }
+ if (l > lastModified) { // however, if we reached this point this
+ lastModified = l; // is very unlikely.
+ doOnChange();
+ warnedAlready = false;
+ }
+ } else {
+ if (!warnedAlready) {
+ LOGGER.debug("[" + filename + "] does not exist.");
+ warnedAlready = true;
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ while (!interrupted && !isInterrupted()) {
+ try {
+ Thread.sleep(delay);
+ } catch (InterruptedException e) {
+ }
+ checkAndConfigure();
+ }
+ }
+ }
+
+ public static class SomeWatchFile extends FileWatchdog{
+
+ protected SomeWatchFile(String filename) {
+ super(filename);
+ this.setDelay(1000);
+ }
+
+ @Override
+ protected void doOnChange() {
+ System.out.println("File has changed");
+ }
+ }
+
+ public static void main(String args[]) throws IOException {
+ SomeWatchFile someWatchFile = new SomeWatchFile ("watchedFile.txt");
+ someWatchFile.start();
+
+ String fileName = "watchedFile.txt";
+ File tempFile = new File(fileName);
+ tempFile.createNewFile();
+
+ System.out.println("1. Press F5 in eclipse to see and modify 2. Press enter to exit");
+ System.in.read();
+ System.out.println("Remove file "+fileName);
+ tempFile.delete();
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/UntilTest.java b/sdnr/wt/devicemanager/provider/src/main/test/UntilTest.java
new file mode 100644
index 000000000..fdf62c2d6
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/UntilTest.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+public class UntilTest {
+
+ public static void main(String[] args) {
+
+ System.out.println("Test");
+ int retry=0, maxRetries=3;
+ boolean noErrorIndication=false;
+
+ do {
+
+ if (retry > 0)
+ System.out.println("Sleep");
+ noErrorIndication = retry == 0;
+ System.out.println(retry+ " " + noErrorIndication);
+
+ } while (noErrorIndication == false && retry++ < maxRetries);
+
+ System.out.println("Done "+noErrorIndication+" "+retry);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/ZonedDateTimeTimesTest.java b/sdnr/wt/devicemanager/provider/src/main/test/ZonedDateTimeTimesTest.java
new file mode 100644
index 000000000..860a46ba6
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/ZonedDateTimeTimesTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * ============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==========================================================================
+ ******************************************************************************/
+import java.time.ZonedDateTime;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.database.types.EsMaintenanceFilter;
+
+public class ZonedDateTimeTimesTest {
+
+ public static void main(String[] args) {
+
+
+ EsMaintenanceFilter fi = new EsMaintenanceFilter();
+
+ System.out.println("Default 1: "+fi);
+
+
+ fi.setEndAsString("2018-01-01T10:00:00+05:00");
+
+ System.out.println("Default 2: "+fi);
+
+ System.out.println("As String: "+fi.getEndAsString());
+
+
+ ZonedDateTime start = ZonedDateTime.parse("2018-01-01T10:00:00+05:00");
+ ZonedDateTime end = ZonedDateTime.parse("2019-01-01T10:00:00+05:00");
+ ZonedDateTime now;
+
+ now = ZonedDateTime.parse("2017-05-01T10:00:00+05:00");
+ System.out.println("Vor: "+EsMaintenanceFilter.isInPeriod(start, end, now));
+
+ now = ZonedDateTime.parse("2018-05-01T10:00:00+05:00");
+ System.out.println("in: "+EsMaintenanceFilter.isInPeriod(start, end, now));
+
+ now = ZonedDateTime.parse("2019-05-01T10:00:00+05:00");
+ System.out.println("nach: "+EsMaintenanceFilter.isInPeriod(start, end, now));
+
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/test/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/DBPluginExtractTest.java b/sdnr/wt/devicemanager/provider/src/main/test/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/DBPluginExtractTest.java
new file mode 100644
index 000000000..4da7251d2
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/test/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/DBPluginExtractTest.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * ============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.base.database;
+
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
+
+public class DBPluginExtractTest {
+
+ public static void main(String[] args)
+ {
+ HtDatabaseNode.checkorcreateplugins("/home/herbert/test");
+ }
+}