diff options
author | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-02-28 17:10:18 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-02-28 17:10:46 +0100 |
commit | e91c316e653979d96c43fd107895be80b33832fc (patch) | |
tree | 13d40239d4588a5d3eda9467ad7ef112a16ae9d6 /sdnr/wt/devicemanager/provider/src/test/java | |
parent | 49b155ec687cdf58fb51fe8245a2f5f4582b68f0 (diff) |
junit tests devicemanager
test cases added and improved
Change-Id: I3f0a6ca238e61ad140a3086504d4f21792b986e9
Issue-ID: SDNC-672
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test/java')
19 files changed, 458 insertions, 127 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 index 2ce5ec9d3..c01685053 100644 --- 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 @@ -21,7 +21,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; 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; @@ -31,21 +34,19 @@ 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.devicemanager.aaiconnector.impl.AaiProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import com.google.common.io.Files; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig; +@SuppressWarnings("restriction") public class TestAai { 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" + @@ -97,7 +98,7 @@ public class TestAai { ""; private HttpServer server; private ExecutorService httpThreadPool; - private HtDevicemanagerConfiguration cfg; + private HtDevicemanagerConfiguration globalCfg; @Test public void test() { @@ -135,10 +136,9 @@ public class TestAai { try { Thread.sleep(3000); } catch (InterruptedException e1) { - // TODO Auto-generated catch block e1.printStackTrace(); } - AaiProviderClient provider = new AaiProviderClient(cfg, null); + AaiProviderClient provider = new AaiProviderClient(globalCfg, null); String mountPointName = "testDevice 01"; String type="Unit"; @@ -169,16 +169,16 @@ public class TestAai { @Before public void initAaiTestWebserver() throws IOException { try { - Files.asCharSink(new File(ENABLEDAAI_TESTCONFIG_FILENAME), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); } catch (IOException e1) { fail(e1.getMessage()); } - cfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); - cfg.getAai().reload(); + globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true); + AaiConfig.reload(); this.server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0); this.httpThreadPool = Executors.newFixedThreadPool(5); this.server.setExecutor(this.httpThreadPool); - this.server.createContext(cfg.getAai().getBaseUri(), new MyHandler()); + this.server.createContext(globalCfg.getAai().getBaseUri(), new MyHandler()); //server.createContext("/", new MyRootHandler()); this.server.setExecutor(null); // creates a default executor this.server.start(); @@ -192,6 +192,10 @@ public class TestAai { this.httpThreadPool.shutdownNow(); System.out.println("http server stopped" ); } + if (ENABLEDAAI_TESTCONFIG_FILE.exists()) { + ENABLEDAAI_TESTCONFIG_FILE.delete(); + } + } static class MyHandler implements HttpHandler { @Override diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java index a9df83d0c..3d690116d 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import static org.junit.Assert.fail; import java.io.File; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterNodeInfo; @@ -121,7 +122,7 @@ public class TestAkkaConfig { System.out.println("testing clusternode config1"); System.out.println("==========================="); cfg = AkkaConfig.load(file.getAbsolutePath()); - System.out.println("succeeded: "); + System.out.println("succeeded: "+cfg.hashCode()); System.out.println(cfg.toString()); System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size())); for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) { @@ -134,5 +135,10 @@ public class TestAkkaConfig { } } + @Test + public void test4() { + AaiConfig cfg = AaiConfig.getDefaultConfiguration(); + cfg.hashCode(); + } } 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 index 6d7cdd130..1c0a889b4 100644 --- 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 @@ -21,7 +21,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; 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; @@ -31,7 +34,6 @@ 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; @@ -39,17 +41,15 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Internal import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InventoryInformation; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient; import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; -import com.google.common.io.Files; - +@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" + @@ -122,7 +122,7 @@ public class TestDcae { String ipv6="::1"; List<String> ifInfos = new ArrayList<>(); ifInfos.add("LP-MWPS-RADIO"); - InventoryInformation ii=new InventoryInformation(type, model, vendor, ipv4, ipv6, ifInfos); + new InventoryInformation(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()); @@ -142,12 +142,12 @@ public class TestDcae { @Before public void initDcaeTestWebserver() throws IOException { try { - Files.asCharSink(new File(ENABLEDDCAE_TESTCONFIG_FILENAME), StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); + Files.asCharSink(ENABLEDDCAE_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT); } catch (IOException e1) { fail(e1.getMessage()); } cfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDDCAE_TESTCONFIG_FILENAME,true); - cfg.getDcae().reload(); + DcaeConfig.reload(); try { this.server = HttpServer.create(new InetSocketAddress(DCAE_SERVER_PORT), 0); @@ -171,6 +171,9 @@ public class TestDcae { this.httpThreadPool.shutdownNow(); System.out.println("http server stopped" ); } + if (ENABLEDDCAE_TESTCONFIG_FILE.exists()) { + ENABLEDDCAE_TESTCONFIG_FILE.delete(); + } } static class MyHandler implements HttpHandler { @Override 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 index 3a6655d60..74d2d2263 100644 --- 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 @@ -28,6 +28,7 @@ import java.nio.charset.StandardCharsets; import org.junit.After; import org.junit.Before; +import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig; import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.DcaeConfig; @@ -39,42 +40,68 @@ import com.google.common.io.Files; public class TestDevMgrPropertiesFile { - private static final String FILENAME = "test.properties"; - private static final String AAIPROP_FILE="aaiclient.properties"; - protected boolean hasChanged; + private static final File FILENAME = new File("test.properties"); + private static final File AAIPROP_FILE=new File("aaiclient.properties"); + protected int hasChanged; @Before public void init() { - File f=new File(FILENAME); - if(f.exists()) { - f.delete(); - } - f=new File(AAIPROP_FILE); - if(f.exists()) { - f.delete(); - } + delete(FILENAME); + delete(AAIPROP_FILE); } @After public void deinit() { this.init(); } + @Test + public void test1() { + + writeFile(FILENAME, this.getContent1()); + writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); + + System.out.println("Read and verify"); + HtDevicemanagerConfiguration cfg=HtDevicemanagerConfiguration.getTestConfiguration(FILENAME.getPath()); + + assertNotNull(cfg.getAai()); + assertNotNull(cfg.getDcae()); + assertNotNull(cfg.getPm()); + assertNotNull(cfg.getEs()); + assertNotNull(cfg.getToggleAlarm()); + assertTrue(AaiConfig.isInstantiated()); + assertTrue(DcaeConfig.isInstantiated()); + assertTrue(PmConfig.isInstantiated()); + assertTrue(EsConfig.isInstantiated()); + assertTrue(ToggleAlarmConfig.isInstantiated()); + + System.out.println("Verify\n"+cfg.getAai()+"\n"+AaiConfig.getDefaultConfiguration()); + boolean res; + res = cfg.getAai().equals(AaiConfig.getDefaultConfiguration()); + res = cfg.getDcae().equals(DcaeConfig.getDefaultConfiguration()); + res = cfg.getPm().equals(PmConfig.getDefaultConfiguration()); + res = cfg.getEs().equals(EsConfig.getDefaultConfiguration()); + res = cfg.getToggleAlarm().equals(ToggleAlarmConfig.getDefaultConfiguration()); + + res = cfg.getAai().hashCode() == AaiConfig.getDefaultConfiguration().hashCode(); + res = cfg.getDcae().hashCode() == DcaeConfig.getDefaultConfiguration().hashCode(); + res = cfg.getPm().hashCode() == PmConfig.getDefaultConfiguration().hashCode(); + res = cfg.getEs().hashCode() == EsConfig.getDefaultConfiguration().hashCode(); + res = cfg.getToggleAlarm().hashCode() == ToggleAlarmConfig.getDefaultConfiguration().hashCode(); + + } + + //-- Observer not working with all testcases, because config does not support different file types. //@Test - public void test() { - File f=new File(FILENAME); - hasChanged=false; - try { - Files.asCharSink(f, StandardCharsets.UTF_8).write(this.getContent1()); - } catch (IOException e) { - fail(e.getMessage()); - }; - f=new File(AAIPROP_FILE); - try { - Files.asCharSink(f, StandardCharsets.UTF_8).write(this.getAaiPropertiesConfig()); - } catch (IOException e) { - fail(e.getMessage()); - }; - HtDevicemanagerConfiguration cfg=HtDevicemanagerConfiguration.getTestConfiguration(FILENAME); + public void test2() { + + hasChanged=0; + writeFile(FILENAME, this.getContent1()); + writeFile(AAIPROP_FILE, this.getAaiPropertiesConfig()); + + + System.out.println("Read and verify"); + HtDevicemanagerConfiguration cfg=HtDevicemanagerConfiguration.getTestConfiguration(FILENAME.getPath()); + assertNotNull(cfg.getAai()); assertNotNull(cfg.getDcae()); assertNotNull(cfg.getPm()); @@ -86,20 +113,16 @@ public class TestDevMgrPropertiesFile { assertTrue(EsConfig.isInstantiated()); assertTrue(ToggleAlarmConfig.isInstantiated()); + System.out.println("Verify456\n"+cfg.getAai()+"\n"+AaiConfig.getDefaultConfiguration()); + cfg.getAai().equals(AaiConfig.getDefaultConfiguration()); + cfg.getDcae().equals(DcaeConfig.getDefaultConfiguration()); + cfg.getPm().equals(PmConfig.getDefaultConfiguration()); + cfg.getEs().equals(EsConfig.getDefaultConfiguration()); + cfg.getToggleAlarm().equals(ToggleAlarmConfig.getDefaultConfiguration()); - assertFalse(cfg.getAai().equals(AaiConfig.getDefaultConfiguration())); - assertFalse(cfg.getDcae().equals(DcaeConfig.getDefaultConfiguration())); - assertFalse(cfg.getPm().equals(PmConfig.getDefaultConfiguration())); - assertFalse(cfg.getEs().equals(EsConfig.getDefaultConfiguration())); - assertFalse(cfg.getToggleAlarm().equals(ToggleAlarmConfig.getDefaultConfiguration())); - System.out.println(cfg.getAai().toString()); - System.out.println(cfg.getDcae().toString()); - System.out.println(cfg.getPm().toString()); - System.out.println(cfg.getEs().toString()); - System.out.println(cfg.getToggleAlarm().toString()); cfg.registerConfigChangedListener(() -> { - hasChanged=true; - System.out.println("file changed listener triggered"); + hasChanged++; + System.out.println("file changed listener triggered: "+hasChanged); AaiConfig.reload(); DcaeConfig.reload(); PmConfig.reload(); @@ -107,20 +130,26 @@ public class TestDevMgrPropertiesFile { ToggleAlarmConfig.reload(); }); - try { - Files.asCharSink(f, StandardCharsets.UTF_8).write(this.getContent2()); - } catch (IOException e) { - fail(e.getMessage()); - }; - int i=0; - while(!hasChanged && i++<10) { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - } + System.out.println("Listerner registered."); + System.out.println(cfg.getAai().toString()); + System.out.println(cfg.getDcae().toString()); + System.out.println(cfg.getPm().toString()); + System.out.println(cfg.getEs().toString()); + System.out.println(cfg.getToggleAlarm().toString()); + sleep(5000); + System.out.println("Write new content. Changes "+hasChanged); + writeFile(FILENAME, this.getContent2()); + sleep(5000); + + int i=10; + while(hasChanged == 0 && i-- > 0) { + System.out.println("Wait for Change indication."); + sleep(1000); } - assertTrue("fileChanged not covered",hasChanged); + System.out.println("Changes "+hasChanged); + + assertTrue("fileChanged counter"+hasChanged, hasChanged > 0); assertFalse(cfg.getAai().hashCode()==AaiConfig.getDefaultConfiguration().hashCode()); assertFalse(cfg.getDcae().hashCode()==DcaeConfig.getDefaultConfiguration().hashCode()); assertFalse(cfg.getPm().hashCode()==PmConfig.getDefaultConfiguration().hashCode()); @@ -129,9 +158,35 @@ public class TestDevMgrPropertiesFile { HtDevicemanagerConfiguration.clear(); + System.out.println("Test done"); } - private CharSequence getContent2() { + + + private void sleep(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (InterruptedException e) { + } + } + + private 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() { return "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=http://localhost:45451/abc\n" + diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceManagerWithDatabase.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceManagerWithDatabase.java index 76684e50f..661194c38 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceManagerWithDatabase.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceManagerWithDatabase.java @@ -25,6 +25,8 @@ import static org.junit.Assert.fail; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -54,6 +56,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@SuppressWarnings("deprecation") public class TestDeviceManagerWithDatabase { private static int DATABASETIMEOUTSECONDS = 30; @@ -89,22 +92,26 @@ public class TestDeviceManagerWithDatabase { RpcProviderRegistry rpcProviderRegistry = new RpcProviderRegistryMock(); //start using blueprint interface - deviceManager = new DeviceManagerImpl(); + String msg = ""; + try { + deviceManager = new DeviceManagerImpl(); - deviceManager.setDataBroker(dataBrokerNetconf); - deviceManager.setMountPointService(mountPointService); - deviceManager.setNotificationPublishService(notificationPublishService); - deviceManager.setRpcProviderRegistry(rpcProviderRegistry); + deviceManager.setDataBroker(dataBrokerNetconf); + deviceManager.setMountPointService(mountPointService); + deviceManager.setNotificationPublishService(notificationPublishService); + deviceManager.setRpcProviderRegistry(rpcProviderRegistry); - try { deviceManager.init(); } catch (Exception e) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + msg = sw.toString(); // stack trace as a string e.printStackTrace(); } - readOnlyTransaction.close(); System.out.println("Initialization status: "+deviceManager.isDevicemanagerInitializationOk()); - assertTrue("Devicemanager not initialized", deviceManager.isDevicemanagerInitializationOk()); + assertTrue("Devicemanager not initialized: "+msg, deviceManager.isDevicemanagerInitializationOk()); System.out.println("Initialization done"); } @@ -159,7 +166,7 @@ public class TestDeviceManagerWithDatabase { mountPoint.setDatabrokerAbsent(true); NodeId nodeId = new NodeId("mountpointTest2"); try { - deviceManager.startListenerOnNodeForConnectedState(Action.ADD, nodeId, nNode); + deviceManager.startListenerOnNodeForConnectedState(Action.CREATE, nodeId, nNode); } catch (Exception e) { e.printStackTrace(); fail("Exception received."); @@ -186,7 +193,7 @@ public class TestDeviceManagerWithDatabase { System.out.println("Node capabilites: "+capabilities); try { - deviceManager.startListenerOnNodeForConnectedState(Action.ADD, nodeId, nNode); + deviceManager.startListenerOnNodeForConnectedState(Action.CREATE, nodeId, nNode); } catch (Exception e) { e.printStackTrace(); fail("Exception received."); @@ -219,7 +226,7 @@ public class TestDeviceManagerWithDatabase { System.out.println("Node capabilites: "+capabilities); try { - deviceManager.startListenerOnNodeForConnectedState(Action.ADD, nodeId, nNode); + deviceManager.startListenerOnNodeForConnectedState(Action.CREATE, nodeId, nNode); } catch (Exception e) { e.printStackTrace(); fail("Exception received."); @@ -253,7 +260,7 @@ public class TestDeviceManagerWithDatabase { System.out.println("Node capabilites: "+capabilities); try { - deviceManager.startListenerOnNodeForConnectedState(Action.ADD, nodeId, nNode); + deviceManager.startListenerOnNodeForConnectedState(Action.CREATE, nodeId, nNode); } catch (Exception e) { e.printStackTrace(); fail("Exception received."); diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestEquipment.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestEquipment.java new file mode 100644 index 000000000..aca44d07e --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestEquipment.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.ExtendedEquipment; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.EquipmentBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.UniversalId; + +public class TestEquipment extends Mockito { + + @Test + public void test() { + + + EquipmentBuilder equipmentBuilder = new EquipmentBuilder(); + equipmentBuilder.setUuid( new UniversalId("EquipmentId")); + ExtendedEquipment extendedEquipment = new ExtendedEquipment("Parent",equipmentBuilder.build(),1); + + String extendedEquipmentString = extendedEquipment.toString(); + System.out.println(extendedEquipmentString); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMapper.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMapper.java index 0ce62d5c6..d532f4256 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMapper.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMapper.java @@ -1,27 +1,25 @@ /******************************************************************************* - * ============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 + * ============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 + * 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========================================================= + * 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.util.Arrays; +import java.util.List; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtMapper; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.JsonMapperBase; import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsHistoricalPerformance15Minutes; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName; @@ -33,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.r public class TestMapper { @Test - public void test() { + public void test1() { int t = 0; System.out.println(t++); @@ -42,13 +40,15 @@ public class TestMapper { System.out.println(t++); - Lp layerProtocol = new LpBuilder().setUuid(new UniversalId("TestId")).setLayerProtocolName(new LayerProtocolName("LayprotcolTest")).build(); + Lp layerProtocol = new LpBuilder().setUuid(new UniversalId("TestId")) + .setLayerProtocolName(new LayerProtocolName("LayprotcolTest")).build(); System.out.println(t++); EsHistoricalPerformance15Minutes pmData = new EsHistoricalPerformance15Minutes("Testnode", layerProtocol); System.out.println(t++); - //AirInterfaceHistoricalPerformancesBuilder builder1 = new AirInterfaceHistoricalPerformancesBuilder(); - //System.out.println(t++); + // AirInterfaceHistoricalPerformancesBuilder builder1 = new + // AirInterfaceHistoricalPerformancesBuilder(); + // System.out.println(t++); HistoricalPerformanceDataListBuilder builder2 = new HistoricalPerformanceDataListBuilder(); @@ -58,10 +58,23 @@ public class TestMapper { String json = mapper.objectToJson(pmData); - System.out.println("Result: "+pmData); - System.out.println("Result: "+json); + System.out.println("Result: " + pmData); + System.out.println("Result: " + json); - //fail("Not yet implemented"); + // fail("Not yet implemented"); } + @Test + public void test2() { + + for (int t = 0; t < 5; t++) { + JsonMapperBase baseMapper = new JsonMapperBase(0); + Integer o = new Integer(6); + List<Integer> oList = Arrays.asList(o); + String json = baseMapper.objectListToJson(oList); + System.out.println(json); + } + } + + } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12.java index a4fa0b410..0037724bf 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.r public class TestPerformanceData12 { @Test - public void test() { + public void test1() { PerformanceDataBuilder p = new PerformanceDataBuilder(); byte b=100; diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211Ethernet.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211Ethernet.java new file mode 100644 index 000000000..60706771e --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211Ethernet.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========================================================= + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsPerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder; + +public class TestPerformanceData1211Ethernet { + + @Test + public void test1() { + PerformanceDataBuilder p = new PerformanceDataBuilder(); + p.setTimePeriod(1); + p.setTxEthernetBytesMaxM(2L); + p.setTxEthernetBytesMaxS(3); + p.setTxEthernetBytesSum(4L); + p.setTimePeriod(100); + + HistoricalPerformanceDataListBuilder pmElement = new HistoricalPerformanceDataListBuilder(); + pmElement.setPerformanceData(p.build()); + + //EthernetContainerHistoricalPerformancesBuilder pmList = new EthernetContainerHistoricalPerformancesBuilder(); + //pmList.setHistoricalPerformanceDataList(Arrays.asList(pmElement.build())); + + EsPerformanceData pmData = new EsPerformanceData(pmElement.build()); + + assertTrue("Verify value", pmData.getEs() == null); + assertTrue("Verify value", pmData.getTxEthernetBytesSum() == 4L); + + System.out.println(pmData.toString()); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211pEthernet.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211pEthernet.java new file mode 100644 index 000000000..68cb5ca3d --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData1211pEthernet.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========================================================= + ******************************************************************************/ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; + +import static org.junit.Assert.assertTrue; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsPerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder; + +public class TestPerformanceData1211pEthernet { + + @Test + public void test1() { + PerformanceDataBuilder p = new PerformanceDataBuilder(); + p.setTimePeriod(1); + p.setTxEthernetBytesMaxM(2L); + p.setTxEthernetBytesMaxS(3); + p.setTxEthernetBytesSum(4L); + p.setTimePeriod(100); + + HistoricalPerformanceDataListBuilder pmElement = new HistoricalPerformanceDataListBuilder(); + pmElement.setPerformanceData(p.build()); + + //EthernetContainerHistoricalPerformancesBuilder pmList = new EthernetContainerHistoricalPerformancesBuilder(); + //pmList.setHistoricalPerformanceDataList(Arrays.asList(pmElement.build())); + + EsPerformanceData pmData = new EsPerformanceData(pmElement.build()); + + assertTrue("Verify value", pmData.getEs() == null); + assertTrue("Verify value", pmData.getTxEthernetBytesSum() == 4L); + + System.out.println(pmData.toString()); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12Ethernet.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12Ethernet.java new file mode 100644 index 000000000..96491af9f --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestPerformanceData12Ethernet.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============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 org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types.EsPerformanceData; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceDataBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder; + +public class TestPerformanceData12Ethernet { + + @Test + public void test1() { + PerformanceDataBuilder p = new PerformanceDataBuilder(); + p.setTimePeriod(1); + p.setTxEthernetBytesMaxM(2L); + p.setTxEthernetBytesMaxS(3); + p.setTxEthernetBytesSum(4L); + + HistoricalPerformanceDataListBuilder pmElement = new HistoricalPerformanceDataListBuilder(); + pmElement.setPerformanceData(p.build()); + + //EthernetContainerHistoricalPerformancesBuilder pmList = new EthernetContainerHistoricalPerformancesBuilder(); + //pmList.setHistoricalPerformanceDataList(Arrays.asList(pmElement.build())); + + EsPerformanceData pmData = new EsPerformanceData(pmElement.build()); + + assertTrue("Verify value", pmData.getEs() == null); + assertTrue("Verify value", pmData.getTxEthernetBytesSum() == 4L); + + System.out.println(pmData.toString()); + } + +} diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java index 65bd2199c..34c5959bd 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java @@ -23,17 +23,14 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; import org.opendaylight.controller.md.sal.binding.api.BindingService; import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * @author herbert @@ -74,11 +71,6 @@ public class DataBrokerMountpointMock implements DataBroker, BindingService { return null; } - @Override - public ListenerRegistration<DataChangeListener> registerDataChangeListener(LogicalDatastoreType store, - InstanceIdentifier<?> path, DataChangeListener listener, DataChangeScope triggeringScope) { - return null; - } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java index 4c4781a70..c9455cc9c 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java @@ -22,17 +22,14 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock; import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * @author herbert @@ -74,10 +71,5 @@ public class DataBrokerNetconfMock implements DataBroker { return null; } - @Override - public ListenerRegistration<DataChangeListener> registerDataChangeListener(LogicalDatastoreType store, - InstanceIdentifier<?> path, DataChangeListener listener, DataChangeScope triggeringScope) { - return null; - } } diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java index 51c33171e..f2065c622 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java @@ -37,6 +37,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * @author herbert * */ +@SuppressWarnings("deprecation") public class MountPointMock implements MountPoint { private boolean databrokerAbsent = true; diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java index 797ccb286..ebb501bc3 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java @@ -30,6 +30,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; * @author herbert * */ +@SuppressWarnings("deprecation") public class MountPointServiceMock implements MountPointService { private final MountPointMock mountpoint; diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java index 91fc331f3..9099a4a87 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java @@ -29,6 +29,7 @@ import org.opendaylight.yangtools.yang.binding.Notification; * @author herbert * */ +@SuppressWarnings("deprecation") public class NotificationPublishServiceMock implements NotificationPublishService { @Override diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java index 5cac97742..89864c2c5 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java @@ -28,6 +28,7 @@ import org.opendaylight.yangtools.yang.binding.RpcService; * @author herbert * */ +@SuppressWarnings("deprecation") public class RpcConsumerRegistryMock implements RpcConsumerRegistry { @Override diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java index 831d5ae75..b95da853b 100644 --- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java @@ -29,6 +29,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; +@SuppressWarnings("deprecation") public class RpcProviderRegistryMock implements RpcProviderRegistry { @Override diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java new file mode 100644 index 000000000..9a926fd64 --- /dev/null +++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * ============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.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipFile implements AutoCloseable { + + private final ZipOutputStream zos; + private final FileOutputStream fos; + + public ZipFile(String zipPath) throws FileNotFoundException { + fos = new FileOutputStream(zipPath); + zos = new ZipOutputStream(fos); + } + + public void addToZipFile(String fileName) throws FileNotFoundException, IOException { + + System.out.println("Writing '" + fileName + "' to zip file"); + + InputStream fis = ZipFile.class.getClassLoader().getResourceAsStream(fileName); + if (fis == null) { + throw new FileNotFoundException("Resource not found: " + fileName); + } + + ZipEntry zipEntry = new ZipEntry(fileName); + zos.putNextEntry(zipEntry); + byte[] bytes = new byte[1024]; + int length; + while ((length = fis.read(bytes)) >= 0) { + zos.write(bytes, 0, length); + } + zos.closeEntry(); + fis.close(); + } + + @Override + public void close() throws IOException { + zos.close(); + fos.close(); + } + +} |