A fluent Java API for virtualizing HTTP services. Service virtualization simplified. No endpoint configuration. Import/export of request-response pairs.
Java
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
codesv-examples New release of CodeSV with Class Repository example. Jul 23, 2018
wiki CodeSV 1.2.0 Oct 2, 2017
README.md CodeSV 1.2.0 Oct 2, 2017

README.md

CodeSV

CA CodeSV is a new, lightweight way to define virtual services and save valuable time.

At the core, CodeSV delivers a simple yet powerful Java library that provides an easy to use API so you can create and run virtual services as a part of jUnit testing.

You can create and run HTTP virtual service definitions directly in your unit testing code.

Even better, the HTTP virtual services are completely transparent to an application under test. This means you don't have to make any other configuration tweaks.

How to use CodeSV

Share ideas and raise issues

Code Example

Here is a simple example of a jUnit test running an embedded virtual service using CodeSV.

import static com.ca.codesv.protocols.http.fluent.HttpFluentInterface.*;
import static org.junit.Assert.*;

import com.ca.codesv.engine.junit4.VirtualServerRule;
import org.junit.*;

public class ExampleTest {

  @Rule
  public VirtualServerRule vs = new VirtualServerRule();

  @Test
  public void exampleTest() {
    // virtual service definition
    forGet("http://www.example.com/time").doReturn(
        okMessage()
            .withJsonBody("{\"timestamp\":1498838896}")
    );

    // application connects to http://www.example.com/test and retrieves JSON response
    int currentTimestamp = Application.retrieveCurrentTimestamp();

    // received timestamp check
    assertEquals(1498838896, currentTimestamp);
  }
}