2 * Copyright 2016-2017, Nokia Corporation
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.
16 package com.nokia.vfcadaptor.vnfmdriver.controller;
18 import java.io.IOException;
19 import java.net.URISyntaxException;
21 import org.apache.http.client.ClientProtocolException;
22 import org.junit.Before;
23 import org.junit.Test;
25 public class VnfmDriverAdaptorControllerTest extends BaseControllerTestCase{
28 private String basicUrl="http://localhost:8080/NvfmDriver/api/nokiavnfm/v1";
29 private String funcPath;
34 isHttpsProtocol = false;
38 public void testInstantiateVnf() throws URISyntaxException, ClientProtocolException, IOException {
39 funcPath = "/vnfmId_001/vnfs";
40 url = basicUrl + funcPath;
41 String message = "{\"vnfInstanceName\":\"vnfInstanceName_001\",\"vnfPackageId\":\"1\"}";
43 String responseContent = sendPostMsg(message, url);
44 System.out.println("-------------------------------");
45 System.out.println( " Initiate Response is " + responseContent);
49 public void testTerminateVnf() throws URISyntaxException, ClientProtocolException, IOException {
50 funcPath = "/vnfmId_001/vnfs/vnfInstanceId_001/terminate";
51 url = basicUrl + funcPath;
52 String message = "{\"terminationType\":\"graceful\"}";
53 String responseContent = sendPostMsg(message, url);
54 System.out.println("-------------------------------");
55 System.out.println("Terminate Response is " + responseContent);
59 public void testQueryVnf() throws URISyntaxException, ClientProtocolException, IOException {
60 funcPath = "/vnfmId_001/vnfs/vnfInstanceId_001";
61 url = basicUrl + funcPath;
62 String message = "{\"vnfInfo\":\"{\"nfInstanceId\":\"1\",\"vnfInstanceName\":\"vFW\",\"vnfInstanceDescription\":\"vFW in Nanjing TIC Edge\",\"vnfdId\":\"1\"}\"}";
63 String responseContent = sendGetMsg(message, url);
65 System.out.println("-------------------------------");
66 System.out.println("QueryResponse is " + responseContent);
70 public void testOperStatusVnf() throws URISyntaxException, ClientProtocolException, IOException {
71 funcPath = "/vnfmId_001/jobs/jobId_001&responseId=responseId_001";
72 url = basicUrl + funcPath;
73 String message = "{\"jobId\":\"12345\",\"responseDescriptor\":\"{\"progress\":\"40\",\"status\":\"proccessing\"}\"}";
74 String responseContent = sendGetMsg(message, url);
75 System.out.println("-------------------------------");
76 System.out.println(" operStatus Response is " + responseContent);
80 public void testScaleVnf() throws URISyntaxException, ClientProtocolException, IOException {
81 funcPath = "/vnfmId_001/vnfs/vnfInstanceId_001/scale";
82 url = basicUrl + funcPath;
83 String message = "{\"type\":\"12345\",\"aspectId\":\"145\"}";
84 String responseContent = sendPostMsg(message, url);
85 System.out.println("-------------------------------");
86 System.out.println(" Scale Response is " + responseContent);
90 public void testHealVnf() throws URISyntaxException, ClientProtocolException, IOException {
91 funcPath = "/vnfmId_001/vnfs/vnfInstanceId_001/heal";
92 url = basicUrl + funcPath;
93 String message = "{\"action\":\"12345\"}";
94 String responseContent = sendPostMsg(message, url);
95 System.out.println("-------------------------------");
96 System.out.println(" Heal Response is " + responseContent);