* @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)){
* @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);
return fileContent;
}
+
private static class RegisterVnfmAdapterThread implements Runnable {
private IDriver2MSBManager adapter2MSBMgr = new Driver2MSBManager();
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.
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();
+ }
+ }
}
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.
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();
+ }
+ }
}