summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKailun Qin <kailun.qin@intel.com>2018-03-27 18:23:01 +0800
committerKailun Qin <kailun.qin@intel.com>2018-03-28 23:34:40 +0800
commitd4a7658f72decfef05d15973d5cee13910eb47ae (patch)
treee9b872d3e58a8fc3c420b0ee020267a22a8c8136
parent29078dd84779639f98739d508e947db0662473df (diff)
Port nfvo/vnf_functest for framework merge
Merged VNF onboarding test functions and frameworks locating separately in nfvo/vnf_functest and vnfsdk/vnf-sdk-function-test seed code. 1) Reconstructed by aligning with the original interface and sequence design; 2) Replaced Restful calls with local invokes; 3) Implemented DB support (PostgreSQL) for persistent recording; 4) Added unit tests associated; 5) Unified package names to "onap"; 6) Fixed several inherent issues. Issue-ID: VNFSDK-178 Change-Id: I2147c5df8dd400adef71dafca9073b12d992d2df Signed-off-by: Kailun Qin <kailun.qin@intel.com>
-rw-r--r--distribution/standalone/pom.xml6
-rw-r--r--distribution/standalone/src/main/assembly/conf/environment/environment.json6
-rw-r--r--distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml15
-rw-r--r--distribution/standalone/src/main/assembly/run.bat2
-rw-r--r--distribution/standalone/src/main/assembly/run.sh2
-rw-r--r--distribution/standalone/src/main/assembly/stop.bat2
-rw-r--r--distribution/standalone/src/main/assembly/stop.sh2
-rw-r--r--pom.xml9
-rw-r--r--vnf-sdk-function-test/conf/environment/environment.json6
-rw-r--r--vnf-sdk-function-test/conf/robot/robotMetaData.json8
-rw-r--r--vnf-sdk-function-test/conf/vnfsdkfunctest.yml15
-rw-r--r--vnf-sdk-function-test/pom.xml87
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/FileUtil.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/FileUtil.java)79
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/TaskExecution.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java)90
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestApp.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java)58
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java)28
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/common/Config.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/Config.java)10
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/constants/ApplicationConstants.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/constants/ApplicationConstants.java)8
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAO.java43
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAO.java51
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/Environment.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/Environment.java)134
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMap.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMap.java)106
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatus.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatus.java)107
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java)147
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java)9
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java)16
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/CaseRecord.java123
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/TaskRecord.java202
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResult.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResult.java)108
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultMap.java51
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultParser.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResultParser.java)289
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java)90
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManager.java227
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/taskmgr/TaskManager.java258
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/GsonUtil.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/GsonUtil.java)8
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/RestResponseUtil.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java)16
-rw-r--r--vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/ZipCompressor.java (renamed from vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java)33
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java79
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java49
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusRest.java37
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java341
-rw-r--r--vnf-sdk-function-test/src/main/resources/migrations.xml57
-rw-r--r--vnf-sdk-function-test/src/main/resources/sample.xml8
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java)7
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java98
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java)26
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java)50
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java)44
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java79
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java87
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java)10
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentTest.java)43
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java)13
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusTest.java)27
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java)23
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java)63
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java55
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java65
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java51
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java)40
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java)23
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java)47
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java)143
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java218
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java68
-rw-r--r--vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/TestGsonUtil.java (renamed from vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java)33
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java42
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java62
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java102
-rw-r--r--vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java37
-rw-r--r--vnf-sdk-function-test/src/test/resources/sample.xml10
71 files changed, 2784 insertions, 1804 deletions
diff --git a/distribution/standalone/pom.xml b/distribution/standalone/pom.xml
index 224e9bd..9134e80 100644
--- a/distribution/standalone/pom.xml
+++ b/distribution/standalone/pom.xml
@@ -27,7 +27,7 @@
<packaging>pom</packaging>
<properties>
- <packagename>openo-vnfsdk-functest</packagename>
+ <packagename>onap-vnfsdk-functest</packagename>
<linux64id>linux64</linux64id>
<win64id>win64</win64id>
<linux64outputdir>target/assembly/${linux64id}</linux64outputdir>
@@ -101,7 +101,7 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <groupId>org.onap.vnf-sdk.function-test</groupId>
<artifactId>vnf-sdk-function-test</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
@@ -120,7 +120,7 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <groupId>org.onap.vnf-sdk.function-test</groupId>
<artifactId>vnf-sdk-function-test</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
diff --git a/distribution/standalone/src/main/assembly/conf/environment/environment.json b/distribution/standalone/src/main/assembly/conf/environment/environment.json
new file mode 100644
index 0000000..a990796
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/conf/environment/environment.json
@@ -0,0 +1,6 @@
+{
+ "remoteIp": "127.0.0.1",
+ "userName": "functest",
+ "password": "password",
+ "path": "/home/root1/test/"
+} \ No newline at end of file
diff --git a/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml b/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml
index 3e1a439..93e4d36 100644
--- a/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml
+++ b/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml
@@ -3,12 +3,11 @@ template: Hello, %s!
defaultName: ${DW_DEFAULT_NAME:-Stranger}
-msbServerAddr: http://127.0.0.1:80
#database
database:
# the name of your JDBC driver
- driverClass: com.mysql.jdbc.Driver
+ driverClass: org.postgresql.Driver
# the username
user: functest
@@ -17,7 +16,13 @@ database:
password: functest
# the JDBC URL
- url: jdbc:mysql://127.0.0.1:3306/functest
+ url: jdbc:postgresql://localhost:5432/functest
+
+ # any properties specific to your JDBC driver:
+ properties:
+ charSet: UTF-8
+ hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect #org.hibernate.dialect.MySQL5InnoDBDialect
+# hibernate.hbm2ddl.auto: create
# use the simple server factory if you only want to run on a single port
#server:
@@ -27,7 +32,7 @@ database:
# port: 8080
server:
type: simple
- rootPath: '/openoapi/vnfsdk/v1/*'
+ rootPath: '/api/vnfsdk/v1/*'
applicationContextPath: /
adminContextPath: /admin
connector:
@@ -44,7 +49,7 @@ logging:
loggers:
# Sets the level for 'com.example.app' to DEBUG.
- org.openo.vnfsdk.functest.VnfSdkFunTestApp: INFO
+ org.onap.vnfsdk.functest.VnfSdkFunTestApp: INFO
appenders:
- type: console
diff --git a/distribution/standalone/src/main/assembly/run.bat b/distribution/standalone/src/main/assembly/run.bat
index 1fda07c..5099274 100644
--- a/distribution/standalone/src/main/assembly/run.bat
+++ b/distribution/standalone/src/main/assembly/run.bat
@@ -29,7 +29,7 @@ set class_path=%RUNHOME%;%RUNHOME%vnf-sdk-function-test.jar
echo ### jvm_opts: %jvm_opts%
echo ### class_path: %class_path%
-%JAVA% -classpath %class_path% %jvm_opts% org.openo.vnfsdk.functest.VnfSdkFuncTestApp server %RUNHOME%conf/vnfsdkfunctest.yml
+%JAVA% -classpath %class_path% %jvm_opts% org.onap.vnfsdk.functest.VnfSdkFuncTestApp server %RUNHOME%conf/vnfsdkfunctest.yml
IF ERRORLEVEL 1 goto showerror
exit
diff --git a/distribution/standalone/src/main/assembly/run.sh b/distribution/standalone/src/main/assembly/run.sh
index b1329c0..99bf172 100644
--- a/distribution/standalone/src/main/assembly/run.sh
+++ b/distribution/standalone/src/main/assembly/run.sh
@@ -27,5 +27,5 @@ port=8701
echo @JAVA_OPTS@ $JAVA_OPTS
export CLASSPATH=CLASSPATH:"$JAVA_HOME/jre/lib"
echo @CLASSPATH@ $CLASSPATH
-"$JAVA" $JAVA_OPTS -cp $RUNHOME/vnf-sdk-function-test org.openo.vnfsdk.functest.VnfSdkFuncTestApp server "$RUNHOME/conf/vnfsdkfunctest.yml"
+"$JAVA" $JAVA_OPTS -cp $RUNHOME/vnf-sdk-function-test org.onap.vnfsdk.functest.VnfSdkFuncTestApp server "$RUNHOME/conf/vnfsdkfunctest.yml"
diff --git a/distribution/standalone/src/main/assembly/stop.bat b/distribution/standalone/src/main/assembly/stop.bat
index ed702ff..5058cc8 100644
--- a/distribution/standalone/src/main/assembly/stop.bat
+++ b/distribution/standalone/src/main/assembly/stop.bat
@@ -18,7 +18,7 @@
title stopping vnfsdk-functest
set HOME=%~dp0
-set Main_Class="org.openo.vnfsdk.functest.VnfSdkFuncTestApp"
+set Main_Class="org.onap.vnfsdk.functest.VnfSdkFuncTestApp"
echo ================== extsys-service info =============================================
echo HOME=$HOME
diff --git a/distribution/standalone/src/main/assembly/stop.sh b/distribution/standalone/src/main/assembly/stop.sh
index 36099c1..6970a54 100644
--- a/distribution/standalone/src/main/assembly/stop.sh
+++ b/distribution/standalone/src/main/assembly/stop.sh
@@ -17,7 +17,7 @@
DIRNAME=`dirname $0`
HOME=`cd $DIRNAME/; pwd`
-Main_Class="org.openo.vnfsdk.functest.VnfSdkFuncTestApp"
+Main_Class="org.onap.vnfsdk.functest.VnfSdkFuncTestApp"
echo ================== catalog-service info =============================================
echo HOME=$HOME
diff --git a/pom.xml b/pom.xml
index 2ee9bc9..44a550d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,17 +15,18 @@
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
+
+ <parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.vnf-sdk.function-test</groupId>
- <artifactId>vnfsdk-functest-core-parent</artifactId>
+ <artifactId>vnfsdk-functest-core-parent</artifactId>
<name>vnfsdk-functest</name>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
diff --git a/vnf-sdk-function-test/conf/environment/environment.json b/vnf-sdk-function-test/conf/environment/environment.json
new file mode 100644
index 0000000..a990796
--- /dev/null
+++ b/vnf-sdk-function-test/conf/environment/environment.json
@@ -0,0 +1,6 @@
+{
+ "remoteIp": "127.0.0.1",
+ "userName": "functest",
+ "password": "password",
+ "path": "/home/root1/test/"
+} \ No newline at end of file
diff --git a/vnf-sdk-function-test/conf/robot/robotMetaData.json b/vnf-sdk-function-test/conf/robot/robotMetaData.json
index 2aa85b0..f322830 100644
--- a/vnf-sdk-function-test/conf/robot/robotMetaData.json
+++ b/vnf-sdk-function-test/conf/robot/robotMetaData.json
@@ -1,6 +1,6 @@
{
- "FRAMEWORK_TYPE": "robot",
- "MAIN_SCRIPT": "main.robot",
- "DIR_RESULT": "D:\\Pitchi_docs\\remote\\",
- "DIR_REMOTE": "/home/root1/test/"
+ "FRAMEWORK_TYPE": "robot",
+ "MAIN_SCRIPT": "main.robot",
+ "DIR_RESULT": "D:\\Pitchi_docs\\remote\\",
+ "DIR_REMOTE": "/home/root1/test/"
} \ No newline at end of file
diff --git a/vnf-sdk-function-test/conf/vnfsdkfunctest.yml b/vnf-sdk-function-test/conf/vnfsdkfunctest.yml
index 3e1a439..93e4d36 100644
--- a/vnf-sdk-function-test/conf/vnfsdkfunctest.yml
+++ b/vnf-sdk-function-test/conf/vnfsdkfunctest.yml
@@ -3,12 +3,11 @@ template: Hello, %s!
defaultName: ${DW_DEFAULT_NAME:-Stranger}
-msbServerAddr: http://127.0.0.1:80
#database
database:
# the name of your JDBC driver
- driverClass: com.mysql.jdbc.Driver
+ driverClass: org.postgresql.Driver
# the username
user: functest
@@ -17,7 +16,13 @@ database:
password: functest
# the JDBC URL
- url: jdbc:mysql://127.0.0.1:3306/functest
+ url: jdbc:postgresql://localhost:5432/functest
+
+ # any properties specific to your JDBC driver:
+ properties:
+ charSet: UTF-8
+ hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect #org.hibernate.dialect.MySQL5InnoDBDialect
+# hibernate.hbm2ddl.auto: create
# use the simple server factory if you only want to run on a single port
#server:
@@ -27,7 +32,7 @@ database:
# port: 8080
server:
type: simple
- rootPath: '/openoapi/vnfsdk/v1/*'
+ rootPath: '/api/vnfsdk/v1/*'
applicationContextPath: /
adminContextPath: /admin
connector:
@@ -44,7 +49,7 @@ logging:
loggers:
# Sets the level for 'com.example.app' to DEBUG.
- org.openo.vnfsdk.functest.VnfSdkFunTestApp: INFO
+ org.onap.vnfsdk.functest.VnfSdkFunTestApp: INFO
appenders:
- type: console
diff --git a/vnf-sdk-function-test/pom.xml b/vnf-sdk-function-test/pom.xml
index b9c783c..ebd0e7a 100644
--- a/vnf-sdk-function-test/pom.xml
+++ b/vnf-sdk-function-test/pom.xml
@@ -14,13 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <groupId>org.onap.vnf-sdk.function-test</groupId>
<artifactId>vnfsdk-functest-core-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -48,7 +48,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
@@ -69,8 +69,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
@@ -102,14 +100,12 @@
<goal>shade</goal>
</goals>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
<transformers>
<transformer
- implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.openo.vnfsdk.functest.VnfSdkFuncTestApp</mainClass>
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.onap.vnfsdk.functest.VnfSdkFuncTestApp</mainClass>
</transformer>
</transformers>
</configuration>
@@ -126,16 +122,6 @@
<goals>
<goal>copy-dependencies</goal>
</goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <version>0.8.0</version>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
- </configuration>
</execution>
</executions>
</plugin>
@@ -146,17 +132,22 @@
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
- <version>0.8.0</version>
+ <version>1.2.0</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
- <version>0.8.0</version>
+ <version>1.2.0</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
- <version>0.8.0</version>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-migrations</artifactId>
+ <version>1.2.0</version>
</dependency>
<!-- lombok -->
<dependency>
@@ -203,10 +194,15 @@
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
+ <!--<dependency>-->
+ <!--<groupId>mysql</groupId>-->
+ <!--<artifactId>mysql-connector-java</artifactId>-->
+ <!--<version>5.1.18</version>-->
+ <!--</dependency>-->
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.18</version>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>42.1.4</version>
</dependency>
<!-- UT -->
<dependency>
@@ -215,6 +211,13 @@
<version>4.10</version>
<scope>test</scope>
</dependency>
+ <!-- https://mvnrepository.com/artifact/io.dropwizard/dropwizard-testing -->
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-testing</artifactId>
+ <version>1.2.0</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
@@ -239,6 +242,13 @@
<version>1.8.2</version>
<scope>test</scope>
</dependency>
+ <!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.8.0</version>
+ <scope>test</scope>
+ </dependency>
<!-- UT end -->
<dependency>
<groupId>org.mockito</groupId>
@@ -246,10 +256,21 @@
<version>1.9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jmockit/jmockit -->
- <dependency>
- <groupId>org.jmockit</groupId>
- <artifactId>jmockit</artifactId>
- <version>1.19</version>
- </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.19</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <!-- https://mvnrepository.com/artifact/javax.activation/activation -->
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
</project>
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/FileUtil.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/FileUtil.java
index 7a5dbba..fd66362 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/FileUtil.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/FileUtil.java
@@ -14,25 +14,18 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+package org.onap.vnfsdk.functest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public final class FileUtil {
public static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);
@@ -47,16 +40,16 @@ public final class FileUtil {
/**
* Create directory.
- *
+ *
* @param dir directory to create
* @return boolean
*/
public static boolean createDirectory(String dir) {
File folder = new File(dir);
int tryCount = 0;
- while(tryCount < TRY_COUNT) {
+ while (tryCount < TRY_COUNT) {
tryCount++;
- if(!folder.exists() && !folder.mkdirs()) {
+ if (!folder.exists() && !folder.mkdirs()) {
continue;
} else {
return true;
@@ -68,7 +61,7 @@ public final class FileUtil {
/**
* delete file.
- *
+ *
* @param file the file to delete
* @return boolean
*/
@@ -76,8 +69,8 @@ public final class FileUtil {
String hintInfo = file.isDirectory() ? "dir " : "file ";
boolean isFileDeleted = file.delete();
boolean isFileExist = file.exists();
- if(!isFileExist) {
- if(isFileDeleted) {
+ if (!isFileExist) {
+ if (isFileDeleted) {
LOG.info("delete " + hintInfo + file.getAbsolutePath());
} else {
isFileDeleted = true;
@@ -91,9 +84,9 @@ public final class FileUtil {
/**
* unzip zip file.
- *
+ *
* @param zipFileName file name to zip
- * @param extPlace extPlace
+ * @param extPlace extPlace
* @return unzip file name
* @throws IOException e1
*/
@@ -106,25 +99,25 @@ public final class FileUtil {
Enumeration<?> fileEn = zipFile.entries();
byte[] buffer = new byte[BUFFER_SIZE];
- while(fileEn.hasMoreElements()) {
+ while (fileEn.hasMoreElements()) {
InputStream input = null;
BufferedOutputStream bos = null;
try {
- ZipEntry entry = (ZipEntry)fileEn.nextElement();
- if(entry.isDirectory()) {
+ ZipEntry entry = (ZipEntry) fileEn.nextElement();
+ if (entry.isDirectory()) {
continue;
}
input = zipFile.getInputStream(entry);
File file = new File(extPlace, entry.getName());
- if(!file.getParentFile().exists()) {
+ if (!file.getParentFile().exists()) {
createDirectory(file.getParentFile().getAbsolutePath());
}
bos = new BufferedOutputStream(new FileOutputStream(file));
- while(true) {
+ while (true) {
int length = input.read(buffer);
- if(length == -1) {
+ if (length == -1) {
break;
}
bos.write(buffer, 0, length);
@@ -153,46 +146,46 @@ public final class FileUtil {
/**
* close InputStream.
- *
+ *
* @param inputStream the inputstream to close
*/
private static void closeInputStream(InputStream inputStream) {
try {
- if(inputStream != null) {
+ if (inputStream != null) {
inputStream.close();
}
- } catch(Exception ex) {
+ } catch (Exception ex) {
LOG.error("close InputStream error!: " + ex);
}
}
/**
* close OutputStream.
- *
+ *
* @param outputStream the output stream to close
*/
private static void closeOutputStream(OutputStream outputStream) {
try {
- if(outputStream != null) {
+ if (outputStream != null) {
outputStream.close();
}
- } catch(Exception ex) {
+ } catch (Exception ex) {
LOG.error("close OutputStream error!: " + ex);
}
}
/**
* close zipFile.
- *
+ *
* @param zipFile the zipFile to close
*/
private static void closeZipFile(ZipFile zipFile) {
try {
ZipFile tempZipFile = zipFile;
- if(tempZipFile != null) {
+ if (tempZipFile != null) {
tempZipFile.close();
}
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
LOG.error("close ZipFile error!: " + ioe);
}
}
@@ -204,7 +197,7 @@ public final class FileUtil {
public static Boolean deleteFile(String filePath) {
File file = new File(filePath);
- if(file.exists()) {
+ if (file.exists()) {
return file.delete();
}
return true;
@@ -213,17 +206,17 @@ public final class FileUtil {
public static byte[] convertZipFiletoByteArray(String filename) {
File file = new File(filename);
byte[] emptyArray = new byte[0];
- if(!file.exists()) {
+ if (!file.exists()) {
return emptyArray;
}
- byte[] byteArrayFile = new byte[(int)file.length()];
+ byte[] byteArrayFile = new byte[(int) file.length()];
try {
FileInputStream fileInputStream = new FileInputStream(filename);
int value = fileInputStream.read(byteArrayFile);
fileInputStream.close();
LOG.debug("Number of bytes read from fileInputStream = " + value);
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.error("convertZipFiletoByteArray: " + e);
}
return byteArrayFile;
@@ -238,11 +231,11 @@ public final class FileUtil {
*/
public static void deleteDirectory(String directory) {
File file = new File(directory);
- if(!file.exists()) {
+ if (!file.exists()) {
return;
}
- if(file.isDirectory()) {
- for(File sub : file.listFiles()) {
+ if (file.isDirectory()) {
+ for (File sub : file.listFiles()) {
deleteFile(sub);
}
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/TaskExecution.java
index d55ec98..51a8799 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/TaskExecution.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/TaskExecution.java
@@ -14,28 +14,28 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest;
+package org.onap.vnfsdk.functest;
+
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonReader;
+import org.apache.commons.lang3.SystemUtils;
+import org.onap.vnfsdk.functest.constants.ApplicationConstants;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+import org.onap.vnfsdk.functest.externalservice.entity.EnvironmentMap;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
-import org.apache.commons.lang3.SystemUtils;
-import org.openo.vnfsdk.functest.constants.ApplicationConstants;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-import org.openo.vnfsdk.functest.externalservice.entity.EnvironmentMap;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
public class TaskExecution {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskExecution.class);
@@ -47,13 +47,14 @@ public class TaskExecution {
String confDir = curDir + nl + ApplicationConstants.CONF + nl + ApplicationConstants.ROBOT + nl;
// Read the MetaData from the VNF package
- ObjectMapper mapper = new ObjectMapper();
+// ObjectMapper mapper = new ObjectMapper();
Map<String, String> mapValues = null;
try {
- mapValues =
- mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
- } catch(IOException e) {
+// mapValues =
+// mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
+ mapValues = new Gson().fromJson(new JsonReader(new FileReader(confDir + ApplicationConstants.ROBOTMETADATA_JSON)), Map.class);
+ } catch (IOException e) {
LOGGER.error(ApplicationConstants.JSON_METADATA_FILE_FAILED, e);
return;
@@ -77,7 +78,7 @@ public class TaskExecution {
mapValues.put("REMOTE_COMMAND", "\"" + remoteCommand + "\"");
String robotvariables = "";
- for(Entry<String, String> values : mapValues.entrySet()) {
+ for (Entry<String, String> values : mapValues.entrySet()) {
robotvariables = robotvariables + " -v " + values.getKey() + ":" + values.getValue() + " ";
}
@@ -92,16 +93,16 @@ public class TaskExecution {
try {
String command = "robot --argumentfile " + argumentFilePath + robotvariables + " " + robotScript;
LOGGER.info("Command execute to execute the script:" + command);
- process = Runtime.getRuntime().exec(new String[] {getShellCommand(), getShellArg(), command});
- if(process != null) {
+ process = Runtime.getRuntime().exec(new String[]{getShellCommand(), getShellArg(), command});
+ if (process != null) {
process.waitFor();
inputStream = process.getInputStream();
}
- while((ch = inputStream.read()) != -1) {
+ while ((ch = inputStream.read()) != -1) {
LOGGER.info(ApplicationConstants.CHARACTER + Integer.toString(ch));
}
- } catch(Exception e) {
+ } catch (Exception e) {
LOGGER.error(ApplicationConstants.TASKEXE_EXESCRIPT_EXCEPTION, e);
}
}
@@ -113,12 +114,13 @@ public class TaskExecution {
String confDir = curDir + nl + ApplicationConstants.CONF + nl + ApplicationConstants.ROBOT + nl;
// Read the MetaData from the VNF package
- ObjectMapper mapper = new ObjectMapper();
+// ObjectMapper mapper = new ObjectMapper();
Map<String, String> mapValues = null;
try {
- mapValues =
- mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
- } catch(IOException e) {
+// mapValues =
+// mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
+ mapValues = new Gson().fromJson(new JsonReader(new FileReader(confDir + ApplicationConstants.ROBOTMETADATA_JSON)), Map.class);
+ } catch (IOException e) {
LOGGER.error(ApplicationConstants.JSON_METADATA_FILE_FAILED, e);
return;
@@ -126,7 +128,7 @@ public class TaskExecution {
// Get environment of given UUID
Environment functestEnv = EnvironmentMap.getInstance().getEnv(envId);
- if(null == functestEnv) {
+ if (null == functestEnv) {
LOGGER.error("Function Test Environment details are empty,EnvID = " + envId);
} else {
LOGGER.info("Function Test Environment path,Path = " + functestEnv.getPath());
@@ -164,16 +166,16 @@ public class TaskExecution {
try {
String command = ApplicationConstants.ROBOT + remoteArgs + robotScript;
LOGGER.info("Command execute to execute the script:" + command);
- process = Runtime.getRuntime().exec(new String[] {getShellCommand(), getShellArg(), command});
- if(process != null) {
+ process = Runtime.getRuntime().exec(new String[]{getShellCommand(), getShellArg(), command});
+ if (process != null) {
process.waitFor();
inputStream = process.getInputStream();
}
- while((ch = inputStream.read()) != -1) {
+ while ((ch = inputStream.read()) != -1) {
LOGGER.info(ApplicationConstants.CHARACTER + Integer.toString(ch));
}
- } catch(Exception e) {
+ } catch (Exception e) {
LOGGER.error(ApplicationConstants.TASKEXE_EXESCRIPT_EXCEPTION, e);
}
@@ -191,14 +193,14 @@ public class TaskExecution {
String confDir = curDir + nl + ApplicationConstants.CONF + nl + ApplicationConstants.ROBOT + nl;
// Read the MetaData from the VNF package
- ObjectMapper mapper = new ObjectMapper();
+// ObjectMapper mapper = new ObjectMapper();
Map<String, String> mapValues = null;
try {
-
- mapValues =
- mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
- } catch(Exception e) {
+// mapValues =
+// mapper.readValue(new FileInputStream(confDir + ApplicationConstants.ROBOTMETADATA_JSON), Map.class);
+ mapValues = new Gson().fromJson(new JsonReader(new FileReader(confDir + ApplicationConstants.ROBOTMETADATA_JSON)), Map.class);
+ } catch (Exception e) {
LOGGER.error(ApplicationConstants.JSON_METADATA_FILE_FAILED, e);
return;
@@ -208,7 +210,7 @@ public class TaskExecution {
mapValues.put("SCRIPT_DIR", dirPath);
String robotvariables = "";
- for(Entry<String, String> values : mapValues.entrySet()) {
+ for (Entry<String, String> values : mapValues.entrySet()) {
robotvariables = robotvariables + " -v " + values.getKey() + ":" + values.getValue() + " ";
}
@@ -229,17 +231,17 @@ public class TaskExecution {
try {
String command = ApplicationConstants.ROBOT_SPACE + robotvariables + robotScript;
LOGGER.info("Command execute to upload the script:" + command);
- process = Runtime.getRuntime().exec(new String[] {getShellCommand(), getShellArg(), command});
- if(process != null) {
+ process = Runtime.getRuntime().exec(new String[]{getShellCommand(), getShellArg(), command});
+ if (process != null) {
process.waitFor();
inputStream = process.getInputStream();
}
- while((ch = inputStream.read()) != -1) {
+ while ((ch = inputStream.read()) != -1) {
LOGGER.info(ApplicationConstants.CHARACTER + Integer.toString(ch));
}
- } catch(Exception e) {
+ } catch (Exception e) {
LOGGER.error(ApplicationConstants.TASKEXE_EXESCRIPT_EXCEPTION, e);
}
@@ -254,7 +256,7 @@ public class TaskExecution {
private String getShellCommand() {
String shellcommand = ApplicationConstants.SHELL_COMMAND;
- if(SystemUtils.IS_OS_LINUX) {
+ if (SystemUtils.IS_OS_LINUX) {
shellcommand = ApplicationConstants.SHELL_COMMAND_BASH;
}
@@ -264,7 +266,7 @@ public class TaskExecution {
private String getShellArg() {
String commandArg = "/c";
- if(SystemUtils.IS_OS_LINUX) {
+ if (SystemUtils.IS_OS_LINUX) {
commandArg = "-c";
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestApp.java
index b368f23..abc8aa9 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestApp.java
@@ -14,27 +14,39 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest;
-
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.common.ServiceRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.onap.vnfsdk.functest;
import com.fasterxml.jackson.annotation.JsonInclude;
-
import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
+import io.dropwizard.db.DataSourceFactory;
+import io.dropwizard.hibernate.HibernateBundle;
+import io.dropwizard.hibernate.ScanningHibernateBundle;
+import io.dropwizard.migrations.MigrationsBundle;
import io.dropwizard.server.SimpleServerFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.onap.vnfsdk.functest.common.Config;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.scriptmgr.ScriptManager;
+import org.onap.vnfsdk.functest.taskmgr.TaskManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class VnfSdkFuncTestApp extends Application<VnfSdkFuncTestAppConfiguration> {
private static final Logger LOGGER = LoggerFactory.getLogger(VnfSdkFuncTestApp.class);
+ private final HibernateBundle<VnfSdkFuncTestAppConfiguration> hibernateBundle =
+ new ScanningHibernateBundle<VnfSdkFuncTestAppConfiguration>("org.onap.vnfsdk.functest.models") {
+ @Override
+ public DataSourceFactory getDataSourceFactory(VnfSdkFuncTestAppConfiguration configuration) {
+ return configuration.getDataSourceFactory();
+ }
+ };
public static void main(String[] args) throws Exception {
new VnfSdkFuncTestApp().run(args);
@@ -42,44 +54,46 @@ public class VnfSdkFuncTestApp extends Application<VnfSdkFuncTestAppConfiguratio
@Override
public String getName() {
- return "OPENO-VNFSDK-FunctionTest";
+ return "ONAP-VNFSDK-FunctionTest";
}
@Override
public void initialize(Bootstrap<VnfSdkFuncTestAppConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc"));
-
- }
-
- private void initService() {
- Thread registerExtsysService = new Thread(new ServiceRegistration());
- registerExtsysService.setName("Register vnfsdk-functionTest service to Microservice Bus");
- registerExtsysService.start();
+ bootstrap.addBundle(new MigrationsBundle<VnfSdkFuncTestAppConfiguration>() {
+ @Override
+ public DataSourceFactory getDataSourceFactory(VnfSdkFuncTestAppConfiguration configuration) {
+ return configuration.getDataSourceFactory();
+ }
+ });
+ bootstrap.addBundle(hibernateBundle);
}
@Override
public void run(VnfSdkFuncTestAppConfiguration configuration, Environment environment) {
LOGGER.info("Start to initialize vnfsdk function test.");
- environment.jersey().packages("org.openo.vnfsdk.functest.resource");
+ environment.jersey().packages("org.onap.vnfsdk.functest.taskmgr");
environment.jersey().register(MultiPartFeature.class);
initSwaggerConfig(environment, configuration);
Config.setConfigration(configuration);
- initService();
LOGGER.info("Initialize vnfsdk function test finished.");
}
private void initSwaggerConfig(Environment environment, VnfSdkFuncTestAppConfiguration configuration) {
+ final TaskMgrTaskTblDAO taskDAO = new TaskMgrTaskTblDAO(hibernateBundle.getSessionFactory());
+ final TaskMgrCaseTblDAO caseDAO = new TaskMgrCaseTblDAO(hibernateBundle.getSessionFactory());
environment.jersey().register(new ApiListingResource());
environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ environment.jersey().register(new TaskManager(taskDAO, caseDAO, new ScriptManager(taskDAO, caseDAO)));
BeanConfig config = new BeanConfig();
- config.setTitle("Open-o VnfSdk Functest Service rest API");
+ config.setTitle("ONAP VnfSdk Functest Service rest API");
config.setVersion("1.0.0");
- config.setResourcePackage("org.openo.vnfsdk.functest.resource");
+ config.setResourcePackage("org.onap.vnfsdk.functest.taskmgr");
- SimpleServerFactory simpleServerFactory = (SimpleServerFactory)configuration.getServerFactory();
+ SimpleServerFactory simpleServerFactory = (SimpleServerFactory) configuration.getServerFactory();
String basePath = simpleServerFactory.getApplicationContextPath();
- String rootPath = simpleServerFactory.getJerseyRootPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath().toString();
rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
basePath =
("/").equals(rootPath) ? rootPath : (new StringBuilder()).append(basePath).append(rootPath).toString();
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java
index 574fe0d..f4b7b83 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java
@@ -14,17 +14,15 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validator.constraints.NotEmpty;
+package org.onap.vnfsdk.functest;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
public class VnfSdkFuncTestAppConfiguration extends Configuration {
@@ -32,16 +30,14 @@ public class VnfSdkFuncTestAppConfiguration extends Configuration {
private String template;
@NotEmpty
- private String defaultName = "OPENO-VnfSdk-FuncTest";
-
- @NotEmpty
- private String msbServerAddr;
+ private String defaultName = "ONAP-VnfSdk-FuncTest";
@Valid
private String serviceIp;
@Valid
@NotNull
+ @JsonProperty
private DataSourceFactory database = new DataSourceFactory();
@JsonProperty("database")
@@ -75,16 +71,6 @@ public class VnfSdkFuncTestAppConfiguration extends Configuration {
}
@JsonProperty
- public String getMsbServerAddr() {
- return msbServerAddr;
- }
-
- @JsonProperty
- public void setMsbServerAddr(String msbServerAddr) {
- this.msbServerAddr = msbServerAddr;
- }
-
- @JsonProperty
public String getServiceIp() {
return serviceIp;
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/Config.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/common/Config.java
index 23d4158..0be814c 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/Config.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/common/Config.java
@@ -14,23 +14,23 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.common;
+package org.onap.vnfsdk.functest.common;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
+import org.onap.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
public class Config {
- private static VnfSdkFuncTestAppConfiguration configration;
+ private static VnfSdkFuncTestAppConfiguration configuration;
private Config() {
}
public static VnfSdkFuncTestAppConfiguration getConfigration() {
- return configration;
+ return configuration;
}
public static void setConfigration(VnfSdkFuncTestAppConfiguration config) {
- configration = config;
+ configuration = config;
}
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/constants/ApplicationConstants.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/constants/ApplicationConstants.java
index d3658a9..630db46 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/constants/ApplicationConstants.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/constants/ApplicationConstants.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.constants;
+package org.onap.vnfsdk.functest.constants;
public class ApplicationConstants {
@@ -50,6 +50,12 @@ public class ApplicationConstants {
public static final String RUN_SCRIPT_EXECUTE_CMD = "Upload the script and execute the script and run command";
+ public static final String ENVIRONMENT = "environment";
+
+ public static final String ENVIRONMENT_JSON = "environment.json";
+
+ public static final String CATALOG_URI = "file:///C:/RobotScript/RobotScript.zip";
+
private ApplicationConstants() {
}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAO.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAO.java
new file mode 100644
index 0000000..f228ab5
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAO.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.db;
+
+import io.dropwizard.hibernate.AbstractDAO;
+import org.hibernate.SessionFactory;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+
+import java.util.List;
+
+public class TaskMgrCaseTblDAO extends AbstractDAO<CaseRecord> {
+ public TaskMgrCaseTblDAO(SessionFactory factory) {
+ super(factory);
+ }
+
+ public CaseRecord findByTaskID(String taskID) {
+ //return Optional.ofNullable(get(taskID));
+ return get(taskID);
+ }
+
+ public CaseRecord saveOrUpdate(CaseRecord caseRecord) {
+ return persist(caseRecord);
+ }
+
+ public List<CaseRecord> findAll() {
+ return list(namedQuery("org.onap.vnfsdk.functest.models.CaseRecord.findAll"));
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAO.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAO.java
new file mode 100644
index 0000000..2e9fbd2
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAO.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.db;
+
+import io.dropwizard.hibernate.AbstractDAO;
+import org.hibernate.SessionFactory;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+
+import java.util.List;
+import java.util.Optional;
+
+public class TaskMgrTaskTblDAO extends AbstractDAO<TaskRecord> {
+ public TaskMgrTaskTblDAO(SessionFactory factory) {
+ super(factory);
+ }
+
+ public Optional<TaskRecord> findByPackageID(String packageID) {
+ return Optional.ofNullable(get(packageID));
+ }
+
+ public TaskRecord saveOrUpdate(TaskRecord taskRecord) {
+ return persist(taskRecord);
+ }
+
+ public List<TaskRecord> findAll() {
+ return list(namedQuery("org.onap.vnfsdk.functest.models.TaskRecord.findAll"));
+ }
+
+ public List<TaskRecord> findByTaskID(String taskID) {
+ StringBuilder builder = new StringBuilder("%");
+ builder.append(taskID).append("%");
+ return list(
+ namedQuery("org.onap.vnfsdk.functest.models.TaskRecord.findByTaskID")
+ .setParameter("taskID", builder.toString())
+ );
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/Environment.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/Environment.java
index b63e49b..b22be82 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/Environment.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/Environment.java
@@ -1,67 +1,67 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.entity;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class Environment {
-
- @JsonProperty("remoteIp")
- private String remoteIp;
-
- @JsonProperty("userName")
- private String userName;
-
- @JsonProperty("password")
- private String password;
-
- @JsonProperty("path")
- private String path;
-
- public String getRemoteIp() {
- return remoteIp;
- }
-
- public void setRemoteIp(String remoteIp) {
- this.remoteIp = remoteIp;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.externalservice.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Environment {
+
+ @JsonProperty("remoteIp")
+ private String remoteIp;
+
+ @JsonProperty("userName")
+ private String userName;
+
+ @JsonProperty("password")
+ private String password;
+
+ @JsonProperty("path")
+ private String path;
+
+ public String getRemoteIp() {
+ return remoteIp;
+ }
+
+ public void setRemoteIp(String remoteIp) {
+ this.remoteIp = remoteIp;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMap.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMap.java
index e2a9ebb..c9584e2 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/EnvironmentMap.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/EnvironmentMap.java
@@ -1,53 +1,53 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.entity;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-public class EnvironmentMap {
-
- private static Map<UUID, Environment> envmap = new HashMap<UUID, Environment>();
-
- private static EnvironmentMap oInstance = new EnvironmentMap();
-
- private EnvironmentMap() {
- // Empty nothing to do
- }
-
- public static synchronized EnvironmentMap getInstance() {
- return oInstance;
- }
-
- public synchronized Map<UUID, Environment> getEnvmap() {
- return envmap;
- }
-
- public synchronized void addEnv(UUID uuid, Environment envobj) {
- envmap.put(uuid, envobj);
- }
-
- public synchronized void delEnv(UUID uuid) {
- envmap.remove(uuid);
- }
-
- public synchronized Environment getEnv(UUID uuid) {
- return envmap.get(uuid);
- }
-
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.externalservice.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class EnvironmentMap {
+
+ private static Map<UUID, Environment> envMap = new HashMap<UUID, Environment>();
+
+ private static EnvironmentMap oInstance = new EnvironmentMap();
+
+ private EnvironmentMap() {
+ // Empty nothing to do
+ }
+
+ public static synchronized EnvironmentMap getInstance() {
+ return oInstance;
+ }
+
+ public synchronized Map<UUID, Environment> getEnvmap() {
+ return envMap;
+ }
+
+ public synchronized void addEnv(UUID uuid, Environment envobj) {
+ envMap.put(uuid, envobj);
+ }
+
+ public synchronized void delEnv(UUID uuid) {
+ envMap.remove(uuid);
+ }
+
+ public synchronized Environment getEnv(UUID uuid) {
+ return envMap.get(uuid);
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatus.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatus.java
index 7856563..3bab7d0 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatus.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatus.java
@@ -1,53 +1,54 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.entity;
-
-public class OperationStatus {
-
- private boolean operFinished = false;
- private String operResultMessage;
-
- public enum operResultCode {
- SUCCESS, FAILURE, NOTFOUND
- };
-
- operResultCode oResultCode;
-
- public operResultCode getoResultCode() {
- return oResultCode;
- }
-
- public void setoResultCode(operResultCode oResultCode) {
- this.oResultCode = oResultCode;
- }
-
- public String getOperResultMessage() {
- return operResultMessage;
- }
-
- public void setOperResultMessage(String operResultMessage) {
- this.operResultMessage = operResultMessage;
- }
-
- public boolean isOperFinished() {
- return operFinished;
- }
-
- public void setOperFinished(boolean operFinished) {
- this.operFinished = operFinished;
- }
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.externalservice.entity;
+
+public class OperationStatus {
+
+ operResultCode oResultCode;
+ private boolean operFinished = false;
+ private String operResultMessage;
+
+ ;
+
+ public operResultCode getoResultCode() {
+ return oResultCode;
+ }
+
+ public void setoResultCode(operResultCode oResultCode) {
+ this.oResultCode = oResultCode;
+ }
+
+ public String getOperResultMessage() {
+ return operResultMessage;
+ }
+
+ public void setOperResultMessage(String operResultMessage) {
+ this.operResultMessage = operResultMessage;
+ }
+
+ public boolean isOperFinished() {
+ return operFinished;
+ }
+
+ public void setOperFinished(boolean operFinished) {
+ this.operFinished = operFinished;
+ }
+
+ public enum operResultCode {
+ SUCCESS, FAILURE, NOTFOUND
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java
index 7cadec4..7ba71cb 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/OperationStatusHandler.java
@@ -1,74 +1,73 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.entity;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.core.Response;
-
-import org.openo.vnfsdk.functest.util.RestResponseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OperationStatusHandler {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(OperationStatusHandler.class);
-
- private static Map<UUID, OperationStatus> operStatusMap = new HashMap<UUID, OperationStatus>();
-
- private static OperationStatusHandler oInstance = new OperationStatusHandler();
-
- private OperationStatusHandler() {
- // Empty nothing to do
- }
-
- public static synchronized OperationStatusHandler getInstance() {
- return oInstance;
- }
-
- public synchronized Map<UUID, OperationStatus> getOperStatusMap() {
- return operStatusMap;
- }
-
- public synchronized void setOperStatusMap(UUID uuid, OperationStatus inputOperStatusMap) {
- operStatusMap.put(uuid, inputOperStatusMap);
- }
-
- public Response getOperationStatus(UUID uuid) {
-
- if(getOperStatusMap().containsKey(uuid)) {
-
- OperationStatus operstatus = getOperStatusMap().get(uuid);
- LOGGER.info("Operation Finished?" + operstatus.isOperFinished());
- LOGGER.info("Operation Result Message" + operstatus.getOperResultMessage());
-
- return RestResponseUtil.getSuccessResponse(operstatus);
- } else {
- OperationStatus operstatus = new OperationStatus();
- operstatus.setOperFinished(true);
- operstatus.setoResultCode(OperationStatus.operResultCode.NOTFOUND);
- LOGGER.error("uuid not found");
-
- return RestResponseUtil.getSuccessResponse(operstatus);
-
- }
-
- }
-
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.externalservice.entity;
+
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class OperationStatusHandler {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OperationStatusHandler.class);
+
+ private static Map<UUID, OperationStatus> operStatusMap = new HashMap<UUID, OperationStatus>();
+
+ private static OperationStatusHandler oInstance = new OperationStatusHandler();
+
+ private OperationStatusHandler() {
+ // Empty nothing to do
+ }
+
+ public static synchronized OperationStatusHandler getInstance() {
+ return oInstance;
+ }
+
+ public synchronized Map<UUID, OperationStatus> getOperStatusMap() {
+ return operStatusMap;
+ }
+
+ public synchronized void setOperStatusMap(UUID uuid, OperationStatus inputOperStatusMap) {
+ operStatusMap.put(uuid, inputOperStatusMap);
+ }
+
+ public Response getOperationStatus(UUID uuid) {
+
+ if (getOperStatusMap().containsKey(uuid)) {
+
+ OperationStatus operstatus = getOperStatusMap().get(uuid);
+ LOGGER.info("Operation Finished?" + operstatus.isOperFinished());
+ LOGGER.info("Operation Result Message" + operstatus.getOperResultMessage());
+
+ return RestResponseUtil.getSuccessResponse(operstatus);
+ } else {
+ OperationStatus operstatus = new OperationStatus();
+ operstatus.setOperFinished(true);
+ operstatus.setoResultCode(OperationStatus.operResultCode.NOTFOUND);
+ LOGGER.error("uuid not found");
+
+ return RestResponseUtil.getSuccessResponse(operstatus);
+
+ }
+
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java
index 0d38f06..ca647d5 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceNode.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -27,8 +26,8 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServiceNode {
-
- private String ip;
+
+ private String ip;
private String port;
@@ -58,5 +57,5 @@ public class ServiceNode {
this.ttl = ttl;
}
-
+
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java
index c6d885a..1cf0585 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java
@@ -14,24 +14,23 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
-
-import java.util.ArrayList;
-import java.util.List;
+package org.onap.vnfsdk.functest.externalservice.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
+import java.util.ArrayList;
+import java.util.List;
+
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServiceRegisterEntity {
-
- private String serviceName;
+
+ private String serviceName;
private String version;
@@ -91,11 +90,10 @@ public class ServiceRegisterEntity {
this.nodes = nodes;
}
-
public void setSingleNode(String ip, String port, int ttl) {
ServiceNode node = new ServiceNode();
- if(ip != null && ip.length() > 0) {
+ if (ip != null && ip.length() > 0) {
node.setIp(ip);
} else {
node.setIp(null);
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/CaseRecord.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/CaseRecord.java
new file mode 100644
index 0000000..683cf2d
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/CaseRecord.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.models;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import javax.persistence.*;
+import java.util.Objects;
+
+@Entity
+@Table(name = "CaseRecord")
+@NamedQueries(
+ {
+ @NamedQuery(
+ name = "org.onap.vnfsdk.functest.models.CaseRecord.findAll",
+ query = "SELECT c FROM CaseRecord c"
+ )
+ })
+public class CaseRecord {
+ @Id
+ private String taskID;
+
+ @Column(name = "funcID")
+ private String funcID;
+
+ @Column(name = "testID", nullable = false)
+ private String testID;
+
+ @Column(name = "testResult", nullable = false)
+ private String testResult;
+
+ @Column(name = "testDescription", nullable = false)
+ private String testDescription;
+
+ public CaseRecord() {
+ }
+
+ public CaseRecord(String taskID, String funcID, String testID, String testResult, String testDescription) {
+ this.taskID = taskID;
+ this.funcID = funcID;
+ this.testID = testID;
+ this.testResult = testResult;
+ this.testDescription = testDescription;
+ }
+
+ @JsonProperty
+ public String getTaskID() {
+ return taskID;
+ }
+
+ @JsonProperty
+ public void setTaskID(String taskID) {
+ this.taskID = taskID;
+ }
+
+ @JsonProperty
+ public String getFuncID() {
+ return funcID;
+ }
+
+ @JsonProperty
+ public void setFuncID(String funcID) {
+ this.funcID = funcID;
+ }
+
+ @JsonProperty
+ public String getTestID() {
+ return testID;
+ }
+
+ @JsonProperty
+ public void setTestID(String testID) {
+ this.testID = testID;
+ }
+
+ @JsonProperty
+ public String getTestResult() {
+ return testResult;
+ }
+
+ @JsonProperty
+ public void setTestResult(String testResult) {
+ this.testResult = testResult;
+ }
+
+ @JsonProperty
+ public String getTestDescription() {
+ return testDescription;
+ }
+
+ @JsonProperty
+ public void setTestDescription(String testDescription) {
+ this.testDescription = testDescription;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof CaseRecord)) {
+ return false;
+ }
+
+ final CaseRecord that = (CaseRecord) o;
+
+ return Objects.equals(this.taskID, that.taskID);
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/TaskRecord.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/TaskRecord.java
new file mode 100644
index 0000000..7fda025
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/models/TaskRecord.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.models;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import javax.persistence.*;
+import java.util.Objects;
+
+@Entity
+@Table(name = "TaskRecord")
+@NamedQueries(
+ {
+ @NamedQuery(
+ name = "org.onap.vnfsdk.functest.models.TaskRecord.findAll",
+ query = "SELECT t FROM TaskRecord t"
+ ),
+ @NamedQuery(name = "org.onap.vnfsdk.functest.models.TaskRecord.findByTaskID",
+ query = "SELECT t FROM TaskRecord t WHERE t.taskID LIKE :taskID"
+ )
+ })
+public class TaskRecord {
+ @Id
+ private String packageID;
+
+ @Column(name = "taskID", nullable = false)
+ private String taskID;
+
+ @Column(name = "envID", nullable = false)
+ private String envID;
+
+ @Column(name = "uploadID", nullable = false)
+ private String uploadID;
+
+ @Column(name = "operID", nullable = false)
+ private String operID;
+
+ @Column(name = "funcID")
+ private String funcID;
+
+ @Column(name = "status", nullable = false)
+ private String status;
+
+ @Column(name = "operFinished", nullable = false)
+ private String operFinished;
+
+ @Column(name = "operResult", nullable = false)
+ private String operResult;
+
+ @Column(name = "operResultMessage")
+ private String operResultMessage;
+
+ public TaskRecord() {
+ }
+
+ public TaskRecord(String packageID, String taskID, String envID, String uploadID, String operID, String funcID, String status, String operFinished, String operResult, String operResultMessage) {
+ this.packageID = packageID;
+ this.taskID = taskID;
+ this.envID = envID;
+ this.uploadID = uploadID;
+ this.operID = operID;
+ this.funcID = funcID;
+ this.status = status;
+ this.operFinished = operFinished;
+ this.operResult = operResult;
+ this.operResultMessage = operResultMessage;
+ }
+
+ @JsonProperty
+ public String getPackageID() {
+ return packageID;
+ }
+
+ @JsonProperty
+ public void setPackageID(String packageID) {
+ this.packageID = packageID;
+ }
+
+ @JsonProperty
+ public String getTaskID() {
+ return taskID;
+ }
+
+ @JsonProperty
+ public void setTaskID(String taskID) {
+ this.taskID = taskID;
+ }
+
+ @JsonProperty
+ public String getEnvID() {
+ return envID;
+ }
+
+ @JsonProperty
+ public void setEnvID(String envID) {
+ this.envID = envID;
+ }
+
+ @JsonProperty
+ public String getUploadID() {
+ return uploadID;
+ }
+
+ @JsonProperty
+ public void setUploadID(String uploadID) {
+ this.uploadID = uploadID;
+ }
+
+ @JsonProperty
+ public String getOperID() {
+ return operID;
+ }
+
+ @JsonProperty
+ public void setOperID(String operID) {
+ this.operID = operID;
+ }
+
+ @JsonProperty
+ public String getFuncID() {
+ return funcID;
+ }
+
+ @JsonProperty
+ public void setFuncID(String funcID) {
+ this.funcID = funcID;
+ }
+
+ @JsonProperty
+ public String getStatus() {
+ return status;
+ }
+
+ @JsonProperty
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ @JsonProperty
+ public String getOperFinished() {
+ return operFinished;
+ }
+
+ @JsonProperty
+ public void setOperFinished(String operFinished) {
+ this.operFinished = operFinished;
+ }
+
+ @JsonProperty
+ public String getOperResult() {
+ return operResult;
+ }
+
+ @JsonProperty
+ public void setOperResult(String operResult) {
+ this.operResult = operResult;
+ }
+
+ @JsonProperty
+ public String getOperResultMessage() {
+ return operResultMessage;
+ }
+
+ @JsonProperty
+ public void setOperResultMessage(String operResultMessage) {
+ this.operResultMessage = operResultMessage;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TaskRecord)) {
+ return false;
+ }
+
+ final TaskRecord that = (TaskRecord) o;
+
+ return Objects.equals(this.packageID, that.packageID) &&
+ Objects.equals(this.taskID, that.taskID);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(packageID, taskID);
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResult.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResult.java
index 4704717..10ab2e6 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResult.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResult.java
@@ -1,54 +1,54 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.responsehandler;
-
-/**
- * @author Administrator
- */
-public class TestResult {
-
- private String name;
-
- private String description;
-
- private String status;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.responsehandler;
+
+/**
+ * @author Administrator
+ */
+public class TestResult {
+
+ private String name;
+
+ private String description;
+
+ private String status;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultMap.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultMap.java
new file mode 100644
index 0000000..4f73db1
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultMap.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.responsehandler;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class TestResultMap {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestResultMap.class);
+
+ private static Map<UUID, List<TestResult>> testResultMap = new HashMap<UUID, List<TestResult>>();
+
+ private static TestResultMap oInstance = new TestResultMap();
+
+ private TestResultMap() {
+ // Empty nothing to do
+ }
+
+ public static synchronized TestResultMap getInstance() {
+ return oInstance;
+ }
+
+ public synchronized Map<UUID, List<TestResult>> getTestResultMap() {
+ return testResultMap;
+ }
+
+ public synchronized void setTestResultMap(UUID uuid, List<TestResult> inputTestResult) {
+ testResultMap.put(uuid, inputTestResult);
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResultParser.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultParser.java
index 7de2461..d3a6b39 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/TestResultParser.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/TestResultParser.java
@@ -1,143 +1,146 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.responsehandler;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.openo.vnfsdk.functest.FileUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-public class TestResultParser {
-
- private static final String STATUSPASS = "PASS";
-
- private static final String RESULTTAG = "test";
-
- private static final String NAMETAG = "name";
-
- private static final String STATUSTAG = "status";
-
- private static final String KWTAG = "kw";
-
- private static final String DOCTAG = "doc";
-
- private static final Logger logger = LoggerFactory.getLogger(TestResultParser.class);
-
- public List<TestResult> populateResultList(String xmlFile) {
- List<TestResult> resultData = new ArrayList<>();
- if(!FileUtil.checkFileExist(xmlFile)) {
- logger.error("File Not Found !!! :" + xmlFile);
- return resultData;
- }
- parseResultData(xmlFile, resultData);
- return resultData;
- }
-
- private void parseResultData(String xmlFile, List<TestResult> resultData) {
- try {
- Document doc = createDocument(xmlFile);
- NodeList list = doc.getElementsByTagName(RESULTTAG);
- for(int i = 0; i < list.getLength(); i++) {
- Node node = list.item(i);
- if(node.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
-
- NamedNodeMap attr = node.getAttributes();
- if(null == attr) {
- continue;
- }
-
- String nameAttr = getNodeValue(attr.getNamedItem(NAMETAG));
- if(null == nameAttr) {
- continue;
- }
-
- String descriptionAttr = nameAttr;
- String statusAttr = STATUSPASS;
- NodeList childlist = node.getChildNodes();
- for(int j = 0; j < childlist.getLength(); j++) {
- Node childNode = childlist.item(j);
- if(childNode.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
-
- if(KWTAG == childNode.getNodeName()) {
- NodeList kwNodeList = childNode.getChildNodes();
- for(int k = 0; k < kwNodeList.getLength(); k++) {
- Node descNode = kwNodeList.item(k);
- if(descNode.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
-
- if(DOCTAG == descNode.getNodeName()) {
- if(null != descNode.getTextContent()) {
- descriptionAttr = descNode.getTextContent();
- break;
- }
- }
- }
- }
-
- if(STATUSTAG == childNode.getNodeName()) {
- NamedNodeMap statusAttrMap = childNode.getAttributes();
- if(null != statusAttrMap) {
- statusAttr = getNodeValue(statusAttrMap.getNamedItem(STATUSTAG));
- }
- }
- }
-
- TestResult testData = new TestResult();
- testData.setName(nameAttr);
- testData.setDescription(descriptionAttr);
- testData.setStatus(statusAttr);
-
- resultData.add(testData);
- }
- } catch(ParserConfigurationException | SAXException | IOException e) {
- logger.error("Exception while parsing file :" + xmlFile);
- logger.error("Exception while parsing file :", e);
- }
- }
-
- private Document createDocument(String fileName) throws ParserConfigurationException, SAXException, IOException {
- InputStream inputStream = new FileInputStream(fileName);
- DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- Document doc = docBuilder.parse(inputStream);
- doc.getDocumentElement().normalize();
- return doc;
- }
-
- private String getNodeValue(Node namedItem) {
- return (null != namedItem) ? namedItem.getNodeValue() : null;
- }
-}
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.responsehandler;
+
+import org.onap.vnfsdk.functest.FileUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class TestResultParser {
+
+ private static final String STATUSPASS = "PASS";
+
+ private static final String RESULTTAG = "test";
+
+ private static final String NAMETAG = "name";
+
+ private static final String STATUSTAG = "status";
+
+ private static final String KWTAG = "kw";
+
+ private static final String DOCTAG = "doc";
+
+ private static final Logger logger = LoggerFactory.getLogger(TestResultParser.class);
+
+ public List<TestResult> populateResultList(String taskID, String xmlFile) {
+ List<TestResult> resultData = new ArrayList<>();
+ if (!FileUtil.checkFileExist(xmlFile)) {
+ logger.error("File Not Found !!! :" + xmlFile);
+ return resultData;
+ }
+ parseResultData(taskID, xmlFile, resultData);
+ return resultData;
+ }
+
+ private void parseResultData(String taskID, String xmlFile, List<TestResult> resultData) {
+ try {
+ Document doc = createDocument(xmlFile);
+ NodeList list = doc.getElementsByTagName(RESULTTAG);
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ NamedNodeMap attr = node.getAttributes();
+ if (null == attr) {
+ continue;
+ }
+
+ String nameAttr = getNodeValue(attr.getNamedItem(NAMETAG));
+ if (null == nameAttr) {
+ continue;
+ }
+
+ String descriptionAttr = nameAttr;
+ String statusAttr = STATUSPASS;
+ NodeList childlist = node.getChildNodes();
+ for (int j = 0; j < childlist.getLength(); j++) {
+ Node childNode = childlist.item(j);
+ if (childNode.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ if (KWTAG == childNode.getNodeName()) {
+ NodeList kwNodeList = childNode.getChildNodes();
+ for (int k = 0; k < kwNodeList.getLength(); k++) {
+ Node descNode = kwNodeList.item(k);
+ if (descNode.getNodeType() != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ if (DOCTAG == descNode.getNodeName()) {
+ if (null != descNode.getTextContent()) {
+ descriptionAttr = descNode.getTextContent();
+ break;
+ }
+ }
+ }
+ }
+
+ if (STATUSTAG == childNode.getNodeName()) {
+ NamedNodeMap statusAttrMap = childNode.getAttributes();
+ if (null != statusAttrMap) {
+ statusAttr = getNodeValue(statusAttrMap.getNamedItem(STATUSTAG));
+ }
+ }
+ }
+
+ TestResult testData = new TestResult();
+ testData.setName(nameAttr);
+ testData.setDescription(descriptionAttr);
+ testData.setStatus(statusAttr);
+
+ resultData.add(testData);
+ }
+
+ TestResultMap.getInstance().setTestResultMap(UUID.fromString(taskID), resultData);
+
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ logger.error("Exception while parsing file :" + xmlFile);
+ logger.error("Exception while parsing file :", e);
+ }
+ }
+
+ private Document createDocument(String fileName) throws ParserConfigurationException, SAXException, IOException {
+ InputStream inputStream = new FileInputStream(fileName);
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ Document doc = docBuilder.parse(inputStream);
+ doc.getDocumentElement().normalize();
+ return doc;
+ }
+
+ private String getNodeValue(Node namedItem) {
+ return (null != namedItem) ? namedItem.getNodeValue() : null;
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java
index 7dd47d7..0dce5a0 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandler.java
@@ -14,45 +14,38 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonReader;
+import org.onap.vnfsdk.functest.FileUtil;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+import org.onap.vnfsdk.functest.util.ZipCompressor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.core.Response;
-
-import org.openo.vnfsdk.functest.FileUtil;
-import org.openo.vnfsdk.functest.util.RestResponseUtil;
-import org.openo.vnfsdk.functest.util.ZipCompressor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
public class VnfFuncTestResponseHandler {
+ private static final Logger logger = LoggerFactory.getLogger(VnfFuncTestResponseHandler.class);
private static int actioninProgress = 21;
-
private static int error = 22;
-
private static String resultFileName = "output.xml";
-
- private static String resultpathkey = "DIR_RESULT";
-
+ private static String resultPathKey = "DIR_RESULT";
private static Map<String, String> mapConfigValues;
-
private static VnfFuncTestResponseHandler vnfFuncRspHandler;
- private static final Logger logger = LoggerFactory.getLogger(VnfFuncTestResponseHandler.class);
-
private VnfFuncTestResponseHandler() {
}
public static VnfFuncTestResponseHandler getInstance() {
- if(vnfFuncRspHandler == null) {
+ if (vnfFuncRspHandler == null) {
vnfFuncRspHandler = new VnfFuncTestResponseHandler();
loadConfigurations();
}
@@ -63,29 +56,43 @@ public class VnfFuncTestResponseHandler {
mapConfigValues = inMapConfigValues;
}
+ @SuppressWarnings("unchecked")
+ private static void loadConfigurations() {
+ String curDir = System.getProperty("user.dir");
+ String confDir = curDir + File.separator + "conf" + File.separator + "robot" + File.separator;
+// ObjectMapper mapper = new ObjectMapper();
+
+ try {
+// mapConfigValues = mapper.readValue(new FileInputStream(confDir + "robotMetaData.json"), Map.class);
+ mapConfigValues = new Gson().fromJson(new JsonReader(new FileReader(confDir + "robotMetaData.json")), Map.class);
+ } catch (IOException e) {
+ logger.error("Reading Json Meta data file failed or file do not exist", e);
+ }
+ }
+
public Response getResponseByFuncTestId(String funcTestId) {
- if((null == mapConfigValues) || (null == mapConfigValues.get(resultpathkey))) {
- logger.warn("Result Store path not configfured !!!");
+ if ((null == mapConfigValues) || (null == mapConfigValues.get(resultPathKey))) {
+ logger.warn("Result Store path not configured !!!");
return RestResponseUtil.getErrorResponse(error);
}
- String resultPath = mapConfigValues.get(resultpathkey);
+ String resultPath = mapConfigValues.get(resultPathKey);
/*
* Check whether file Exists for the Request received !!!
* -----------------------------------------------------
*/
String fileName = resultPath + File.separator + funcTestId;
- if(!FileUtil.checkFileExist(fileName)) {
- logger.warn("Resquested function Test result not avaliable/In-Progress !!!");
+ if (!FileUtil.checkFileExist(fileName)) {
+ logger.warn("Requested function Test result not available/In-Progress !!!");
return RestResponseUtil.getErrorResponse(actioninProgress);
}
String zipFileName = fileName + ".zip";
try {
new ZipCompressor(zipFileName).compress(fileName);
- } catch(IOException e) {
+ } catch (IOException e) {
logger.error("getResponseByFuncTestId ", e);
}
@@ -95,7 +102,7 @@ public class VnfFuncTestResponseHandler {
*/
byte[] byteArrayFile = FileUtil.convertZipFiletoByteArray(zipFileName);
- if(null != byteArrayFile) {
+ if (null != byteArrayFile) {
/*
* Delete Result folders present if Success !!!
@@ -105,40 +112,27 @@ public class VnfFuncTestResponseHandler {
/*
* Later will delete this file
*/
- logger.warn("Resquested function Test result Sucess !!!");
+ logger.warn("Requested function Test result Success !!!");
return RestResponseUtil.getSuccessResponse(byteArrayFile);
} else {
- logger.warn("Resquested function Test result Faiuled !!!");
+ logger.warn("Requested function Test result Failed !!!");
return RestResponseUtil.getErrorResponse(error);
}
}
public Response downloadResults(String funcTestId) {
- if((null == mapConfigValues) || (null == mapConfigValues.get(resultpathkey))) {
- logger.warn("Result Store path not configfured !!!");
+ if ((null == mapConfigValues) || (null == mapConfigValues.get(resultPathKey))) {
+ logger.warn("Result Store path not configured !!!");
return RestResponseUtil.getErrorResponse(error);
}
- String resultPath = mapConfigValues.get(resultpathkey);
+ String resultPath = mapConfigValues.get(resultPathKey);
String resultfileName = resultPath + File.separator + funcTestId + File.separator + resultFileName;
-
+ logger.info(resultfileName);
TestResultParser oTestResultParser = new TestResultParser();
- List<TestResult> resultList = oTestResultParser.populateResultList(resultfileName);
+ List<TestResult> resultList = oTestResultParser.populateResultList(funcTestId, resultfileName);
return (!resultList.isEmpty()) ? RestResponseUtil.getSuccessResponse(resultList)
: RestResponseUtil.getErrorResponse(error);
}
-
- @SuppressWarnings("unchecked")
- private static void loadConfigurations() {
- String curDir = System.getProperty("user.dir");
- String confDir = curDir + File.separator + "conf" + File.separator + "robot" + File.separator;
- ObjectMapper mapper = new ObjectMapper();
- try {
- mapConfigValues = mapper.readValue(new FileInputStream(confDir + "robotMetaData.json"), Map.class);
- } catch(IOException e) {
- logger.error("Reading Json Meta data file failed or file do not exist", e);
- return;
- }
- }
}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManager.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManager.java
new file mode 100644
index 0000000..1dae79f
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/scriptmgr/ScriptManager.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.scriptmgr;
+
+import com.google.gson.Gson;
+import org.onap.vnfsdk.functest.FileUtil;
+import org.onap.vnfsdk.functest.TaskExecution;
+import org.onap.vnfsdk.functest.constants.ApplicationConstants;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+import org.onap.vnfsdk.functest.externalservice.entity.EnvironmentMap;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.responsehandler.TestResult;
+import org.onap.vnfsdk.functest.responsehandler.TestResultMap;
+import org.onap.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.UUID;
+import java.util.concurrent.*;
+
+public class ScriptManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ScriptManager.class);
+ private final TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private final TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+
+ public ScriptManager(TaskMgrTaskTblDAO taskMgrTaskTblDAO, TaskMgrCaseTblDAO taskMgrCaseTblDAO) {
+ this.taskMgrTaskTblDAO = taskMgrTaskTblDAO;
+ this.taskMgrCaseTblDAO = taskMgrCaseTblDAO;
+ }
+
+ /**
+ * Convert the stream to File Name<br/>
+ *
+ * @param dirName - Directory name
+ * @param fileName - FileName
+ * @param uploadedInputStream - Input Stream
+ * @return - File Path
+ * @throws IOException - Exception while writing file
+ * @since VNFSDK
+ */
+ public static String storeChunkFileInLocal(String dirName, String fileName, InputStream uploadedInputStream)
+ throws IOException {
+ File tmpDir = new File(dirName);
+ LOGGER.info("tmpdir=" + dirName);
+ if (!tmpDir.exists()) {
+ tmpDir.mkdirs();
+ }
+ StringTokenizer st = new StringTokenizer(fileName, "/");
+ String actualFile = null;
+ while (st.hasMoreTokens()) {
+ actualFile = st.nextToken();
+ }
+ File file = new File(tmpDir + File.separator + actualFile);
+ OutputStream os = null;
+ try {
+ int read = 0;
+ byte[] bytes = new byte[1024];
+ os = new FileOutputStream(file, true);
+ while ((read = uploadedInputStream.read(bytes)) != -1) {
+ os.write(bytes, 0, read);
+ }
+ os.flush();
+ return file.getAbsolutePath();
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+
+ public UUID setEnvironment(String env) {
+ LOGGER.info("[Scrip Manager] Set Environment.");
+
+ try {
+
+ // Generate UUID for each environment
+ final UUID envID = UUID.randomUUID();
+
+ // Convert input string to Environment class
+// ObjectMapper mapper = new ObjectMapper();
+// Environment envObj = mapper.readValue(env, Environment.class);
+ Environment envObj = new Gson().fromJson(env, Environment.class);
+ if (null == envObj) {
+ // Converting input to Env object failed
+ return null;
+ }
+
+ // Set to the environment map
+ EnvironmentMap.getInstance().addEnv(envID, envObj);
+ LOGGER.info(EnvironmentMap.getInstance().getEnv(envID).getPassword());
+
+ // Send the envID back
+ return envID;
+
+ } catch (Exception e) {
+ LOGGER.error("Setting the Environment Fail", e);
+ }
+
+ return null;
+ }
+
+ public UUID uploadFuncTestPackage(UUID taskID, UUID envID, String url) {
+ LOGGER.info("[Scrip Manager] Upload Function Test Package.");
+
+ try {
+ URL oracle = new URL(url);
+
+ InputStream fis = new BufferedInputStream(oracle.openStream());
+
+ // Convert the stream to script folder
+ String nl = File.separator;
+ String filePath = storeChunkFileInLocal("temp", "TempFile.zip", fis);
+
+ // Unzip the folder
+ String tempDir = System.getProperty("user.dir") + nl + "temp";
+ List<String> list = FileUtil.unzip(filePath, tempDir);
+ LOGGER.info("File path=" + filePath);
+
+ String[] directories = FileUtil.getDirectory(tempDir);
+ LOGGER.info("tempdir=" + tempDir);
+ if (null != directories && 0 != directories.length) {
+ filePath = tempDir + File.separator + directories[0];
+ } else {
+ filePath = tempDir;
+ }
+
+ // generate UUID for the upload
+ final UUID uploadID = UUID.randomUUID();
+ List<TaskRecord> taskRecordList = taskMgrTaskTblDAO.findByTaskID(taskID.toString());
+ TaskRecord taskRecord = taskRecordList.get(0);
+ taskRecord.setUploadID(uploadID.toString());
+ taskRecord.setOperID(uploadID.toString());
+ taskMgrTaskTblDAO.saveOrUpdate(taskRecord);
+
+ final String finalPath = filePath;
+
+ ExecutorService es = Executors.newFixedThreadPool(3);
+ Future<Integer> future = es.submit(new Callable<Integer>() {
+
+ @Override
+ public Integer call() throws Exception {
+
+ new TaskExecution().uploadScript(finalPath, envID, uploadID);
+ return 0;
+ }
+ });
+
+ try {
+ if (0 == future.get(5, TimeUnit.SECONDS)) {
+ LOGGER.info("ExecutorService Done");
+
+ OperationStatus operStatus = OperationStatusHandler.getInstance().getOperStatusMap().get(uploadID);
+ taskRecord.setOperFinished(operStatus.isOperFinished() ? "True" : "False");
+ taskRecord.setOperResult(operStatus.getoResultCode().toString());
+ taskRecord.setOperResultMessage(operStatus.getOperResultMessage());
+ taskMgrTaskTblDAO.saveOrUpdate(taskRecord);
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ } catch (TimeoutException e) {
+ LOGGER.info("Time out.");
+ e.printStackTrace();
+ }
+
+ return uploadID;
+
+ } catch (IOException e) {
+ LOGGER.error(ApplicationConstants.RUN_SCRIPT_EXECUTE_CMD, e);
+ }
+
+ return null;
+ }
+
+ public Response getOperationResult(UUID operID) {
+ LOGGER.info("[Script Manager] Query functest Status by ID." + operID);
+
+ return OperationStatusHandler.getInstance().getOperationStatus(operID);
+ }
+
+ public Response downloadResults(UUID taskID) {
+ LOGGER.info("[Script Manager] Download functest Result by ID: " + taskID);
+
+ Response resp = VnfFuncTestResponseHandler.getInstance().downloadResults(taskID.toString());
+
+ try {
+ TestResult testResult = TestResultMap.getInstance().getTestResultMap().get(taskID).get(0);
+
+ CaseRecord caseRecord = taskMgrCaseTblDAO.findByTaskID(taskID.toString());
+ caseRecord.setTestID(testResult.getName());
+ caseRecord.setTestResult(testResult.getStatus());
+ caseRecord.setTestDescription(testResult.getDescription());
+ taskMgrCaseTblDAO.saveOrUpdate(caseRecord);
+ } catch (Exception e) {
+ LOGGER.error("Collect Functest Result by ID Failed.", e);
+ }
+ return resp;
+ }
+
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/taskmgr/TaskManager.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/taskmgr/TaskManager.java
new file mode 100644
index 0000000..79e611b
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/taskmgr/TaskManager.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.taskmgr;
+
+import com.codahale.metrics.annotation.Timed;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.stream.JsonReader;
+import io.dropwizard.hibernate.UnitOfWork;
+import io.swagger.annotations.*;
+import org.eclipse.jetty.http.HttpStatus;
+import org.onap.vnfsdk.functest.constants.ApplicationConstants;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.scriptmgr.ScriptManager;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@Path("/functest/taskmanager")
+@Api(tags = {" Function Test Task Manager "})
+public class TaskManager {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TaskManager.class);
+
+ private final TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private final TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+ private final ScriptManager scriptManager;
+
+ public TaskManager(TaskMgrTaskTblDAO taskMgrTaskTblDAO, TaskMgrCaseTblDAO taskMgrCaseTblDAO, ScriptManager scriptManager) {
+ this.taskMgrTaskTblDAO = taskMgrTaskTblDAO;
+ this.taskMgrCaseTblDAO = taskMgrCaseTblDAO;
+ this.scriptManager = scriptManager;
+ }
+
+ @Path("/onboard")
+ @POST
+ @ApiOperation(value = "Start Onboard Testing")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ //@Timed
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
+ @UnitOfWork
+ public Response startOnboardTesting(RequestBody requestBody) {
+ LOGGER.info("[Task Manager] Start Onboard Testing");
+ TaskRecord taskRecord = new TaskRecord();
+ CaseRecord caseRecord = new CaseRecord();
+
+ String packageID = requestBody.packageID;
+
+ try {
+ if (taskMgrTaskTblDAO.findByPackageID(packageID).isPresent()) {
+ throw new Exception("Already Onboard.");
+ } else {
+ initOnboardTesting(taskRecord, caseRecord, packageID);
+ scriptManager.uploadFuncTestPackage(UUID.fromString(taskRecord.getTaskID()), UUID.fromString(taskRecord.getEnvID()), ApplicationConstants.CATALOG_URI);
+ }
+ return RestResponseUtil.getCreateSuccessResponse(UUID.fromString(taskRecord.getTaskID()));
+
+ } catch (Exception e) {
+ if ("Already Onboard.".equals(e.getMessage())) {
+ LOGGER.error("The Package " + packageID + " is already the onboarding package.", e);
+ return RestResponseUtil.getErrorResponse(packageID);
+ } else {
+ LOGGER.error("Start Onboard Testing Fail", e);
+ }
+ }
+ return null;
+ }
+
+ @Path("/status/{taskID}")
+ @GET
+ @ApiOperation(value = "Query Function Test Status by ID")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
+ @Timed
+ @UnitOfWork
+ public Response queryTestStatus(@ApiParam(value = "taskID") @PathParam("taskID") String taskID) {
+ LOGGER.info("[Task Manager] Query Function Test Status by ID: " + taskID);
+
+ try {
+
+ List<TaskRecord> taskRecordList = taskMgrTaskTblDAO.findByTaskID(taskID);
+ if (taskRecordList.isEmpty()) {
+ throw new Exception("Task Not Exist.");
+ } else {
+
+ TaskRecord taskRecord = taskRecordList.get(0);
+ UUID operID = UUID.fromString(taskRecord.getOperID());
+
+ LOGGER.info(taskRecord.getOperID());
+ OperationStatus operStatus = OperationStatusHandler.getInstance().getOperStatusMap().get(operID);
+ /**
+ * To check whether the operID belongs to a record in memory.
+ * If so, needs refresh db: retrieve the data from the record in memory and update the db accordingly.
+ * If not, means a historical record in db. Obtain the data from db.
+ * */
+ if (null != operStatus) {
+ taskRecord.setOperFinished(operStatus.isOperFinished() ? "True" : "False");
+ taskRecord.setOperResult(operStatus.getoResultCode().toString());
+ taskRecord.setOperResultMessage(operStatus.getOperResultMessage());
+ taskMgrTaskTblDAO.saveOrUpdate(taskRecord);
+ } else {
+ OperationStatus oldOperStatus = new OperationStatus();
+ oldOperStatus.setoResultCode(OperationStatus.operResultCode.valueOf(taskRecord.getOperResult()));
+ oldOperStatus.setOperResultMessage(taskRecord.getOperResultMessage());
+ oldOperStatus.setOperFinished("True".equals(taskRecord.getOperFinished()));
+ OperationStatusHandler.getInstance().setOperStatusMap(operID, oldOperStatus);
+ }
+ return scriptManager.getOperationResult(operID);
+ }
+ } catch (Exception e) {
+ if ("Task Not Exist.".equals(e.getMessage())) {
+ LOGGER.error("The Task " + taskID + " does not exist..!", e);
+ return RestResponseUtil.getNotFoundResponse(taskID);
+ } else {
+ LOGGER.error("Query Function Test Status by ID Failed.", e);
+ }
+ }
+ return null;
+ }
+
+ @Path("/result/{taskID}")
+ @GET
+ @ApiOperation(value = "Get Function Test Result by ID")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+ @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
+ @Timed
+ @UnitOfWork
+ public Response collectTaskResult(@ApiParam(value = "taskID") @PathParam("taskID") String taskID) {
+ LOGGER.info("[Task Manager] Collect Function Test Result by ID." + taskID);
+
+ try {
+ CaseRecord caseRecord = taskMgrCaseTblDAO.findByTaskID(taskID);
+ if (null == caseRecord) {
+ throw new Exception("Task Not Exist.");
+ } else {
+ /* To check whether we have already collected the result of Task: taskID. */
+ if ("NOT CREATED".equals(caseRecord.getTestID())) {
+ return scriptManager.downloadResults(UUID.fromString(taskID));
+ } else {
+ CaseRecord oldCaseRecord = new CaseRecord();
+ oldCaseRecord.setTestID(caseRecord.getTestID());
+ oldCaseRecord.setTestResult(caseRecord.getTestResult());
+ oldCaseRecord.setTestDescription(caseRecord.getTestDescription());
+ return RestResponseUtil.getSuccessResponse(oldCaseRecord);
+ }
+ }
+ } catch (Exception e) {
+ if ("Task Not Exist.".equals(e.getMessage())) {
+ LOGGER.error("The Task " + taskID + " does not exist..!", e);
+ return RestResponseUtil.getNotFoundResponse(taskID);
+ } else {
+ LOGGER.error("Collect Function Test Result by ID Failed.", e);
+ }
+ }
+ return null;
+ }
+
+ private void initOnboardTesting(TaskRecord taskRecord, CaseRecord caseRecord, String packageID) {
+ /* Create TaskRecord entry in db */
+ taskRecord.setPackageID(packageID);
+ // Generate UUID for each task
+ final UUID taskID = UUID.randomUUID();
+ taskRecord.setTaskID(taskID.toString());
+ // Setup the environment
+ final UUID envID = scriptManager.setEnvironment(loadEnvConfigurations());
+ taskRecord.setEnvID(envID.toString());
+ taskRecord.setUploadID("NOT CREATED");
+ taskRecord.setOperID("NOT CREATED");
+ taskRecord.setFuncID("");
+ taskRecord.setStatus("CREATED");
+ taskRecord.setOperFinished("False");
+ taskRecord.setOperResult("FAILURE");
+ taskRecord.setOperResultMessage("");
+ taskMgrTaskTblDAO.saveOrUpdate(taskRecord);
+
+ /* Create CaseRecord entry in db */
+ caseRecord.setTaskID(taskID.toString());
+ caseRecord.setFuncID("");
+ caseRecord.setTestID("NOT CREATED");
+ caseRecord.setTestResult("NULL");
+ caseRecord.setTestDescription("");
+ taskMgrCaseTblDAO.saveOrUpdate(caseRecord);
+ }
+
+ private String loadEnvConfigurations() {
+ Map<String, String> envConfigurations;
+ String strEnvConfigurations;
+ String curDir = System.getProperty("user.dir");
+ String confDir = curDir + File.separator + ApplicationConstants.CONF + File.separator + ApplicationConstants.ENVIRONMENT + File.separator;
+
+ try {
+
+ envConfigurations = new Gson().fromJson(new JsonReader(new FileReader(confDir + ApplicationConstants.ENVIRONMENT_JSON)), Map.class);
+ Gson gson = new GsonBuilder().create();
+ strEnvConfigurations = gson.toJson(envConfigurations);
+
+ return strEnvConfigurations;
+ } catch (IOException e) {
+ LOGGER.error("Reading Environment Json data file failed or file does not exist", e);
+ }
+ return null;
+ }
+
+ public static class RequestBody {
+
+ @JsonProperty("packageID")
+ private String packageID;
+
+ public String getPackageID() {
+ return packageID;
+ }
+
+ public void setPackageID(String packageID) {
+ this.packageID = packageID;
+ }
+ }
+
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/GsonUtil.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/GsonUtil.java
index 78936da..b453d3c 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/GsonUtil.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/GsonUtil.java
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.util;
+package org.onap.vnfsdk.functest.util;
+
+import com.google.gson.Gson;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
-import com.google.gson.Gson;
-
public class GsonUtil {
private GsonUtil() {
@@ -41,7 +41,7 @@ public class GsonUtil {
*/
public static String objectToString(Object obj) {
Gson gson = new Gson();
- if(obj != null) {
+ if (obj != null) {
return gson.toJson(obj);
} else {
return null;
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/RestResponseUtil.java
index 1c5404f..40ab57e 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/RestResponseUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.util;
+package org.onap.vnfsdk.functest.util;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@@ -25,19 +25,27 @@ public class RestResponseUtil {
}
public static Response getSuccessResponse(Object obj) {
- if(obj != null) {
+ if (obj != null) {
return Response.ok(GsonUtil.objectToString(obj)).build();
} else {
return Response.ok().build();
}
}
- public static Response getCreateSussceeResponse(Object obj) {
+ public static Response getCreateSuccessResponse(Object obj) {
return Response.status(Status.CREATED).entity(obj).build();
}
+ public static Response getNotFoundResponse(Object obj) {
+ if (obj != null) {
+ return Response.status(Status.NOT_FOUND).entity(GsonUtil.objectToString(obj)).build();
+ } else {
+ return Response.serverError().build();
+ }
+ }
+
public static Response getErrorResponse(Object obj) {
- if(obj != null) {
+ if (obj != null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(GsonUtil.objectToString(obj)).build();
} else {
return Response.serverError().build();
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/ZipCompressor.java
index 94773b3..de2875e 100644
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/ZipCompressor.java
+++ b/vnf-sdk-function-test/src/main/java/org/onap/vnfsdk/functest/util/ZipCompressor.java
@@ -14,22 +14,17 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.util;
+package org.onap.vnfsdk.functest.util;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
import java.util.zip.CRC32;
import java.util.zip.CheckedOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public class ZipCompressor {
public static final Logger LOG = LoggerFactory.getLogger(ZipCompressor.class);
@@ -44,13 +39,13 @@ public class ZipCompressor {
/**
* compress file according file path.
- *
+ *
* @param srcPathName file path name
* @throws IOException
*/
public void compress(String srcPathName) throws IOException {
File file = new File(srcPathName);
- if(!file.exists()) {
+ if (!file.exists()) {
throw new FileNotFoundException(srcPathName + "not exist!");
}
try {
@@ -60,13 +55,13 @@ public class ZipCompressor {
String basedir = "";
compress(file, out, basedir);
out.close();
- } catch(Exception e1) {
+ } catch (Exception e1) {
throw new IOException(e1);
}
}
private void compress(File file, ZipOutputStream out, String basedir) {
- if(file.isDirectory()) {
+ if (file.isDirectory()) {
LOG.info("compress: " + basedir + file.getName());
this.compressDirectory(file, out, basedir);
} else {
@@ -76,18 +71,18 @@ public class ZipCompressor {
}
private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
- if(!dir.exists()) {
+ if (!dir.exists()) {
return;
}
File[] files = dir.listFiles();
- for(int i = 0; i < files.length; i++) {
+ for (int i = 0; i < files.length; i++) {
compress(files[i], out, basedir + dir.getName() + "/");
}
}
private void compressFile(File file, ZipOutputStream out, String basedir) {
- if(!file.exists()) {
+ if (!file.exists()) {
return;
}
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
@@ -97,11 +92,11 @@ public class ZipCompressor {
ZipEntry entry = new ZipEntry(basedir + file.getName());
out.putNextEntry(entry);
int count;
- while((count = bis.read(data, 0, BUFFER)) != -1) {
+ while ((count = bis.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
bis.close();
- } catch(IOException e) {
+ } catch (IOException e) {
LOG.info("Exception wile compress file" + file.getAbsolutePath(), e);
}
}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java
deleted file mode 100644
index f6cffba..0000000
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.common;
-
-import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity;
-import org.openo.vnfsdk.functest.externalservice.msb.MicroserviceBusConsumer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ServiceRegistration implements Runnable {
-
- private final ServiceRegisterEntity funcTestEntity = new ServiceRegisterEntity();
-
- private static final Logger LOG = LoggerFactory.getLogger(ServiceRegistration.class);
-
- public ServiceRegistration() {
- initServiceEntity();
- }
-
- @Override
- public void run() {
- LOG.info("start extsys microservice register");
- boolean flag = false;
- int retry = 0;
-
- while(!flag) {
- LOG.info("VNF-SDK function test microservice register.retry:" + retry);
- retry++;
-
- flag = MicroserviceBusConsumer.registerService(funcTestEntity);
- if(retry >= 1000) {
- flag = true;
- }
-
- if(flag == false) {
- LOG.warn("microservice register failed, sleep 30S and try again.");
- threadSleep(30000);
- } else {
- LOG.info("microservice register success!");
- break;
- }
- }
- LOG.info("VNF-SDK function test microservice register end.");
- }
-
- private void threadSleep(int second) {
- LOG.info("start sleep ....");
- try {
- Thread.sleep(second);
- } catch(InterruptedException error) {
- LOG.error("thread sleep error.errorMsg:", error);
- Thread.currentThread().interrupt();
- }
- LOG.info("sleep end .");
- }
-
- private void initServiceEntity() {
- funcTestEntity.setServiceName("vnfsdk");
- funcTestEntity.setProtocol("REST");
- funcTestEntity.setVersion("v1");
- funcTestEntity.setUrl("/openoapi/vnfsdk/v1");
- funcTestEntity.setSingleNode(Config.getConfigration().getServiceIp(), "8701", 0);
- funcTestEntity.setVisualRange("1");
- }
-}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java
deleted file mode 100644
index 7c74545..0000000
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.msb;
-
-import javax.ws.rs.ProcessingException;
-
-import org.glassfish.jersey.client.ClientConfig;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-
-public class MicroserviceBusConsumer {
-
- private static final Logger LOG = LoggerFactory.getLogger(MicroserviceBusConsumer.class);
-
- private MicroserviceBusConsumer() {
-
- }
-
- public static boolean registerService(ServiceRegisterEntity entity) {
- ClientConfig config = new ClientConfig();
- try {
- MicroserviceBusRest resourceserviceproxy = ConsumerFactory
- .createConsumer(Config.getConfigration().getMsbServerAddr(), config, MicroserviceBusRest.class);
- resourceserviceproxy.registerService("false", entity);
- } catch(ProcessingException error) {
- LOG.error("Microservice register failed!", error);
- return false;
- }
- return true;
- }
-}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusRest.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusRest.java
deleted file mode 100644
index 1433605..0000000
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusRest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.msb;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity;
-
-@Path("/openoapi/microservices/v1/services")
-public interface MicroserviceBusRest {
-
- @Path("")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public ServiceRegisterEntity registerService(@QueryParam("createOrUpdate") String createOrUpdate,
- ServiceRegisterEntity entity);
-}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java
deleted file mode 100644
index 937073b..0000000
--- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.resource;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.eclipse.jetty.http.HttpStatus;
-import org.openo.vnfsdk.functest.FileUtil;
-import org.openo.vnfsdk.functest.TaskExecution;
-import org.openo.vnfsdk.functest.constants.ApplicationConstants;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-import org.openo.vnfsdk.functest.externalservice.entity.EnvironmentMap;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
-import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
-import org.openo.vnfsdk.functest.util.RestResponseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.codahale.metrics.annotation.Timed;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-@Path("/functest")
-@Api(tags = {" function test Management "})
-public class CommonManager {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CommonManager.class);
-
- @POST
- @Path("/setenv")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Timed
- public Response setEnvironment(String env) {
- LOGGER.info("set Environment");
-
- try {
-
- // Generate UUID for each environment
- final UUID uniqueKey = UUID.randomUUID();
-
- // Convert input string to Environment class
- ObjectMapper mapper = new ObjectMapper();
- Environment envObj = mapper.readValue(env, Environment.class);
- if(null == envObj) {
- // Converting input to Env object failed
- return null;
- }
-
- // Set to the environment map
- EnvironmentMap.getInstance().addEnv(uniqueKey, envObj);
-
- // Send REST response
- return RestResponseUtil.getSuccessResponse(uniqueKey);
-
- } catch(Exception e) {
- LOGGER.error("Setting the Environment Fail", e);
- }
-
- return null;
- }
-
- @Path("/upload/{functestEnvId}")
- @POST
- @ApiOperation(value = "upload the function test")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response uploadFuncTestPackage(@PathParam("functestEnvId") String functestEnvId,
- @HeaderParam("URL") String url) {
- LOGGER.info("Upload function test package");
-
- try {
- URL oracle = new URL(url);
-
- InputStream fis = new BufferedInputStream(oracle.openStream());
-
- // Convert the stream to script folder
- String nl = File.separator;
- String filePath = storeChunkFileInLocal("temp", "TempFile.zip", fis);
-
- // Unzip the folder
- String tempDir = System.getProperty("user.dir") + nl + "temp";
- List<String> list = FileUtil.unzip(filePath, tempDir);
- LOGGER.info("File path=" + filePath);
-
- String[] directories = FileUtil.getDirectory(tempDir);
- if(null != directories) {
- filePath = tempDir + File.separator + directories[0];
- }
-
- // convert uuid string to UUID
- final UUID uuidEnv = UUID.fromString(functestEnvId);
- // generate UUID for the upload
- final UUID uuidUpload = UUID.randomUUID();
-
- final String finalPath = filePath;
- ExecutorService es = Executors.newFixedThreadPool(3);
- es.submit(new Callable<Integer>() {
-
- @Override
- public Integer call() throws Exception {
-
- new TaskExecution().uploadScript(finalPath, uuidEnv, uuidUpload);
- return 0;
- }
- });
-
- // Send REST response
- return RestResponseUtil.getSuccessResponse(uuidUpload);
-
- } catch(IOException e) {
- LOGGER.error(ApplicationConstants.RUN_SCRIPT_EXECUTE_CMD, e);
- }
-
- return null;
- }
-
- @Path("/{uploadUUID}/{envUUID}/{frameworktype}")
- @POST
- @ApiOperation(value = "execute the function test")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response executeFunctionTest(@PathParam("envUUID") String functestEnvId,
- @PathParam("uploadUUID") String uploadId, @PathParam("frameworktype") String frameworktype) {
- LOGGER.info("Execute function test");
-
- try {
-
- final UUID envUUID = UUID.fromString(functestEnvId);
-
- // generate UUID for execute
- final UUID executeUUID = UUID.randomUUID();
-
- ExecutorService es = Executors.newFixedThreadPool(3);
- es.submit(new Callable<Integer>() {
-
- @Override
- public Integer call() throws Exception {
-
- new TaskExecution().executeRobotScript(envUUID, executeUUID);
- return 0;
- }
- });
-
- // Send REST response
- return RestResponseUtil.getSuccessResponse(executeUUID);
-
- } catch(Exception e) {
- LOGGER.error(ApplicationConstants.RUN_SCRIPT_EXECUTE_CMD, e);
- }
-
- return null;
- }
-
- @Path("")
- @POST
- @ApiOperation(value = "execute the function test")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response executeFuncTest(InputStream csarInputStream) {
- LOGGER.info("execute function test");
-
- try {
-
- // Upload the script and execute the script and run command
- final UUID uniqueKey = UUID.randomUUID();
-
- // Convert the stream to script folder
- String nl = File.separator;
- String filePath =
- storeChunkFileInLocal("package" + nl + uniqueKey.toString(), "TempFile.rar", csarInputStream);
-
- // Unzip the folder
- String tempDir = System.getProperty("user.dir") + nl + "package" + nl + uniqueKey + nl + "temp";
- FileUtil.unzip(filePath, tempDir);
- LOGGER.info("File path=" + filePath);
-
- filePath = tempDir + File.separator + "RobotScript";
- if(!FileUtil.checkFileExist(filePath)) {
- return RestResponseUtil.getErrorResponse(null);
- }
-
- final String finalPath = filePath;
- ExecutorService es = Executors.newFixedThreadPool(3);
- es.submit(new Callable<Integer>() {
-
- public Integer call() throws Exception {
-
- new TaskExecution().executeScript(finalPath, uniqueKey);
- return 0;
- }
- });
-
- // Send REST response
- return RestResponseUtil.getSuccessResponse(uniqueKey.toString());
-
- } catch(IOException e) {
- LOGGER.error(ApplicationConstants.RUN_SCRIPT_EXECUTE_CMD, e);
- }
-
- return null;
- }
-
- @Path("/{functestId}")
- @GET
- @ApiOperation(value = "get function test result by id")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response queryResultByFuncTest(@ApiParam(value = "functestId") @PathParam("functestId") String instanceId) {
- LOGGER.info("query functest result by id." + instanceId);
- // Query VNF Function test result by function test ID
- return VnfFuncTestResponseHandler.getInstance().getResponseByFuncTestId(instanceId);
- }
-
- @Path("/status/{operationId}")
- @GET
- @ApiOperation(value = "get function test result by id")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response getOperationResult(@ApiParam(value = "operationId") @PathParam("operationId") String operationId) {
- LOGGER.info("Query functest status by id." + operationId);
-
- return OperationStatusHandler.getInstance().getOperationStatus(UUID.fromString(operationId));
- }
-
- @Path("/download/{functestId}")
- @GET
- @ApiOperation(value = "get function test result by id")
- @Produces(MediaType.APPLICATION_JSON)
- @ApiResponses(value = {
- @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
- @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
- @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", response = String.class)})
- @Timed
- public Response downloadResults(@ApiParam(value = "functestId") @PathParam("functestId") String funcTestId) {
- LOGGER.info("query functest result by id." + funcTestId);
- return VnfFuncTestResponseHandler.getInstance().downloadResults(funcTestId);
- }
-
- /**
- * Convert the stream to File Name<br/>
- *
- * @param dirName - Directory name
- * @param fileName - FileName
- * @param uploadedInputStream - Input Stream
- * @return - File Path
- * @throws IOException - Exception while writing file
- * @since VNFSDK
- */
- public String storeChunkFileInLocal(String dirName, String fileName, InputStream uploadedInputStream)
- throws IOException {
- File tmpDir = new File(dirName);
- LOGGER.info("tmpdir=" + dirName);
- if(!tmpDir.exists()) {
- tmpDir.mkdirs();
- }
- StringTokenizer st = new StringTokenizer(fileName, "/");
- String actualFile = null;
- while(st.hasMoreTokens()) {
- actualFile = st.nextToken();
- }
- File file = new File(tmpDir + File.separator + actualFile);
- OutputStream os = null;
- try {
- int read = 0;
- byte[] bytes = new byte[1024];
- os = new FileOutputStream(file, true);
- while((read = uploadedInputStream.read(bytes)) != -1) {
- os.write(bytes, 0, read);
- }
- os.flush();
- return file.getAbsolutePath();
- } finally {
- if(os != null) {
- os.close();
- }
- }
- }
-
-}
diff --git a/vnf-sdk-function-test/src/main/resources/migrations.xml b/vnf-sdk-function-test/src/main/resources/migrations.xml
new file mode 100644
index 0000000..9ec5510
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/resources/migrations.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<databaseChangeLog
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
+
+ <changeSet id="1" author="Kailun Qin">
+ <createTable tableName="TaskRecord">
+ <column name="packageID" type="varchar(255)">
+ <constraints primaryKey="true" nullable="false"/>
+ </column>
+ <column name="taskID" type="varchar(255)">
+ <constraints unique="true" foreignKeyName="CaseRecord.taskID" nullable="false"/>
+ </column>
+ <column name="envID" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="uploadID" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="operID" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="funcID" type="varchar(255)">
+ </column>
+ <column name="status" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="operFinished" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="operResult" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="OperResultMessage" type="varchar(255)">
+ </column>
+ </createTable>
+
+ <createTable tableName="CaseRecord">
+ <column name="taskID" type="varchar(255)">
+ <constraints primaryKey="true" nullable="false"/>
+ </column>
+ <column name="funcID" type="varchar(255)">
+ </column>
+ <column name="testID" type="varchar(255)">
+ </column>
+ <column name="testResult" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ <column name="testDescription" type="varchar(255)">
+ <constraints nullable="false"/>
+ </column>
+ </createTable>
+ </changeSet>
+</databaseChangeLog>
diff --git a/vnf-sdk-function-test/src/main/resources/sample.xml b/vnf-sdk-function-test/src/main/resources/sample.xml
new file mode 100644
index 0000000..db1d2f0
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/resources/sample.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<class>
+ <TestResult>
+ <test name="Huawei"></test>
+ <test description="Huawei"></test>
+ <test status="success"></test>
+ </TestResult>
+</class> \ No newline at end of file
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java
index bd46fc7..01e2c0b 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/FileUtilTest.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
+package org.onap.vnfsdk.functest;
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
import java.io.File;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.FileUtil;
+import static org.junit.Assert.assertTrue;
public class FileUtilTest {
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java
new file mode 100644
index 0000000..86dc566
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/TaskExecutionTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+import org.onap.vnfsdk.functest.externalservice.entity.EnvironmentMap;
+
+import java.util.UUID;
+
+public class TaskExecutionTest {
+
+ private TaskExecution testExecution = null;
+ private Environment functestEnv = null;
+
+ private String dirPath = "src\\test\\resources\\RobotScript";
+ private UUID UUIDEnv = UUID.randomUUID();
+ private UUID UUIDUpload = UUID.randomUUID();
+ private UUID uniqueKey = UUID.randomUUID();
+ private String remoteIP = "192.168.4.47";
+ private String userName = "root";
+ private String password = "root123";
+ private String path = "src\\test\\resources";
+ private UUID envId = UUID.randomUUID();
+ private UUID executeId = UUID.randomUUID();
+
+ @Before
+ public void setUp() {
+ testExecution = new TaskExecution();
+ functestEnv = new Environment();
+ }
+
+ @Test
+ public void testExecuteScript() {
+ try {
+ testExecution.executeScript(dirPath, uniqueKey);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testExecuteRobotScript() {
+ new MockUp<EnvironmentMap>() {
+ @Mock
+ public synchronized Environment getEnv(UUID uuid) {
+ functestEnv.setRemoteIp(remoteIP);
+ functestEnv.setUserName(userName);
+ functestEnv.setPassword(password);
+ functestEnv.setPath(path);
+ return functestEnv;
+ }
+ };
+ try {
+ testExecution.executeRobotScript(envId, executeId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testUploadScript() {
+ new MockUp<EnvironmentMap>() {
+ @Mock
+ public synchronized Environment getEnv(UUID uuid) {
+ functestEnv.setRemoteIp(remoteIP);
+ functestEnv.setUserName(userName);
+ functestEnv.setPassword(password);
+ functestEnv.setPath(path);
+ return functestEnv;
+ }
+ };
+ try {
+ testExecution.uploadScript(dirPath, UUIDEnv, UUIDUpload);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java
index b9e2786..b727e35 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppConfigurationTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppConfigurationTest.java
@@ -14,29 +14,25 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
+package org.onap.vnfsdk.functest;
import io.dropwizard.db.DataSourceFactory;
+import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class VnfSdkFuncTestAppConfigurationTest {
-
+
@Test
public void vnfSdkFuncTestBean() {
VnfSdkFuncTestAppConfiguration vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
- vnfSdkBean.setTemplate( "" );
- vnfSdkBean.setMsbServerAddr( "127.0.0.1" );
- vnfSdkBean.setServiceIp( "127.0.0.1" );
- vnfSdkBean.setDataSourceFactory( new DataSourceFactory() );
-
- assertNotNull( vnfSdkBean );
- assertNotNull( vnfSdkBean.getTemplate() );
- assertNotNull( vnfSdkBean .getMsbServerAddr() );
- assertNotNull( vnfSdkBean.getServiceIp() );
- assertNotNull( vnfSdkBean.getDataSourceFactory() );
+ vnfSdkBean.setTemplate("");
+ vnfSdkBean.setServiceIp("127.0.0.1");
+ vnfSdkBean.setDataSourceFactory(new DataSourceFactory());
+
+ assertNotNull(vnfSdkBean);
+ assertNotNull(vnfSdkBean.getTemplate());
+ assertNotNull(vnfSdkBean.getServiceIp());
+ assertNotNull(vnfSdkBean.getDataSourceFactory());
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java
index 883ed61..684f8a3 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/VnfSdkFuncTestAppTest.java
@@ -14,71 +14,47 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functests;
-
-import org.junit.Test;
-
-import org.openo.vnfsdk.functest.VnfSdkFuncTestApp;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.common.ServiceRegistration;
+package org.onap.vnfsdk.functest;
import io.dropwizard.Application;
import io.dropwizard.setup.Environment;
-
-import static org.junit.Assert.assertNotNull;
-
import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.common.Config;
-import java.lang.reflect.Method;
+import static org.junit.Assert.assertNotNull;
public class VnfSdkFuncTestAppTest {
private VnfSdkFuncTestApp vnfSdkFuncTestApp;
private Environment environment;
-
+
private Application<VnfSdkFuncTestAppConfiguration> vnfsdkFuncApp;
-
+
@Before
public void setUp() {
- vnfsdkFuncApp = new VnfSdkFuncTestApp();
+ vnfsdkFuncApp = new VnfSdkFuncTestApp();
}
-
+
@Test
public void RunApp() {
try {
VnfSdkFuncTestAppConfiguration oConfig = new VnfSdkFuncTestAppConfiguration();
- oConfig.setMsbServerAddr("http://127.0.0.1");
Config.setConfigration(oConfig);
- Thread registerExtsysService = new Thread(new ServiceRegistration());
- registerExtsysService.setName("Register vnfsdk-functionTest service to Microservice Bus");
- registerExtsysService.start();
- } catch(Exception e) {
+ } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
- @Test
- public void testGetName() {
- assertNotNull( vnfsdkFuncApp.getName() );
- }
-
+
@Test
- public void tesInitService() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
- try {
- VnfSdkFuncTestApp vnfsdkTest = new VnfSdkFuncTestApp();
- Method method = VnfSdkFuncTestApp.class.getDeclaredMethod( "initService" );
- method.setAccessible(true);
- method.invoke( vnfsdkTest );
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ public void testGetName() {
+ assertNotNull(vnfsdkFuncApp.getName());
}
-
+
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java
index c2a33ab..132fdf8 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/TestConfig.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/common/TestConfig.java
@@ -14,35 +14,31 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.common;
+package org.onap.vnfsdk.functest.common;
+import io.dropwizard.db.DataSourceFactory;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-
-import io.dropwizard.db.DataSourceFactory;
-
-import org.openo.vnfsdk.functest.common.Config;
+import org.onap.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
import static org.junit.Assert.assertNotNull;
public class TestConfig {
-
- private VnfSdkFuncTestAppConfiguration vnfSdkBean;
-
- @Before
- public void setUp() {
- vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
- }
-
- @Test
- public void testVnfSdkConfigBean() {
- vnfSdkBean.setTemplate( "" );
- vnfSdkBean.setMsbServerAddr( "127.0.0.1" );
- vnfSdkBean.setServiceIp( "127.0.0.1" );
- vnfSdkBean.setDataSourceFactory( new DataSourceFactory() );
-
- Config.setConfigration( vnfSdkBean );
- assertNotNull( Config.getConfigration() );
- }
+
+ private VnfSdkFuncTestAppConfiguration vnfSdkBean;
+
+ @Before
+ public void setUp() {
+ vnfSdkBean = new VnfSdkFuncTestAppConfiguration();
+ }
+
+ @Test
+ public void testVnfSdkConfigBean() {
+ vnfSdkBean.setTemplate("");
+ vnfSdkBean.setServiceIp("127.0.0.1");
+ vnfSdkBean.setDataSourceFactory(new DataSourceFactory());
+
+ Config.setConfigration(vnfSdkBean);
+ assertNotNull(Config.getConfigration());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java
new file mode 100644
index 0000000..11e7f07
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrCaseTblDAOTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.db;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+
+import javax.persistence.PersistenceException;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TaskMgrCaseTblDAOTest {
+
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String funcID = "";
+ private String testID = "INTEL";
+ private String testResult = "SUCCESS";
+ private String testDescription = "";
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ }
+
+ @Test
+ public void testSaveOrUpdate() {
+ final CaseRecord caseRecord = daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ assertThat(caseRecord.getTaskID()).isEqualTo("c0a1a373-8635-484d-bc6c-307a606cb8a1");
+ assertThat(caseRecord.getTestID()).isEqualTo("INTEL");
+ assertThat(caseRecord.getTestResult()).isEqualTo("SUCCESS");
+ assertThat(taskMgrCaseTblDAO.findByTaskID(caseRecord.getTaskID()).equals(caseRecord));
+ }
+
+ @Test
+ public void findAll() {
+ daoTestRule.inTransaction(() -> {
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a2";
+ testResult = "NOT FOUND";
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a3";
+ testResult = "FAILURE";
+ taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription));
+ });
+
+ final List<CaseRecord> caseRecordList = taskMgrCaseTblDAO.findAll();
+ assertThat(caseRecordList).extracting("taskID").containsOnly("c0a1a373-8635-484d-bc6c-307a606cb8a1", "c0a1a373-8635-484d-bc6c-307a606cb8a2", "c0a1a373-8635-484d-bc6c-307a606cb8a3");
+ assertThat(caseRecordList).extracting("testResult").containsOnly("SUCCESS", "NOT FOUND", "FAILURE");
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void handlesNullTaskID() {
+ testID = null;
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java
new file mode 100644
index 0000000..e6ff003
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/db/TaskMgrTaskTblDAOTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.db;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+
+import javax.persistence.PersistenceException;
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TaskMgrTaskTblDAOTest {
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .build();
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ }
+
+ @Test
+ public void testSaveOrUpdate() {
+ final TaskRecord taskRecord = daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ assertThat(taskRecord.getTaskID()).isEqualTo("c0a1a373-8635-484d-bc6c-307a606cb8a1");
+ assertThat(taskRecord.getStatus()).isEqualTo("CREATED");
+ assertThat(taskRecord.getOperResult()).isEqualTo("SUCCESS");
+ assertThat(taskMgrTaskTblDAO.findByPackageID(taskRecord.getPackageID())).isEqualTo(Optional.of(taskRecord));
+ assertThat(taskMgrTaskTblDAO.findByTaskID(taskRecord.getTaskID()).get(0).equals(taskRecord));
+ }
+
+ @Test
+ public void findAll() {
+ daoTestRule.inTransaction(() -> {
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ packageID = "1234567891";
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a2";
+ status = "NOT FOUND";
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ packageID = "1234567892";
+ taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a3";
+ status = "DONE";
+ taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage));
+ });
+
+ final List<TaskRecord> taskRecordList = taskMgrTaskTblDAO.findAll();
+ assertThat(taskRecordList).extracting("taskID").containsOnly("c0a1a373-8635-484d-bc6c-307a606cb8a1", "c0a1a373-8635-484d-bc6c-307a606cb8a2", "c0a1a373-8635-484d-bc6c-307a606cb8a3");
+ assertThat(taskRecordList).extracting("status").containsOnly("CREATED", "NOT FOUND", "DONE");
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void handlesNullTaskID() {
+ taskID = null;
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ }
+}
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/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
index 0ca9cc7..887171b 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/onap/vnfsdk/functest/externalservice/entity/EnvironmentMapTest.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
import java.util.UUID;
-import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
public class EnvironmentMapTest {
@@ -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/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
index 2dcb7a3..61ae077 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/onap/vnfsdk/functest/externalservice/entity/EnvironmentTest.java
@@ -14,31 +14,32 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.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;
-
- @Before
- public void setUp() {
- environment = new Environment();
- }
-
- @Test
- public void testEnvironment() {
- environment.setRemoteIp( "192.168.4.47" );
- environment.setUserName( "root" );
- environment.setPassword( "root123" );
- environment.setPath( "src\\test\\resources" );
-
- assertNotNull( environment );
- assertNotNull( environment.getRemoteIp() );
- assertNotNull( environment.getUserName() );
- assertNotNull( environment.getPassword() );
- assertNotNull( environment.getPath() );
- }
+ private Environment environment = null;
+
+ @Before
+ public void setUp() {
+ environment = new Environment();
+ }
+
+ @Test
+ public void testEnvironment() {
+ environment.setRemoteIp("192.168.4.47");
+ environment.setUserName("root");
+ environment.setPassword("root123");
+ 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/OPerationStatusHandlerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
index 5c19d7a..bbfc3db 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/externalservice/entity/OPerationStatusHandlerTest.java
@@ -14,19 +14,18 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import javax.ws.rs.core.Response;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
public class OPerationStatusHandlerTest {
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/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
index 5696269..37b8d2a 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/onap/vnfsdk/functest/externalservice/entity/OperationStatusTest.java
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
+
import static org.junit.Assert.assertNotNull;
@@ -33,15 +34,15 @@ public class OperationStatusTest {
@Test
public void testOperationStatus() {
- operationStatus.setoResultCode(operResultCode.SUCCESS);
- operationStatus.setOperResultMessage("success");
- operationStatus.setOperFinished(true);
-
- assertNotNull( operationStatus );
- assertNotNull( operationStatus.getoResultCode() );
- assertNotNull( operationStatus.getoResultCode() );
- assertNotNull( operationStatus.isOperFinished() );
-
- }
-
+ 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/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
index 9ebf220..24e780f 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/onap/vnfsdk/functest/externalservice/entity/ServiceNodeTest.java
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.vnfsdk.functest.externalservice.entity;
import org.junit.Before;
import org.junit.Test;
+
import static org.junit.Assert.assertNotNull;
public class ServiceNodeTest {
@@ -28,16 +29,16 @@ public class ServiceNodeTest {
public void setUp() {
serviceNode = new ServiceNode();
}
-
+
@Test
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() );
- }
+ 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/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
index dfaf7ae..493882f 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/onap/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.externalservice.entity;
+package org.onap.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;
+import static org.junit.Assert.assertNotNull;
+
public class ServiceRegisterEntityTest {
private ServiceRegisterEntity serviceRegistry;
@@ -35,33 +36,33 @@ public class ServiceRegisterEntityTest {
}
@Test
- 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 );
- }
+ 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/onap/vnfsdk/functest/models/CaseRecordTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java
new file mode 100644
index 0000000..49535df
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/CaseRecordTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.models;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public class CaseRecordTest {
+
+ private CaseRecord caseRecord = null;
+
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String funcID = "";
+ private String testID = "INTEL";
+ private String testResult = "SUCCESS";
+ private String testDescription = "";
+
+ @Before
+ public void setUp() {
+ caseRecord = new CaseRecord();
+ }
+
+ @Test
+ public void testCaseRecord() {
+ caseRecord.setTaskID(taskID);
+ caseRecord.setFuncID(funcID);
+ caseRecord.setTestID(testID);
+ caseRecord.setTestResult(testResult);
+ caseRecord.setTestDescription(testDescription);
+
+ assertNotNull(caseRecord);
+ assertNotNull(caseRecord.getTestID());
+ assertThat(caseRecord.getTestID(), is("INTEL"));
+ assertNotNull(caseRecord.getTestResult(), is("SUCCESS"));
+ assertNotNull(caseRecord.getTestDescription(), is(""));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java
new file mode 100644
index 0000000..f51a6b5
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/models/TaskRecordTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.models;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public class TaskRecordTest {
+
+ private TaskRecord taskRecord = null;
+
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+
+ @Before
+ public void setUp() {
+ taskRecord = new TaskRecord();
+ }
+
+ @Test
+ public void testTaskRecord() {
+ taskRecord.setPackageID(packageID);
+ taskRecord.setTaskID(taskID);
+ taskRecord.setEnvID(envID);
+ taskRecord.setUploadID(uploadID);
+ taskRecord.setOperID(operID);
+ taskRecord.setFuncID(funcID);
+ taskRecord.setStatus(status);
+ taskRecord.setOperFinished(operFinished);
+ taskRecord.setOperResult(operResult);
+ taskRecord.setOperResultMessage(operResultMessage);
+
+ assertNotNull(taskRecord);
+ assertNotNull(taskRecord.getPackageID());
+ assertThat(taskRecord.getTaskID(), is("c0a1a373-8635-484d-bc6c-307a606cb8a1"));
+ assertNotNull(taskRecord.getOperFinished(), is("True"));
+ assertNotNull(taskRecord.getOperResult(), is("SUCCESS"));
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java
new file mode 100644
index 0000000..e70be84
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultMapTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.responsehandler;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.junit.Assert.assertNotNull;
+
+public class TestResultMapTest {
+
+ private UUID uuid = UUID.randomUUID();
+
+ private Map<UUID, TestResult> testResultMap = new HashMap<UUID, TestResult>();
+
+ @Test
+ public void testGetInstance() {
+ assertNotNull(TestResultMap.getInstance());
+ }
+
+ @Test
+ public void testGetTestResultMap() {
+ assertNotNull(TestResultMap.getInstance().getTestResultMap());
+ }
+
+ @Test
+ public void testSetTestResultMap() {
+ TestResult testResult = new TestResult();
+ testResult.setName("INTEL");
+ testResult.setStatus("SUCCESS");
+ testResult.setDescription("INTEL TEST");
+ testResultMap.put(uuid, testResult);
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java
index d0be770..2357346 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultParserTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultParserTest.java
@@ -14,19 +14,22 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
-import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.Test;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.TestResultParser;
+import static org.junit.Assert.assertNotNull;
public class TestResultParserTest {
private TestResultParser testResParser = null;
+ private UUID UUIDTask = UUID.randomUUID();
@Before
public void setUp() {
@@ -35,19 +38,22 @@ public class TestResultParserTest {
@Test
public void testPopulateResultList() {
- assertNotNull(testResParser.populateResultList("src/test/resources/sample.xml"));
- }
-
+ assertNotNull(testResParser.populateResultList(UUIDTask.toString(), "src/test/resources/sample.xml"));
+ }
+
@Test
public void testParseResultData() {
- try {
- Class<?> resParser = Class.forName( "TestResultParser" );
- Object serviceRegObj = resParser.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "threadSleep",new Class[]{String.class});
- m.setAccessible( true );
- m.invoke( serviceRegObj,100 );
- } catch( Exception e ) {
- e.printStackTrace();
- }
+ String taskID = "12919afc-5975-4da9-bd41-c050b305262c";
+ String xmlFile = "src/test/resources/sample.xml";
+ List<TestResult> resultData = new ArrayList<>();
+ try {
+ Class<?> resParser = Class.forName("org.onap.vnfsdk.functest.responsehandler.TestResultParser");
+ Object resParserObj = resParser.newInstance();
+ Method m = resParserObj.getClass().getDeclaredMethod("parseResultData", new Class[]{String.class, String.class, List.class});
+ m.setAccessible(true);
+ m.invoke(resParserObj, taskID, xmlFile, resultData);
+ } 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/onap/vnfsdk/functest/responsehandler/TestResultTest.java
index 56756d6..d5bd6b0 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/TestResultTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/TestResultTest.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
import org.junit.Before;
import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.TestResult;
import static org.junit.Assert.assertNotNull;
@@ -30,16 +29,16 @@ public class TestResultTest {
public void setUp() {
testResult = new TestResult();
}
-
+
@Test
public void testResultTest() {
- testResult.setName("Huawei");
- testResult.setDescription("description");
- testResult.setStatus("success");
-
- assertNotNull( testResult );
- assertNotNull( testResult.getName() );
- assertNotNull( testResult.getStatus() );
- assertNotNull( testResult.getDescription() );
- }
+ testResult.setName("Huawei");
+ testResult.setDescription("description");
+ testResult.setStatus("success");
+
+ assertNotNull(testResult);
+ assertNotNull(testResult.getName());
+ assertNotNull(testResult.getStatus());
+ assertNotNull(testResult.getDescription());
+ }
}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java
index 4b0bbf3..26007e3 100644
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/responsehandler/VnfFuncTestResponseHandlerTest.java
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/responsehandler/VnfFuncTestResponseHandlerTest.java
@@ -14,34 +14,33 @@
* limitations under the License.
*/
-package org.openo.vnfsdkfunctest.responsehandler;
+package org.onap.vnfsdk.functest.responsehandler;
import org.junit.Test;
-import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
-
-import static org.junit.Assert.assertNotNull;
import java.lang.reflect.Method;
+import static org.junit.Assert.assertNotNull;
+
public class VnfFuncTestResponseHandlerTest {
-
- private VnfFuncTestResponseHandler vnfSdkFuncHandler;
-
- @Test
- public void testGetInstance() {
- vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance();
- assertNotNull( vnfSdkFuncHandler );
- }
-
- @Test
- public void testLoadConfigurations() {
- try {
- Class<?> vnfsdkResHandler = Class.forName( "VnfFuncTestResponseHandler" );
- Object serviceRegObj = vnfsdkResHandler.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "loadConfigurations" );
- m.setAccessible( true );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
+
+ private VnfFuncTestResponseHandler vnfSdkFuncHandler;
+
+ @Test
+ public void testGetInstance() {
+ vnfSdkFuncHandler = VnfFuncTestResponseHandler.getInstance();
+ assertNotNull(vnfSdkFuncHandler);
+ }
+
+ @Test
+ public void testLoadConfigurations() {
+ try {
+ Object vnfFuncTestResponseHandlerObj = VnfFuncTestResponseHandler.getInstance();
+ Method m = vnfFuncTestResponseHandlerObj.getClass().getDeclaredMethod("loadConfigurations");
+ m.setAccessible(true);
+ m.invoke(vnfFuncTestResponseHandlerObj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
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/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java
index 32a03f5..cf77560 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/onap/vnfsdk/functest/scriptmgr/ScriptManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,86 +14,56 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.resource;
+package org.onap.vnfsdk.functest.scriptmgr;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import io.dropwizard.testing.junit.DAOTestRule;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.FileUtil;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+import org.onap.vnfsdk.functest.util.ZipCompressor;
+import javax.ws.rs.core.Response;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
import java.util.UUID;
-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.externalservice.entity.OperationStatus;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatus.operResultCode;
-import org.openo.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
-import org.openo.vnfsdk.functest.responsehandler.VnfFuncTestResponseHandler;
-import org.openo.vnfsdk.functest.util.RestResponseUtil;
-import org.openo.vnfsdk.functest.util.ZipCompressor;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class CommonManagerTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
- private CommonManager commonManger;
+public class ScriptManagerTest {
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private ScriptManager scriptManager;
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
private String instanceId;
-
- private String funcTestId = "59d1e651-df9f-4008-902f-e3b377e6ec30";
-
+ private UUID taskID = UUID.fromString("59d1e651-df9f-4008-902f-e3b377e6ec30");
+ private UUID envID = UUID.fromString("f5881897-c748-4f6e-9294-92c730faa001");
+ private UUID operID = UUID.fromString("ed058d84-4a42-4c8e-8ecf-90de4c5a8bc8");
private Response response = null;
@Before
public void setUp() {
- commonManger = new CommonManager();
- }
-
- @Test
- public void testexecuteFunc() throws FileNotFoundException {
-
- URL url = Thread.currentThread().getContextClassLoader().getResource("RobotScript");
- String zipFileName = url.getPath() + ".zip";
- try {
- new ZipCompressor(zipFileName).compress(url.getPath());
- } catch(IOException e) {
-
- }
-
- InputStream mockInputStream = new FileInputStream(zipFileName);
- Response response = commonManger.executeFuncTest(mockInputStream);
- instanceId = response.getEntity().toString();
- assertNotNull(instanceId);
- }
-
- @Test
- public void testQueryResultWhenInstanceIdPresent() {
-
- Map<String, String> mapConfigValues = new HashMap<String, String>();
- String resultFolder = "59d1e651-df9f-4008-902f-e3b377e6ec30";
- URL url = Thread.currentThread().getContextClassLoader().getResource(resultFolder);
- File file = new File(url.getPath());
- File parentFile = file.getParentFile();
- mapConfigValues.put("DIR_RESULT", parentFile.getAbsolutePath());
- VnfFuncTestResponseHandler.getInstance().setConfigMap(mapConfigValues);
- Response response = commonManger.queryResultByFuncTest(resultFolder);
- assertNotNull(response);
- }
-
- @Test
- public void testQueryResultWhenInstanceIdAbsent() {
- Response response = commonManger.queryResultByFuncTest(funcTestId);
- assertNotNull(response);
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ scriptManager = new ScriptManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO);
}
@Test
@@ -113,10 +83,9 @@ public class CommonManagerTest {
try {
// InputStream mockInputStream = new FileInputStream(zipFileName);
- response = commonManger.uploadFuncTestPackage(funcTestId, zipFileName);
- assertNotNull(response);
- assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ UUID uploadID = scriptManager.uploadFuncTestPackage(taskID, envID, zipFileName);
+ assertNotNull(uploadID);
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -124,35 +93,35 @@ public class CommonManagerTest {
@Test
public void testGetOperationResult() {
try {
- response = commonManger.getOperationResult(funcTestId);
+ response = scriptManager.getOperationResult(operID);
assertNotNull(response);
assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testDownloadResults() {
- new MockUp<OperationStatusHandler>() {
+ MockUp<OperationStatusHandler> mockOperationStatusHandler = new MockUp<OperationStatusHandler>() {
@Mock
public Response getOperationStatus(UUID uuid) {
OperationStatus operstatus = new OperationStatus();
operstatus.setOperFinished(true);
- operstatus.setoResultCode(operResultCode.SUCCESS);
+ operstatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
operstatus.setOperResultMessage("finished");
return response;
}
};
- new MockUp<VnfFuncTestResponseHandler>() {
+ MockUp<VnfFuncTestResponseHandler> mockVnfFuncTestResponseHandler = new MockUp<VnfFuncTestResponseHandler>() {
@Mock
- public Response downloadResults(String funcTestId) {
+ public Response downloadResults(String taskID) {
OperationStatus operstatus = new OperationStatus();
operstatus.setOperFinished(true);
- operstatus.setoResultCode(operResultCode.SUCCESS);
+ operstatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
operstatus.setOperResultMessage("finished");
return RestResponseUtil.getSuccessResponse(operstatus);
@@ -160,12 +129,15 @@ public class CommonManagerTest {
};
try {
- response = commonManger.downloadResults(funcTestId);
+ response = scriptManager.downloadResults(taskID);
assertNotNull(response);
assertEquals(200, response.getStatus());
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
+
+ mockOperationStatusHandler.tearDown();
+ mockVnfFuncTestResponseHandler.tearDown();
}
@Test
@@ -174,11 +146,12 @@ public class CommonManagerTest {
String zipFileName = url.getPath() + ".zip";
try {
+ new ZipCompressor(zipFileName).compress(url.getPath());
InputStream mockInputStream = new FileInputStream(zipFileName);
String chunkFilePath =
- commonManger.storeChunkFileInLocal("src/test/resources", "chunkFileInLocal", mockInputStream);
+ scriptManager.storeChunkFileInLocal("src/test/resources", "chunkFileInLocal", mockInputStream);
assertNotNull(chunkFilePath);
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -189,10 +162,10 @@ public class CommonManagerTest {
String jsonInput =
"{\"remoteIp\":\"192.168.4.47\",\"userName\":\"root\",\"password\":\"root123\", \"path\":\"/src/test/resources\"}";
- response = commonManger.setEnvironment(jsonInput);
- commonManger.executeFunctionTest(funcTestId, response.getEntity().toString(), "robot");
- assertNotNull(response);
- } catch(Exception e) {
+ envID = scriptManager.setEnvironment(jsonInput);
+// scriptManager.executeFunctionTest(taskID.toString(), response.getEntity().toString(), "robot");
+ assertNotNull(envID);
+ } catch (Exception e) {
e.printStackTrace();
}
}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java
new file mode 100644
index 0000000..921a8e0
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/taskmgr/TaskManagerTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2018 Intel Corporation Intellectual Property
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.taskmgr;
+
+import io.dropwizard.testing.junit.DAOTestRule;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.db.TaskMgrCaseTblDAO;
+import org.onap.vnfsdk.functest.db.TaskMgrTaskTblDAO;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatus;
+import org.onap.vnfsdk.functest.externalservice.entity.OperationStatusHandler;
+import org.onap.vnfsdk.functest.models.CaseRecord;
+import org.onap.vnfsdk.functest.models.TaskRecord;
+import org.onap.vnfsdk.functest.scriptmgr.ScriptManager;
+import org.onap.vnfsdk.functest.util.RestResponseUtil;
+
+import javax.ws.rs.core.Response;
+import java.lang.reflect.Method;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TaskManagerTest {
+
+ @Rule
+ public DAOTestRule daoTestRule = DAOTestRule.newBuilder()
+ .addEntityClass(TaskRecord.class)
+ .addEntityClass(CaseRecord.class)
+ .build();
+ private TaskManager taskManager;
+ private ScriptManager scriptManager;
+ private TaskMgrTaskTblDAO taskMgrTaskTblDAO;
+ private TaskMgrCaseTblDAO taskMgrCaseTblDAO;
+ private Response response = null;
+ private TaskManager.RequestBody requestBody;
+ private String packageID = "1234567890";
+ private String taskID = "c0a1a373-8635-484d-bc6c-307a606cb8a1";
+ private String envID = "0034b3f3-caea-4138-b186-e260a0cc509c";
+ private String uploadID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String operID = "3dbf7978-0e5d-4fa8-ade7-bf6450b54a9b";
+ private String funcID = "";
+ private String status = "CREATED";
+ private String operFinished = "True";
+ private String operResult = "SUCCESS";
+ private String operResultMessage = "";
+ private String testID = "NOT CREATED";
+ private String testResult = "NULL";
+ private String testDescription = "";
+
+ @Before
+ public void setUp() throws Exception {
+ taskMgrTaskTblDAO = new TaskMgrTaskTblDAO(daoTestRule.getSessionFactory());
+ taskMgrCaseTblDAO = new TaskMgrCaseTblDAO(daoTestRule.getSessionFactory());
+ scriptManager = new ScriptManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO);
+ taskManager = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ requestBody = new TaskManager.RequestBody();
+ requestBody.setPackageID("1234567890");
+ }
+
+ @Test
+ public void testStartOnboardTestingPackageIDAbsentInDB() {
+ new MockUp<ScriptManager>() {
+ @Mock
+ public UUID uploadFuncTestPackage(UUID taskID, UUID envID, String url) {
+ return UUID.randomUUID();
+ }
+ };
+
+ try {
+ response = taskManager.startOnboardTesting(requestBody);
+ assertNotNull(response);
+ assertEquals(201, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStartOnboardTestingPackageIDAlreadyPresentInDB() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ response = taskManager.startOnboardTesting(requestBody);
+ assertNotNull(response);
+ assertEquals(500, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusPresentInDB() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusPresentInOperationStatus() {
+ try {
+ daoTestRule.inTransaction(() -> taskMgrTaskTblDAO.saveOrUpdate(new TaskRecord(packageID, taskID, envID, uploadID, operID, funcID, status, operFinished, operResult, operResultMessage)));
+ UUID operID = UUID.fromString(taskMgrTaskTblDAO.findByTaskID(taskID).get(0).getOperID());
+ OperationStatus operStatus = new OperationStatus();
+ operStatus.setoResultCode(OperationStatus.operResultCode.SUCCESS);
+ operStatus.setOperResultMessage("Execute function test finished");
+ operStatus.setOperFinished(true);
+ OperationStatusHandler.getInstance().setOperStatusMap(operID, operStatus);
+
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testQueryTestStatusAbsent() {
+ try {
+ response = taskManager.queryTestStatus(taskID);
+ assertNotNull(response);
+ assertEquals(404, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultCreated() {
+ try {
+ testID = "INTEL";
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultUncreated() {
+ new MockUp<ScriptManager>() {
+ @Mock
+ public Response downloadResults(UUID taskID) {
+ return RestResponseUtil.getSuccessResponse(null);
+ }
+ };
+ try {
+ daoTestRule.inTransaction(() -> taskMgrCaseTblDAO.saveOrUpdate(new CaseRecord(taskID, funcID, testID, testResult, testDescription)));
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testCollectTaskResultAbsent() {
+ try {
+ response = taskManager.collectTaskResult(taskID);
+ assertNotNull(response);
+ assertEquals(404, response.getStatus());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testInitOnboardTesting() {
+ TaskRecord taskRecord = new TaskRecord();
+ CaseRecord caseRecord = new CaseRecord();
+
+ try {
+ TaskManager taskManagerObj = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ Method m = taskManagerObj.getClass().getDeclaredMethod("initOnboardTesting", new Class[]{TaskRecord.class, CaseRecord.class, String.class});
+ m.setAccessible(true);
+ m.invoke(taskManagerObj, taskRecord, caseRecord, packageID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadEnvConfigurations() {
+ try {
+ TaskManager loadEnvConfigurationsObj = new TaskManager(taskMgrTaskTblDAO, taskMgrCaseTblDAO, scriptManager);
+ Method m = loadEnvConfigurationsObj.getClass().getDeclaredMethod("loadEnvConfigurations");
+ m.setAccessible(true);
+ m.invoke(loadEnvConfigurationsObj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java
new file mode 100644
index 0000000..fcb47dc
--- /dev/null
+++ b/vnf-sdk-function-test/src/test/java/org/onap/vnfsdk/functest/util/RestResponseUtilTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vnfsdk.functest.util;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class RestResponseUtilTest {
+
+ private Response response;
+ private Object envObj;
+
+ @Before
+ public void setUp() {
+ envObj = new Environment();
+ ((Environment) envObj).setRemoteIp("192.168.4.47");
+ ((Environment) envObj).setUserName("root");
+ ((Environment) envObj).setPassword("root123");
+ ((Environment) envObj).setPath("src\\test\\resources");
+ }
+
+
+ @Test
+ public void testGetSuccessResponse() {
+ response = RestResponseUtil.getSuccessResponse(envObj);
+ assertNotNull(response);
+ assertEquals(200, response.getStatus());
+ }
+
+ @Test
+ public void testGetCreateSussceeResponse() {
+ response = RestResponseUtil.getCreateSuccessResponse(envObj);
+ assertNotNull(response);
+ assertEquals(201, response.getStatus());
+ }
+
+ @Test
+ public void testGetErrorResponse() {
+ response = RestResponseUtil.getErrorResponse(envObj);
+ assertEquals(500, response.getStatus());
+ }
+
+ @Test
+ public void testGetNotFoundResponse() {
+ response = RestResponseUtil.getNotFoundResponse(envObj);
+ assertEquals(404, response.getStatus());
+ }
+}
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/onap/vnfsdk/functest/util/TestGsonUtil.java
index a8ada98..04687ca 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/onap/vnfsdk/functest/util/TestGsonUtil.java
@@ -14,14 +14,13 @@
* limitations under the License.
*/
-package org.openo.vnfsdk.functest.util;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+package org.onap.vnfsdk.functest.util;
import org.junit.Test;
+import org.onap.vnfsdk.functest.externalservice.entity.Environment;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
public class TestGsonUtil {
@@ -39,19 +38,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();
- }
+ 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/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java
deleted file mode 100644
index 8250700..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.externalservice.msb;
-
-import javax.ws.rs.ProcessingException;
-
-import org.junit.Test;
-import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration;
-import org.openo.vnfsdk.functest.common.Config;
-import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity;
-
-public class MicroserviceBusConsumerTest {
-
- @Test
- public void testRegisterService() {
-
- try {
- ServiceRegisterEntity entity = new ServiceRegisterEntity();
- VnfSdkFuncTestAppConfiguration oConfig = new VnfSdkFuncTestAppConfiguration();
- oConfig.setMsbServerAddr("http://127.0.0.1");
- Config.setConfigration(oConfig);
-
- MicroserviceBusConsumer.registerService(entity);
- } catch(ProcessingException e) {
- // Connect to MSB will fail, Connect refused is OK
- }
- }
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java
deleted file mode 100644
index b20b10a..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/RestResponseUtilTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functest.util;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.core.Response;
-
-public class RestResponseUtilTest {
-
- private Response response;
- private Object envObj;
-
- @Before
- public void setUp() {
- envObj = new Environment();
- ( ( Environment ) envObj ).setRemoteIp( "192.168.4.47" );
- ( ( Environment ) envObj ).setUserName( "root" );
- ( ( Environment ) envObj ).setPassword( "root123" );
- ( ( Environment ) envObj ).setPath( "src\\test\\resources" );
- }
-
-
- @Test
- public void testGetSuccessResponse() {
- response = RestResponseUtil.getSuccessResponse( envObj ) ;
- assertNotNull( response );
- assertEquals( 200, response.getStatus() );
- }
-
- @Test
- public void testGetCreateSussceeResponse() {
- response = RestResponseUtil.getCreateSussceeResponse( envObj );
- assertNotNull( response );
- assertEquals( 201, response.getStatus() );
- }
-
- @Test
- public void testGetErrorResponse() {
- response = RestResponseUtil.getErrorResponse(envObj );
- assertEquals( 500, response.getStatus() );
- }
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java
deleted file mode 100644
index 27d86bf..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/TaskExecutionTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdk.functests;
-
-import java.util.UUID;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.openo.vnfsdk.functest.TaskExecution;
-import org.openo.vnfsdk.functest.externalservice.entity.Environment;
-
-import org.openo.vnfsdk.functest.externalservice.entity.EnvironmentMap;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class TaskExecutionTest {
-
- private TaskExecution testExecution = null;
- private Environment functestEnv = null;
-
- private String dirPath = "src\\test\\resources\\RobotScript";
- private UUID UUIDEnv = UUID.randomUUID();
- private UUID UUIDUpload = UUID.randomUUID();
- private UUID uniqueKey = UUID.randomUUID();
- private String remoteIP = "192.168.4.47";
- private String userName = "root";
- private String password = "root123";
- private String path = "src\\test\\resources";
- private UUID envId = UUID.randomUUID();
- private UUID executeId = UUID.randomUUID();
-
- @Before
- public void setUp() {
- testExecution = new TaskExecution();
- functestEnv = new Environment();
- }
-
- @Test
- public void testExecuteScript() {
- try {
- testExecution.executeScript( dirPath, uniqueKey );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExecuteRobotScript() {
- new MockUp<EnvironmentMap>() {
- @Mock
- public synchronized Environment getEnv( UUID uuid ) {
- functestEnv.setRemoteIp( remoteIP );
- functestEnv.setUserName( userName );
- functestEnv.setPassword( password );
- functestEnv.setPath( path );
- return functestEnv;
- }
- };
- try {
- testExecution.executeRobotScript(envId, executeId );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testUploadScript() {
- new MockUp<EnvironmentMap>() {
- @Mock
- public synchronized Environment getEnv( UUID uuid ) {
- functestEnv.setRemoteIp( remoteIP );
- functestEnv.setUserName( userName );
- functestEnv.setPassword( password );
- functestEnv.setPath( path );
- return functestEnv;
- }
- };
- try {
- testExecution.uploadScript( dirPath, UUIDEnv, UUIDUpload );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
-
-}
diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java
deleted file mode 100644
index fd4906d..0000000
--- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdkfunctest/common/ServiceRegistrationTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.vnfsdkfunctest.common;
-
-import org.junit.Test;
-
-import java.lang.reflect.Method;
-
-public class ServiceRegistrationTest {
- @Test
- public void testThreadSleep() {
- try {
- Class<?> serviceReg = Class.forName( "ServiceRegistration" );
- Object serviceRegObj = serviceReg.newInstance();
- Method m=( ( Class<?> ) serviceRegObj ).getDeclaredMethod( "threadSleep",new Class[]{String.class});
- m.setAccessible( true );
- m.invoke( serviceRegObj,100 );
- } catch( Exception e ) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/vnf-sdk-function-test/src/test/resources/sample.xml b/vnf-sdk-function-test/src/test/resources/sample.xml
index 2492e9c..db1d2f0 100644
--- a/vnf-sdk-function-test/src/test/resources/sample.xml
+++ b/vnf-sdk-function-test/src/test/resources/sample.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<class>
- <TestResult>
- <name>Huawei</name>
- <description>Huawei</description>
- <status>success</status>
- </TestResult>
+ <TestResult>
+ <test name="Huawei"></test>
+ <test description="Huawei"></test>
+ <test status="success"></test>
+ </TestResult>
</class> \ No newline at end of file