Skip to content

Commit 3317b4d

Browse files
chore: merge from main and fix ubuntu failing (#2192)
1 parent 9fb65dd commit 3317b4d

4 files changed

Lines changed: 56 additions & 13 deletions

File tree

DynamoDbEncryption/runtimes/java/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ dependencies {
9898

9999
// For the DDB-EC with SDK v1
100100
compileOnly("com.amazonaws:aws-java-sdk-dynamodb:1.12.780")
101+
101102
// For the DDB-EC with SDK V2
102103
implementation("io.netty:netty-common:4.2.9.Final")
103104

DynamoDbEncryption/runtimes/java/src/test/sdkv1/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticIT.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import java.util.stream.Collectors;
5757
import javax.crypto.SecretKey;
5858
import javax.crypto.spec.SecretKeySpec;
59+
import org.testng.annotations.AfterTest;
5960
import org.testng.annotations.BeforeTest;
6061
import org.testng.annotations.DataProvider;
6162
import org.testng.annotations.Test;
@@ -349,6 +350,14 @@ public void decryptWithECConfigTest()
349350
);
350351
}
351352

353+
@AfterTest
354+
public void tearDownDDBLocal() {
355+
if (client != null) {
356+
client.shutdown();
357+
client = null;
358+
}
359+
}
360+
352361
@Test(dataProvider = "getDecryptTestVectors")
353362
public void decryptTestVector(Scenario scenario) throws IOException {
354363
client = DynamoDBEmbedded.create().amazonDynamoDB();
@@ -1583,6 +1592,9 @@ private static String stripFilePath(String path) {
15831592
return path.replaceFirst("file://", "");
15841593
}
15851594

1586-
@JsonDeserialize(using = AttributeValueDeserializer.class)
1587-
public static class DeserializedAttributeValue extends AttributeValue {}
1595+
@com.fasterxml.jackson.databind.annotation.JsonDeserialize(
1596+
using = AttributeValueDeserializer.class
1597+
)
1598+
public static class DeserializedAttributeValue
1599+
extends com.amazonaws.services.dynamodbv2.model.AttributeValue {}
15881600
}

DynamoDbEncryption/runtimes/java/src/test/sdkv1/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/CachingMostRecentProviderTests.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import java.util.Map;
2727
import javax.crypto.SecretKey;
2828
import javax.crypto.spec.SecretKeySpec;
29+
import org.testng.annotations.AfterClass;
30+
import org.testng.annotations.AfterMethod;
31+
import org.testng.annotations.BeforeClass;
2932
import org.testng.annotations.BeforeMethod;
3033
import org.testng.annotations.Test;
3134

@@ -47,30 +50,48 @@ public class CachingMostRecentProviderTests {
4750
private static final DynamoDBEncryptor ENCRYPTOR =
4851
DynamoDBEncryptor.getInstance(BASE_PROVIDER);
4952

50-
private AmazonDynamoDB client;
51-
private Map<String, Integer> methodCalls;
53+
private static AmazonDynamoDB rawClient;
54+
private static AmazonDynamoDB instrumentedClient;
55+
private static Map<String, Integer> methodCalls;
5256
private ProviderStore store;
5357
private EncryptionContext ctx;
5458

59+
// DDB Local client is created once per class since DynamoDBEmbedded.create() is expensive.
60+
// Table is created/deleted per method to ensure test isolation, as tests assert
61+
// exact DynamoDB call counts and expect a clean table with no leftover data.
62+
@BeforeClass
63+
public static void setupClient() {
64+
methodCalls = new HashMap<String, Integer>();
65+
rawClient = DynamoDBEmbedded.create().amazonDynamoDB();
66+
instrumentedClient =
67+
instrument(rawClient, AmazonDynamoDB.class, methodCalls);
68+
}
69+
70+
@AfterClass
71+
public static void tearDownDDBLocal() {
72+
if (rawClient != null) {
73+
rawClient.shutdown();
74+
rawClient = null;
75+
}
76+
}
77+
5578
@BeforeMethod
5679
public void setup() {
57-
methodCalls = new HashMap<String, Integer>();
58-
client =
59-
instrument(
60-
DynamoDBEmbedded.create().amazonDynamoDB(),
61-
AmazonDynamoDB.class,
62-
methodCalls
63-
);
6480
MetaStore.createTable(
65-
client,
81+
instrumentedClient,
6682
TABLE_NAME,
6783
new ProvisionedThroughput(1L, 1L)
6884
);
69-
store = new MetaStore(client, TABLE_NAME, ENCRYPTOR);
85+
store = new MetaStore(instrumentedClient, TABLE_NAME, ENCRYPTOR);
7086
ctx = new EncryptionContext.Builder().build();
7187
methodCalls.clear();
7288
}
7389

90+
@AfterMethod
91+
public void tearDown() {
92+
rawClient.deleteTable(TABLE_NAME);
93+
}
94+
7495
@Test
7596
public void testConstructors() {
7697
final CachingMostRecentProvider prov = new CachingMostRecentProvider(

DynamoDbEncryption/runtimes/java/src/test/sdkv1/com/amazonaws/services/dynamodbv2/mapper/integration/DynamoDBTestBase.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Collection;
2222
import java.util.HashSet;
2323
import java.util.Set;
24+
import org.testng.annotations.AfterClass;
2425

2526
public class DynamoDBTestBase {
2627

@@ -30,6 +31,14 @@ public static void setUpTestBase() {
3031
dynamo = DynamoDBEmbedded.create().amazonDynamoDB();
3132
}
3233

34+
@AfterClass
35+
public static void tearDownDDBLocal() {
36+
if (dynamo != null) {
37+
dynamo.shutdown();
38+
dynamo = null;
39+
}
40+
}
41+
3342
public static AmazonDynamoDB getClient() {
3443
if (dynamo == null) {
3544
setUpTestBase();

0 commit comments

Comments
 (0)