Merge "Code Improvements-Vnfsdk-refrepo sonar issue fixes"
authorKanagaraj Manickam <kanagaraj.manickam@huawei.com>
Tue, 1 Sep 2020 04:05:17 +0000 (04:05 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 1 Sep 2020 04:05:17 +0000 (04:05 +0000)
13 files changed:
.gitignore
README.md
pom.xml
vnfmarket-be/deployment/docker/docker-refrepo/pom.xml
vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/Dockerfile
vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/certgen.sh
vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/docker-entrypoint.sh
vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/install-vtp.sh
vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker/instance-run.sh
vnfmarket-be/pom.xml
vnfmarket-be/vnf-sdk-marketplace/pom.xml
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/profile/VTPProfileResource.java
vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/profile/VTPProfileResourceTest.java [new file with mode: 0644]

index fe6b66c..fa1a61d 100644 (file)
@@ -1,5 +1,7 @@
+.idea
 .project
 .settings/
 .checkstyle
 .classpath
 target/
+*.iml
index efe41b8..57c7b29 100644 (file)
--- a/README.md
+++ b/README.md
@@ -40,3 +40,38 @@ Docker image building
 ```
     mvn clean package -Pdocker -Dpush.docker.image=false
 ```
+
+Run refrepo locally
+======================
+```
+    docker run --name refrepo -p 8702:8702 nexus3.onap.org:10003/onap/vnfsdk/refrepo:latest
+```
+
+Refrepo container - important folders
+=====================================
+To browse folder you must enter to the refrepo container, so first run docker container locally (see above section) then execute
+```
+    docker exec -it refrepo bash
+```
+
+In the running container you will find a few important folders:
+- /service/logs - it contains vnfmarket application logs
+- /opt/vtp/logs - it contains oclip logs
+- /opt/vtp/lib - it contains oclip dependencies, such as: validation-csar-XXX.jar file
+
+Verify validation logic 
+=============================
+If you want to verify validation logic (validation-csar project), first you need to build validation-csar project,
+next remove existing validation-csar.jar from /opt/vpt/lib folder in the container 
+and then copy the new validation-csar jar file into the /opt/vpt/lib folder in the container and restart this container.
+
+```
+    1. docker exec -it refrepo bash
+    2. Inside the container: rm /opt/vtp/lib/ validation-csar-XXX.jar
+    3. docker cp validation-csar.jar refrepo:/opt/vtp/lib
+    4. docker restart refrepo
+```
+
+VNF Marketplace UI
+==================
+VNF Marketplace UI is available at <http://127.0.0.1:8702/onapui/vnfmarket>
diff --git a/pom.xml b/pom.xml
index f7a82ac..c24e2d5 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -3,6 +3,7 @@
 
     Copyright (C) 2018, Huawei Technologies, Ltd.
     Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
+    Copyright (C) 2020 Nokia
 
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -31,8 +32,9 @@
     <version>1.5.1-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>vnfsdk-refrepo</name>
-       
+
        <properties>
+        <java.version>11</java.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <sonar.language>java</sonar.language>
         <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
         <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
     </properties>
 
-    <modules>     
+    <modules>
         <module>vnfmarket-be</module>
     </modules>
-       
+
        <build>
         <plugins>
             <plugin>
@@ -82,5 +84,5 @@
             </properties>
         </profile>
     </profiles>
-       
+
 </project>
index 23274d4..745b6fa 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
     Copyright 2017 Huawei Technologies Co., Ltd.
+    Copyright 2020 Nokia
 
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
                                 </resource>
                             </resources>
                         </configuration>
-
+                        <dependencies>
+                            <dependency>
+                                <groupId>javax.activation</groupId>
+                                <artifactId>javax.activation-api</artifactId>
+                                <version>${javax.activation-api.version}</version>
+                            </dependency>
+                            <dependency>
+                                <groupId>javax.xml.bind</groupId>
+                                <artifactId>jaxb-api</artifactId>
+                                <version>${jaxb-api.version}</version>
+                            </dependency>
+                        </dependencies>
                         <executions>
                             <execution>
                                 <id>build-image</id>
index 65812d6..21086fc 100644 (file)
@@ -1,4 +1,5 @@
 # Copyright 2020 Huawei Technologies Co., Ltd.
+# Copyright 2020 Nokia
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually.
-#
 # vnf-sdk-marketplace/target/Dockerfile
 #
 
 # 10-basebuild.txt
 
-FROM ubuntu:16.04
-#RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
-RUN apt-get install -y
-RUN apt-get update --fix-missing -y
-RUN apt-get install wget -y
-
-WORKDIR /service
-
-
+FROM ubuntu:20.04
+ARG DEBIAN_FRONTEND=noninteractive
 
-ENV JAVA_VERSION_MAJOR=8 \
-    JAVA_VERSION_MINOR=111 \
+ENV JAVA_VERSION_MAJOR=11 \
+    JAVA_VERSION_MINOR=08 \
     JAVA_HOME=/usr/lib/jvm/default-jvm \
-    PATH=${PATH}:/usr/lib/jvm/default-jvm/bin/
-
-RUN DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
-RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-software-properties
-RUN DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common sudo
-
+    PATH=${PATH}:/usr/lib/jvm/default-jvm/bin/ \
+    CATALINA_HOME=/service
+
+# Install required libraries
+RUN apt-get update && apt-get install -y \
+    curl \
+    g++ \
+    make \
+    nano \
+    nginx \
+    nodejs \
+    npm \
+    software-properties-common \
+    sudo \
+    unzip \
+    wget \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install Java
+WORKDIR /service
 RUN add-apt-repository ppa:openjdk-r/ppa -y && \
     # update data from repositories
-    apt-get update --fix-missing -y && \
-    # upgrade OS
-    apt-get -y dist-upgrade && \
+    apt-get update && \
     # Make info file about this build
-    printf "Build of java:openjdk-8-jre-headless, date: %s\n"  `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /service/java && \
+    printf "Build of java:openjdk-11-jre-headless, date: %s\n"  `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /service/java && \
     # install application
-    apt-get install -y --no-install-recommends openjdk-8-jre-headless && \
+    apt-get install -y --no-install-recommends openjdk-11-jre-headless && \
     # fix default setting
-    ln -s java-8-openjdk-amd64  /usr/lib/jvm/default-jvm && \
+    ln -s java-11-openjdk-amd64  /usr/lib/jvm/default-jvm && \
     # remove apt cache from image
-    apt-get clean all
-
-# Set up tomcat
-RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz && tar --strip-components=1 -xf apache-tomcat-8.5.30.tar.gz && rm -f apache-tomcat-8.5.30.tar.gz && rm -rf webapps && mkdir -p webapps/ROOT
-RUN echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh
-ENV CATALINA_HOME /service
-
-
-# Set up microservice
-#ADD ./STAGE  /service
-#RUN apt-get install -y g++ make &&  curl -sL https://rpm.nodesource.com/setup_6.x |  bash -
-#RUN apt-get install -y nodejs
-#RUN apt-get install -y npm
-#RUN cd /service/webapps/onapui/vnfmarket &&  npm install phantomjs-prebuilt@2.1.14 --ignore-scripts &&  npm install
-
-
-
-RUN add-apt-repository -y ppa:nginx/stable && \
-  apt-get update && \
-  apt-get install -y nginx && \
-  rm -rf /var/lib/apt/lists/* && \
-  echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
-  chown -R www-data:www-data /var/lib/nginx
-
-# Define mountable directories.
-VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
-
-# Define working directory.
-WORKDIR /etc/nginx
-
-#CMD ["nginx"]
-
-
-EXPOSE 8702
-EXPOSE 8703
+    apt-get clean all && \
+    rm -rf /var/lib/apt/lists/*
 
+# Download and set up Tomcat
 WORKDIR /service
+RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz && \
+    tar --strip-components=1 -xf apache-tomcat-8.5.30.tar.gz && \
+    rm -f apache-tomcat-8.5.30.tar.gz && rm -rf webapps && mkdir -p webapps/ROOT && \
+    echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh
 
-RUN  mkdir -p /etc/nginx/ssl
+# Copy artifacts
+WORKDIR /service
 COPY nginx.conf /etc/nginx/nginx.conf
 COPY certgen.sh /service
-RUN  chmod +x /service/certgen.sh
-RUN  /service/certgen.sh
-
-
-
-RUN apt-get update && apt-get install nano -y
-RUN apt-get install curl -y
-
-
-#RUN apt-get install vim -y
-
-
 COPY instance-config.sh .
 COPY instance-init.sh .
 COPY instance-run.sh .
@@ -110,43 +75,40 @@ COPY instance-workaround.sh .
 COPY docker-entrypoint.sh .
 COPY install-vtp.sh .
 COPY vtp-tc.sh .
+COPY LICENSE ./ONAP_LICENSE
+
+# Configure NGINX
+RUN mkdir -p /etc/nginx/ssl && \
+    chown -R www-data:www-data /var/lib/nginx
 
+# Generate certificates
+RUN chmod +x /service/certgen.sh  && \
+    /service/certgen.sh
 
 # Set up microservice
 ADD ./STAGE  /service
-RUN apt-get install -y g++ make &&  curl -sL https://rpm.nodesource.com/setup_6.x
-RUN apt-get install -y nodejs
-RUN apt-get install -y npm
-RUN apt-get -qq update && apt-get -qq -y install bzip2
-RUN chmod +x /service/bin/*.sh
-RUN service nginx start &
-RUN cd /service/webapps/onapui/vnfmarket && npm install phantomjs-prebuilt@2.1.14 --ignore-scripts && npm install
-
-#VTP setup
-RUN chmod a+x /service/install-vtp.sh
-RUN chmod a+x /service/vtp-tc.sh
-RUN /service/install-vtp.sh
-EXPOSE 50051
+RUN chmod +x /service/bin/*.sh && \
+    cd /service/webapps/onapui/vnfmarket && \
+    npm install phantomjs-prebuilt@2.1.14 --ignore-scripts && \
+    npm install
+
+# VTP setup
+RUN chmod a+x /service/install-vtp.sh && \
+    chmod a+x /service/vtp-tc.sh && \
+    /service/install-vtp.sh
 
+# Create group and user
 RUN groupadd -r vnfadmin && useradd -m --no-log-init -r -g vnfadmin vnfadmin && \
     usermod -aG sudo vnfadmin && echo "vnfadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
     chmod -R 777 /usr/local/
 
 USER vnfadmin
 
-RUN umask 000 && sudo chmod +x /service/bin/*.sh /service/*.sh && \
-    mkdir -p /service/logs && mkdir -p /var/log/nginx/ && \
-    sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ && \
-    sudo chown -R vnfadmin:vnfadmin /service/ /opt/vtp /var/log && \
-    sudo chmod -R +w /service/ /opt/vtp /var/log && \
-    sudo touch /run/nginx.pid && sudo chown -R vnfadmin:vnfadmin /run/nginx.pid && \
-    chmod +w /run/nginx.pid  && sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ && \
-    sudo usermod -aG www-data vnfadmin && sudo chmod -R a+w /var/lib/nginx
+# Define mountable directories.
+VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
 
+EXPOSE 8702
+EXPOSE 8703
+EXPOSE 50051
 
-#ENTRYPOINT /service/docker-entrypoint.sh
 ENTRYPOINT ["/service/docker-entrypoint.sh"]
-
-
-
-COPY LICENSE ./ONAP_LICENSE
index ae3d351..5c038dd 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright 2020 Huawei Technologies Co., Ltd.
+# Copyright 2020 Nokia
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -19,4 +20,5 @@ openssl req -nodes -newkey rsa:2048 -keyout example.key -out example.csr -subj "
 openssl x509 -req -in example.csr -signkey example.key -out cert.crt
 cp -p cert.crt /etc/nginx/ssl/
 cp -p example.key /etc/nginx/ssl/cert.key
-#service nginx start & 
+chmod 644 /etc/nginx/ssl/cert.crt
+chmod 644 /etc/nginx/ssl/cert.key
index 3bb1414..9428d7f 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-#
-# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually.
-#
 # vnf-sdk-marketplace/target/docker-entrypoint.sh
 #
 
-umask 000 && sudo chmod +x /service/bin/*.sh /service/*.sh && mkdir -p /service/logs && mkdir -p /var/log/nginx/ && sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ /service/ /opt/vtp /var/log && sudo chmod -R +w /service/ /opt/vtp /var/log && sudo touch /run/nginx.pid && sudo chown -R vnfadmin:vnfadmin /run/nginx.pid && chmod +w /run/nginx.pid  && sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ && sudo usermod -aG www-data vnfadmin && sudo chmod -R a+w /var/lib/nginx
+umask 000 && sudo chmod +x /service/bin/*.sh /service/*.sh && mkdir -p /service/logs && mkdir -p /var/log/nginx/ && sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ /service/ /opt/vtp /var/log && sudo chmod -R +w /service/ /opt/vtp /var/log && sudo touch /run/nginx.pid && sudo chown -R vnfadmin:vnfadmin /run/nginx.pid && chmod 644 /run/nginx.pid  && sudo chown -R vnfadmin:vnfadmin /var/log/nginx/ && sudo usermod -aG www-data vnfadmin && sudo chmod -R a+w /var/lib/nginx
 
 if [ -z "$SERVICE_IP" ]; then
     export SERVICE_IP=`hostname -i`
index c3364da..6109d40 100644 (file)
 
 export _PWD=`pwd`
 
-echo ################ Check for java
+echo ################ Make sure that mandatory libraries are installed
+sudo apt-get update --fix-missing -y
 sudo apt-get install -y wget unzip
 
 #check for java
 java -version
 if [ $? == 127 ]
 then
-    sudo apt-get install -y openjdk-8-jre
+    sudo apt-get install -y openjdk-11-jre
 fi
 
 echo ################ Install OCLIP
index 1f0d14d..058937c 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/bash
 #
 # Copyright 2017 Huawei Technologies Co., Ltd.
+# Copyright 2020 Nokia
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -21,7 +22,9 @@
 # Start tomcat service
 ./bin/start.sh
 
-service nginx start
+# Start NGINX service
+service nginx start&
+
 # Show log files
 echo Waiting for log file...
 while [ ! -f /service/logs/* ]; do
index 240a9d6..47b1cb3 100644 (file)
@@ -1,13 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   Copyright 2016-2018 Huawei Technologies Co., Ltd.
+  Copyright 2020 Nokia
+
   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.
        <scm>
         <tag>HEAD</tag>
     </scm>
-      <modules>
+
+    <properties>
+        <javax.activation-api.version>1.2.0</javax.activation-api.version>
+        <jaxb-api.version>2.3.1</jaxb-api.version>
+    </properties>
+
+    <modules>
           <module>vnf-sdk-marketplace</module>
           <module>deployment</module>
     </modules>
index 41139fb..3dcda1a 100644 (file)
 
 
     <dependencies>
-          <dependency>
-             <groupId>javax.xml.bind</groupId>
-             <artifactId>jaxb-api</artifactId>
-             <version>2.3.1</version>
-          </dependency>
     <!--  oclip -->
           <dependency>
             <groupId>org.onap.cli</groupId>
                     <groupId>com.fasterxml.jackson.core</groupId>
                     <artifactId>jackson-databind</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>com.fasterxml.jackson.dataformat</groupId>
+                    <artifactId>jackson-dataformat-yaml</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.dataformat</groupId>
+            <artifactId>jackson-dataformat-yaml</artifactId>
+            <version>2.9.5</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.yaml</groupId>
+                    <artifactId>snakeyaml</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+            <version>1.26</version>
+        </dependency>
         <!-- jersey -->
 <!-- excluded jetty-util and added invulnerable version -->
         <dependency>
@@ -189,6 +204,16 @@ due to Security Issues:- CVE-2019-10241,CVE-2019-10247,CVE-2019-10246
             <artifactId>mybatis</artifactId>
             <version>3.2.7</version>
         </dependency>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>javax.activation-api</artifactId>
+            <version>${javax.activation-api.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>${jaxb-api.version}</version>
+        </dependency>
         <!-- UT -->
         <dependency>
             <groupId>junit</groupId>
@@ -226,17 +251,10 @@ due to Security Issues:- CVE-2019-10241,CVE-2019-10247,CVE-2019-10246
             <version>1.8.2</version>
             <scope>test</scope>
         </dependency>
-
-
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>1.3.2</version>
-        </dependency>
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.4</version>
+            <version>2.7</version>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
index 880bfef..a5c601d 100644 (file)
@@ -67,7 +67,7 @@ public class VTPProfileResource extends VTPResource {
                 "--product", "open-cli", "profile-list", "--format", "json"
                 }));
 
-        JsonObject results = this.makeRpcAndGetJson(args).getAsJsonObject();
+        JsonArray results = this.makeRpcAndGetJson(args).getAsJsonArray();
 
         VTPTestProfileList list = new VTPTestProfileList();
 
@@ -100,7 +100,7 @@ public class VTPProfileResource extends VTPResource {
         args.addAll(Arrays.asList(new String[] {
                  "--product", "open-cli", "profile-show", "--profile", profileName, "--format", "json"
                 }));
-        JsonObject results = this.makeRpcAndGetJson(args).getAsJsonObject();
+        JsonArray results = this.makeRpcAndGetJson(args).getAsJsonArray();
 
         VTPTestProfile profile = new VTPTestProfile();
         profile.setName(profileName);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/profile/VTPProfileResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vtp/profile/VTPProfileResourceTest.java
new file mode 100644 (file)
index 0000000..662e6bb
--- /dev/null
@@ -0,0 +1,119 @@
+/**
+ * Copyright 2020 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.vtp.profile;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import mockit.Expectations;
+import mockit.Mock;
+import mockit.MockUp;
+import mockit.Mocked;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.vtp.VTPResource;
+import org.onap.vtp.error.VTPError;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.List;
+import org.eclipse.jetty.http.HttpStatus;
+
+import static org.junit.Assert.assertEquals;
+
+
+public class VTPProfileResourceTest {
+
+    VTPProfileResource vtpProfileResource;
+    @Before
+    public void setUp() {
+        vtpProfileResource=new VTPProfileResource();
+    }
+
+    private void mockVTPResource(String jsonValue){
+        new MockUp<VTPResource>() {
+            @Mock
+            protected JsonElement makeRpcAndGetJson(List<String> args, int timeout) throws VTPError.VTPException, IOException {
+                JsonElement jsonNode = new JsonParser().parse(jsonValue);
+                return jsonNode;
+            }
+        };
+    }
+
+    private void mockGetInputStream(HttpServletRequest request) throws IOException {
+        new Expectations(){{
+            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+                    ("{\"name\":\"https\",\"properties\":[{\"testCaseName\":\"weather-report\"," +
+                            " \"testSuiteName\":\"tutorial\", \"scenario\":\"learning\"," +
+                            " \"inputParameterName\":\"zipcod\",\"value\":\"412\"}]}").getBytes());
+            request.getInputStream();
+            result =  new ServletInputStream(){
+                public int read() throws IOException {
+                    return byteArrayInputStream.read();
+                }
+                @Override
+                public boolean isFinished() {
+                    return true;
+                }
+                @Override
+                public boolean isReady() {
+                    return true;
+                }
+                @Override
+                public void setReadListener(ReadListener arg0) {
+                }
+            };
+        }};
+    }
+
+    @Test
+    public void testListTestProfiles() throws IOException, VTPError.VTPException {
+        String jsonValue = "[{\"profile\":\"https\"}]";
+        mockVTPResource(jsonValue);
+        assertEquals(HttpStatus.OK_200,vtpProfileResource.listTestProfiles().getStatus());
+    }
+
+    @Test
+    public void testGetTestProfile() throws IOException, VTPError.VTPException {
+        String jsonValue = "[{\"profile\":\"https\",\"parameter\":\"tutorial\"," +
+                "\"value\":\"value\",\"service\":\"service\",\"command\":\"command\"" +
+                ",\"product\":\"product\"}]";
+        mockVTPResource(jsonValue);
+        assertEquals(HttpStatus.OK_200,vtpProfileResource.getTestProfile("https").getStatus());
+    }
+
+    @Test
+    public void testCreateProfile(@Mocked HttpServletRequest request) throws IOException, VTPError.VTPException {
+        mockGetInputStream(request);
+        mockVTPResource("[]");
+        Response response= vtpProfileResource.createProfile(request);
+        assertEquals(HttpStatus.OK_200,response.getStatus());
+    }
+
+    @Test(expected = VTPError.VTPException.class)
+    public void testCreateProfile2(@Mocked HttpServletRequest request) throws IOException, VTPError.VTPException {
+        String jsonValue = "[{\"profile\":\"https\"}]";
+        mockGetInputStream(request);
+        mockVTPResource(jsonValue);
+        vtpProfileResource.createProfile(request);
+    }
+
+}
\ No newline at end of file