summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurali-P <murali.p@huawei.com>2017-04-07 13:17:41 +0530
committerMurali-P <murali.p@huawei.com>2017-04-07 13:17:41 +0530
commit2be23d1f915c1c3dda4b79e4a43a05a4b94128d0 (patch)
tree8098ba051f1e894aad2faa1227cc59b6abb4fca8
parente9ba9ebc4085d5aa0834e9e11732635dc39bd634 (diff)
Fix unit test coverage issue
Resolved:VNFSDK-21 VNF SDK Function tests Change-Id: I148ed2c00c27ddb0fd42d3313e1d18f31477066e Signed-off-by: Murali-P <murali.p@huawei.com>
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java157
1 files changed, 80 insertions, 77 deletions
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java
index 052462e..664cbb8 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java
@@ -16,8 +16,8 @@
package org.openo.vnfsdk.functest.resource;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.FileInputStream;
@@ -27,24 +27,24 @@ import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+
import javax.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;
+import org.openo.vnfsdk.functest.FileUtil;
import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
import org.openo.vnfsdk.functest.util.ZipCompressor;
import mockit.Mock;
import mockit.MockUp;
-import org.openo.vnfsdk.functest.FileUtil;
-
public class CommonManagerTest {
private CommonManager commonManger;
private String instanceId;
-
+
private String funcTestId = "59d1e651-df9f-4008-902f-e3b377e6ec30";
private Response response = null;
@@ -55,78 +55,6 @@ public class CommonManagerTest {
}
@Test
- public void testUploadFuncTestPackage() {
- URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
- String zipFileName = url.getPath() + ".zip";
-
- new MockUp<FileUtil>() {
- @Mock
- public String[] getDirectory(String directory) {
- File file = new File( "temp" );
- return file.list();
- }
- };
-
- try {
- InputStream mockInputStream = new FileInputStream(zipFileName);
- response = commonManger.uploadFuncTestPackage( mockInputStream, funcTestId );
- assertNotNull( response );
- assertEquals( 200 , response.getStatus() );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testGetOperationResult() {
- try {
- response = commonManger.getOperationResult( funcTestId );
- assertNotNull( response );
- assertEquals( 200 , response.getStatus() );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testDownloadResults() {
- try {
- response = commonManger.downloadResults( funcTestId );
- /*assertNotNull( response );
- assertEquals( 200 , response.getStatus() ); */
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testStoreChunkFileInLocal() {
- URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
- String zipFileName = url.getPath() + ".zip";
-
- try {
- InputStream mockInputStream = new FileInputStream(zipFileName);
- String chunkFilePath = commonManger.storeChunkFileInLocal( "src/test/resources", "chunkFileInLocal" , mockInputStream );
- assertNotNull( chunkFilePath );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testSetEnvironment() {
- try {
-
- String jsonInput =
- "{\"remoteIp\":\"192.168.4.47\",\"userName\":\"root\",\"password\":\"root123\", \"path\":\"/src/test/resources\"}";
- response = commonManger.setEnvironment(jsonInput);
- assertNotNull(response);
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
public void testexecuteFunc() throws FileNotFoundException {
URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
@@ -159,7 +87,82 @@ public class CommonManagerTest {
@Test
public void testQueryResultWhenInstanceIdAbsent() {
- Response response = commonManger.queryResultByFuncTest( funcTestId );
+ Response response = commonManger.queryResultByFuncTest(funcTestId);
assertNotNull(response);
}
+
+ @Test
+ public void testUploadFuncTestPackage() {
+ URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
+ String zipFileName = url.getPath() + ".zip";
+
+ new MockUp<FileUtil>() {
+
+ @Mock
+ public String[] getDirectory(String directory) {
+ File file = new File("temp");
+ return file.list();
+ }
+ };
+
+ try {
+ InputStream mockInputStream = new FileInputStream(zipFileName);
+ response = commonManger.uploadFuncTestPackage(mockInputStream, funcTestId);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetOperationResult() {
+ try {
+ response = commonManger.getOperationResult(funcTestId);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testDownloadResults() {
+ try {
+ response = commonManger.downloadResults(funcTestId);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStoreChunkFileInLocal() {
+ URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
+ String zipFileName = url.getPath() + ".zip";
+
+ try {
+ InputStream mockInputStream = new FileInputStream(zipFileName);
+ String chunkFilePath =
+ commonManger.storeChunkFileInLocal("src/test/resources", "chunkFileInLocal", mockInputStream);
+ assertNotNull(chunkFilePath);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testSetEnvironment() {
+ try {
+
+ String jsonInput =
+ "{\"remoteIp\":\"192.168.4.47\",\"userName\":\"root\",\"password\":\"root123\", \"path\":\"/src/test/resources\"}";
+ response = commonManger.setEnvironment(jsonInput);
+ assertNotNull(response);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
}