Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 9aa23db

Browse files
author
Ales Lanar
committed
New example with AWS S3 Service virtualization
1 parent 3f9bf8f commit 9aa23db

35 files changed

+1952
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AWS S3 Demo virtualization with CodeSV
2+
3+
In this example, we are going to virtualize the AWS S3 client from AWS SDK to be able to create tests for uncommon edge cases (like AccessDenied, NonExistingBucket or OperationAborted).
4+
5+
## How to run it
6+
1. For running AWS SDK on your local machine, you need to setup your environment (AWS Profile). For more information see this [page](https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/setup-credentials.html).
7+
2. Create your bucket in AWS S3 to be sure it works with the real endpoint.
8+
3. Add the host of your AWS S3 bucket to your KeyStore/TrustStore. AWS SDK client works with HTTPS. For tests in this example we are using _keystore.jks_ file from test resources.
9+
4. Virtualize!
10+
11+
## Where are definitions for virtualized endpoints defined?
12+
In this example, we are using our repository feature from CodeSV 1.3 and all our definitions for virtualization are stored in repository classes located in repository package under test folder (_S3CodeSvDemoBucketRepository.java_ and _S3CodeSvRepoTxnName.java_).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
group 'com.ca.codesv'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
10+
}
11+
}
12+
13+
apply plugin: "io.spring.dependency-management"
14+
apply plugin: 'java'
15+
16+
sourceCompatibility = 1.8
17+
18+
repositories {
19+
mavenCentral()
20+
maven {
21+
url "http://ca.bintray.com/sv"
22+
}
23+
}
24+
25+
dependencyManagement {
26+
imports {
27+
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.228'
28+
}
29+
}
30+
31+
dependencies {
32+
compile 'com.amazonaws:aws-java-sdk-s3'
33+
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
34+
35+
testCompile 'com.ca.codesv:codesv-dist-jar:1.3.0'
36+
testCompile group: 'junit', name: 'junit', version: '4.12'
37+
}
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Mon Oct 22 13:47:33 CEST 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-bin.zip

codesv-examples/aws_s3_virtualized/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codesv-examples/aws_s3_virtualized/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = 'codesv-aws-service'
2+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/******************************************************************************
2+
*
3+
* Copyright (c) 2018 CA. All rights reserved.
4+
*
5+
* This software and all information contained therein is confidential and
6+
* proprietary and shall not be duplicated, used, disclosed or disseminated
7+
* in any way except as authorized by the applicable license agreement,
8+
* without the express written permission of CA. All authorized reproductions
9+
* must be marked with this language.
10+
*
11+
* EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT
12+
* PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS SOFTWARE WITHOUT
13+
* WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED
14+
* WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN
15+
* NO EVENT WILL CA BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY
16+
* LOSS OR DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE,
17+
* INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION,
18+
* GOODWILL, OR LOST DATA, EVEN IF CA IS EXPRESSLY ADVISED OF SUCH LOSS OR
19+
* DAMAGE.
20+
*
21+
******************************************************************************/
22+
23+
package com.ca.codesv.codesv_aws_service;
24+
25+
import java.util.Objects;
26+
27+
public class AppEnv {
28+
private String name;
29+
private String host;
30+
31+
public AppEnv(String name, String host) {
32+
this.name = name;
33+
this.host = host;
34+
}
35+
36+
public String getName() {
37+
return name;
38+
}
39+
40+
public void setName(String name) {
41+
this.name = name;
42+
}
43+
44+
public String getHost() {
45+
return host;
46+
}
47+
48+
public void setHost(String host) {
49+
this.host = host;
50+
}
51+
52+
@Override
53+
public boolean equals(Object o) {
54+
if (this == o) return true;
55+
if (o == null || getClass() != o.getClass()) return false;
56+
AppEnv appEnv = (AppEnv) o;
57+
return Objects.equals(name, appEnv.name) &&
58+
Objects.equals(host, appEnv.host);
59+
}
60+
61+
@Override
62+
public int hashCode() {
63+
return Objects.hash(name, host);
64+
}
65+
}

0 commit comments

Comments
 (0)