CodeSVby CA Technologies

SOAP Virtualization

Both examples use an application generated from WSDL by Spring Boot called HelloWorldClient, that uses SOAP. This client is set to receive a SOAP request with name and surname and responds with a greeting that includes these details. TestRealService shows the request created by HelloWorldClient as it hits the real WebService, and as it sends […]

Read more

HTTPs

Using HTTPs protocol CodeSV supports the HTTPs protocol that is easily enabled by using the usingHttps() method. There are three required parameters to be specified: keystorePath points to the location of the keystore on the file system. keystorePassword specifies a password for the provided keystore. keyPassword specifies the password to a key. Note: In the provided example, we are using […]

Read more

Exporting Virtual Services from CodeSV

Use our handy export feature to share your virtualized assets with other team members and integrate seamlessly with our CA Service Virtualization solution. After you have created your custom service, you can export the executed HTTP requests from that service and the responses in to text files. These text files are created in a Request-Response […]

Read more

Complex Assertions

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 […]

Read more

Different File Formats

Use JSON in Virtualized Response This service is configured to respond to GET requests that are defined using the forGet(String url) method with a message that contains JSON body as defined by the JSON_EXAMPLES_PORTFOLIO variable. The JSON response is converted to a POJO CaPortfolio class. Using JSON private static final String URL = “http://www.ca.com/portfolio”; private static […]

Read more

Matching

Advanced Matching for Request This service is configured to respond to GET requests that are defined using the forGet(String url) method with specific query parameters and headers: Headers Custom-Header Value: CustomValue Accept-Language Value: Contains the string “us” Query Parameters tokenQuery Example: x4sphj15wqe Note: Not case sensitive Year Value: 2016 Note: You can also use references for […]

Read more

Lambda

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 = “http://www.ca.com/portfolio?year=2016&tokenQuery=X4sPhj15WQE”; @Rule public VirtualServerRule vs = new VirtualServerRule(); @Test public void testLambda() throws Exception { forGet(URL) .matchesHeader(“Custom-Header”, s -> s.equals(“CustomValue”)) .doReturn( okMessage() […]

Read more

HTTP GET and POST

GET METHOD This service is configured to respond to GET requests that are defined using the forGet(String url) method with the following: Custom status code Defined by the CUSTOM_STATUS_CODE variable. Value: 258 in this example Predefined String response body Defined by the RESPONSE_BODY_GET variable Create GET request: private static final String URL = “http://www.ca.com/portfolio”; private static String […]

Read more