diff options
Diffstat (limited to 'vnf-sdk-function-test/src/test/java')
-rw-r--r-- | vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java | 157 |
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(); + } + } + } |