summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMurali-P <murali.p@huawei.com>2017-01-30 20:25:40 +0530
committerMurali-P <murali.p@huawei.com>2017-01-31 10:30:07 +0530
commit3075304c7f0a4814e2de297fb6ca54e48ffe7b91 (patch)
treeece70a3fd823d98d68c5142b7e85da8d4d07f803
parentf4a9f582e9dc1fb064e650f8934e8a402749d6bb (diff)
VNF SDK Function test init Code
Resolved:VNFSDK-21 Function test base code Change-Id: Ib8070d0549acdea4775bd325c5a282d5e2a708e0 Signed-off-by: Murali-P <murali.p@huawei.com>
-rw-r--r--.gitignore6
-rw-r--r--distribution/.gitignore6
-rw-r--r--distribution/pom.xml25
-rw-r--r--distribution/standalone/.gitignore6
-rw-r--r--distribution/standalone/pom.xml160
-rw-r--r--distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml61
-rw-r--r--distribution/standalone/src/main/assembly/find_kill_process.bat9
-rw-r--r--distribution/standalone/src/main/assembly/run.bat25
-rw-r--r--distribution/standalone/src/main/assembly/run.sh19
-rw-r--r--distribution/standalone/src/main/assembly/stop.bat19
-rw-r--r--distribution/standalone/src/main/assembly/stop.sh28
-rw-r--r--pom.xml22
-rw-r--r--vnf-sdk-function-test/.gitignore6
-rw-r--r--vnf-sdk-function-test/pom.xml214
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java89
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java96
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/Config.java32
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java72
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestException.java51
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java60
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java105
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java44
-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.java74
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/GsonUtil.java56
-rw-r--r--vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java44
26 files changed, 1366 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..67a2e60
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+target/
+.project
+.settings
+.classpath
+.class
+.checkstyle
diff --git a/distribution/.gitignore b/distribution/.gitignore
new file mode 100644
index 0000000..67a2e60
--- /dev/null
+++ b/distribution/.gitignore
@@ -0,0 +1,6 @@
+target/
+.project
+.settings
+.classpath
+.class
+.checkstyle
diff --git a/distribution/pom.xml b/distribution/pom.xml
new file mode 100644
index 0000000..590fdb1
--- /dev/null
+++ b/distribution/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+
+<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>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnfsdk-functest-core-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>distribution</artifactId>
+ <name>vnfsdk-functest-distribution</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>standalone</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnf-sdk-function-test</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/distribution/standalone/.gitignore b/distribution/standalone/.gitignore
new file mode 100644
index 0000000..67a2e60
--- /dev/null
+++ b/distribution/standalone/.gitignore
@@ -0,0 +1,6 @@
+target/
+.project
+.settings
+.classpath
+.class
+.checkstyle
diff --git a/distribution/standalone/pom.xml b/distribution/standalone/pom.xml
new file mode 100644
index 0000000..eff47f6
--- /dev/null
+++ b/distribution/standalone/pom.xml
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<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>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>distribution</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>standalone</artifactId>
+ <name>vnfsdk-functest-distribution-standalone</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <packagename>openo-vnfsdk-functest</packagename>
+ <linux64id>linux64</linux64id>
+ <win64id>win64</win64id>
+ <linux64outputdir>target/assembly/${linux64id}</linux64outputdir>
+ <win64outputdir>target/assembly/${win64id}</win64outputdir>
+ <version.output>target/version</version.output>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources-${linux64id}</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${linux64outputdir}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/assembly/</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.bat</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <overwrite>true</overwrite>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-resources-${win64id}</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${win64outputdir}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/assembly/</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.sh</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <overwrite>true</overwrite>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-jar-${linux64id}</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnf-sdk-function-test</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${linux64outputdir}</outputDirectory>
+ <destFileName>vnf-sdk-function-test</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-jar-${win64id}</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnf-sdk-function-test</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${win64outputdir}</outputDirectory>
+ <destFileName>vnf-sdk-function-test</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>distribution</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="distribution">
+ <tar destfile="${version.output}/${packagename}-${project.version}-linux64.tar.gz" longfile="posix" compression="gzip">
+ <tarfileset dir="target/assembly/linux64" filemode="0644" dirmode="0755">
+ <exclude name="**/*.sh"/>
+ </tarfileset>
+ <tarfileset dir="target/assembly/linux64" filemode="0755" dirmode="0755">
+ <include name="**/*.sh"/>
+ </tarfileset>
+ </tar>
+ <attachartifact file="${version.output}/${packagename}-${project.version}-linux64.tar.gz" classifier="linux64" type="tar.gz"/>
+ <zip destfile="${version.output}/${packagename}-${project.version}-win64.zip" update="true">
+ <zipfileset dir="target/assembly/win64" includes="**"/>
+ </zip>
+ <attachartifact file="${version.output}/${packagename}-${project.version}-win64.zip" classifier="win64" type="zip"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnf-sdk-function-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml b/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml
new file mode 100644
index 0000000..e4e00d0
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/conf/vnfsdkfunctest.yml
@@ -0,0 +1,61 @@
+
+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
+
+ # the username
+ user: functest
+
+ # the password
+ password: functest
+
+ # the JDBC URL
+ url: jdbc:mysql://127.0.0.1:3306/functest
+
+# use the simple server factory if you only want to run on a single port
+#server:
+# type: simple
+# connector:
+# type: http
+# port: 8080
+server:
+ type: simple
+ rootPath: '/openoapi/vnfsdk/v1/*'
+ applicationContextPath: /
+ adminContextPath: /admin
+ connector:
+ type: http
+ port: 8100
+
+# Logging settings.
+logging:
+
+ # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
+ level: ALL
+
+ # Logger-specific levels.
+ loggers:
+
+ # Sets the level for 'com.example.app' to DEBUG.
+ org.openo.vnfsdk.functest.VnfSdkFunTestApp: INFO
+
+ appenders:
+ - type: console
+ threshold: INFO
+ timeZone: UTC
+ logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"
+ - type: file
+ threshold: INFO
+ logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n"
+ currentLogFilename: ./works/logs/vnfsdk.log
+ archivedLogFilenamePattern: ./works/logs/zip/vnfsdk-%d{yyyy-MM-dd}.log.gz
+ archivedFileCount: 7
+ timeZone: UTC
+
diff --git a/distribution/standalone/src/main/assembly/find_kill_process.bat b/distribution/standalone/src/main/assembly/find_kill_process.bat
new file mode 100644
index 0000000..4a4baaf
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/find_kill_process.bat
@@ -0,0 +1,9 @@
+
+echo %1 | findstr %2 >NUL
+echo ERRORLEVEL=%ERRORLEVEL%
+IF ERRORLEVEL 1 goto findend
+for /f "tokens=1" %%a in (%1) do (
+ echo kill %1
+ taskkill /F /pid %%a
+)
+:findend \ No newline at end of file
diff --git a/distribution/standalone/src/main/assembly/run.bat b/distribution/standalone/src/main/assembly/run.bat
new file mode 100644
index 0000000..3ce5172
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/run.bat
@@ -0,0 +1,25 @@
+
+@echo off
+title vnfsdk-functest
+
+set RUNHOME=%~dp0
+echo ### RUNHOME: %RUNHOME%
+echo ### Starting vnfsdk-functest
+
+set JAVA="%JAVA_HOME%\bin\java.exe"
+set port=8312
+set jvm_opts=-Xms50m -Xmx128m
+rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n
+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
+
+IF ERRORLEVEL 1 goto showerror
+exit
+:showerror
+echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
+echo After checking, press any key to close
+pause
+exit \ No newline at end of file
diff --git a/distribution/standalone/src/main/assembly/run.sh b/distribution/standalone/src/main/assembly/run.sh
new file mode 100644
index 0000000..b20c252
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/run.sh
@@ -0,0 +1,19 @@
+
+DIRNAME=`dirname $0`
+RUNHOME=`cd $DIRNAME/; pwd`
+echo @RUNHOME@ $RUNHOME
+
+echo @JAVA_HOME@ $JAVA_HOME
+JAVA="$JAVA_HOME/bin/java"
+echo @JAVA@ $JAVA
+
+JAVA_OPTS="-Xms50m -Xmx128m"
+port=8312
+#JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n"
+echo @JAVA_OPTS@ $JAVA_OPTS
+
+class_path="$RUNHOME/:$RUNHOME/org.openo.vnfsdk.functest.jar"
+echo @class_path@ $class_path
+
+"$JAVA" $JAVA_OPTS -classpath "$class_path" org.openo.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
new file mode 100644
index 0000000..c075ac1
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/stop.bat
@@ -0,0 +1,19 @@
+
+@echo off
+title stopping vnfsdk-functest
+
+set HOME=%~dp0
+set Main_Class="org.openo.vnfsdk.functest.VnfSdkFuncTestApp"
+
+echo ================== extsys-service info =============================================
+echo HOME=$HOME
+echo Main_Class=%Main_Class%
+echo ===============================================================================
+
+echo ### Stopping vnfsdk-functest
+cd /d %HOME%
+
+for /f "delims=" %%i in ('"%JAVA_HOME%\bin\jcmd"') do (
+ call find_kill_process "%%i" %Main_Class%
+)
+exit \ No newline at end of file
diff --git a/distribution/standalone/src/main/assembly/stop.sh b/distribution/standalone/src/main/assembly/stop.sh
new file mode 100644
index 0000000..0080d41
--- /dev/null
+++ b/distribution/standalone/src/main/assembly/stop.sh
@@ -0,0 +1,28 @@
+
+DIRNAME=`dirname $0`
+HOME=`cd $DIRNAME/; pwd`
+Main_Class="org.openo.vnfsdk.functest.VnfSdkFuncTestApp"
+
+echo ================== catalog-service info =============================================
+echo HOME=$HOME
+echo Main_Class=$Main_Class
+echo ===============================================================================
+cd $HOME; pwd
+
+echo @WORK_DIR@ $HOME
+
+function save_service_pid(){
+ service_pid=`ps -ef | grep $Main_Class | grep -v grep | awk '{print $2}'`
+ echo @service_pid@ $service_pid
+}
+
+function kill_service_process(){
+ ps -p $service_pid
+ if [ $? == 0 ]; then
+ kill -9 $service_pid
+ fi
+}
+
+save_service_pid;
+echo @C_CMD@ kill -9 $service_pid
+kill_service_process;
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e573a91
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+
+<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>
+ <groupId>org.openo.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../oparent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnfsdk-functest-core-parent</artifactId>
+ <name>vnfsdk-functest-core-parent</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>vnf-sdk-function-test</module>
+ <module>distribution</module>
+ </modules>
+</project>
diff --git a/vnf-sdk-function-test/.gitignore b/vnf-sdk-function-test/.gitignore
new file mode 100644
index 0000000..67a2e60
--- /dev/null
+++ b/vnf-sdk-function-test/.gitignore
@@ -0,0 +1,6 @@
+target/
+.project
+.settings
+.classpath
+.class
+.checkstyle
diff --git a/vnf-sdk-function-test/pom.xml b/vnf-sdk-function-test/pom.xml
new file mode 100644
index 0000000..e91b92e
--- /dev/null
+++ b/vnf-sdk-function-test/pom.xml
@@ -0,0 +1,214 @@
+<?xml version="1.0"?>
+
+<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>
+ <groupId>org.openo.vnf-sdk.function-test</groupId>
+ <artifactId>vnfsdk-functest-core-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>vnf-sdk-function-test</artifactId>
+ <name>vnf-sdk-function-test</name>
+ <packaging>jar</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore/>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.openo.vnfsdk.functest.VnfSdkFuncTestApp</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <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>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-assets</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-hibernate</artifactId>
+ <version>0.8.0</version>
+ </dependency>
+ <!-- lombok -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.16.4</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+ <!-- jersey -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <!-- consumer -->
+ <dependency>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>consumer</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>jersey-all</artifactId>
+ </exclusion>
+ </exclusions>
+ <version>5.0</version>
+ </dependency>
+ <!-- gson -->
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.18</version>
+ </dependency>
+ <!-- UT -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.182</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- UT end -->
+ </dependencies>
+</project>
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/openo/vnfsdk/functest/VnfSdkFuncTestApp.java
new file mode 100644
index 0000000..faca92e
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestApp.java
@@ -0,0 +1,89 @@
+/*
+ * 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;
+
+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;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.dropwizard.Application;
+import io.dropwizard.assets.AssetsBundle;
+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;
+
+public class VnfSdkFuncTestApp extends Application<VnfSdkFuncTestAppConfiguration> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfSdkFuncTestApp.class);
+
+ public static void main(String[] args) throws Exception {
+ new VnfSdkFuncTestApp().run(args);
+ }
+
+ @Override
+ public String getName() {
+ return "OPENO-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();
+ }
+
+ @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().register(MultiPartFeature.class);
+ initSwaggerConfig(environment, configuration);
+ Config.setConfigration(configuration);
+ initService();
+ LOGGER.info("Initialize vnfsdk function test finished.");
+ }
+
+ private void initSwaggerConfig(Environment environment, VnfSdkFuncTestAppConfiguration configuration) {
+ environment.jersey().register(new ApiListingResource());
+ environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ BeanConfig config = new BeanConfig();
+ config.setTitle("Open-o VnfSdk Functest Service rest API");
+ config.setVersion("1.0.0");
+ config.setResourcePackage("org.openo.vnfsdk.functest.resource");
+
+ SimpleServerFactory simpleServerFactory = (SimpleServerFactory)configuration.getServerFactory();
+ String basePath = simpleServerFactory.getApplicationContextPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath();
+ rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
+ basePath = basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath).append(rootPath).toString();
+ config.setBasePath(basePath);
+ config.setScan(true);
+ }
+
+}
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/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java
new file mode 100644
index 0000000..574fe0d
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/VnfSdkFuncTestAppConfiguration.java
@@ -0,0 +1,96 @@
+/*
+ * 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;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.dropwizard.Configuration;
+import io.dropwizard.db.DataSourceFactory;
+
+public class VnfSdkFuncTestAppConfiguration extends Configuration {
+
+ @NotEmpty
+ private String template;
+
+ @NotEmpty
+ private String defaultName = "OPENO-VnfSdk-FuncTest";
+
+ @NotEmpty
+ private String msbServerAddr;
+
+ @Valid
+ private String serviceIp;
+
+ @Valid
+ @NotNull
+ private DataSourceFactory database = new DataSourceFactory();
+
+ @JsonProperty("database")
+ public DataSourceFactory getDataSourceFactory() {
+ return database;
+ }
+
+ @JsonProperty("database")
+ public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
+ this.database = dataSourceFactory;
+ }
+
+ @JsonProperty
+ public String getTemplate() {
+ return template;
+ }
+
+ @JsonProperty
+ public void setTemplate(String template) {
+ this.template = template;
+ }
+
+ @JsonProperty
+ public String getDefaultName() {
+ return defaultName;
+ }
+
+ @JsonProperty
+ public void setDefaultName(String name) {
+ this.defaultName = name;
+ }
+
+ @JsonProperty
+ public String getMsbServerAddr() {
+ return msbServerAddr;
+ }
+
+ @JsonProperty
+ public void setMsbServerAddr(String msbServerAddr) {
+ this.msbServerAddr = msbServerAddr;
+ }
+
+ @JsonProperty
+ public String getServiceIp() {
+ return serviceIp;
+ }
+
+ @JsonProperty
+ public void setServiceIp(String serviceIp) {
+ this.serviceIp = 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/openo/vnfsdk/functest/common/Config.java
new file mode 100644
index 0000000..cb19c98
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/Config.java
@@ -0,0 +1,32 @@
+/*
+ * 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.VnfSdkFuncTestAppConfiguration;
+
+public class Config {
+
+ private static VnfSdkFuncTestAppConfiguration configration;
+
+ public static VnfSdkFuncTestAppConfiguration getConfigration() {
+ return configration;
+ }
+
+ public static void setConfigration(VnfSdkFuncTestAppConfiguration config) {
+ configration = config;
+ }
+}
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
new file mode 100644
index 0000000..ab1566c
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/common/ServiceRegistration.java
@@ -0,0 +1,72 @@
+/*
+ * 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 && retry < 1000) {
+ LOG.info("VNF-SDK function test microservice register.retry:" + retry);
+ retry++;
+ flag = MicroserviceBusConsumer.registerService(funcTestEntity);
+ 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.getMessage());
+ }
+ 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(), "8100", 0);
+ funcTestEntity.setVisualRange("1");
+ }
+}
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestException.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestException.java
new file mode 100644
index 0000000..af2a612
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.exception;
+
+public class VnfSdkFuncTestException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private String errorCode;
+
+ private String errorMsg;
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ public VnfSdkFuncTestException() {
+ super();
+ }
+
+ public VnfSdkFuncTestException(String errorCode, String errorMsg) {
+ this.errorCode = errorCode;
+ this.errorMsg = errorMsg;
+ }
+}
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/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java
new file mode 100644
index 0000000..28ae31e
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceNode.java
@@ -0,0 +1,60 @@
+/*
+ * 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.JsonIgnoreProperties;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceNode {
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public int getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(int ttl) {
+ this.ttl = ttl;
+ }
+
+ private String ip;
+
+ private String port;
+
+ private int 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/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java
new file mode 100644
index 0000000..b622a6c
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntity.java
@@ -0,0 +1,105 @@
+/*
+ * 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.ArrayList;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceRegisterEntity {
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getVisualRange() {
+ return visualRange;
+ }
+
+ public void setVisualRange(String visualRange) {
+ this.visualRange = visualRange;
+ }
+
+ public ArrayList<ServiceNode> getNodes() {
+ return nodes;
+ }
+
+ public void setNodes(ArrayList<ServiceNode> nodes) {
+ this.nodes = nodes;
+ }
+
+ private String serviceName;
+
+ private String version;
+
+ private String url;
+
+ private String protocol;
+
+ private String visualRange;
+
+ private ArrayList<ServiceNode> nodes = new ArrayList<ServiceNode>();
+
+ public void setSingleNode(String ip, String port, int ttl) {
+ ServiceNode node = new ServiceNode();
+ if(ip != null && ip.length() > 0) {
+ node.setIp(ip);
+ } else {
+ node.setIp(null);
+ }
+ node.setPort(port);
+ node.setTtl(ttl);
+ nodes.add(node);
+ }
+
+}
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
new file mode 100644
index 0000000..1c7bdd6
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumer.java
@@ -0,0 +1,44 @@
+/*
+ * 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 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);
+
+ public static boolean registerService(ServiceRegisterEntity entity) {
+ ClientConfig config = new ClientConfig();
+ // LOG.info("microservice register body:" + ExtsysDbUtil.objectToString(entity));
+ try {
+ MicroserviceBusRest resourceserviceproxy = ConsumerFactory
+ .createConsumer(Config.getConfigration().getMsbServerAddr(), config, MicroserviceBusRest.class);
+ resourceserviceproxy.registerServce("false", entity);
+ } catch(Exception error) {
+ LOG.error("Microservice register failed!" + error.getMessage());
+ 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
new file mode 100644
index 0000000..02361c1
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusRest.java
@@ -0,0 +1,37 @@
+/*
+ * 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 registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
+ ServiceRegisterEntity entity) throws Exception;
+}
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
new file mode 100644
index 0000000..5c80314
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java
@@ -0,0 +1,74 @@
+/*
+ * 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 javax.ws.rs.GET;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.codahale.metrics.annotation.Timed;
+
+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);
+
+ @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() {
+ LOGGER.info("execute function test");
+ 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);
+ return null;
+
+ }
+
+}
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/openo/vnfsdk/functest/util/GsonUtil.java
new file mode 100644
index 0000000..acf8cc3
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/GsonUtil.java
@@ -0,0 +1,56 @@
+/*
+ * 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 java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class GsonUtil {
+
+ private final static Logger logger = LoggerFactory.getLogger(GsonUtil.class);
+
+ public static String generateId() {
+ return UUID.randomUUID().toString();
+ }
+
+ public static boolean isNotEmpty(String str) {
+ return str != null && !"".equals(str) && str.length() > 0;
+ }
+
+ /**
+ * change object to str.
+ */
+ public static String objectToString(Object obj) {
+ Gson gson = new Gson();
+ if(obj != null) {
+ return gson.toJson(obj);
+ } else {
+ return null;
+ }
+ }
+
+ public static String getNowTime() {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ return sdf.format(new Date());
+ }
+}
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/openo/vnfsdk/functest/util/RestResponseUtil.java
new file mode 100644
index 0000000..4130952
--- /dev/null
+++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java
@@ -0,0 +1,44 @@
+/*
+ * 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 javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+public class RestResponseUtil {
+
+ public static Response getSuccessResponse(Object obj) {
+ if(obj != null) {
+ return Response.ok(obj).build();
+ } else {
+ return Response.ok().build();
+ }
+ }
+
+ public static Response getCreateSussceeResponse(Object obj) {
+ return Response.status(Status.CREATED).entity(obj).build();
+ }
+
+ public static Response getErrorResponse(Object obj) {
+ if(obj != null) {
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj).build();
+ } else {
+ return Response.serverError().build();
+ }
+
+ }
+}