summaryrefslogtreecommitdiffstats
path: root/ResmanagementService/service/src
diff options
context:
space:
mode:
Diffstat (limited to 'ResmanagementService/service/src')
-rw-r--r--ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java14
-rw-r--r--ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java20
2 files changed, 28 insertions, 6 deletions
diff --git a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java
index 12e4061..606ce50 100644
--- a/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java
+++ b/ResmanagementService/service/src/main/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java
@@ -82,14 +82,19 @@ public class ResmgrAdapterMgrService implements IResmgrAdapterMgrService {
* @throws IOException
*/
public static String readVimAdapterInfoFromJson() throws IOException {
- String fileContent = "";
-
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator")
+ "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator")
+ RESMGRADAPTERINFO;
- 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 ResmgrAdapterMgrService implements IResmgrAdapterMgrService {
return fileContent;
}
+
private static class RegisterResmgrThread implements Runnable {
private IResmgrAdapter2MSBManager adapter2MSBMgr = new ResmgrAdapter2MSBManager();
diff --git a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java
index 3ddaf26..2c49ba3 100644
--- a/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java
+++ b/ResmanagementService/service/src/test/java/org/onap/vfc/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java
@@ -16,11 +16,12 @@
package org.onap.vfc.nfvo.resmanagement.service.adapter.impl;
+import java.io.File;
import java.io.IOException;
import org.junit.Test;
-import org.onap.vfc.nfvo.resmanagement.service.adapter.impl.ResmgrAdapterMgrService;
+import junit.framework.Assert;
import mockit.Mock;
import mockit.MockUp;
@@ -28,7 +29,7 @@ import mockit.MockUp;
* <br>
* <p>
* </p>
- *
+ *
* @author
* @version VFC 1.0 Sep 24, 2016
*/
@@ -66,4 +67,19 @@ public class ResmgrAdapterMgrServiceTest {
ResmgrAdapterMgrService resmgrService = new ResmgrAdapterMgrService();
resmgrService.register();
}
+
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testReadJson() {
+ File file = new File("./demo.json");
+ try {
+ file.createNewFile();
+ String content = ResmgrAdapterMgrService.readJson("./demo.json");
+ Assert.assertEquals(content, "");
+ file.delete();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}