Skip to content

Commit 9b7c284

Browse files
chore: add DDBEC examples (#2064)
1 parent abbac83 commit 9b7c284

16 files changed

Lines changed: 1654 additions & 0 deletions

.github/workflows/ci_examples_java.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
jobs:
2727
testJava:
2828
strategy:
29+
fail-fast: false
2930
matrix:
3031
java-version: [8, 11, 17, 19]
3132
os: [macos-14]
@@ -103,6 +104,7 @@ jobs:
103104
run: |
104105
# Run simple examples
105106
gradle -p runtimes/java/DynamoDbEncryption test
107+
gradle -p runtimes/java/DDBECwithSDKV2 test
106108
# Run migration examples
107109
gradle -p runtimes/java/Migration/PlaintextToAWSDBE test
108110
gradle -p runtimes/java/Migration/DDBECToAWSDBE test
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
6+
7+
# Compiled class file
8+
*.class
9+
10+
# Log file
11+
*.log
12+
13+
# BlueJ files
14+
*.ctxt
15+
16+
# Mobile Tools for Java (J2ME)
17+
.mtj.tmp/
18+
19+
# Package Files #
20+
*.jar
21+
*.war
22+
*.nar
23+
*.ear
24+
*.zip
25+
*.tar.gz
26+
*.rar
27+
28+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
29+
hs_err_pid*
30+
replay_pid*
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import java.io.File
2+
import java.io.FileInputStream
3+
import java.util.Properties
4+
import java.net.URI
5+
import javax.annotation.Nullable
6+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
7+
import org.gradle.api.tasks.testing.logging.TestLogEvent
8+
9+
plugins {
10+
`java`
11+
`java-library`
12+
}
13+
14+
var props = Properties().apply {
15+
load(FileInputStream(File(rootProject.rootDir, "../../../../project.properties")))
16+
}
17+
18+
group = "software.amazon.cryptography"
19+
version = "1.0-SNAPSHOT"
20+
description = "DDBECExamples"
21+
22+
var mplVersion = props.getProperty("mplDependencyJavaVersion")
23+
var ddbecVersion = props.getProperty("projectJavaVersion")
24+
25+
java {
26+
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
27+
sourceSets["main"].java {
28+
srcDir("src/main/java")
29+
}
30+
sourceSets["test"].java {
31+
srcDir("src/test/java")
32+
}
33+
}
34+
35+
var caUrl: URI? = null
36+
@Nullable
37+
val caUrlStr: String? = System.getenv("CODEARTIFACT_REPO_URL")
38+
if (!caUrlStr.isNullOrBlank()) {
39+
caUrl = URI.create(caUrlStr)
40+
}
41+
42+
var caPassword: String? = null
43+
@Nullable
44+
val caPasswordString: String? = System.getenv("CODEARTIFACT_TOKEN")
45+
if (!caPasswordString.isNullOrBlank()) {
46+
caPassword = caPasswordString
47+
}
48+
49+
repositories {
50+
mavenLocal()
51+
maven {
52+
name = "DynamoDB Local Release Repository - US West (Oregon) Region"
53+
url = URI.create("https://s3-us-west-2.amazonaws.com/dynamodb-local/release")
54+
}
55+
mavenCentral()
56+
if (caUrl != null && caPassword != null) {
57+
maven {
58+
name = "CodeArtifact"
59+
url = caUrl!!
60+
credentials {
61+
username = "aws"
62+
password = caPassword!!
63+
}
64+
}
65+
}
66+
}
67+
68+
dependencies {
69+
implementation("software.amazon.cryptography:aws-database-encryption-sdk-dynamodb:${ddbecVersion}")
70+
implementation("software.amazon.cryptography:aws-cryptographic-material-providers:${mplVersion}")
71+
72+
implementation(platform("software.amazon.awssdk:bom:2.19.1"))
73+
implementation("software.amazon.awssdk:dynamodb")
74+
implementation("software.amazon.awssdk:dynamodb-enhanced")
75+
implementation("software.amazon.awssdk:kms")
76+
77+
testImplementation("org.testng:testng:7.5")
78+
}
79+
80+
tasks.withType<JavaCompile>() {
81+
options.encoding = "UTF-8"
82+
}
83+
84+
tasks.test {
85+
useTestNG()
86+
87+
// This will show System.out.println statements
88+
testLogging.showStandardStreams = true
89+
90+
testLogging {
91+
lifecycle {
92+
events = mutableSetOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED)
93+
exceptionFormat = TestExceptionFormat.FULL
94+
showExceptions = true
95+
showCauses = true
96+
showStackTraces = true
97+
showStandardStreams = true
98+
}
99+
info.events = lifecycle.events
100+
info.exceptionFormat = lifecycle.exceptionFormat
101+
}
102+
103+
// See https://github.com/gradle/kotlin-dsl/issues/836
104+
addTestListener(object : TestListener {
105+
override fun beforeSuite(suite: TestDescriptor) {}
106+
override fun beforeTest(testDescriptor: TestDescriptor) {}
107+
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
108+
109+
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
110+
if (suite.parent == null) { // root suite
111+
logger.lifecycle("----")
112+
logger.lifecycle("Test result: ${result.resultType}")
113+
logger.lifecycle("Test summary: ${result.testCount} tests, " +
114+
"${result.successfulTestCount} succeeded, " +
115+
"${result.failedTestCount} failed, " +
116+
"${result.skippedTestCount} skipped")
117+
}
118+
}
119+
})
120+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)