Skip to content

Commit b03e484

Browse files
committed
finish refactoring and fix tests
1 parent a3c784d commit b03e484

File tree

4 files changed

+64
-15
lines changed

4 files changed

+64
-15
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ build: ## Build the code using Maven
99
publish-maven: ## Publish artifacts to Maven Central
1010
ADDITIONAL_MVN_TARGETS=deploy ADDITIONAL_MVN_ARGS=" " make build
1111

12-
test: ## Run tests for Java/JUnit compatibility
13-
USE_SSL=1 SERVICES=serverless,kinesis,sns,sqs,iam,cloudwatch mvn $(MVN_ARGS) test
12+
test: ## Run Java/JUnit tests for AWS SDK v1 and v2
13+
USE_SSL=1 SERVICES=serverless,kinesis,sns,sqs,iam,cloudwatch mvn -Pawssdkv2 \
14+
-Dtest="cloud.localstack.awssdkv2.*Test" test
15+
USE_SSL=1 SERVICES=serverless,kinesis,sns,sqs,iam,cloudwatch mvn -Pawssdkv1 \
16+
-Dtest="!cloud.localstack.awssdkv2.*Test" test
1417

1518
.PHONY: usage clean install test

pom.xml

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<maven.compiler.source>1.8</maven.compiler.source>
3333
<maven.compiler.target>1.8</maven.compiler.target>
3434
<aws.sdk.version>1.11.642</aws.sdk.version>
35+
<aws.sdkv2.version>2.13.36</aws.sdkv2.version>
3536
</properties>
3637

3738
<dependencies>
@@ -40,17 +41,20 @@
4041
<artifactId>junit</artifactId>
4142
<version>4.12</version>
4243
<optional>true</optional>
44+
<scope>provided</scope>
4345
</dependency>
4446
<dependency>
4547
<groupId>org.junit.jupiter</groupId>
4648
<artifactId>junit-jupiter-api</artifactId>
4749
<version>5.5.2</version>
4850
<optional>true</optional>
51+
<scope>provided</scope>
4952
</dependency>
5053
<dependency>
5154
<groupId>org.apache.commons</groupId>
5255
<artifactId>commons-lang3</artifactId>
5356
<version>3.5</version>
57+
<scope>provided</scope>
5458
</dependency>
5559
<dependency>
5660
<groupId>net.java.dev.jna</groupId>
@@ -62,6 +66,7 @@
6266
<groupId>org.jvnet.winp</groupId>
6367
<artifactId>winp</artifactId>
6468
<version>1.23</version>
69+
<scope>provided</scope>
6570
</dependency>
6671
<dependency>
6772
<groupId>org.projectlombok</groupId>
@@ -80,6 +85,7 @@
8085
<groupId>commons-logging</groupId>
8186
<artifactId>commons-logging</artifactId>
8287
<version>1.2</version>
88+
<scope>provided</scope>
8389
</dependency>
8490

8591
<!-- AWS SDKs -->
@@ -99,48 +105,57 @@
99105
<groupId>com.amazonaws</groupId>
100106
<artifactId>aws-lambda-java-core</artifactId>
101107
<version>1.2.0</version>
108+
<scope>provided</scope>
102109
</dependency>
103110
<dependency>
104111
<groupId>com.amazonaws</groupId>
105112
<artifactId>aws-lambda-java-events</artifactId>
106113
<version>2.2.7</version>
114+
<scope>provided</scope>
107115
</dependency>
108116
<dependency>
109117
<groupId>com.amazonaws</groupId>
110118
<artifactId>aws-java-sdk-core</artifactId>
111119
<version>${aws.sdk.version}</version>
120+
<scope>provided</scope>
112121
</dependency>
113122
<dependency>
114123
<groupId>com.amazonaws</groupId>
115124
<artifactId>aws-java-sdk-lambda</artifactId>
116125
<version>${aws.sdk.version}</version>
126+
<scope>provided</scope>
117127
</dependency>
118128
<dependency>
119129
<groupId>com.amazonaws</groupId>
120130
<artifactId>aws-java-sdk-sqs</artifactId>
121131
<version>${aws.sdk.version}</version>
132+
<scope>provided</scope>
122133
</dependency>
123134

