summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java8
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java14
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java22
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java25
4 files changed, 55 insertions, 14 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
index 83652b70..b3ba1760 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
@@ -82,12 +82,16 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi
* @throws IOException
*/
public static String readVnfmAdapterInfoFromJson() throws IOException {
- String fileContent = "";
-
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTER2DRIVERMGR;
+ return readJson(fileName);
+ }
+
+ public static String readJson(String fileName) throws IOException {
+ String fileContent = "";
+
try (InputStream ins = new FileInputStream(fileName)){
try(BufferedInputStream bins = new BufferedInputStream(ins)){
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
index dabaf380..8df2c796 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
@@ -81,14 +81,19 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService {
* @throws IOException
*/
public String readVnfmAdapterInfoFromJson() throws IOException {
- String fileContent = "";
-
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTERINFO;
- try (InputStream ins = new FileInputStream(fileName)) {
- try (BufferedInputStream bins = new BufferedInputStream(ins)){
+
+ return readJson(fileName);
+ }
+
+ public static String readJson(String fileName) throws IOException {
+ String fileContent = "";
+
+ try (InputStream ins = new FileInputStream(fileName)){
+ try(BufferedInputStream bins = new BufferedInputStream(ins)){
byte[] contentByte = new byte[ins.available()];
int num = bins.read(contentByte);
@@ -104,6 +109,7 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService {
return fileContent;
}
+
private static class RegisterVnfmAdapterThread implements Runnable {
private IDriver2MSBManager adapter2MSBMgr = new Driver2MSBManager();
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java
index 12910c8e..d61c3b1c 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapter2DriverMgrServiceTest.java
@@ -16,12 +16,15 @@
package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.ai.internalsvc.impl;
-import mockit.Mock;
-import mockit.MockUp;
+import java.io.File;
+import java.io.IOException;
+
import org.junit.Test;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.impl.VnfmAdapter2DriverMgrService;
-import java.io.IOException;
+import junit.framework.Assert;
+import mockit.Mock;
+import mockit.MockUp;
/**
* Created by QuanZhong on 2017/3/20.
@@ -48,4 +51,17 @@ public class VnfmAdapter2DriverMgrServiceTest {
mgr.register();
mgr.unregister();
}
+
+ @Test
+ public void testReadJson() {
+ File file = new File("./demo.json");
+ try {
+ file.createNewFile();
+ String content = VnfmAdapter2DriverMgrService.readJson("./demo.json");
+ Assert.assertEquals(content, "");
+ file.delete();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java
index 84a7c914..56e1eea3 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/ai/internalsvc/impl/VnfmAdapterMgrServiceTest.java
@@ -16,14 +16,15 @@
package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.ai.internalsvc.impl;
-import mockit.Mock;
-import mockit.MockUp;
-import net.sf.json.JSONObject;
+import java.io.File;
+import java.io.IOException;
+
import org.junit.Test;
import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.api.internalsvc.impl.VnfmAdapterMgrService;
-import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.process.VnfMgr;
-import java.io.IOException;
+import junit.framework.Assert;
+import mockit.Mock;
+import mockit.MockUp;
/**
* Created by QuanZhong on 2017/3/20.
@@ -42,4 +43,18 @@ public class VnfmAdapterMgrServiceTest {
mgr.register();
}
+
+
+ @Test
+ public void testReadJson() {
+ File file = new File("./demo.json");
+ try {
+ file.createNewFile();
+ String content = VnfmAdapterMgrService.readJson("./demo.json");
+ Assert.assertEquals(content, "");
+ file.delete();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}