Skip to content

CA-DevTest/CodeSV

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

CodeSV

End of Life Feature as of February 1, 2023

Effective February 1, 2023, CodeSV will be deprecated. CodeSV will be supported until Jan 31st, 2023.

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);
  }
}

About

A fluent Java API for virtualizing HTTP services. Service virtualization simplified. No endpoint configuration. Import/export of request-response pairs.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages