User's Blog!by CA Technologies


How Can We Help?
< Back

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


Java 8 functionality

CodeSV also supports lambda expressions from Java 8. They can be quite easy and conventionally used as matchers or with matchers.

Basic lambda example:

private static final String URL = "";

public VirtualServerRule vs = new VirtualServerRule();

public void testLambda() throws Exception {
.matchesHeader("Custom-Header", s -> s.equals("CustomValue"))

HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(URL);
request.addHeader("Custom-Header", "CustomValue");

HttpResponse response = client.execute(request);

BufferedReader reader = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {

String body = result.toString();

assertEquals(200, response.getStatusLine().getStatusCode());

Complete example is here.

Previous Matching
Next Different File Formats
Table of Contents

Comments are currently closed.