mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.59k stars 1.07k forks source link

Logs are not clear that matches the requestDefinition #1332

Closed Aravinthan-R closed 2 years ago

Aravinthan-R commented 2 years ago

I'm trying to clear logs using requestDefinition , unfortunately, logs are not cleared.

Code:

mockServer.clear( request() .withPath("/mockserver/qwe/msg.ashx"));

The above line clears the expectation but does not logs.

Log Details: CLEARED
cleared expectations that match:

{
  "path": "/mockserver/que/msg.ashx"
}

removed expectation:

{
  "httpRequest": {
    "path": "/mockserver/que/msg.ashx"
  },
  "httpResponseClassCallback": {
    "callbackClass": "com.wo.mock.MockBidResponse"
  },
  "id": "74e93c0b-b2a5-4033-be24-960b926b4b57",
  "priority": 0,
  "timeToLive": {
    "unlimited": true
  },
  "times": {
    "unlimited": true
  }
}

cleared logs that match:

{
  "path": "/mockserver/que/msg.ashx"
}

MockServer version version . 5.13.2

Aravinthan-R commented 2 years ago

Tried with function -> MockServerClient clear(RequestDefinition requestDefinition, ClearType type) But log messages are not cleared.

Please find the code below -

Initialize Expectation by path :

 Expectation.when(request().withPath("/mockserver/qwe/msg.ashx"))

I'm tried with the following line to clear logs:

mockServer.clear(HttpRequest.request().withPath("/mockserver/qwe/msg.ashx"), ClearType.LOG);

Following message is getting in Dashboard - cleared logs that match:

{
  "path": "/mockserver/qeu/msg.ashx"
}

Note: No logs are cleared

Please suggest to me if any wrong with my code

Also tried the following code to clear all logs, but not cleared any log messages -

RequestDefinition NULL = null;
mockServer.clear(NULL, ClearType.LOG);