2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.adapter.impl;
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertTrue;
22 import java.io.IOException;
23 import java.lang.reflect.Method;
24 import java.util.HashMap;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient.RestfulParametes;
30 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.testutils.JsonUtil;
32 import net.sf.json.JSONException;
33 import net.sf.json.JSONObject;
35 public class AdapterResourceManagerTest {
37 AdapterResourceManager manager = null;
41 manager = new AdapterResourceManager();
44 @Test(expected=JSONException.class)
45 public void uploadVNFPackageTestJsonException() {
46 JSONObject vnfpkg = new JSONObject();
47 Map<String, String> paramsMap = new HashMap<>();
48 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
52 public void uploadVNFPackageTestJsonException1() {
53 JSONObject vnfpkg = new JSONObject();
55 Map<String, String> paramsMap = new HashMap<>();
56 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
59 @Test(expected=JSONException.class)
60 public void uploadVNFPackageTestJsonException2() {
61 Map<String, String> paramsMap = new HashMap<>();
62 manager.uploadVNFPackage(null, paramsMap);
66 public void uploadVNFPackageTestJsonException3() {
67 JSONObject vnfpkg = new JSONObject();
68 vnfpkg.put("name", "test");
69 Map<String, String> paramsMap = new HashMap<>();
70 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
71 assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
76 public void uploadVNFPackageTestEmptyParam() {
77 JSONObject vnfpkg = new JSONObject();
78 vnfpkg.put("name", "test");
79 Map<String, String> paramsMap = new HashMap<>();
80 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
81 assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
85 @Test(expected=NullPointerException.class)
86 public void uploadVNFPackageTestNullParam() {
87 JSONObject vnfpkg = new JSONObject();
88 vnfpkg.put("name", "test");
89 JSONObject res = manager.uploadVNFPackage(vnfpkg, null);
90 assertTrue(res.get("reason").equals("csarid and vnfmid are null."));
95 public void uploadVNFPackageTestInvalidCsrid() {
96 JSONObject vnfpkg = new JSONObject();
97 vnfpkg.put("name", "test");
98 Map<String, String> paramsMap = new HashMap<>();
99 paramsMap.put("csarid", "");
100 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
101 assertTrue(res.get("reason").equals("csarid is null."));
106 public void uploadVNFPackageTestInvalidCsrid2() {
107 JSONObject vnfpkg = new JSONObject();
108 vnfpkg.put("name", "test");
109 Map<String, String> paramsMap = new HashMap<>();
110 paramsMap.put("csarid", null);
111 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
112 assertTrue(res.get("reason").equals("csarid is null."));
117 public void uploadVNFPackageTestInvalidVnfmid() {
118 JSONObject vnfpkg = new JSONObject();
119 vnfpkg.put("name", "test");
120 Map<String, String> paramsMap = new HashMap<>();
121 paramsMap.put("csarid", "csarid123");
122 paramsMap.put("vnfmid", null);
123 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
124 assertTrue(res.get("reason").equals("vnfmid is null."));
129 public void uploadVNFPackageTestInvalidVnfmid2() {
130 JSONObject vnfpkg = new JSONObject();
131 vnfpkg.put("name", "test");
132 Map<String, String> paramsMap = new HashMap<>();
133 paramsMap.put("csarid", "csarid123");
134 paramsMap.put("vnfmid", "");
135 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
136 assertTrue(res.get("reason").equals("vnfmid is null."));
141 public void uploadVNFPackageTestNullResp() {
142 JSONObject vnfpkg = new JSONObject();
143 vnfpkg.put("name", "test");
144 Map<String, String> paramsMap = new HashMap<>();
145 paramsMap.put("csarid", "csarid123");
146 paramsMap.put("vnfmid", "vnfmid1234");
147 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
148 assertTrue(res.get("reason").equals("RestfulResponse is null."));
153 public void downloadCsarTestNullUrl() {
155 String filePath = null;
156 JSONObject res = manager.downloadCsar(url, filePath);
157 assertTrue(res.get("reason").equals("url is null."));
161 public void downloadCsarTestEmptyUrl() {
163 String filePath = null;
164 JSONObject res = manager.downloadCsar(url, filePath);
165 assertTrue(res.get("reason").equals("url is null."));
169 public void downloadCsarTestNullFilePath() {
170 String url = "http://localhost:8080";
171 String filePath = null;
172 JSONObject res = manager.downloadCsar(url, filePath);
173 assertTrue(res.get("reason").equals("downloadUrl filePath is null."));
177 public void downloadCsarTestEmptyFilePath() {
178 String url = "http://localhost:8080";
179 String filePath = "";
180 JSONObject res = manager.downloadCsar(url, filePath);
181 assertTrue(res.get("reason").equals("downloadUrl filePath is null."));
185 public void getVnfmConnInfoTestSuccess() {
186 // new MockUp<VNFRestfulUtil>() {
189 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
190 // RestfulResponse resp = new RestfulResponse();
191 // resp.setStatus(200);
192 // Map<String, String> objMap = new HashMap<String, String>();
193 // objMap.put("id", "test123");
195 // String responseString = toJson(objMap);
196 // resp.setResponseJson(responseString);
201 Map<String, String> paramsMap = new HashMap<String, String>();
202 JSONObject res = manager.getVnfmConnInfo(paramsMap);
203 assertTrue(res.get("id").equals("test123"));
207 public void getVnfmConnInfoTestNullResp() {
208 // new MockUp<VNFRestfulUtil>() {
211 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
217 Map<String, String> paramsMap = new HashMap<String, String>();
218 JSONObject res = manager.getVnfmConnInfo(paramsMap);
219 assertTrue(res.get("reason").equals("RestfulResponse is null."));
223 public void getVnfmConnInfoTestServerError() {
224 // new MockUp<VNFRestfulUtil>() {
227 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
228 // RestfulResponse resp = new RestfulResponse();
229 // resp.setStatus(500);
230 // Map<String, String> objMap = new HashMap<String, String>();
231 // objMap.put("id", "test123");
233 // String responseString = toJson(objMap);
234 // resp.setResponseJson(responseString);
239 Map<String, String> paramsMap = new HashMap<String, String>();
240 JSONObject res = manager.getVnfmConnInfo(paramsMap);
241 assertTrue(res.get("reason").equals("ESR return fail."));
245 public void uploadTestInternalError() {
246 JSONObject vnfpackage = new JSONObject();
247 String vnfmurl = "http://localhost";
248 String conntoken = "test";
249 JSONObject res = manager.upload(vnfpackage, vnfmurl, conntoken);
250 assertEquals(res.get("retCode"), 500);
253 public static String toJson(Map o) {
255 return JsonUtil.marshal(o);
256 } catch(IOException e) {
262 public void testGetAllCloud(){
264 manager.getAllCloud(url,null);
268 public void testGetAllCloud2(){
269 String url = "http://127.0.0.1:31943";
270 manager.getAllCloud(url,null);
273 public void testUnzipCSAR(){
274 manager.unzipCSAR(null,null);
277 public void testUnzipCSAR2(){
278 manager.unzipCSAR("vCpe.zip",null);
281 public void testUnzipCSAR3(){
282 manager.unzipCSAR("vCpe.zip","/opt");
285 public void testUnzipCSAR4(){
286 // new MockUp<DownloadCsarManager>(){
288 // public int unzipCSAR(String fileName,String filePath){
292 manager.unzipCSAR("vCpe.zip","/opt");
295 public void testUnzipCSAR5(){
296 // new MockUp<DownloadCsarManager>(){
298 // public int unzipCSAR(String fileName,String filePath){
302 manager.unzipCSAR("vCpe.zip","/opt");
306 public void testGetVnfdVersion(){
307 manager.getVnfdVersion("http://","127.0.0.1","token");
310 @Test(expected=NullPointerException.class)
311 public void testgetVNFDPlanInfoNull(){
313 manager.getVNFDPlanInfo(null, null, null);
317 public void testgetVNFDPlanInfo(){
319 manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "token");
323 public void testgetVNFDPlanInfoConn(){
325 // new MockUp<HttpClient>(){
327 // public int executeMethod(HttpMethod method) {
332 // new MockUp<HttpMethodBase>(){
335 // public int getStatusCode(){
341 // public String getResponseBodyAsString()
342 // throws IOException
344 // JSONObject jobj = new JSONObject();
345 // jobj.put("Status", 200);
346 // jobj.put("UserName", "User");
347 // jobj.put("password", "pass");
348 // String str = jobj.toString();
354 manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "accessSession");
358 public void testgetVNFDPlanInfoConn500(){
360 // new MockUp<HttpClient>(){
362 // public int executeMethod(HttpMethod method) {
367 // new MockUp<HttpMethodBase>(){
370 // public int getStatusCode(){
376 // public String getResponseBodyAsString()
377 // throws IOException
379 // String str = "Failed";
385 manager.getVNFDPlanInfo("https://127.0.0.1:80", "vnfd123", "accessSession");
390 public void testGetVnfdVersion200(){
392 // new MockUp<HttpClient>(){
394 // public int executeMethod(HttpMethod method) {
399 // new MockUp<HttpMethodBase>(){
402 // public int getStatusCode(){
408 // public String getResponseBodyAsString()
409 // throws IOException
411 // JSONObject jobj = new JSONObject();
412 // jobj.put("Status", 200);
413 // jobj.put("UserName", "User");
414 // jobj.put("password", "pass");
415 // String str = jobj.toString();
421 JSONObject jobj = manager.getVnfdVersion("http://","127.0.0.1:80","accessSession");
425 public void testGetVnfdVersion500(){
427 // new MockUp<HttpClient>(){
429 // public int executeMethod(HttpMethod method) {
434 // new MockUp<HttpMethodBase>(){
437 // public int getStatusCode(){
443 // public String getResponseBodyAsString()
444 // throws IOException
446 // String str = "Failed";
451 manager.getVnfdVersion("http://","127.0.0.1:80","accessSession");
455 public void uploadVNFPackageTestcsarid() {
456 RestfulParametes rp = new RestfulParametes();
457 rp.setRawData("success");
458 rp.setRawData("sdjhbfj");
459 HashMap<String,String> headerMap = new HashMap<String,String>();
460 headerMap.put("Content-Type", "application/json");
461 headerMap.put("X-TransactionId", "5851");
462 rp.setHeaderMap(headerMap);
463 HashMap<String,String> paramMap = new HashMap<String,String>();
464 paramMap.put("id", "1234");
465 rp.setParamMap(paramMap);
466 JSONObject vnfpkg = new JSONObject();
467 vnfpkg.put("name", "test");
468 vnfpkg.put("Restfulparameters", rp);
469 Map<String, String> paramsMap = new HashMap<>();
470 paramsMap.put("csarid", "csarid200");
471 paramsMap.put("vnfmid", "vnfmid1234");
472 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
473 assertTrue(res.get("reason").equals("RestfulResponse is null."));
477 public void uploadVNFPackageTestcsaridNull() {
478 JSONObject vnfpkg = new JSONObject();
479 vnfpkg.put("name", "test");
480 Map<String, String> paramsMap = new HashMap<>();
481 paramsMap.put("csarid", "caser200");
482 paramsMap.put("vnfmid", "vnfmid1234");
483 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
484 assertTrue(res.get("reason").equals("RestfulResponse is null."));
489 public void uploadVNFPackageTestParamEmpty() {
490 JSONObject vnfpkg = new JSONObject();
491 vnfpkg.put("name", "test");
492 Map<String, String> paramsMap = new HashMap<>();
493 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
497 public void downloadCsarTestUrlAndFilePathWrong() {
498 String url = "http://localhost:8080";
499 String filePath = "Tset";
500 JSONObject res = manager.downloadCsar(url, filePath);
503 public void downloadCsarTestUrlAndFilePath() {
504 String url = "https://127.0.0.1:31943";
505 String filePath = "src/test/resources/Check.txt";
506 JSONObject res = manager.downloadCsar(url, filePath);
510 public void testGetAllCloudUrlEmpty(){
512 manager.getAllCloud(url,null);
516 public void testGetAllCloudUrlandConn(){
517 String url = "http://127.0.0.1:31943";
518 String conn = "conn";
519 manager.getAllCloud(url,conn);
523 public void testUnzipCSAREmpty(){
524 manager.unzipCSAR("vCpe.zip","");
527 public void testUnzipCSAREmpty1(){
528 manager.unzipCSAR("","/opt");
532 public void readVfnPkgInfoFromJsonTest() throws IOException{
534 System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
535 AdapterResourceManager.readVfnPkgInfoFromJson();
538 public void readVfnPkgInfoFromJsonTestNumBelowZero() throws IOException{
540 System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
541 AdapterResourceManager.readVfnPkgInfoFromJson();
545 public void testGetAllCloudUrlandaccessSession(){
547 // new MockUp<HttpClient>(){
549 // public int executeMethod(HttpMethod method) {
554 // new MockUp<HttpMethodBase>(){
557 // public int getStatusCode(){
563 // public String getResponseBodyAsString()
564 // throws IOException
566 // String str = "{\n\t\"driverInfo\": {\n\t\t\"driverName\": \"hwvnfm\",\n\t\t\"instanceID\": \"hwvnfm-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\"services\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\"support_sys\": [{\n\t\t\t\t\"type\": \"vnfm\",\n\t\t\t\t\"version\": \"V100R001\"\n\t\t\t}]\n\t\t}]\n\t}\n}";
567 // JSONObject jobj = new JSONObject();
568 // jobj.put("Status", 200);
569 // jobj.put("UserName", "User");
570 // jobj.put("password", "pass");
571 // JSONArray ja = new JSONArray();
573 // jobj.put("vim_info", ja);
574 // String str1 = jobj.toString();
580 System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
581 String url = "http://127.0.0.1:31943";
582 String conn = "accessSession";
583 manager.getAllCloud(url,conn);
587 public void testGetAllCloudUrlandaccessSession500(){
589 // new MockUp<HttpClient>(){
591 // public int executeMethod(HttpMethod method) {
596 // new MockUp<HttpMethodBase>(){
599 // public int getStatusCode(){
605 // public String getResponseBodyAsString()
606 // throws IOException
608 // String str = "Failed";
614 System.setProperty("catalina.base", "C:/Users/Huawei/Desktop");
615 String url = "http://127.0.0.1:31943";
616 String conn = "accessSession";
617 manager.getAllCloud(url,conn);
621 public void testUpload(){
623 // new MockUp<HttpClient>(){
625 // public int executeMethod(HttpMethod method) {
630 // new MockUp<HttpMethodBase>(){
633 // public int getStatusCode(){
639 // public String getResponseBodyAsString()
640 // throws IOException
642 // JSONObject jobj = new JSONObject();
643 // jobj.put("Status", 200);
644 // jobj.put("UserName", "User");
645 // jobj.put("password", "pass");
646 // String str = jobj.toString();
652 JSONObject vnfpackage = new JSONObject();
653 vnfpackage.put("UserName", "User");
654 vnfpackage.put("password", "Pass");
655 String vnfmurl = "http://127.0.0.1:31943";
656 String conntoken = "accessSession";
657 System.setProperty("catalina.base", "src/test/resources/");
658 manager.upload(vnfpackage, vnfmurl, conntoken);
662 public void testUploadNoJson(){
664 // new MockUp<HttpClient>(){
666 // public int executeMethod(HttpMethod method) {
671 // new MockUp<HttpMethodBase>(){
674 // public int getStatusCode(){
680 // public String getResponseBodyAsString()
681 // throws IOException
684 // String str = "Test";
690 JSONObject vnfpackage = new JSONObject();
691 vnfpackage.put("UserName", "User");
692 vnfpackage.put("password", "Pass");
693 String vnfmurl = "http://127.0.0.1:31943";
694 String conntoken = "accessSession";
695 System.setProperty("catalina.base", "src/test/resources/");
696 manager.upload(vnfpackage, vnfmurl, conntoken);
700 public void testUpload500(){
702 // new MockUp<HttpClient>(){
704 // public int executeMethod(HttpMethod method) {
709 // new MockUp<HttpMethodBase>(){
712 // public int getStatusCode(){
718 // public String getResponseBodyAsString()
719 // throws IOException
721 // String str = "Failed";
727 JSONObject vnfpackage = new JSONObject();
728 vnfpackage.put("UserName", "User");
729 vnfpackage.put("password", "Pass");
730 String vnfmurl = "http://127.0.0.1:31943";
731 String conntoken = "accessSession";
732 System.setProperty("catalina.base", "src/test/resources/");
733 manager.upload(vnfpackage, vnfmurl, conntoken);
737 public void testGetVnfmCsarInfoEmpty(){
738 manager.getVnfmCsarInfo("");
741 public void testGetVnfmCsarInfoNull(){
742 manager.getVnfmCsarInfo(null);
745 public void testGetVnfmCsarInfo(){
746 manager.getVnfmCsarInfo("casr-id-123");
749 public void downloadCsarTest() {
751 // new MockUp<DownloadCsarManager>(){
753 // public String download(String url, String filepath) {
759 String url = "http://localhost:8080";
760 String filePath = "src/test/resources/Check.txt";
761 JSONObject res = manager.downloadCsar(url, filePath);
765 @Test(expected=JSONException.class)
766 public void uploadVNFPackageTest() {
768 // new MockUp<VNFRestfulUtil>(){
770 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
771 // RestfulResponse rr = new RestfulResponse();
772 // Map<String, String> header = new HashMap<>();
773 // header.put("Content-Type", "Application/Json");
774 // header.put("X-FormId", "jhfdl");
775 // rr.setRespHeaderMap(header);
776 // rr.setStatus(200);
777 // rr.setResponseJson("shdfhj");
784 // new MockUp<RestfulResponse>(){
787 // public String getResponseContent() {
794 // new MockUp<JSONObject>(){
796 // public JSONObject fromObject(Object object){
797 // JSONObject js = new JSONObject();
798 // js.put("Result", "Success");
799 // js.put("Check", "Ok");
800 // js.put("downloadUri", "http://127.0.0.1:80");
805 JSONObject vnfpkg = new JSONObject();
806 vnfpkg.put("name", "test");
807 JSONObject obj = new JSONObject();
808 obj.put("csar_file_path", "src/test/resources/Check10.txt");
809 obj.put("csar_file_name", "casrFile");
810 vnfpkg.put("template", obj);
811 Map<String, String> paramsMap = new HashMap<>();
812 paramsMap.put("csarid", "csarid123");
813 paramsMap.put("vnfmid", "vnfmid1234");
814 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
819 @Test(expected=JSONException.class)
820 public void uploadVNFPackageTestSuccess() {
822 // new MockUp<VNFRestfulUtil>(){
824 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
825 // RestfulResponse rr = new RestfulResponse();
826 // Map<String, String> header = new HashMap<>();
827 // header.put("Content-Type", "Application/Json");
828 // header.put("X-FormId", "jhfdl");
829 // rr.setRespHeaderMap(header);
830 // rr.setStatus(200);
831 // rr.setResponseJson("shdfhj");
838 // new MockUp<RestfulResponse>(){
841 // public String getResponseContent() {
848 // new MockUp<JSONObject>(){
850 // public JSONObject fromObject(Object object){
851 // JSONObject js = new JSONObject();
852 // js.put("Result", "Success");
853 // js.put("Check", "Ok");
854 // js.put("downloadUri", "http://127.0.0.1:80");
859 // new MockUp<DownloadCsarManager>(){
861 // public String download(String url, String filepath) {
867 JSONObject vnfpkg = new JSONObject();
868 vnfpkg.put("name", "test");
869 JSONObject obj = new JSONObject();
870 obj.put("csar_file_path", "src/test/resources/Check10.txt");
871 obj.put("csar_file_name", "casrFile");
872 vnfpkg.put("template", obj);
873 Map<String, String> paramsMap = new HashMap<>();
874 paramsMap.put("csarid", "csarid123");
875 paramsMap.put("vnfmid", "vnfmid1234");
876 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
881 @Test(expected=JSONException.class)
882 public void uploadVNFPackageTestSuccessUNZIP() {
884 // new MockUp<VNFRestfulUtil>(){
886 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
887 // RestfulResponse rr = new RestfulResponse();
888 // Map<String, String> header = new HashMap<>();
889 // header.put("Content-Type", "Application/Json");
890 // header.put("X-FormId", "jhfdl");
891 // rr.setRespHeaderMap(header);
892 // rr.setStatus(200);
893 // rr.setResponseJson("shdfhj");
900 // new MockUp<RestfulResponse>(){
903 // public String getResponseContent() {
910 // new MockUp<JSONObject>(){
912 // public JSONObject fromObject(Object object){
913 // JSONObject js = new JSONObject();
914 // js.put("Result", "Success");
915 // js.put("Check", "Ok");
916 // js.put("downloadUri", "http://127.0.0.1:80");
921 // new MockUp<DownloadCsarManager>(){
923 // public String download(String url, String filepath) {
929 // new MockUp<DownloadCsarManager>(){
931 // public int unzipCSAR(String fileName, String filePath) {
937 JSONObject vnfpkg = new JSONObject();
938 vnfpkg.put("name", "test");
939 JSONObject obj = new JSONObject();
940 obj.put("csar_file_path", "src/test/resources/Check10.txt");
941 obj.put("csar_file_name", "casrFile");
942 vnfpkg.put("template", obj);
943 Map<String, String> paramsMap = new HashMap<>();
944 paramsMap.put("csarid", "csarid123");
945 paramsMap.put("vnfmid", "vnfmid1234");
946 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
947 assertTrue(res.get("reason").equals("RestfulResponse is null."));
951 @Test(expected=JSONException.class)
952 public void uploadVNFPackageTestSuccessUNZIPFTPSClient() {
954 // new MockUp<VNFRestfulUtil>(){
956 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
957 // RestfulResponse rr = new RestfulResponse();
958 // Map<String, String> header = new HashMap<>();
959 // header.put("Content-Type", "Application/Json");
960 // header.put("X-FormId", "jhfdl");
961 // rr.setRespHeaderMap(header);
962 // rr.setStatus(200);
963 // rr.setResponseJson("shdfhj");
970 // new MockUp<RestfulResponse>(){
973 // public String getResponseContent() {
980 // new MockUp<JSONObject>(){
982 // public JSONObject fromObject(Object object){
983 // JSONObject js = new JSONObject();
984 // js.put("Result", "Success");
985 // js.put("Check", "Ok");
986 // js.put("downloadUri", "http://127.0.0.1:80");
991 // new MockUp<DownloadCsarManager>(){
993 // public String download(String url, String filepath) {
999 // new MockUp<DownloadCsarManager>(){
1001 // public int unzipCSAR(String fileName, String filePath) {
1007 JSONObject vnfpkg = new JSONObject();
1008 vnfpkg.put("name", "test");
1009 JSONObject obj = new JSONObject();
1010 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1011 obj.put("csar_file_name", "casrFile");
1012 obj.put("ftp_server_ip", "https:127.0.0.1:80");
1013 obj.put("ftp_username", "FtpUser");
1014 obj.put("ftp_password", "FtpPass");
1015 vnfpkg.put("template", obj);
1016 Map<String, String> paramsMap = new HashMap<>();
1017 paramsMap.put("csarid", "csarid123");
1018 paramsMap.put("vnfmid", "vnfmid1234");
1019 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1020 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1024 @Test(expected=JSONException.class)
1025 public void uploadVNFPackageTestSuccessUNZIPWithUrl() {
1027 // new MockUp<VNFRestfulUtil>(){
1029 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1030 // RestfulResponse rr = new RestfulResponse();
1031 // Map<String, String> header = new HashMap<>();
1032 // header.put("Content-Type", "Application/Json");
1033 // header.put("X-FormId", "jhfdl");
1034 // rr.setRespHeaderMap(header);
1035 // rr.setStatus(200);
1036 // rr.setResponseJson("shdfhj");
1043 // new MockUp<RestfulResponse>(){
1046 // public String getResponseContent() {
1048 // return "Success";
1053 // new MockUp<DownloadCsarManager>(){
1055 // public String download(String url, String filepath) {
1056 // return "Success";
1060 // new MockUp<JSONObject>(){
1062 // public JSONObject fromObject(Object object){
1063 // JSONObject js = new JSONObject();
1064 // js.put("Result", "Success");
1065 // js.put("Check", "Ok");
1066 // js.put("url", "http://localhost:80");
1067 // js.put("userName", "User");
1068 // js.put("password", "pass");
1069 // js.put("downloadUri", "http://127.0.0.1:80");
1074 // new MockUp<DownloadCsarManager>(){
1076 // public int unzipCSAR(String fileName, String filePath) {
1082 JSONObject vnfpkg = new JSONObject();
1083 vnfpkg.put("name", "test");
1084 JSONObject obj = new JSONObject();
1085 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1086 obj.put("csar_file_name", "casrFile");
1087 vnfpkg.put("template", obj);
1088 Map<String, String> paramsMap = new HashMap<>();
1089 paramsMap.put("csarid", "csarid123");
1090 paramsMap.put("vnfmid", "vnfmid1234");
1091 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1098 public void uploadVNFPackageTestSuccessUNZIP1() {
1100 // new MockUp<RestfulResponse>(){
1103 // public String getResponseContent() {
1105 // return "Success";
1110 // new MockUp<DownloadCsarManager>(){
1112 // public String download(String url, String filepath) {
1113 // return "Success";
1117 // new MockUp<JSONObject>(){
1119 // public JSONObject fromObject(Object object){
1120 // JSONObject js = new JSONObject();
1121 // js.put("Result", "Success");
1122 // js.put("Check", "Ok");
1123 // js.put("downloadUri", "http://127.0.0.1:80");
1128 // new MockUp<DownloadCsarManager>(){
1130 // public int unzipCSAR(String fileName, String filePath) {
1136 JSONObject vnfpkg = new JSONObject();
1137 vnfpkg.put("name", "test");
1138 JSONObject obj = new JSONObject();
1139 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1140 obj.put("csar_file_name", "casrFile");
1141 vnfpkg.put("template", obj);
1142 Map<String, String> paramsMap = new HashMap<>();
1143 paramsMap.put("csarid", "csarid123");
1144 paramsMap.put("vnfmid", "vnfmid1234");
1145 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1146 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1150 @Test(expected=JSONException.class)
1151 public void uploadVNFPackageTestSuccessConnect() {
1153 // new MockUp<VNFRestfulUtil>(){
1155 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1156 // RestfulResponse rr = new RestfulResponse();
1157 // Map<String, String> header = new HashMap<>();
1158 // header.put("Content-Type", "Application/Json");
1159 // header.put("X-FormId", "jhfdl");
1160 // rr.setRespHeaderMap(header);
1161 // rr.setStatus(200);
1162 // rr.setResponseJson("shdfhj");
1169 // new MockUp<RestfulResponse>(){
1172 // public String getResponseContent() {
1174 // return "Success";
1179 // new MockUp<DownloadCsarManager>(){
1181 // public String download(String url, String filepath) {
1182 // return "Success";
1186 // new MockUp<JSONObject>(){
1188 // public JSONObject fromObject(Object object){
1189 // JSONObject js = new JSONObject();
1190 // js.put("Result", "Success");
1191 // js.put("Check", "Ok");
1192 // js.put("url", "http://localhost:80");
1193 // js.put("userName", "User");
1194 // js.put("password", "pass");
1195 // js.put("downloadUri", "http://127.0.0.1:80");
1200 // new MockUp<DownloadCsarManager>(){
1202 // public int unzipCSAR(String fileName, String filePath) {
1208 // new MockUp<ConnectMgrVnfm>(){
1211 // public int connect(JSONObject vnfmObj, String authModel) {
1213 // authModel = "accessSession";
1219 JSONObject vnfpkg = new JSONObject();
1220 vnfpkg.put("name", "test");
1221 JSONObject obj = new JSONObject();
1222 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1223 obj.put("csar_file_name", "casrFile");
1224 vnfpkg.put("template", obj);
1225 Map<String, String> paramsMap = new HashMap<>();
1226 paramsMap.put("csarid", "csarid123");
1227 paramsMap.put("vnfmid", "vnfmid1234");
1228 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1233 @Test(expected=JSONException.class)
1234 public void uploadVNFPackageTestSuccessConnectPath() {
1236 // new MockUp<VNFRestfulUtil>(){
1238 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1239 // RestfulResponse rr = new RestfulResponse();
1240 // Map<String, String> header = new HashMap<>();
1241 // header.put("Content-Type", "Application/Json");
1242 // header.put("X-FormId", "jhfdl");
1243 // rr.setRespHeaderMap(header);
1244 // rr.setStatus(200);
1245 // rr.setResponseJson("shdfhj");
1252 // new MockUp<RestfulResponse>(){
1255 // public String getResponseContent() {
1257 // return "Success";
1262 // new MockUp<DownloadCsarManager>(){
1264 // public String download(String url, String filepath) {
1265 // return "Success";
1269 // new MockUp<JSONObject>(){
1271 // public JSONObject fromObject(Object object){
1272 // JSONObject js = new JSONObject();
1273 // js.put("Result", "Success");
1274 // js.put("Check", "Ok");
1275 // js.put("url", "http://localhost:80");
1276 // js.put("userName", "User");
1277 // js.put("password", "pass");
1278 // js.put("downloadUri", "http://127.0.0.1:80");
1279 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1280 // js.put("keyStorePass", "Changeme_123");
1281 // js.put("keyStoreType", "PKCS12");
1282 // JSONArray ja = new JSONArray();
1283 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1285 // js.put("vim_info", ja);
1290 // new MockUp<DownloadCsarManager>(){
1292 // public int unzipCSAR(String fileName, String filePath) {
1298 // new MockUp<ConnectMgrVnfm>(){
1301 // public int connect(JSONObject vnfmObj, String authModel) {
1302 // vnfmObj.put("connToken", "accessSession");
1303 // vnfmObj.put("Content-Type", "Application/Json");
1304 // authModel = "accessSession";
1310 // new MockUp<HttpClient>(){
1312 // public int executeMethod(HttpMethod method) {
1317 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1319 // new MockUp<HttpMethodBase>(){
1322 // public int getStatusCode(){
1328 // public String getResponseBodyAsString()
1329 // throws IOException
1331 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1332 // JSONObject jobj = new JSONObject();
1333 // jobj.put("Status", 200);
1334 // jobj.put("UserName", "User");
1335 // jobj.put("password", "pass");
1336 // JSONArray ja = new JSONArray();
1338 // jobj.put("vim_info", ja);
1339 // String str1 = jobj.toString();
1344 JSONObject vnfpkg = new JSONObject();
1345 vnfpkg.put("name", "test");
1346 JSONObject obj = new JSONObject();
1347 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1348 obj.put("csar_file_name", "casrFile");
1349 vnfpkg.put("template", obj);
1350 Map<String, String> paramsMap = new HashMap<>();
1351 paramsMap.put("csarid", "csarid123");
1352 paramsMap.put("vnfmid", "vnfmid1234");
1353 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1354 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1358 @Test(expected=JSONException.class)
1359 public void uploadVNFPackageTestSuccessConnectPath500() {
1361 // new MockUp<VNFRestfulUtil>(){
1363 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1364 // RestfulResponse rr = new RestfulResponse();
1365 // Map<String, String> header = new HashMap<>();
1366 // header.put("Content-Type", "Application/Json");
1367 // header.put("X-FormId", "jhfdl");
1368 // rr.setRespHeaderMap(header);
1369 // rr.setStatus(200);
1370 // rr.setResponseJson("shdfhj");
1377 // new MockUp<RestfulResponse>(){
1380 // public String getResponseContent() {
1382 // return "Success";
1387 // new MockUp<DownloadCsarManager>(){
1389 // public String download(String url, String filepath) {
1390 // return "Success";
1394 // new MockUp<JSONObject>(){
1396 // public JSONObject fromObject(Object object){
1397 // JSONObject js = new JSONObject();
1398 // js.put("Result", "Success");
1399 // js.put("Check", "Ok");
1400 // js.put("url", "http://localhost:80");
1401 // js.put("userName", "User");
1402 // js.put("password", "pass");
1403 // js.put("downloadUri", "http://127.0.0.1:80");
1404 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1405 // js.put("keyStorePass", "Changeme_123");
1406 // js.put("keyStoreType", "PKCS12");
1407 // JSONArray ja = new JSONArray();
1408 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1410 // js.put("vim_info", ja);
1415 // new MockUp<DownloadCsarManager>(){
1417 // public int unzipCSAR(String fileName, String filePath) {
1423 // new MockUp<ConnectMgrVnfm>(){
1426 // public int connect(JSONObject vnfmObj, String authModel) {
1427 // vnfmObj.put("connToken", "accessSession");
1428 // vnfmObj.put("Content-Type", "Application/Json");
1429 // authModel = "accessSession";
1435 // new MockUp<HttpClient>(){
1437 // public int executeMethod(HttpMethod method) {
1442 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1444 // new MockUp<HttpMethodBase>(){
1447 // public int getStatusCode(){
1453 // public String getResponseBodyAsString()
1454 // throws IOException
1456 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1457 // JSONObject jobj = new JSONObject();
1458 // jobj.put("Status", 500);
1459 // jobj.put("UserName", "User");
1460 // jobj.put("password", "pass");
1461 // JSONArray ja = new JSONArray();
1463 // jobj.put("vim_info", ja);
1464 // String str1 = jobj.toString();
1469 JSONObject vnfpkg = new JSONObject();
1470 vnfpkg.put("name", "test");
1471 JSONObject obj = new JSONObject();
1472 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1473 obj.put("csar_file_name", "casrFile");
1474 vnfpkg.put("template", obj);
1475 Map<String, String> paramsMap = new HashMap<>();
1476 paramsMap.put("csarid", "csarid123");
1477 paramsMap.put("vnfmid", "vnfmid1234");
1478 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1483 @Test(expected=JSONException.class)
1484 public void uploadVNFPackageTestSuccessConnectPathEmpty() {
1486 // new MockUp<VNFRestfulUtil>(){
1488 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1489 // RestfulResponse rr = new RestfulResponse();
1490 // Map<String, String> header = new HashMap<>();
1491 // header.put("Content-Type", "Application/Json");
1492 // header.put("X-FormId", "jhfdl");
1493 // rr.setRespHeaderMap(header);
1494 // rr.setStatus(200);
1495 // rr.setResponseJson("shdfhj");
1502 // new MockUp<RestfulResponse>(){
1505 // public String getResponseContent() {
1507 // return "Success";
1512 // new MockUp<DownloadCsarManager>(){
1514 // public String download(String url, String filepath) {
1515 // return "Success";
1519 // new MockUp<JSONObject>(){
1521 // public JSONObject fromObject(Object object){
1522 // JSONObject js = new JSONObject();
1523 // js.put("Result", "Success");
1524 // js.put("Check", "Ok");
1525 // js.put("url", "http://localhost:80");
1526 // js.put("userName", "User");
1527 // js.put("password", "pass");
1528 // js.put("downloadUri", "http://127.0.0.1:80");
1529 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1530 // js.put("keyStorePass", "Changeme_123");
1531 // js.put("keyStoreType", "PKCS12");
1532 // JSONArray ja = new JSONArray();
1533 // String str = "{\n\"vim_id\": \"\",\n\t\t\"vim-info\": \"1\",\n\t\t\"vim-name\": \"\"\n}";
1535 // js.put("vim_info", ja);
1540 // new MockUp<DownloadCsarManager>(){
1542 // public int unzipCSAR(String fileName, String filePath) {
1548 // new MockUp<ConnectMgrVnfm>(){
1551 // public int connect(JSONObject vnfmObj, String authModel) {
1552 // vnfmObj.put("connToken", "accessSession");
1553 // vnfmObj.put("Content-Type", "Application/Json");
1554 // authModel = "accessSession";
1560 // new MockUp<HttpClient>(){
1562 // public int executeMethod(HttpMethod method) {
1567 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1569 // new MockUp<HttpMethodBase>(){
1572 // public int getStatusCode(){
1578 // public String getResponseBodyAsString()
1579 // throws IOException
1581 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1582 // JSONObject jobj = new JSONObject();
1583 // jobj.put("Status", 200);
1584 // jobj.put("UserName", "User");
1585 // jobj.put("password", "pass");
1586 // JSONArray ja = new JSONArray();
1588 // jobj.put("vim_info", ja);
1589 // String str1 = jobj.toString();
1594 JSONObject vnfpkg = new JSONObject();
1595 vnfpkg.put("name", "test");
1596 JSONObject obj = new JSONObject();
1597 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1598 obj.put("csar_file_name", "casrFile");
1599 vnfpkg.put("template", obj);
1600 Map<String, String> paramsMap = new HashMap<>();
1601 paramsMap.put("csarid", "csarid123");
1602 paramsMap.put("vnfmid", "vnfmid1234");
1603 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1604 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1607 @Test(expected=JSONException.class)
1608 public void uploadVNFPackageTestSuccessId() {
1610 // new MockUp<VNFRestfulUtil>(){
1612 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1613 // RestfulResponse rr = new RestfulResponse();
1614 // Map<String, String> header = new HashMap<>();
1615 // header.put("Content-Type", "Application/Json");
1616 // header.put("X-FormId", "jhfdl");
1617 // rr.setRespHeaderMap(header);
1618 // rr.setStatus(200);
1619 // rr.setResponseJson("shdfhj");
1626 // new MockUp<RestfulResponse>(){
1629 // public String getResponseContent() {
1631 // return "Success";
1636 // new MockUp<DownloadCsarManager>(){
1638 // public String download(String url, String filepath) {
1639 // return "Success";
1643 // new MockUp<JSONObject>(){
1645 // public JSONObject fromObject(Object object){
1646 // JSONObject js = new JSONObject();
1647 // js.put("id", "upload-id-123");
1648 // js.put("Result", "Success");
1649 // js.put("Check", "Ok");
1650 // js.put("url", "http://localhost:80");
1651 // js.put("userName", "User");
1652 // js.put("password", "pass");
1653 // js.put("downloadUri", "http://127.0.0.1:80");
1654 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1655 // js.put("keyStorePass", "Changeme_123");
1656 // js.put("keyStoreType", "PKCS12");
1657 // JSONArray ja = new JSONArray();
1658 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1660 // js.put("vim_info", ja);
1665 // new MockUp<DownloadCsarManager>(){
1667 // public int unzipCSAR(String fileName, String filePath) {
1673 // new MockUp<ConnectMgrVnfm>(){
1676 // public int connect(JSONObject vnfmObj, String authModel) {
1677 // vnfmObj.put("connToken", "accessSession");
1678 // vnfmObj.put("Content-Type", "Application/Json");
1679 // authModel = "accessSession";
1685 // new MockUp<HttpClient>(){
1687 // public int executeMethod(HttpMethod method) {
1692 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1694 // new MockUp<HttpMethodBase>(){
1697 // public int getStatusCode(){
1703 // public String getResponseBodyAsString()
1704 // throws IOException
1706 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1707 // JSONObject jobj = new JSONObject();
1708 // jobj.put("Status", 200);
1709 // jobj.put("UserName", "User");
1710 // jobj.put("password", "pass");
1711 // JSONArray ja = new JSONArray();
1713 // jobj.put("vim_info", ja);
1714 // String str1 = jobj.toString();
1719 JSONObject vnfpkg = new JSONObject();
1720 vnfpkg.put("name", "test");
1721 JSONObject obj = new JSONObject();
1722 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1723 obj.put("csar_file_name", "casrFile");
1724 vnfpkg.put("template", obj);
1725 Map<String, String> paramsMap = new HashMap<>();
1726 paramsMap.put("csarid", "csarid123");
1727 paramsMap.put("vnfmid", "vnfmid1234");
1728 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1729 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1732 @Test(expected=JSONException.class)
1733 public void uploadVNFPackageTestSuccessIdNull() {
1735 // new MockUp<VNFRestfulUtil>(){
1737 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1738 // RestfulResponse rr = new RestfulResponse();
1739 // Map<String, String> header = new HashMap<>();
1740 // header.put("Content-Type", "Application/Json");
1741 // header.put("X-FormId", "jhfdl");
1742 // rr.setRespHeaderMap(header);
1743 // rr.setStatus(200);
1744 // rr.setResponseJson("shdfhj");
1751 // new MockUp<RestfulResponse>(){
1754 // public String getResponseContent() {
1756 // return "Success";
1761 // new MockUp<DownloadCsarManager>(){
1763 // public String download(String url, String filepath) {
1764 // return "Success";
1768 // new MockUp<JSONObject>(){
1770 // public JSONObject fromObject(Object object){
1771 // JSONObject js = new JSONObject();
1772 // js.put("id", null);
1773 // js.put("Result", "Success");
1774 // js.put("Check", "Ok");
1775 // js.put("url", "http://localhost:80");
1776 // js.put("userName", "User");
1777 // js.put("password", "pass");
1778 // js.put("downloadUri", "http://127.0.0.1:80");
1779 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
1780 // js.put("keyStorePass", "Changeme_123");
1781 // js.put("keyStoreType", "PKCS12");
1782 // JSONArray ja = new JSONArray();
1783 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1785 // js.put("vim_info", ja);
1790 // new MockUp<DownloadCsarManager>(){
1792 // public int unzipCSAR(String fileName, String filePath) {
1798 // new MockUp<ConnectMgrVnfm>(){
1801 // public int connect(JSONObject vnfmObj, String authModel) {
1802 // vnfmObj.put("connToken", "accessSession");
1803 // vnfmObj.put("Content-Type", "Application/Json");
1804 // authModel = "accessSession";
1810 // new MockUp<HttpClient>(){
1812 // public int executeMethod(HttpMethod method) {
1817 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1819 // new MockUp<HttpMethodBase>(){
1822 // public int getStatusCode(){
1828 // public String getResponseBodyAsString()
1829 // throws IOException
1831 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1832 // JSONObject jobj = new JSONObject();
1833 // jobj.put("Status", 200);
1834 // jobj.put("UserName", "User");
1835 // jobj.put("password", "pass");
1836 // JSONArray ja = new JSONArray();
1838 // jobj.put("vim_info", ja);
1839 // String str1 = jobj.toString();
1844 JSONObject vnfpkg = new JSONObject();
1845 vnfpkg.put("name", "test");
1846 JSONObject obj = new JSONObject();
1847 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1848 obj.put("csar_file_name", "casrFile");
1849 vnfpkg.put("template", obj);
1850 Map<String, String> paramsMap = new HashMap<>();
1851 paramsMap.put("csarid", "csarid123");
1852 paramsMap.put("vnfmid", "vnfmid1234");
1853 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1854 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1857 @Test(expected=JSONException.class)
1858 public void uploadVNFPackageTestSuccessIdFile0() {
1860 // new MockUp<VNFRestfulUtil>(){
1862 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1863 // RestfulResponse rr = new RestfulResponse();
1864 // Map<String, String> header = new HashMap<>();
1865 // header.put("Content-Type", "Application/Json");
1866 // header.put("X-FormId", "jhfdl");
1867 // rr.setRespHeaderMap(header);
1868 // rr.setStatus(200);
1869 // rr.setResponseJson("shdfhj");
1876 // new MockUp<RestfulResponse>(){
1879 // public String getResponseContent() {
1881 // return "Success";
1886 // new MockUp<DownloadCsarManager>(){
1888 // public String download(String url, String filepath) {
1889 // return "Success";
1893 // new MockUp<JSONObject>(){
1895 // public JSONObject fromObject(Object object){
1896 // JSONObject js = new JSONObject();
1897 // js.put("id", "");
1898 // js.put("Result", "Success");
1899 // js.put("Check", "Ok");
1900 // js.put("url", "http://localhost:80");
1901 // js.put("userName", "User");
1902 // js.put("password", "pass");
1903 // js.put("downloadUri", "http://127.0.0.1:80");
1904 // js.put("keyStore", "C:/Users/Huawei/Desktop/Check10.txt");
1905 // js.put("keyStorePass", "Changeme_123");
1906 // js.put("keyStoreType", "PKCS12");
1907 // JSONArray ja = new JSONArray();
1908 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1910 // js.put("vim_info", ja);
1915 // new MockUp<DownloadCsarManager>(){
1917 // public int unzipCSAR(String fileName, String filePath) {
1923 // new MockUp<ConnectMgrVnfm>(){
1926 // public int connect(JSONObject vnfmObj, String authModel) {
1927 // vnfmObj.put("connToken", "accessSession");
1928 // vnfmObj.put("Content-Type", "Application/Json");
1929 // authModel = "accessSession";
1935 // new MockUp<HttpClient>(){
1937 // public int executeMethod(HttpMethod method) {
1942 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
1944 // new MockUp<HttpMethodBase>(){
1947 // public int getStatusCode(){
1953 // public String getResponseBodyAsString()
1954 // throws IOException
1956 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
1957 // JSONObject jobj = new JSONObject();
1958 // jobj.put("Status", 200);
1959 // jobj.put("UserName", "User");
1960 // jobj.put("password", "pass");
1961 // JSONArray ja = new JSONArray();
1963 // jobj.put("vim_info", ja);
1964 // String str1 = jobj.toString();
1969 JSONObject vnfpkg = new JSONObject();
1970 vnfpkg.put("name", "test");
1971 JSONObject obj = new JSONObject();
1972 obj.put("csar_file_path", "src/test/resources/Check10.txt");
1973 obj.put("csar_file_name", "casrFile");
1974 vnfpkg.put("template", obj);
1975 Map<String, String> paramsMap = new HashMap<>();
1976 paramsMap.put("csarid", "csarid123");
1977 paramsMap.put("vnfmid", "vnfmid1234");
1978 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
1979 assertTrue(res.get("reason").equals("RestfulResponse is null."));
1983 @Test(expected=JSONException.class)
1984 public void uploadVNFPackageTestSuccessId500() {
1986 // new MockUp<VNFRestfulUtil>(){
1988 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
1989 // RestfulResponse rr = new RestfulResponse();
1990 // Map<String, String> header = new HashMap<>();
1991 // header.put("Content-Type", "Application/Json");
1992 // header.put("X-FormId", "jhfdl");
1993 // rr.setRespHeaderMap(header);
1994 // rr.setStatus(200);
1995 // rr.setResponseJson("shdfhj");
2002 // new MockUp<RestfulResponse>(){
2005 // public String getResponseContent() {
2007 // return "Success";
2012 // new MockUp<DownloadCsarManager>(){
2014 // public String download(String url, String filepath) {
2015 // return "Success";
2019 // new MockUp<JSONObject>(){
2021 // public JSONObject fromObject(Object object){
2022 // JSONObject js = new JSONObject();
2023 // js.put("id", "upload-id-123");
2024 // js.put("Result", "Success");
2025 // js.put("Check", "Ok");
2026 // js.put("url", "http://localhost:80");
2027 // js.put("userName", "User");
2028 // js.put("password", "pass");
2029 // js.put("downloadUri", "http://127.0.0.1:80");
2030 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2031 // js.put("keyStorePass", "Changeme_123");
2032 // js.put("keyStoreType", "PKCS12");
2033 // JSONArray ja = new JSONArray();
2034 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2036 // js.put("vim_info", ja);
2041 // new MockUp<DownloadCsarManager>(){
2043 // public int unzipCSAR(String fileName, String filePath) {
2049 // new MockUp<ConnectMgrVnfm>(){
2052 // public int connect(JSONObject vnfmObj, String authModel) {
2053 // vnfmObj.put("connToken", "accessSession");
2054 // vnfmObj.put("Content-Type", "Application/Json");
2055 // authModel = "accessSession";
2061 // new MockUp<HttpClient>(){
2063 // public int executeMethod(HttpMethod method) {
2068 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2070 JSONObject vnfpkg = new JSONObject();
2071 vnfpkg.put("name", "test");
2072 JSONObject obj = new JSONObject();
2073 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2074 obj.put("csar_file_name", "casrFile");
2075 vnfpkg.put("template", obj);
2076 Map<String, String> paramsMap = new HashMap<>();
2077 paramsMap.put("csarid", "csarid123");
2078 paramsMap.put("vnfmid", "vnfmid1234");
2079 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2084 @Test(expected=JSONException.class)
2085 public void uploadVNFPackageTestSuccessIdEmpty() {
2087 // new MockUp<VNFRestfulUtil>(){
2089 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2090 // RestfulResponse rr = new RestfulResponse();
2091 // Map<String, String> header = new HashMap<>();
2092 // header.put("Content-Type", "Application/Json");
2093 // header.put("X-FormId", "jhfdl");
2094 // rr.setRespHeaderMap(header);
2095 // rr.setStatus(200);
2096 // rr.setResponseJson("shdfhj");
2103 // new MockUp<RestfulResponse>(){
2106 // public String getResponseContent() {
2108 // return "Success";
2113 // new MockUp<DownloadCsarManager>(){
2115 // public String download(String url, String filepath) {
2116 // return "Success";
2120 // new MockUp<JSONObject>(){
2122 // public JSONObject fromObject(Object object){
2123 // JSONObject js = new JSONObject();
2124 // js.put("id", "");
2125 // js.put("Result", "Success");
2126 // js.put("Check", "Ok");
2127 // js.put("url", "http://localhost:80");
2128 // js.put("userName", "User");
2129 // js.put("password", "pass");
2130 // js.put("downloadUri", "http://127.0.0.1:80");
2131 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2132 // js.put("keyStorePass", "Changeme_123");
2133 // js.put("keyStoreType", "PKCS12");
2134 // JSONArray ja = new JSONArray();
2135 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2137 // js.put("vim_info", ja);
2142 // new MockUp<DownloadCsarManager>(){
2144 // public int unzipCSAR(String fileName, String filePath) {
2150 // new MockUp<ConnectMgrVnfm>(){
2153 // public int connect(JSONObject vnfmObj, String authModel) {
2154 // vnfmObj.put("connToken", "accessSession");
2155 // vnfmObj.put("Content-Type", "Application/Json");
2156 // authModel = "accessSession";
2162 // new MockUp<HttpClient>(){
2164 // public int executeMethod(HttpMethod method) {
2169 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2171 JSONObject vnfpkg = new JSONObject();
2172 vnfpkg.put("name", "test");
2173 JSONObject obj = new JSONObject();
2174 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2175 obj.put("csar_file_name", "casrFile");
2176 vnfpkg.put("template", obj);
2177 Map<String, String> paramsMap = new HashMap<>();
2178 paramsMap.put("csarid", "csarid123");
2179 paramsMap.put("vnfmid", "vnfmid1234");
2180 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2181 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2185 @Test(expected=JSONException.class)
2186 public void uploadVNFPackageTestSuccessTemplete() {
2188 // new MockUp<VNFRestfulUtil>(){
2190 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2191 // RestfulResponse rr = new RestfulResponse();
2192 // Map<String, String> header = new HashMap<>();
2193 // header.put("Content-Type", "Application/Json");
2194 // header.put("X-FormId", "jhfdl");
2195 // rr.setRespHeaderMap(header);
2196 // rr.setStatus(200);
2197 // rr.setResponseJson("shdfhj");
2204 // new MockUp<RestfulResponse>(){
2207 // public String getResponseContent() {
2209 // return "Success";
2214 // new MockUp<DownloadCsarManager>(){
2216 // public String download(String url, String filepath) {
2217 // return "Success";
2221 // new MockUp<JSONObject>(){
2223 // public JSONObject fromObject(Object object){
2224 // JSONObject js = new JSONObject();
2225 // js.put("id", "upload-id-123");
2226 // js.put("Result", "Success");
2227 // js.put("Check", "Ok");
2228 // js.put("url", "http://localhost:80");
2229 // js.put("userName", "User");
2230 // js.put("password", "pass");
2231 // js.put("downloadUri", "http://127.0.0.1:80");
2232 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2233 // js.put("keyStorePass", "Changeme_123");
2234 // js.put("keyStoreType", "PKCS12");
2235 // JSONArray ja = new JSONArray();
2236 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2238 // JSONArray ja1 = new JSONArray();
2239 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2241 // js.put("vim_info", ja);
2242 // js.put("templates", ja1);
2247 // new MockUp<DownloadCsarManager>(){
2249 // public int unzipCSAR(String fileName, String filePath) {
2255 // new MockUp<ConnectMgrVnfm>(){
2258 // public int connect(JSONObject vnfmObj, String authModel) {
2259 // vnfmObj.put("connToken", "accessSession");
2260 // vnfmObj.put("Content-Type", "Application/Json");
2261 // authModel = "accessSession";
2267 // new MockUp<HttpClient>(){
2269 // public int executeMethod(HttpMethod method) {
2274 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2276 JSONObject vnfpkg = new JSONObject();
2277 vnfpkg.put("name", "test");
2278 JSONObject obj = new JSONObject();
2279 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2280 obj.put("csar_file_name", "casrFile");
2281 vnfpkg.put("template", obj);
2282 Map<String, String> paramsMap = new HashMap<>();
2283 paramsMap.put("csarid", "csarid123");
2284 paramsMap.put("vnfmid", "vnfmid1234");
2285 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2286 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2290 @Test(expected=JSONException.class)
2291 public void uploadVNFPackageTestSuccessTempleteForVPlan() {
2293 // new MockUp<VNFRestfulUtil>(){
2295 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2296 // RestfulResponse rr = new RestfulResponse();
2297 // Map<String, String> header = new HashMap<>();
2298 // header.put("Content-Type", "Application/Json");
2299 // header.put("X-FormId", "jhfdl");
2300 // rr.setRespHeaderMap(header);
2301 // rr.setStatus(200);
2302 // rr.setResponseJson("shdfhj");
2309 // new MockUp<RestfulResponse>(){
2312 // public String getResponseContent() {
2314 // return "Success";
2319 // new MockUp<DownloadCsarManager>(){
2321 // public String download(String url, String filepath) {
2322 // return "Success";
2326 // new MockUp<JSONObject>(){
2328 // public JSONObject fromObject(Object object){
2329 // JSONObject js = new JSONObject();
2330 // js.put("id", "upload-id-123");
2331 // js.put("Result", "Success");
2332 // js.put("Check", "Ok");
2333 // js.put("url", "http://localhost:80");
2334 // js.put("userName", "User");
2335 // js.put("password", "pass");
2336 // js.put("downloadUri", "http://127.0.0.1:80");
2337 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2338 // js.put("keyStorePass", "Changeme_123");
2339 // js.put("keyStoreType", "PKCS12");
2340 // JSONArray ja = new JSONArray();
2341 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2343 // JSONArray ja1 = new JSONArray();
2344 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2346 // JSONArray ja2 = new JSONArray();
2347 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2349 // JSONObject jsObject = new JSONObject();
2350 // jsObject.put("downloadUrl", "http://localhost:80");
2351 // jsObject.put("csarName", "Csar_Check");
2352 // js.put("vim_info", ja);
2353 // js.put("template", ja2);
2354 // js.put("templates", ja1);
2355 // js.put("packageInfo", jsObject);
2360 // new MockUp<DownloadCsarManager>(){
2362 // public int unzipCSAR(String fileName, String filePath) {
2368 // new MockUp<ConnectMgrVnfm>(){
2371 // public int connect(JSONObject vnfmObj, String authModel) {
2372 // vnfmObj.put("connToken", "accessSession");
2373 // vnfmObj.put("Content-Type", "Application/Json");
2374 // authModel = "accessSession";
2380 // new MockUp<HttpClient>(){
2382 // public int executeMethod(HttpMethod method) {
2387 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2389 JSONObject vnfpkg = new JSONObject();
2390 vnfpkg.put("name", "test");
2391 JSONObject obj = new JSONObject();
2392 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2393 obj.put("csar_file_name", "casrFile");
2394 vnfpkg.put("template", obj);
2395 Map<String, String> paramsMap = new HashMap<>();
2396 paramsMap.put("csarid", "csarid123");
2397 paramsMap.put("vnfmid", "vnfmid1234");
2398 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2399 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2406 public void uploadVNFPackageTestParamMapEmpty() {
2408 JSONObject vnfpkg = new JSONObject();
2409 vnfpkg.put("name", "test");
2410 JSONObject obj = new JSONObject();
2411 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2412 obj.put("csar_file_name", "casrFile");
2413 vnfpkg.put("template", obj);
2414 Map<String, String> paramsMap = new HashMap<>();
2415 paramsMap.put("", "");
2416 paramsMap.put("", "");
2417 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2423 public void uploadVNFPackageTestVnfpkgEmpty() {
2425 JSONObject vnfpkg = new JSONObject();
2427 JSONObject obj = new JSONObject();
2428 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2429 obj.put("csar_file_name", "casrFile");
2430 vnfpkg.put("template", obj);
2431 Map<String, String> paramsMap = new HashMap<>();
2432 paramsMap.put("csarid", "csarid123");
2433 paramsMap.put("vnfmid", "vnfmid1234");
2434 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2440 public void readScaleInVmIdFromJsonTest() {
2442 System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2443 AdapterResourceManager.readScaleInVmIdFromJson();
2447 public void readScaleInVmIdFromJsonTestNoFile() {
2449 System.setProperty("catalina.base", "src/test/resources");
2450 AdapterResourceManager.readScaleInVmIdFromJson();
2453 @Test(expected=JSONException.class)
2454 public void uploadVNFPackageTestWithCscf() {
2456 // new MockUp<VNFRestfulUtil>(){
2458 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2459 // RestfulResponse rr = new RestfulResponse();
2460 // Map<String, String> header = new HashMap<>();
2461 // header.put("Content-Type", "Application/Json");
2462 // header.put("X-FormId", "jhfdl");
2463 // rr.setRespHeaderMap(header);
2464 // rr.setStatus(200);
2465 // rr.setResponseJson("shdfhj");
2472 // new MockUp<RestfulResponse>(){
2475 // public String getResponseContent() {
2477 // return "Success";
2482 // new MockUp<DownloadCsarManager>(){
2484 // public String download(String url, String filepath) {
2485 // return "Success";
2489 // new MockUp<JSONObject>(){
2491 // public JSONObject fromObject(Object object){
2492 // JSONObject js = new JSONObject();
2493 // js.put("id", "upload-id-123");
2494 // js.put("Result", "Success");
2495 // js.put("Check", "Ok");
2496 // js.put("url", "http://localhost:80");
2497 // js.put("userName", "User");
2498 // js.put("password", "pass");
2499 // js.put("downloadUri", "http://127.0.0.1:80");
2500 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2501 // js.put("keyStorePass", "Changeme_123");
2502 // js.put("keyStoreType", "PKCS12");
2503 // JSONArray ja = new JSONArray();
2504 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2506 // JSONArray ja1 = new JSONArray();
2507 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2509 // JSONArray ja2 = new JSONArray();
2510 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2512 // JSONObject jsObject = new JSONObject();
2513 // jsObject.put("downloadUrl", "http://localhost:80");
2514 // jsObject.put("csarName", "CSCF_SI");
2515 // js.put("vim_info", ja);
2516 // js.put("template", ja2);
2517 // js.put("templates", ja1);
2518 // js.put("packageInfo", jsObject);
2523 // new MockUp<DownloadCsarManager>(){
2525 // public int unzipCSAR(String fileName, String filePath) {
2531 // new MockUp<ConnectMgrVnfm>(){
2534 // public int connect(JSONObject vnfmObj, String authModel) {
2535 // vnfmObj.put("connToken", "accessSession");
2536 // vnfmObj.put("Content-Type", "Application/Json");
2537 // authModel = "accessSession";
2543 // new MockUp<HttpClient>(){
2545 // public int executeMethod(HttpMethod method) {
2550 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2552 JSONObject vnfpkg = new JSONObject();
2553 vnfpkg.put("name", "test");
2554 JSONObject obj = new JSONObject();
2555 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2556 obj.put("csar_file_name", "casrFile");
2557 vnfpkg.put("template", obj);
2558 Map<String, String> paramsMap = new HashMap<>();
2559 paramsMap.put("csarid", "csarid123");
2560 paramsMap.put("vnfmid", "vnfmid1234");
2561 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2562 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2566 @Test(expected=JSONException.class)
2567 public void uploadVNFPackageTestWithMME() {
2569 // new MockUp<VNFRestfulUtil>(){
2571 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2572 // RestfulResponse rr = new RestfulResponse();
2573 // Map<String, String> header = new HashMap<>();
2574 // header.put("Content-Type", "Application/Json");
2575 // header.put("X-FormId", "jhfdl");
2576 // rr.setRespHeaderMap(header);
2577 // rr.setStatus(200);
2578 // rr.setResponseJson("shdfhj");
2585 // new MockUp<JSONObject>(){
2587 // public JSONObject fromObject(Object object){
2588 // JSONObject js = new JSONObject();
2589 // js.put("id", "upload-id-123");
2590 // js.put("Result", "Success");
2591 // js.put("Check", "Ok");
2592 // js.put("url", "http://localhost:80");
2593 // js.put("userName", "User");
2594 // js.put("password", "pass");
2595 // js.put("downloadUri", "http://127.0.0.1:80");
2596 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2597 // js.put("keyStorePass", "Changeme_123");
2598 // js.put("keyStoreType", "PKCS12");
2599 // JSONArray ja = new JSONArray();
2600 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2602 // JSONArray ja1 = new JSONArray();
2603 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2605 // JSONArray ja2 = new JSONArray();
2606 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2608 // JSONObject jsObject = new JSONObject();
2609 // jsObject.put("downloadUrl", "http://localhost:80");
2610 // jsObject.put("csarName", "MME");
2611 // js.put("vim_info", ja);
2612 // js.put("template", ja2);
2613 // js.put("templates", ja1);
2614 // js.put("packageInfo", jsObject);
2619 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2621 JSONObject vnfpkg = new JSONObject();
2622 vnfpkg.put("name", "test");
2623 JSONObject obj = new JSONObject();
2624 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2625 obj.put("csar_file_name", "casrFile");
2626 vnfpkg.put("template", obj);
2627 Map<String, String> paramsMap = new HashMap<>();
2628 paramsMap.put("csarid", "csarid123");
2629 paramsMap.put("vnfmid", "vnfmid1234");
2630 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2631 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2635 @Test(expected=JSONException.class)
2636 public void uploadVNFPackageTestWithSPGW() {
2638 // new MockUp<VNFRestfulUtil>(){
2640 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2641 // RestfulResponse rr = new RestfulResponse();
2642 // Map<String, String> header = new HashMap<>();
2643 // header.put("Content-Type", "Application/Json");
2644 // header.put("X-FormId", "jhfdl");
2645 // rr.setRespHeaderMap(header);
2646 // rr.setStatus(200);
2647 // rr.setResponseJson("shdfhj");
2654 // new MockUp<JSONObject>(){
2656 // public JSONObject fromObject(Object object){
2657 // JSONObject js = new JSONObject();
2658 // js.put("id", "upload-id-123");
2659 // js.put("Result", "Success");
2660 // js.put("Check", "Ok");
2661 // js.put("url", "http://localhost:80");
2662 // js.put("userName", "User");
2663 // js.put("password", "pass");
2664 // js.put("downloadUri", "http://127.0.0.1:80");
2665 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2666 // js.put("keyStorePass", "Changeme_123");
2667 // js.put("keyStoreType", "PKCS12");
2668 // JSONArray ja = new JSONArray();
2669 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2671 // JSONArray ja1 = new JSONArray();
2672 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2674 // JSONArray ja2 = new JSONArray();
2675 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2677 // JSONObject jsObject = new JSONObject();
2678 // jsObject.put("downloadUrl", "http://localhost:80");
2679 // jsObject.put("csarName", "SPGW");
2680 // js.put("vim_info", ja);
2681 // js.put("template", ja2);
2682 // js.put("templates", ja1);
2683 // js.put("packageInfo", jsObject);
2688 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2690 JSONObject vnfpkg = new JSONObject();
2691 vnfpkg.put("name", "test");
2692 JSONObject obj = new JSONObject();
2693 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2694 obj.put("csar_file_name", "casrFile");
2695 vnfpkg.put("template", obj);
2696 Map<String, String> paramsMap = new HashMap<>();
2697 paramsMap.put("csarid", "csarid123");
2698 paramsMap.put("vnfmid", "vnfmid1234");
2699 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2700 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2704 @Test(expected=JSONException.class)
2705 public void uploadVNFPackageTestWithHSS() {
2707 // new MockUp<VNFRestfulUtil>(){
2709 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2710 // RestfulResponse rr = new RestfulResponse();
2711 // Map<String, String> header = new HashMap<>();
2712 // header.put("Content-Type", "Application/Json");
2713 // header.put("X-FormId", "jhfdl");
2714 // rr.setRespHeaderMap(header);
2715 // rr.setStatus(200);
2716 // rr.setResponseJson("shdfhj");
2723 // new MockUp<JSONObject>(){
2725 // public JSONObject fromObject(Object object){
2726 // JSONObject js = new JSONObject();
2727 // js.put("id", "upload-id-123");
2728 // js.put("Result", "Success");
2729 // js.put("Check", "Ok");
2730 // js.put("url", "http://localhost:80");
2731 // js.put("userName", "User");
2732 // js.put("password", "pass");
2733 // js.put("downloadUri", "http://127.0.0.1:80");
2734 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2735 // js.put("keyStorePass", "Changeme_123");
2736 // js.put("keyStoreType", "PKCS12");
2737 // JSONArray ja = new JSONArray();
2738 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2740 // JSONArray ja1 = new JSONArray();
2741 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2743 // JSONArray ja2 = new JSONArray();
2744 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2746 // JSONObject jsObject = new JSONObject();
2747 // jsObject.put("downloadUrl", "http://localhost:80");
2748 // jsObject.put("csarName", "HSS");
2749 // js.put("vim_info", ja);
2750 // js.put("template", ja2);
2751 // js.put("templates", ja1);
2752 // js.put("packageInfo", jsObject);
2757 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2759 JSONObject vnfpkg = new JSONObject();
2760 vnfpkg.put("name", "test");
2761 JSONObject obj = new JSONObject();
2762 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2763 obj.put("csar_file_name", "casrFile");
2764 vnfpkg.put("template", obj);
2765 Map<String, String> paramsMap = new HashMap<>();
2766 paramsMap.put("csarid", "csarid123");
2767 paramsMap.put("vnfmid", "vnfmid1234");
2768 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2769 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2773 @Test(expected=JSONException.class)
2774 public void uploadVNFPackageTestWithSBC() {
2776 // new MockUp<VNFRestfulUtil>(){
2778 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2779 // RestfulResponse rr = new RestfulResponse();
2780 // Map<String, String> header = new HashMap<>();
2781 // header.put("Content-Type", "Application/Json");
2782 // header.put("X-FormId", "jhfdl");
2783 // rr.setRespHeaderMap(header);
2784 // rr.setStatus(200);
2785 // rr.setResponseJson("shdfhj");
2792 // new MockUp<JSONObject>(){
2794 // public JSONObject fromObject(Object object){
2795 // JSONObject js = new JSONObject();
2796 // js.put("id", "upload-id-123");
2797 // js.put("Result", "Success");
2798 // js.put("Check", "Ok");
2799 // js.put("url", "http://localhost:80");
2800 // js.put("userName", "User");
2801 // js.put("password", "pass");
2802 // js.put("downloadUri", "http://127.0.0.1:80");
2803 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2804 // js.put("keyStorePass", "Changeme_123");
2805 // js.put("keyStoreType", "PKCS12");
2806 // JSONArray ja = new JSONArray();
2807 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2809 // JSONArray ja1 = new JSONArray();
2810 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2812 // JSONArray ja2 = new JSONArray();
2813 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2815 // JSONObject jsObject = new JSONObject();
2816 // jsObject.put("downloadUrl", "http://localhost:80");
2817 // jsObject.put("csarName", "SBC");
2818 // js.put("vim_info", ja);
2819 // js.put("template", ja2);
2820 // js.put("templates", ja1);
2821 // js.put("packageInfo", jsObject);
2826 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2828 JSONObject vnfpkg = new JSONObject();
2829 vnfpkg.put("name", "test");
2830 JSONObject obj = new JSONObject();
2831 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2832 obj.put("csar_file_name", "casrFile");
2833 vnfpkg.put("template", obj);
2834 Map<String, String> paramsMap = new HashMap<>();
2835 paramsMap.put("csarid", "csarid123");
2836 paramsMap.put("vnfmid", "vnfmid1234");
2837 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2838 assertTrue(res.get("reason").equals("RestfulResponse is null."));
2842 @Test(expected=JSONException.class)
2843 public void uploadVNFPackageTestWithPCRF() {
2845 // new MockUp<VNFRestfulUtil>(){
2847 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2848 // RestfulResponse rr = new RestfulResponse();
2849 // Map<String, String> header = new HashMap<>();
2850 // header.put("Content-Type", "Application/Json");
2851 // header.put("X-FormId", "jhfdl");
2852 // rr.setRespHeaderMap(header);
2853 // rr.setStatus(200);
2854 // rr.setResponseJson("shdfhj");
2861 // new MockUp<JSONObject>(){
2863 // public JSONObject fromObject(Object object){
2864 // JSONObject js = new JSONObject();
2865 // js.put("id", "upload-id-123");
2866 // js.put("Result", "Success");
2867 // js.put("Check", "Ok");
2868 // js.put("url", "http://localhost:80");
2869 // js.put("userName", "User");
2870 // js.put("password", "pass");
2871 // js.put("downloadUri", "http://127.0.0.1:80");
2872 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2873 // js.put("keyStorePass", "Changeme_123");
2874 // js.put("keyStoreType", "PKCS12");
2875 // JSONArray ja = new JSONArray();
2876 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2878 // JSONArray ja1 = new JSONArray();
2879 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2881 // JSONArray ja2 = new JSONArray();
2882 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2884 // JSONObject jsObject = new JSONObject();
2885 // jsObject.put("downloadUrl", "http://localhost:80");
2886 // jsObject.put("csarName", "PCRF");
2887 // js.put("vim_info", ja);
2888 // js.put("template", ja2);
2889 // js.put("templates", ja1);
2890 // js.put("packageInfo", jsObject);
2895 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2897 JSONObject vnfpkg = new JSONObject();
2898 vnfpkg.put("name", "test");
2899 JSONObject obj = new JSONObject();
2900 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2901 obj.put("csar_file_name", "casrFile");
2902 vnfpkg.put("template", obj);
2903 Map<String, String> paramsMap = new HashMap<>();
2904 paramsMap.put("csarid", "csarid123");
2905 paramsMap.put("vnfmid", "vnfmid1234");
2906 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2907 assertTrue(res.get("reason").equals("download csar file failed."));
2911 @Test(expected=JSONException.class)
2912 public void uploadVNFPackageTestWithTAS() {
2914 // new MockUp<VNFRestfulUtil>(){
2916 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2917 // RestfulResponse rr = new RestfulResponse();
2918 // Map<String, String> header = new HashMap<>();
2919 // header.put("Content-Type", "Application/Json");
2920 // header.put("X-FormId", "jhfdl");
2921 // rr.setRespHeaderMap(header);
2922 // rr.setStatus(200);
2923 // rr.setResponseJson("shdfhj");
2930 // new MockUp<JSONObject>(){
2932 // public JSONObject fromObject(Object object){
2933 // JSONObject js = new JSONObject();
2934 // js.put("id", "upload-id-123");
2935 // js.put("Result", "Success");
2936 // js.put("Check", "Ok");
2937 // js.put("url", "http://localhost:80");
2938 // js.put("userName", "User");
2939 // js.put("password", "pass");
2940 // js.put("downloadUri", "http://127.0.0.1:80");
2941 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
2942 // js.put("keyStorePass", "Changeme_123");
2943 // js.put("keyStoreType", "PKCS12");
2944 // JSONArray ja = new JSONArray();
2945 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
2947 // JSONArray ja1 = new JSONArray();
2948 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
2950 // JSONArray ja2 = new JSONArray();
2951 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
2953 // JSONObject jsObject = new JSONObject();
2954 // jsObject.put("downloadUrl", "http://localhost:80");
2955 // jsObject.put("csarName", "TAS");
2956 // js.put("vim_info", ja);
2957 // js.put("template", ja2);
2958 // js.put("templates", ja1);
2959 // js.put("packageInfo", jsObject);
2964 // System.setProperty("catalina.base", "D:/ONAP-VFC/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
2966 JSONObject vnfpkg = new JSONObject();
2967 vnfpkg.put("name", "test");
2968 JSONObject obj = new JSONObject();
2969 obj.put("csar_file_path", "src/test/resources/Check10.txt");
2970 obj.put("csar_file_name", "casrFile");
2971 vnfpkg.put("template", obj);
2972 Map<String, String> paramsMap = new HashMap<>();
2973 paramsMap.put("csarid", "csarid123");
2974 paramsMap.put("vnfmid", "vnfmid1234");
2975 JSONObject res = manager.uploadVNFPackage(vnfpkg, paramsMap);
2976 assertTrue(res.get("reason").equals("download csar file failed."));
2981 public void uploadVNFPackageTestWithCSCF() {
2983 // new MockUp<VNFRestfulUtil>(){
2985 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
2986 // RestfulResponse rr = new RestfulResponse();
2987 // Map<String, String> header = new HashMap<>();
2988 // header.put("Content-Type", "Application/Json");
2989 // header.put("X-FormId", "jhfdl");
2990 // rr.setRespHeaderMap(header);
2991 // rr.setStatus(200);
2992 // rr.setResponseJson("shdfhj");
2999 // new MockUp<JSONObject>(){
3001 // public JSONObject fromObject(Object object){
3002 // JSONObject js = new JSONObject();
3003 // js.put("id", "upload-id-123");
3004 // js.put("Result", "Success");
3005 // js.put("Check", "Ok");
3006 // js.put("url", "http://localhost:80");
3007 // js.put("userName", "User");
3008 // js.put("password", "pass");
3009 // js.put("downloadUri", "http://127.0.0.1:80");
3010 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3011 // js.put("keyStorePass", "Changeme_123");
3012 // js.put("keyStoreType", "PKCS12");
3013 // JSONArray ja = new JSONArray();
3014 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3016 // JSONArray ja1 = new JSONArray();
3017 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3019 // JSONArray ja2 = new JSONArray();
3020 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3022 // JSONObject jsObject = new JSONObject();
3023 // jsObject.put("downloadUrl", "http://localhost:80");
3024 // jsObject.put("csarName", "CSCF");
3025 // JSONObject jsEms = new JSONObject();
3026 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3027 // JSONObject jsCsar = new JSONObject();
3028 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3029 // jsCsar.put("csar_file_name", "Csar_File");
3030 // jsCsar.put("emsUuid", jsEms);
3031 // JSONObject jsTemp = new JSONObject();
3032 // jsTemp.put("template", jsCsar);
3033 // js.put("vCSCF", jsTemp);
3034 // js.put("vim_info", ja);
3035 // js.put("template", ja2);
3036 // js.put("templates", ja1);
3037 // js.put("packageInfo", jsObject);
3042 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3044 JSONObject vnfpkg = new JSONObject();
3045 JSONObject vnfpkg1 = new JSONObject();
3046 vnfpkg.put("name", "test");
3047 JSONObject obj = new JSONObject();
3048 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3049 obj.put("csar_file_name", "casrFile");
3050 vnfpkg.put("template", obj);
3051 Map<String, String> paramsMap = new HashMap<>();
3052 paramsMap.put("csarid", "csarid123");
3053 paramsMap.put("vnfmid", "vnfmid1234");
3054 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3055 assertTrue(res.get("reason").equals("download csar file failed."));
3059 public void uploadVNFPackageTestWithOutEmsUid() {
3061 // new MockUp<VNFRestfulUtil>(){
3063 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3064 // RestfulResponse rr = new RestfulResponse();
3065 // Map<String, String> header = new HashMap<>();
3066 // header.put("Content-Type", "Application/Json");
3067 // header.put("X-FormId", "jhfdl");
3068 // rr.setRespHeaderMap(header);
3069 // rr.setStatus(200);
3070 // rr.setResponseJson("shdfhj");
3077 // new MockUp<JSONObject>(){
3079 // public JSONObject fromObject(Object object){
3080 // JSONObject js = new JSONObject();
3081 // js.put("id", "upload-id-123");
3082 // js.put("Result", "Success");
3083 // js.put("Check", "Ok");
3084 // js.put("url", "http://localhost:80");
3085 // js.put("userName", "User");
3086 // js.put("password", "pass");
3087 // js.put("downloadUri", "http://127.0.0.1:80");
3088 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3089 // js.put("keyStorePass", "Changeme_123");
3090 // js.put("keyStoreType", "PKCS12");
3091 // JSONArray ja = new JSONArray();
3092 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3094 // JSONArray ja1 = new JSONArray();
3095 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3097 // JSONArray ja2 = new JSONArray();
3098 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3100 // JSONObject jsObject = new JSONObject();
3101 // jsObject.put("downloadUrl", "http://localhost:80");
3102 // jsObject.put("csarName", "CSCF");
3103 // JSONObject jsCsar = new JSONObject();
3104 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3105 // jsCsar.put("csar_file_name", "Csar_File");
3106 // JSONObject jsTemp = new JSONObject();
3107 // jsTemp.put("template", jsCsar);
3108 // js.put("vCSCF", jsTemp);
3109 // js.put("vim_info", ja);
3110 // js.put("template", ja2);
3111 // js.put("templates", ja1);
3112 // js.put("packageInfo", jsObject);
3117 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3119 JSONObject vnfpkg = new JSONObject();
3120 JSONObject vnfpkg1 = new JSONObject();
3121 vnfpkg.put("name", "test");
3122 JSONObject obj = new JSONObject();
3123 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3124 obj.put("csar_file_name", "casrFile");
3125 vnfpkg.put("template", obj);
3126 Map<String, String> paramsMap = new HashMap<>();
3127 paramsMap.put("csarid", "csarid123");
3128 paramsMap.put("vnfmid", "vnfmid1234");
3129 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3130 assertTrue(res.get("reason").equals("download csar file failed."));
3134 public void uploadVNFPackageTestWithCSDowCsar() {
3136 // new MockUp<VNFRestfulUtil>(){
3138 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3139 // RestfulResponse rr = new RestfulResponse();
3140 // Map<String, String> header = new HashMap<>();
3141 // header.put("Content-Type", "Application/Json");
3142 // header.put("X-FormId", "jhfdl");
3143 // rr.setRespHeaderMap(header);
3144 // rr.setStatus(200);
3145 // rr.setResponseJson("shdfhj");
3152 // new MockUp<DownloadCsarManager>(){
3154 // public String download(String url, String filepath) {
3155 // String response = "Success";
3160 // new MockUp<JSONObject>(){
3162 // public JSONObject fromObject(Object object){
3163 // JSONObject js = new JSONObject();
3164 // js.put("id", "upload-id-123");
3165 // js.put("Result", "Success");
3166 // js.put("Check", "Ok");
3167 // js.put("url", "http://localhost:80");
3168 // js.put("userName", "User");
3169 // js.put("password", "pass");
3170 // js.put("downloadUri", "http://127.0.0.1:80");
3171 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3172 // js.put("keyStorePass", "Changeme_123");
3173 // js.put("keyStoreType", "PKCS12");
3174 // JSONArray ja = new JSONArray();
3175 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3177 // JSONArray ja1 = new JSONArray();
3178 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3180 // JSONArray ja2 = new JSONArray();
3181 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3183 // JSONObject jsObject = new JSONObject();
3184 // jsObject.put("downloadUrl", "http://localhost:80");
3185 // jsObject.put("csarName", "CSCF");
3186 // JSONObject jsEms = new JSONObject();
3187 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3188 // JSONObject jsCsar = new JSONObject();
3189 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3190 // jsCsar.put("csar_file_name", "Csar_File");
3191 // jsCsar.put("emsUuid", jsEms);
3192 // JSONObject jsTemp = new JSONObject();
3193 // jsTemp.put("template", jsCsar);
3194 // js.put("vCSCF", jsTemp);
3195 // js.put("vim_info", ja);
3196 // js.put("template", ja2);
3197 // js.put("templates", ja1);
3198 // js.put("packageInfo", jsObject);
3203 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3205 JSONObject vnfpkg = new JSONObject();
3206 JSONObject vnfpkg1 = new JSONObject();
3207 vnfpkg.put("name", "test");
3208 JSONObject obj = new JSONObject();
3209 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3210 obj.put("csar_file_name", "casrFile");
3211 vnfpkg.put("template", obj);
3212 Map<String, String> paramsMap = new HashMap<>();
3213 paramsMap.put("csarid", "csarid123");
3214 paramsMap.put("vnfmid", "vnfmid1234");
3215 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3216 assertTrue(res.get("reason").equals("unzip csar file failed."));
3220 public void uploadVNFPackageTestWithUnZipCsar() {
3222 // new MockUp<VNFRestfulUtil>(){
3224 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3225 // RestfulResponse rr = new RestfulResponse();
3226 // Map<String, String> header = new HashMap<>();
3227 // header.put("Content-Type", "Application/Json");
3228 // header.put("X-FormId", "jhfdl");
3229 // rr.setRespHeaderMap(header);
3230 // rr.setStatus(200);
3231 // rr.setResponseJson("shdfhj");
3237 // new MockUp<VnfmUtil>(){
3239 // public JSONObject getVnfmById(String vnfmId) {
3241 // JSONObject jsonObject = new JSONObject();
3242 // jsonObject.put("url", "https://localhost:80");
3243 // jsonObject.put("userName", "ubuntu");
3244 // jsonObject.put("password", "******");
3245 // return jsonObject;
3250 // new MockUp<DownloadCsarManager>(){
3252 // public String download(String url, String filepath) {
3253 // String response = "Success";
3258 // public int unzipCSAR(String fileName, String filePath) {
3264 // new MockUp<ConnectMgrVnfm>(){
3266 // public int connect(JSONObject vnfmObj, String authModel) {
3274 // new MockUp<JSONObject>(){
3276 // public JSONObject fromObject(Object object){
3277 // JSONObject js = new JSONObject();
3278 // js.put("id", "upload-id-123");
3279 // js.put("Result", "Success");
3280 // js.put("Check", "Ok");
3281 // js.put("url", "http://localhost:80");
3282 // js.put("userName", "User");
3283 // js.put("password", "pass");
3284 // js.put("downloadUri", "http://127.0.0.1:80");
3285 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3286 // js.put("keyStorePass", "Changeme_123");
3287 // js.put("keyStoreType", "PKCS12");
3288 // JSONArray ja = new JSONArray();
3289 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3291 // JSONArray ja1 = new JSONArray();
3292 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3294 // JSONArray ja2 = new JSONArray();
3295 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3297 // JSONObject jsObject = new JSONObject();
3298 // jsObject.put("downloadUrl", "http://localhost:80");
3299 // jsObject.put("csarName", "CSCF");
3300 // JSONObject jsEms = new JSONObject();
3301 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3302 // JSONObject jsCsar = new JSONObject();
3303 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3304 // jsCsar.put("csar_file_name", "Csar_File");
3305 // jsCsar.put("emsUuid", jsEms);
3306 // JSONObject jsTemp = new JSONObject();
3307 // jsTemp.put("template", jsCsar);
3308 // js.put("vCSCF", jsTemp);
3309 // js.put("vim_info", ja);
3310 // js.put("template", ja2);
3311 // js.put("templates", ja1);
3312 // js.put("packageInfo", jsObject);
3317 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3319 JSONObject vnfpkg = new JSONObject();
3320 JSONObject vnfpkg1 = new JSONObject();
3321 vnfpkg.put("name", "test");
3322 JSONObject obj = new JSONObject();
3323 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3324 obj.put("csar_file_name", "casrFile");
3325 vnfpkg.put("template", obj);
3326 Map<String, String> paramsMap = new HashMap<>();
3327 paramsMap.put("csarid", "csarid123");
3328 paramsMap.put("vnfmid", "vnfmid1234");
3329 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3330 assertTrue(res.get("reason").equals("connect fail."));
3333 @Test(expected=JSONException.class)
3334 public void uploadVNFPackageTestWithConnectMgr() {
3336 // new MockUp<VNFRestfulUtil>(){
3338 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3339 // RestfulResponse rr = new RestfulResponse();
3340 // Map<String, String> header = new HashMap<>();
3341 // header.put("Content-Type", "Application/Json");
3342 // header.put("X-FormId", "jhfdl");
3343 // rr.setRespHeaderMap(header);
3344 // rr.setStatus(200);
3345 // rr.setResponseJson("shdfhj");
3352 // new MockUp<VnfmUtil>(){
3354 // public JSONObject getVnfmById(String vnfmId) {
3356 // JSONObject jsonObject = new JSONObject();
3357 // jsonObject.put("url", "https://localhost:80");
3358 // jsonObject.put("userName", "ubuntu");
3359 // jsonObject.put("password", "******");
3360 // return jsonObject;
3365 // new MockUp<DownloadCsarManager>(){
3367 // public String download(String url, String filepath) {
3368 // String response = "Success";
3373 // public int unzipCSAR(String fileName, String filePath) {
3379 // new MockUp<HttpClient>(){
3381 // public int executeMethod(HttpMethod method) {
3386 // new MockUp<HttpMethodBase>(){
3389 // public int getStatusCode(){
3396 // new MockUp<ConnectMgrVnfm>(){
3398 // public int connect(JSONObject vnfmObj, String authModel) {
3406 // public String getAccessSession() {
3412 // new MockUp<JSONObject>(){
3414 // public JSONObject fromObject(Object object){
3415 // JSONObject js = new JSONObject();
3416 // js.put("id", "upload-id-123");
3417 // js.put("Result", "Success");
3418 // js.put("Check", "Ok");
3419 // js.put("url", "http://localhost:80");
3420 // js.put("userName", "User");
3421 // js.put("password", "pass");
3422 // js.put("downloadUri", "http://127.0.0.1:80");
3423 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3424 // js.put("keyStorePass", "Changeme_123");
3425 // js.put("keyStoreType", "PKCS12");
3426 // JSONArray ja = new JSONArray();
3427 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3429 // JSONArray ja1 = new JSONArray();
3430 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3432 // JSONArray ja2 = new JSONArray();
3433 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3435 // JSONObject jsObject = new JSONObject();
3436 // jsObject.put("downloadUrl", "http://localhost:80");
3437 // jsObject.put("csarName", "CSCF");
3438 // JSONObject jsEms = new JSONObject();
3439 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3440 // JSONObject jsCsar = new JSONObject();
3441 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3442 // jsCsar.put("csar_file_name", "Csar_File");
3443 // jsCsar.put("emsUuid", jsEms);
3444 // JSONObject jsTemp = new JSONObject();
3445 // jsTemp.put("template", jsCsar);
3446 // js.put("vCSCF", jsTemp);
3447 // js.put("vim_info", ja);
3448 // js.put("template", ja2);
3449 // js.put("templates", ja1);
3450 // js.put("packageInfo", jsObject);
3455 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3457 JSONObject vnfpkg = new JSONObject();
3458 JSONObject vnfpkg1 = new JSONObject();
3459 vnfpkg.put("name", "test");
3460 JSONObject obj = new JSONObject();
3461 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3462 obj.put("csar_file_name", "casrFile");
3463 vnfpkg.put("template", obj);
3464 Map<String, String> paramsMap = new HashMap<>();
3465 paramsMap.put("csarid", "csarid123");
3466 paramsMap.put("vnfmid", "vnfmid1234");
3467 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3468 assertTrue(res.get("reason").equals("RestfulResponse is null."));
3472 public void uploadVNFPackageTestWithConnectMgrGetAllFail() {
3474 // new MockUp<VNFRestfulUtil>(){
3476 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3477 // RestfulResponse rr = new RestfulResponse();
3478 // Map<String, String> header = new HashMap<>();
3479 // header.put("Content-Type", "Application/Json");
3480 // header.put("X-FormId", "jhfdl");
3481 // rr.setRespHeaderMap(header);
3482 // rr.setStatus(200);
3483 // rr.setResponseJson("shdfhj");
3490 // new MockUp<VnfmUtil>(){
3492 // public JSONObject getVnfmById(String vnfmId) {
3494 // JSONObject jsonObject = new JSONObject();
3495 // jsonObject.put("url", "https://localhost:80");
3496 // jsonObject.put("userName", "ubuntu");
3497 // jsonObject.put("password", "******");
3498 // return jsonObject;
3503 // new MockUp<DownloadCsarManager>(){
3505 // public String download(String url, String filepath) {
3506 // String response = "Success";
3511 // public int unzipCSAR(String fileName, String filePath) {
3517 // new MockUp<ConnectMgrVnfm>(){
3519 // public int connect(JSONObject vnfmObj, String authModel) {
3527 // public String getAccessSession() {
3533 // new MockUp<JSONObject>(){
3535 // public JSONObject fromObject(Object object){
3536 // JSONObject js = new JSONObject();
3537 // js.put("id", "upload-id-123");
3538 // js.put("Result", "Success");
3539 // js.put("Check", "Ok");
3540 // js.put("url", "http://localhost:80");
3541 // js.put("userName", "User");
3542 // js.put("password", "pass");
3543 // js.put("downloadUri", "http://127.0.0.1:80");
3544 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3545 // js.put("keyStorePass", "Changeme_123");
3546 // js.put("keyStoreType", "PKCS12");
3547 // JSONArray ja = new JSONArray();
3548 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3550 // JSONArray ja1 = new JSONArray();
3551 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";;
3553 // JSONArray ja2 = new JSONArray();
3554 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3556 // JSONObject jsObject = new JSONObject();
3557 // jsObject.put("downloadUrl", "http://localhost:80");
3558 // jsObject.put("csarName", "CSCF");
3559 // JSONObject jsEms = new JSONObject();
3560 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3561 // JSONObject jsCsar = new JSONObject();
3562 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3563 // jsCsar.put("csar_file_name", "Csar_File");
3564 // jsCsar.put("emsUuid", jsEms);
3565 // JSONObject jsTemp = new JSONObject();
3566 // jsTemp.put("template", jsCsar);
3567 // js.put("vCSCF", jsTemp);
3568 // js.put("vim_info", ja);
3569 // js.put("template", ja2);
3570 // js.put("templates", ja1);
3571 // js.put("packageInfo", jsObject);
3576 // System.setProperty("catalina.base", "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3578 JSONObject vnfpkg = new JSONObject();
3579 JSONObject vnfpkg1 = new JSONObject();
3580 vnfpkg.put("name", "test");
3581 JSONObject obj = new JSONObject();
3582 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3583 obj.put("csar_file_name", "casrFile");
3584 vnfpkg.put("template", obj);
3585 Map<String, String> paramsMap = new HashMap<>();
3586 paramsMap.put("csarid", "csarid123");
3587 paramsMap.put("vnfmid", "vnfmid1234");
3588 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3589 assertTrue(res.get("reason").equals("get allcloud failed and IOException.Connection refused (Connection refused)"));
3593 public void uploadVNFPackageTestVnfdPlanInfo() throws IOException {
3595 // new MockUp<VNFRestfulUtil>() {
3597 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3598 // RestfulResponse rr = new RestfulResponse();
3599 // Map<String, String> header = new HashMap<>();
3600 // header.put("Content-Type", "Application/Json");
3601 // header.put("X-FormId", "jhfdl");
3602 // rr.setRespHeaderMap(header);
3603 // rr.setStatus(200);
3604 // rr.setResponseJson("shdfhj");
3611 // new MockUp<VnfmUtil>() {
3613 // public JSONObject getVnfmById(String vnfmId) {
3615 // JSONObject jsonObject = new JSONObject();
3616 // jsonObject.put("url", "https://localhost:80");
3617 // jsonObject.put("userName", "ubuntu");
3618 // jsonObject.put("password", "******");
3619 // return jsonObject;
3624 // new MockUp<DownloadCsarManager>() {
3626 // public String download(String url, String filepath) {
3627 // String response = "Success";
3632 // public int unzipCSAR(String fileName, String filePath) {
3638 // new MockUp<ConnectMgrVnfm>() {
3640 // public int connect(JSONObject vnfmObj, String authModel) {
3647 // public String getAccessSession() {
3653 // new MockUp<JSONObject>() {
3655 // public JSONObject fromObject(Object object) {
3656 // JSONObject js = new JSONObject();
3657 // js.put("id", "upload-id-123");
3658 // js.put("Result", "Success");
3659 // js.put("Check", "Ok");
3660 // js.put("url", "http://localhost:80");
3661 // js.put("userName", "User");
3662 // js.put("password", "pass");
3663 // js.put("downloadUri", "http://127.0.0.1:80");
3664 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3665 // js.put("keyStorePass", "Changeme_123");
3666 // js.put("keyStoreType", "PKCS12");
3667 // JSONArray ja = new JSONArray();
3668 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3670 // JSONArray ja1 = new JSONArray();
3671 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3674 // JSONArray ja2 = new JSONArray();
3675 // String str2 = "{\n \"template_name\": \"vnfd-name-123\",\n \"topology_template\": [{\n\t\t\t\"service_url\": \"/api/hwvnfm/v1\",\n\t\t\t\n\t\t}]\n\t\n\t\n}";
3677 // JSONObject jsObject = new JSONObject();
3678 // jsObject.put("downloadUrl", "http://localhost:80");
3679 // jsObject.put("csarName", "CSCF");
3680 // JSONObject jsEms = new JSONObject();
3681 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3682 // JSONObject jsCsar = new JSONObject();
3683 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3684 // jsCsar.put("csar_file_name", "Csar_File");
3685 // jsCsar.put("emsUuid", jsEms);
3686 // JSONObject jsTemp = new JSONObject();
3687 // jsTemp.put("template", jsCsar);
3688 // js.put("vCSCF", jsTemp);
3689 // js.put("vim_info", ja);
3690 // js.put("template", ja2);
3691 // js.put("templates", ja1);
3692 // js.put("packageInfo", jsObject);
3697 // System.setProperty("catalina.base",
3698 // "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3700 JSONObject vnfpkg = new JSONObject();
3701 JSONObject vnfpkg1 = new JSONObject();
3702 vnfpkg.put("name", "test");
3703 JSONObject obj = new JSONObject();
3704 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3705 obj.put("csar_file_name", "casrFile");
3706 vnfpkg.put("template", obj);
3707 Map<String, String> paramsMap = new HashMap<>();
3708 paramsMap.put("csarid", "csarid123");
3709 paramsMap.put("vnfmid", "vnfmid1234");
3710 String testString = "test\nstring";
3711 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3712 assertTrue(res.get("reason")
3713 .equals("get allcloud failed and IOException.Connection refused (Connection refused)"));
3717 public void uploadVNFPackageSuccessTest() {
3719 // new MockUp<VNFRestfulUtil>() {
3721 // public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
3722 // RestfulResponse rr = new RestfulResponse();
3723 // Map<String, String> header = new HashMap<>();
3724 // header.put("Content-Type", "Application/Json");
3725 // header.put("X-FormId", "jhfdl");
3726 // rr.setRespHeaderMap(header);
3727 // rr.setStatus(200);
3728 // rr.setResponseJson("shdfhj");
3735 // new MockUp<VnfmUtil>() {
3737 // public JSONObject getVnfmById(String vnfmId) {
3739 // JSONObject jsonObject = new JSONObject();
3740 // jsonObject.put("url", "https://localhost:80");
3741 // jsonObject.put("userName", "ubuntu");
3742 // jsonObject.put("password", "******");
3743 // return jsonObject;
3748 // new MockUp<DownloadCsarManager>() {
3750 // public String download(String url, String filepath) {
3751 // String response = "Success";
3756 // public int unzipCSAR(String fileName, String filePath) {
3762 // new MockUp<HttpClient>() {
3764 // public int executeMethod(HttpMethod method) {
3769 // new MockUp<HttpMethodBase>() {
3772 // public int getStatusCode() {
3779 // new MockUp<ConnectMgrVnfm>() {
3781 // public int connect(JSONObject vnfmObj, String authModel) {
3788 // public String getAccessSession() {
3794 // new MockUp<JSONObject>() {
3796 // public JSONObject fromObject(Object object) {
3797 // JSONObject js = new JSONObject();
3798 // js.put("id", "upload-id-123");
3799 // js.put("Result", "Success");
3800 // js.put("Check", "Ok");
3801 // js.put("url", "http://localhost:80");
3802 // js.put("userName", "User");
3803 // js.put("password", "pass");
3804 // js.put("downloadUri", "http://127.0.0.1:80");
3805 // js.put("keyStore", "C:/Users/Huawei/Desktop/etc/conf/server.p12");
3806 // js.put("keyStorePass", "Changeme_123");
3807 // js.put("keyStoreType", "PKCS12");
3808 // JSONArray ja = new JSONArray();
3809 // String str = "{\n \"vim_id\": \"vim-0-1\",\n\t\"vim-info\": {\n\t\t\"vim-name\": \"vim-name-123\",\n\t\t\"vim-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3811 // JSONArray ja1 = new JSONArray();
3812 // String str1 = "{\n \"vnfdVersion\": \"1.0version\",\n\t\"vnfd-info\": {\n\t\t\"vnfd-name\": \"vnfd-name-123\",\n\t\t\"vnfd-id\": \"vim-0-1\",\n\t\t\"ip\": \"127.0.0.1\",\n\t\t\"port\": \"8482\",\n\t\t\"protocol\": \"http\",\n\t\t\n\t}\n}";
3815 // JSONArray ja2 = new JSONArray();
3816 // String str2 = "{\"template_name\": \"VNFD_vUGW\",\"topology_template\":[{\"plan_name\": \"Normal_E9K\",\"plan_id\": \"Normal_E9K\"}]}";
3818 // JSONObject verTmpObj = ja2.getJSONObject(0);
3819 // JSONObject jsObject = new JSONObject();
3820 // jsObject.put("downloadUrl", "http://localhost:80");
3821 // jsObject.put("csarName", "CSCF");
3822 // JSONObject jsEms = new JSONObject();
3823 // jsEms.put("emsUuid", "123erbhi-hjdek123");
3824 // JSONObject jsCsar = new JSONObject();
3825 // jsCsar.put("csar_file_path", "/home/ubuntu/check/");
3826 // jsCsar.put("csar_file_name", "Csar_File");
3827 // jsCsar.put("emsUuid", jsEms);
3828 // JSONObject jsTemp = new JSONObject();
3829 // jsTemp.put("template", jsCsar);
3830 // js.put("vCSCF", jsTemp);
3831 // js.put("vim_info", ja);
3832 // js.put("template", verTmpObj);
3833 // js.put("templates", ja1);
3834 // js.put("packageInfo", jsObject);
3839 // System.setProperty("catalina.base",
3840 // "D:/VFC/23-08-2018/svnfm/huawei/vnfmadapter/VnfmadapterService/deployment/src/main/release");
3842 JSONObject vnfpkg = new JSONObject();
3843 JSONObject vnfpkg1 = new JSONObject();
3844 vnfpkg.put("name", "test");
3845 JSONObject obj = new JSONObject();
3846 obj.put("csar_file_path", "src/test/resources/Check10.txt");
3847 obj.put("csar_file_name", "casrFile");
3848 vnfpkg.put("template", obj);
3849 Map<String, String> paramsMap = new HashMap<>();
3850 paramsMap.put("csarid", "csarid123");
3851 paramsMap.put("vnfmid", "vnfmid1234");
3852 JSONObject res = manager.uploadVNFPackage(vnfpkg1, paramsMap);
3853 assertEquals(res.get("retCode"), 200);
3858 public void transferFromCsarSI() throws Exception {
3860 AdapterResourceManager arManager = new AdapterResourceManager();
3861 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3862 m.setAccessible(true);
3863 m.invoke(arManager, "CSCF_SI");
3867 public void transferFromCsarCSCF() throws Exception {
3869 AdapterResourceManager arManager = new AdapterResourceManager();
3870 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3871 m.setAccessible(true);
3872 m.invoke(arManager, "CSCF");
3876 public void transferFromCsarMME() throws Exception {
3878 AdapterResourceManager arManager = new AdapterResourceManager();
3879 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3880 m.setAccessible(true);
3881 m.invoke(arManager, "MME");
3885 public void transferFromCsarSPGW() throws Exception {
3887 AdapterResourceManager arManager = new AdapterResourceManager();
3888 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3889 m.setAccessible(true);
3890 m.invoke(arManager, "SPGW");
3894 public void transferFromCsarHSS() throws Exception {
3896 AdapterResourceManager arManager = new AdapterResourceManager();
3897 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3898 m.setAccessible(true);
3899 m.invoke(arManager, "HSS");
3903 public void transferFromCsarSBC() throws Exception {
3905 AdapterResourceManager arManager = new AdapterResourceManager();
3906 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3907 m.setAccessible(true);
3908 m.invoke(arManager, "SBC");
3912 public void transferFromCsarPCRF() throws Exception {
3914 AdapterResourceManager arManager = new AdapterResourceManager();
3915 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3916 m.setAccessible(true);
3917 m.invoke(arManager, "PCRF");
3921 public void transferFromCsarTAS() throws Exception {
3923 AdapterResourceManager arManager = new AdapterResourceManager();
3924 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3925 m.setAccessible(true);
3926 m.invoke(arManager, "TAS");
3930 public void transferFromCsar() throws Exception {
3932 AdapterResourceManager arManager = new AdapterResourceManager();
3933 Method m =AdapterResourceManager.class.getDeclaredMethod("transferFromCsar", new Class[] {String.class});
3934 m.setAccessible(true);
3935 m.invoke(arManager, "transferFromCsar");
3939 public void uploadCsar() throws Exception {
3940 JSONObject vnfpkg = new JSONObject();
3941 vnfpkg.put("ftp_server_ip","127.0.0.1");
3942 vnfpkg.put("ftp_username","ftp_username");
3943 vnfpkg.put("ftp_password","ftp_password");
3944 AdapterResourceManager arManager = new AdapterResourceManager();
3945 Method m =AdapterResourceManager.class.getDeclaredMethod("uploadCsar", new Class[] {JSONObject.class,String.class});
3946 m.setAccessible(true);
3947 m.invoke(arManager, vnfpkg,"csarfilepath");
3953 public void readVnfdIdInfoFromJson() throws Exception{
3954 AdapterResourceManager arManager = new AdapterResourceManager();
3955 Method m =AdapterResourceManager.class.getDeclaredMethod("readVnfdIdInfoFromJson");
3956 m.setAccessible(true);
3957 m.invoke(arManager);