Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


Introduction

MockServer is an open source tool to mock any system with REST interface. The tool is implemented in java, and REST APIs are provided to configure and query it. See more details at http://www.mock-server.com/.

Installation

Install MockServer docker on Robot VM

>sudo docker pull jamesdbloom/mockserver
>sudo docker run --name mockserver -d -p 1080:1080 jamesdbloom/mockserver


You can restart MockServer container or reset it anytime with the following commands:

ubuntu@onap-robot:~/mockserverclient$ sudo docker restart mockserver
ubuntu@onap-robot:~/mockserverclient$ curl -v -X PUT "http://localhost:1080/reset"

Configuration

You can set the expectations in MockServer with REST APIs, e.g.:

# DCI Overlay
curl -v -X PUT "http://localhost:1080/expectation" -d '{
    "httpRequest": {
        "method": "POST",
        "path": "/v2.0/l3-dci-connects"
    },
    "httpResponse": {
        "statusCode": 201
    },
    "times" : {
        "unlimited" : true
    },
    "timeToLive" : {
        "unlimited" : true
    }
}'

Verification

Verify all requests received by MockServer with REST API. e.g.:

ubuntu@onap-robot:~/mockserverclient$ curl -X PUT "http://localhost:1080/retrieve?type=REQUESTS&format=JSON"

or a particular request filtered by url, e.g.:

ubuntu@onap-robot:~/mockserverclient$ curl -X PUT "http://localhost:1080/retrieve?type=REQUESTS&format=JSON" -d '{
    "path""/controller/v2/tokens"
}'

  • No labels