124135
<!-- AWS SDK version 2 libs -->
125136
<dependency>
126137
<groupId>software.amazon.awssdk</groupId>
127138
<artifactId>sns</artifactId>
128-
<version>2.13.36</version>
139+
<version>${aws.sdkv2.version}</version>
140+
<scope>provided</scope>
129141
</dependency>
130142
<dependency>
131143
<groupId>software.amazon.awssdk</groupId>
132144
<artifactId>sqs</artifactId>
133-
<version>2.13.36</version>
145+
<version>${aws.sdkv2.version}</version>
146+
<scope>provided</scope>
134147
</dependency>
135148
<dependency>
136149
<groupId>software.amazon.awssdk</groupId>
137150
<artifactId>kinesis</artifactId>
138-
<version>2.13.36</version>
151+
<version>${aws.sdkv2.version}</version>
152+
<scope>provided</scope>
139153
</dependency>
140154
<dependency>
141155
<groupId>software.amazon.awssdk</groupId>
142156
<artifactId>netty-nio-client</artifactId>
143-
<version>2.13.36</version>
157+
<version>${aws.sdkv2.version}</version>
158+
<scope>provided</scope>
144159
</dependency>
145160

146161

@@ -189,6 +204,32 @@
189204
</dependency>
190205
</dependencies>
191206
</profile>
207+
<profile>
208+
<id>awssdkv1</id>
209+
<dependencies>
210+
211+
</dependencies>
212+
</profile>
213+
<profile>
214+
<id>awssdkv2</id>
215+
<dependencies>
216+
<dependency>
217+
<groupId>software.amazon.awssdk</groupId>
218+
<artifactId>sns</artifactId>
219+
<version>${aws.sdkv2.version}</version>
220+
</dependency>
221+
<dependency>
222+
<groupId>software.amazon.awssdk</groupId>
223+
<artifactId>sqs</artifactId>
224+
<version>${aws.sdkv2.version}</version>
225+
</dependency>
226+
<dependency>
227+
<groupId>software.amazon.awssdk</groupId>
228+
<artifactId>kinesis</artifactId>
229+
<version>${aws.sdkv2.version}</version>
230+
</dependency>
231+
</dependencies>
232+
</profile>
192233
</profiles>
193234

194235
<build>

src/main/java/cloud/localstack/awssdkv2/TestUtils.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@
77
import software.amazon.awssdk.services.sns.*;
88
import software.amazon.awssdk.services.sqs.*;
99
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
10+
import software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder;
11+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
12+
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
13+
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
14+
import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
1015

1116
import cloud.localstack.Localstack;
1217

1318
import java.net.*;
1419

20+
/**
21+
* Utility methods for AWS SDK v2
22+
*/
1523
@SuppressWarnings("all")
1624
public class TestUtils {
1725

18-
/**
19-
* AWS SDK V2 METHODS
20-
*/
21-
2226
public static KinesisAsyncClient getClientKinesisAsyncV2() {
2327
return wrapApiClientV2(KinesisAsyncClient.builder(), Localstack.INSTANCE.getEndpointKinesis()).build();
2428
}
@@ -31,9 +35,9 @@ public static SnsAsyncClient getClientSNSAsyncV2() {
3135
return wrapApiClientV2(SnsAsyncClient.builder(), Localstack.INSTANCE.getEndpointSNS()).build();
3236
}
3337

34-
public static <T extends software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder> T wrapApiClientV2(T builder, String endpointURL) {
38+
public static <T extends SdkAsyncClientBuilder> T wrapApiClientV2(T builder, String endpointURL) {
3539
try {
36-
return (T) ((software.amazon.awssdk.awscore.client.builder.AwsClientBuilder)builder
40+
return (T) ((AwsClientBuilder)builder
3741
.httpClient(NettyNioAsyncHttpClient.builder().buildWithDefaults(
3842
AttributeMap.builder().put(
3943
SdkHttpConfigurationOption.TRUST_ALL_CERTIFICATES, java.lang.Boolean.TRUE).build())))
@@ -45,9 +49,8 @@ public static <T extends software.amazon.awssdk.core.client.builder.SdkAsyncClie
4549
}
4650
}
4751

48-
private static software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialsV2() throws Exception {
49-
return software.amazon.awssdk.auth.credentials.StaticCredentialsProvider.create(
50-
software.amazon.awssdk.auth.credentials.AwsBasicCredentials.create("access", "secret"));
52+
private static AwsCredentialsProvider getCredentialsV2() throws Exception {
53+
return StaticCredentialsProvider.create(AwsBasicCredentials.create("access", "secret"));
5154
}
5255

5356
}

src/test/java/cloud/localstack/CWMetricsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cloud.localstack;
22

33
import cloud.localstack.docker.annotation.LocalstackDockerProperties;
4+
import cloud.localstack.awssdkv1.TestUtils;
5+
46
import com.amazonaws.auth.AWSStaticCredentialsProvider;
57
import com.amazonaws.auth.BasicAWSCredentials;
68
import com.amazonaws.client.builder.AwsClientBuilder;

0 commit comments

Comments
 (0)