summaryrefslogtreecommitdiffstats
path: root/vnf-sdk-function-test/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vnf-sdk-function-test/src/test')
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java4
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java25
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java27
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java26
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java62
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java72
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java17
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java27
8 files changed, 172 insertions, 88 deletions
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
index 56ff72b..0ca9cc7 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
@@ -38,11 +38,11 @@ public class EnvironmentMapTest {
@Test
public void testAddEnv() {
- EnvironmentMap.getInstance().addEnv(uuid, new Environment());
+ EnvironmentMap.getInstance().addEnv( uuid, new Environment() );
}
@Test
public void testDelEnv() {
- EnvironmentMap.getInstance().delEnv(uuid);
+ EnvironmentMap.getInstance().delEnv( uuid );
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
index 78ef2d8..2dcb7a3 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
@@ -18,6 +18,7 @@ package org.openo.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
public class EnvironmentTest {
private Environment environment = null;
@@ -25,25 +26,19 @@ public class EnvironmentTest {
@Before
public void setUp() {
environment = new Environment();
- }
+ }
@Test
- public void testSetRemoteIp() {
+ public void testEnvironment() {
environment.setRemoteIp( "192.168.4.47" );
- }
-
- @Test
- public void testSetUserName() {
environment.setUserName( "root" );
- }
-
- @Test
- public void testSetPassword() {
environment.setPassword( "root123" );
- }
-
- @Test
- public void testSetPath() {
environment.setPath( "src\\test\\resources" );
- }
+
+ assertNotNull( environment );
+ assertNotNull( environment.getRemoteIp() );
+ assertNotNull( environment.getUserName() );
+ assertNotNull( environment.getPassword() );
+ assertNotNull( environment.getPath() );
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
index 12a861c..5696269 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
@@ -19,6 +19,8 @@ package org.openo.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import static org.junit.Assert.assertNotNull;
+
public class OperationStatusTest {
@@ -30,17 +32,16 @@ public class OperationStatusTest {
}
@Test
- public void setTestResultCode() {
- operationStatus.setoResultCode(operResultCode.SUCCESS);
- }
-
- @Test
- public void setOperResultMsg() {
- operationStatus.setOperResultMessage("success");
- }
-
- @Test
- public void testOperationFinished() {
- operationStatus.setOperFinished(true);
- }
+ public void testOperationStatus() {
+ operationStatus.setoResultCode(operResultCode.SUCCESS);
+ operationStatus.setOperResultMessage("success");
+ operationStatus.setOperFinished(true);
+
+ assertNotNull( operationStatus );
+ assertNotNull( operationStatus.getoResultCode() );
+ assertNotNull( operationStatus.getoResultCode() );
+ assertNotNull( operationStatus.isOperFinished() );
+
+ }
+
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
index 4884a9f..9ebf220 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
@@ -18,6 +18,7 @@ package org.openo.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
public class ServiceNodeTest {
@@ -27,19 +28,16 @@ public class ServiceNodeTest {
public void setUp() {
serviceNode = new ServiceNode();
}
-
- @Test
- public void testSetIP() {
- serviceNode.setIp("192.168.4.47");
- }
-
+
@Test
- public void testSetPort() {
- serviceNode.setPort("8080");
- }
-
- @Test
- public void testSetTtl() {
- serviceNode.setTtl(80);
- }
+ public void testServiceNode() {
+ serviceNode.setIp("192.168.4.47");
+ serviceNode.setPort("8080");
+ serviceNode.setTtl( 10 );
+
+ assertNotNull( serviceNode );
+ assertNotNull( serviceNode.getIp() );
+ assertNotNull( serviceNode.getPort() );
+ assertNotNull( serviceNode.getTtl() );
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
index 3cb5823..dfaf7ae 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
@@ -18,42 +18,50 @@ package org.openo.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
public class ServiceRegisterEntityTest {
private ServiceRegisterEntity serviceRegistry;
+ private ServiceNode serviceNode;
@Before
public void setUp() {
serviceRegistry = new ServiceRegisterEntity();
+ serviceNode = new ServiceNode();
}
@Test
- public void testSetSingleNode() {
- serviceRegistry.setSingleNode("127.0.0.1", "80", 10);
- }
-
- @Test
- public void testSetServiceName() {
- serviceRegistry.setServiceName("nfvo");
-
- }
-
- @Test
- public void testSetVersion() {
- serviceRegistry.setVersion("5.6");
-
- }
-
- @Test
- public void testSetProtocol() {
- serviceRegistry.setProtocol("http");
- }
-
- @Test
- public void testSetVisualRange() {
- serviceRegistry.setVisualRange("range");
-
- }
-
+ public void ServiceRegisterEntity() {
+
+ List<ServiceNode> nodes = new ArrayList<ServiceNode>();
+
+ serviceRegistry.setServiceName("nfvo");
+ serviceRegistry.setVersion("5.6");
+ serviceRegistry.setProtocol("http");
+ serviceRegistry.setVisualRange("range");
+
+ serviceNode.setIp( "192.168.4.47" );
+ serviceNode.setPort( "8080" );
+ serviceNode.setTtl( 10 );
+ nodes.add( serviceNode );
+
+ serviceRegistry.setNodes( nodes );
+
+ assertNotNull( serviceRegistry );
+ assertNotNull( serviceRegistry.getServiceName() );
+ assertNotNull( serviceRegistry.getVersion() );
+ assertNotNull( serviceRegistry.getProtocol() );
+ assertNotNull( serviceRegistry.getVisualRange() );
+ assertNotNull( serviceRegistry.getNodes() );
+
+ }
+
+ @Test
+ public void testSetSingleNode() {
+ serviceRegistry.setSingleNode( "192.168.4.47", "8080", 10 );
+ }
}
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 a6fa27f..a965330 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
@@ -17,6 +17,7 @@
package org.openo.vnfsdk.functest.resource;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
@@ -26,7 +27,6 @@ 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;
@@ -34,11 +34,18 @@ import org.junit.Test;
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 = "1234567";
+ private String instanceId;
+
+ private String funcTestId = "59d1e651-df9f-4008-902f-e3b377e6ec30";
private Response response = null;
@@ -48,6 +55,65 @@ 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 {
@@ -93,7 +159,7 @@ public class CommonManagerTest {
@Test
public void testQueryResultWhenInstanceIdAbsent() {
- Response response = commonManger.queryResultByFuncTest("1234567");
+ Response response = commonManger.queryResultByFuncTest( funcTestId );
assertNotNull(response);
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java
index 99fa46d..a8ada98 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.openo.vnfsdk.functest.externalservice.entity.Environment;
+
public class TestGsonUtil {
@Test
@@ -37,4 +39,19 @@ public class TestGsonUtil {
public void testGetNowTime() {
assertNotNull(GsonUtil.getNowTime());
}
+
+ @Test
+ public void testObjectToString() {
+ try {
+ Object envObj = new Environment();
+ ( ( Environment ) envObj ).setRemoteIp( "192.168.4.47" );
+ ( ( Environment ) envObj ).setUserName( "root" );
+ ( ( Environment ) envObj ).setPassword( "root123" );
+ ( ( Environment ) envObj ).setPath( "src\\test\\resources" );
+
+ assertNotNull( GsonUtil.objectToString( envObj ) );
+ } catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java
index a2b50f3..56756d6 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java
@@ -20,6 +20,8 @@ import org.junit.Before;
import org.junit.Test;
import org.openo.vnfsdk.functest.responsehandler.TestResult;
+import static org.junit.Assert.assertNotNull;
+
public class TestResultTest {
private TestResult testResult = null;
@@ -28,19 +30,16 @@ public class TestResultTest {
public void setUp() {
testResult = new TestResult();
}
-
- @Test
- public void testSetName() {
- testResult.setName("Huawei");
- }
-
+
@Test
- public void testSetDescription() {
- testResult.setDescription("description");
- }
-
- @Test
- public void testStatus() {
- testResult.setStatus("success");
- }
+ public void testResultTest() {
+ testResult.setName("Huawei");
+ testResult.setDescription("description");
+ testResult.setStatus("success");
+
+ assertNotNull( testResult );
+ assertNotNull( testResult.getName() );
+ assertNotNull( testResult.getStatus() );
+ assertNotNull( testResult.getDescription() );
+ }
}