Skip to content

Commit c97d920

Browse files
committed
fix test for Kinesis Lambda handler
1 parent 8504a13 commit c97d920

File tree

2 files changed

+46
-23
lines changed

2 files changed

+46
-23
lines changed

pom.xml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>cloud.localstack</groupId>
66
<artifactId>localstack-utils</artifactId>
77
<packaging>jar</packaging>
8-
<version>0.2.2</version>
8+
<version>0.2.5</version>
99
<name>localstack-utils</name>
1010

1111
<description>Java utilities for the LocalStack platform.</description>
@@ -33,6 +33,8 @@
3333
<maven.compiler.target>1.8</maven.compiler.target>
3434
<aws.sdk.version>1.11.642</aws.sdk.version>
3535
<aws.sdkv2.version>2.13.39</aws.sdkv2.version>
36+
<commons.lang3.version>3.5</commons.lang3.version>
37+
<lambda.core.version>1.2.0</lambda.core.version>
3638
</properties>
3739

3840
<dependencies>
@@ -53,8 +55,7 @@
5355
<dependency>
5456
<groupId>org.apache.commons</groupId>
5557
<artifactId>commons-lang3</artifactId>
56-
<version>3.5</version>
57-
<scope>provided</scope>
58+
<version>${commons.lang3.version}</version>
5859
</dependency>
5960
<dependency>
6061
<groupId>net.java.dev.jna</groupId>
@@ -104,7 +105,7 @@
104105
<dependency>
105106
<groupId>com.amazonaws</groupId>
106107
<artifactId>aws-lambda-java-core</artifactId>
107-
<version>1.2.0</version>
108+
<version>${lambda.core.version}</version>
108109
<scope>provided</scope>
109110
</dependency>
110111
<dependency>
@@ -203,17 +204,48 @@
203204
<profile>
204205
<id>fatjar</id>
205206
<dependencies>
207+
<!-- TODO: verify whether we still need a separate fatjar profile, or whether
208+
the specified libs could also be added to the test JAR directly. -->
206209
<dependency>
207210
<groupId>com.amazonaws</groupId>
208211
<artifactId>aws-java-sdk</artifactId>
209-
<version>1.11.505</version>
212+
<version>${aws.sdk.version}</version>
213+
</dependency>
214+
<dependency>
215+
<groupId>com.amazonaws</groupId>
216+
<artifactId>aws-java-sdk-core</artifactId>
217+
<version>${aws.sdk.version}</version>
218+
</dependency>
219+
<dependency>
220+
<groupId>com.amazonaws</groupId>
221+
<artifactId>aws-java-sdk-dynamodb</artifactId>
222+
<version>${aws.sdk.version}</version>
223+
</dependency>
224+
<dependency>
225+
<groupId>com.amazonaws</groupId>
226+
<artifactId>aws-lambda-java-core</artifactId>
227+
<version>${lambda.core.version}</version>
228+
</dependency>
229+
<dependency>
230+
<groupId>com.amazonaws</groupId>
231+
<artifactId>aws-lambda-java-events</artifactId>
232+
<version>2.2.7</version>
233+
</dependency>
234+
<dependency>
235+
<groupId>org.apache.commons</groupId>
236+
<artifactId>commons-lang3</artifactId>
237+
<version>${commons.lang3.version}</version>
238+
</dependency>
239+
<dependency>
240+
<groupId>joda-time</groupId>
241+
<artifactId>joda-time</artifactId>
242+
<version>2.6</version>
210243
</dependency>
211244
</dependencies>
212245
</profile>
213246
<profile>
214247
<id>awssdkv1</id>
215248
<dependencies>
216-
217249
</dependencies>
218250
</profile>
219251
<profile>
@@ -273,6 +305,7 @@
273305
<artifactSet>
274306
<includes>
275307
<include>com.amazonaws:aws-java-sdk-core</include>
308+
<include>com.amazonaws:aws-java-sdk-dynamodb</include>
276309
<include>com.amazonaws:aws-java-sdk-kinesis</include>
277310
<include>com.amazonaws:aws-java-sdk-lambda</include>
278311
<include>com.amazonaws:aws-java-sdk-sqs</include>
@@ -294,7 +327,8 @@
294327
<relocations>
295328
<!--Default relocations of-->
296329
<!--http://central.maven.org/maven2/com/amazonaws/aws-java-sdk-bundle/1.11.301/aws-java-sdk-bundle-1.11.301.pom-->
297-
<relocation>
330+
<!-- TODO remove this section..? -->
331+
<!-- <relocation>
298332
<pattern>org.joda</pattern>
299333
<shadedPattern>com.amazonaws.thirdparty.joda</shadedPattern>
300334
</relocation>
@@ -313,7 +347,7 @@
313347
<relocation>
314348
<pattern>software.amazon.ion</pattern>
315349
<shadedPattern>com.amazonaws.thirdparty.ion</shadedPattern>
316-
</relocation>
350+
</relocation> -->
317351
</relocations>
318352
</configuration>
319353
</plugin>

src/test/java/cloud/localstack/sample/KinesisLambdaHandler.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,16 @@
99
/**
1010
* Test Lambda handler class triggered from a Kinesis event
1111
*/
12-
public class KinesisLambdaHandler implements RequestHandler<Object, Object> {
13-
14-
@Override
15-
public Object handleRequest(Object event, Context context) {
16-
if(event instanceof KinesisEvent) {
17-
return handleRequest((KinesisEvent)event, context);
18-
}
19-
return handleRequest((Map<?, ?>)event, context);
20-
}
21-
22-
public Object handleRequest(Map<?, ?> event, Context context) {
23-
System.err.println("Kinesis record: " + event);
24-
return "{}";
25-
}
12+
public class KinesisLambdaHandler implements RequestHandler<KinesisEvent, Object> {
2613

2714
public Object handleRequest(KinesisEvent event, Context context) {
15+
String result = "";
2816
for (KinesisEvent.KinesisEventRecord rec : event.getRecords()) {
2917
String msg = new String(rec.getKinesis().getData().array());
3018
System.err.println("Kinesis record: " + msg);
19+
result += msg + " ";
3120
}
32-
return "{}";
21+
return result;
3322
}
3423

3524
}

0 commit comments

Comments
 (0)