Skip to content

Commit

Permalink
Update AWS Java Hamcrest
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Serth <[email protected]>
  • Loading branch information
mpass99 and MrSerth committed Sep 22, 2024
1 parent c91cdf5 commit b966aac
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions deploy/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project contains source code and supporting files for a serverless applicat
The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.

See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for deployment, usage and an introduction to SAM specification, the SAM CLI, and serverless application concepts.
[The AWS Toolkit Plugin](https://aws.amazon.com/de/intellij/) helps build the Lambda function without errors.

## Interface

Expand Down
4 changes: 2 additions & 2 deletions deploy/aws/java11Exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<artifactId>hamcrest</artifactId>
<version>3.0</version>
</dependency>
</dependencies>
Expand Down
2 changes: 2 additions & 0 deletions deploy/aws/java11Exec/src/main/java/poseidon/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayV2WebSocketEve

ProcessBuilder pb = new ProcessBuilder(cmd);
pb.directory(workingDirectory);
Map<String, String> env = pb.environment();
env.put("CLASSPATH", ".:/var/task/lib/org.hamcrest.hamcrest-3.0.jar:/var/task/lib/junit.junit-4.13.2.jar:" + env.get("CLASSPATH"));
Process p = pb.start();
InputStream stdout = p.getInputStream(), stderr = p.getErrorStream();
this.forwardOutput(p, stdout, stderr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ private void parseRules(String makefile) {
.map(s -> s.startsWith("@") ? s.substring(1) : s)
.map(s -> s.contains("#") ? s.substring(0, s.indexOf("#")) : s)
.filter(s -> !s.isEmpty())
.map(s -> s.replaceAll("/usr/java/lib/hamcrest-core-1\\.3\\.jar", "/var/task/lib/org.hamcrest.hamcrest-core-1.3.jar"))
.map(s -> s.replaceAll("/usr/java/lib/junit-4\\.13\\.jar", "/var/task/lib/junit.junit-4.13.2.jar"))
.toArray(String[]::new);

rules.put(ruleName, trimmedCommands);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class SimpleMakefileTest {

static final String SuccessfulMakefileWithAssignments = Base64.getEncoder().encodeToString(
("test:\n" +
"\tjavac -encoding utf8 -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.13.jar ${FILENAME}\n" +
"\tjava -Dfile.encoding=UTF8 -cp .:/usr/java/lib/hamcrest-core-1.3.jar:/usr/java/lib/junit-4.13.jar org.junit.runner.JUnitCore ${CLASS_NAME}\n"
"\tjavac -encoding utf8 ${FILENAME}\n" +
"\tjava -Dfile.encoding=UTF8 ${CLASS_NAME}\n"
).getBytes(StandardCharsets.UTF_8));

static final String SuccessfulMakefileWithComment = Base64.getEncoder().encodeToString(
Expand Down Expand Up @@ -126,8 +126,8 @@ public void sucessfullMakeWithAssignments() {
SimpleMakefile make = new SimpleMakefile(files);
String cmd = make.parseCommand(command);

assertEquals("javac -encoding utf8 -cp .:/var/task/lib/org.hamcrest.hamcrest-core-1.3.jar:/var/task/lib/junit.junit-4.13.2.jar RecursiveMath-Test.java && " +
"java -Dfile.encoding=UTF8 -cp .:/var/task/lib/org.hamcrest.hamcrest-core-1.3.jar:/var/task/lib/junit.junit-4.13.2.jar org.junit.runner.JUnitCore RecursiveMath", cmd);
assertEquals("javac -encoding utf8 RecursiveMath-Test.java && " +
"java -Dfile.encoding=UTF8 RecursiveMath", cmd);
} catch (NoMakefileFoundException | InvalidMakefileException | NoMakeCommandException ignored) {
fail();
}
Expand Down

0 comments on commit b966aac

Please sign in to comment.