User's Blog!by CA Technologies

Complex Assertions

How Can We Help?
< Back

[expand title=”Prerequisites” expanded=”true”]


Verification of Invocation Count

This service is configured to respond to GET requests that are defined using the forGet(String url) method, and test check how many times the virtualized service is invoked.

For more complex asserting, you can also use advanced matchers such as the following:

  • moreThan()
  • moreThanOrEqualsTo()
  • lessThan()
  • lessThanOrEqualsTo()

Verification of invocation example

public class VerificationExample {

  private static final String URL = "";

  private static final String JSON_EXAMPLES_PORTFOLIO = "{"
      + "\"portfolio\": {\n"
      + "   \"id\": \"1\",\n"
      + "   \"year\": \"{{argument.year}}\",\n"
      + "  \"productNamesList\": [\n"
      + "    \"CA Server Automation\",\n"
      + "    \"CA Service Catalog\",\n"
      + "    \"CA Service Desk Manager\",\n"
      + "    \"CA Service Management\",\n"
      + "    \"CA Service Operations Insight\",\n"
      + "    \"CA Service Virtualization\"\n"
      + "  ]\n"
      + "}}";

  public VirtualServerRule vs = new VirtualServerRule();

  public void testInvokedCount() throws Exception {
        .matchesHeader("Accept-Language", contains("us"))

    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(URL);
    request.addHeader("Accept-Language", "en_us");


For a complete example see: VerificationExample

Previous Different File Formats
Next Exporting Virtual Services from CodeSV
Table of Contents

Comments are currently closed.