-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4750 Java invoke local support for handlers that implement RequestStreamHandler #5954
Merged
pmuens
merged 5 commits into
serverless:master
from
XaeroDegreaz:4750-java-localinvoke-support-requeststreamhandler
Apr 8, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
363361a
#4750 - add support for com.amazonaws.services.lambda.runtime.Request…
8fdc137
add .gitignore entry for intellij project file
56f46ed
fix tests directory
e10bbe9
correctly format the test json payload.
bfd2641
increment invoke-bridge version
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
lib/plugins/aws/invokeLocal/java/src/test/java/com/serverless/InvokeBridgeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
package com.serverless; | |||
|
|||
import static org.junit.Assert.assertNotNull; | |||
|
|||
import org.junit.Before; | |||
import org.junit.Test; | |||
|
|||
public class InvokeBridgeTest { | |||
@Before | |||
public void before() { | |||
System.setProperty("artifactPath", "target/test-classes/com/serverless/RequestStreamHandler.class"); | |||
System.setProperty("className", "com.serverless.RequestStreamHandler"); | |||
System.setProperty("handlerName", "handleRequest"); | |||
} | |||
|
|||
@Test | |||
public void verifyInvoke() { | |||
System.setIn(getClass().getResourceAsStream("/test.json")); | |||
InvokeBridge.main(new String[] {}); | |||
assertNotNull(RequestStreamHandler.input); | |||
} | |||
} |
14 changes: 14 additions & 0 deletions
14
lib/plugins/aws/invokeLocal/java/src/test/java/com/serverless/RequestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
package com.serverless; | |||
|
|||
import java.util.Map; | |||
|
|||
import com.amazonaws.services.lambda.runtime.Context; | |||
|
|||
public class RequestHandler | |||
implements com.amazonaws.services.lambda.runtime.RequestHandler<Map<String,Object>, Object> { | |||
|
|||
@Override | |||
public Object handleRequest(Map<String, Object> stringObjectMap, Context context) { | |||
return "Complete."; | |||
} | |||
} |
34 changes: 34 additions & 0 deletions
34
lib/plugins/aws/invokeLocal/java/src/test/java/com/serverless/RequestStreamHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
package com.serverless; | |||
|
|||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.OutputStream; | |||
import java.io.Serializable; | |||
import java.util.Map; | |||
|
|||
import com.amazonaws.services.lambda.runtime.Context; | |||
import com.fasterxml.jackson.databind.ObjectMapper; | |||
|
|||
public class RequestStreamHandler implements com.amazonaws.services.lambda.runtime.RequestStreamHandler { | |||
static Map<String, Object> input; | |||
@Override | |||
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { | |||
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules(); | |||
input = objectMapper.readValue(inputStream, Map.class); | |||
System.out.println("Input received:" + input); | |||
objectMapper.writeValue(outputStream, new TestPojo("RequestStreamHandler invoke complete.")); | |||
} | |||
|
|||
static private class TestPojo implements Serializable { | |||
private final static Long serialVersionUID = 1L; | |||
private final String message; | |||
|
|||
public TestPojo(String message) { | |||
this.message = message; | |||
} | |||
|
|||
public String getMessage() { | |||
return message; | |||
} | |||
} | |||
} |
37 changes: 37 additions & 0 deletions
37
lib/plugins/aws/invokeLocal/java/src/test/resources/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
{ | |||
"context": {}, | |||
"event": { | |||
"body": "{\"test\":\"data\"}", | |||
"headers": { | |||
"Accept": "*/*", | |||
"Accept-Encoding": "gzip, deflate", | |||
"cache-control": "no-cache", | |||
"CloudFront-Forwarded-Proto": "https", | |||
"CloudFront-Is-Desktop-Viewer": "true", | |||
"CloudFront-Is-Mobile-Viewer": "false", | |||
"CloudFront-Is-SmartTV-Viewer": "false", | |||
"CloudFront-Is-Tablet-Viewer": "false", | |||
"CloudFront-Viewer-Country": "KR", | |||
"Host": "rr4lbbmtfb.execute-api.us-east-1.amazonaws.com", | |||
"Postman-Token": "60d4d786-60bf-4ba5-bcde-5a00ac688041", | |||
"User-Agent": "PostmanRuntime/7.3.0", | |||
"Via": "1.1 17b1095550a8ffe13061114dbfceeb81.cloudfront.net (CloudFront)", | |||
"X-Amz-Cf-Id": "QK3FgYHC89HWK03RsV7L8lJv34WzlFDyHmS0pbbCYtz9WyUCiw7JCQ==", | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Old test dev CF id -- no longer valid. |
|||
"X-Amzn-Trace-Id": "Root=1-5c93c7ca-1f19d2028476793a98d5e844", | |||
"X-Forwarded-For": "211.229.207.20, 52.46.53.147", | |||
"X-Forwarded-Port": "443", | |||
"X-Forwarded-Proto": "https" | |||
}, | |||
"httpMethod": "GET", | |||
"base64Encoded": false, | |||
"path": "/version/12345", | |||
"pathParameters": { | |||
"incomingClientVersion": "12345" | |||
}, | |||
"queryStringParameters": { | |||
"asdasd": "123123" | |||
}, | |||
"stageVariables": null, | |||
"resource": "/version/{incomingClientVersion}" | |||
} | |||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old test dev APP id -- no longer valid.