generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9195a50
commit e7fca8e
Showing
4 changed files
with
102 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
schema_version: 20180708 | ||
name: hello-java | ||
version: 0.0.1 | ||
runtime: java | ||
build_image: fnproject/fn-java-fdk-build:jdk17-1.0.192 | ||
run_image: fnproject/fn-java-fdk:jre17-1.0.192 | ||
cmd: com.example.fn.HelloFunction::handleRequest |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<fdk.version>1.0.192</fdk.version> | ||
</properties> | ||
<groupId>com.example.fn</groupId> | ||
<artifactId>hello</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.fnproject.fn</groupId> | ||
<artifactId>api</artifactId> | ||
<version>${fdk.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fnproject.fn</groupId> | ||
<artifactId>testing-core</artifactId> | ||
<version>${fdk.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fnproject.fn</groupId> | ||
<artifactId>testing-junit4</artifactId> | ||
<version>${fdk.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>17</source> | ||
<target>17</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
<configuration> | ||
<useSystemClassLoader>false</useSystemClassLoader> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
fn-ci-cd-deployment-pipeline/hello-java/src/main/java/com/example/fn/HelloFunction.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.fn; | ||
|
||
public class HelloFunction { | ||
|
||
public String handleRequest(String input) { | ||
String name = (input == null || input.isEmpty()) ? "world" : input; | ||
|
||
System.out.println("Inside Java Hello World function"); | ||
return "Hello, " + name + "!"; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
fn-ci-cd-deployment-pipeline/hello-java/src/test/java/com/example/fn/HelloFunctionTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.example.fn; | ||
|
||
import com.fnproject.fn.testing.*; | ||
import org.junit.*; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class HelloFunctionTest { | ||
|
||
@Rule | ||
public final FnTestingRule testing = FnTestingRule.createDefault(); | ||
|
||
@Test | ||
public void shouldReturnGreeting() { | ||
testing.givenEvent().enqueue(); | ||
testing.thenRun(HelloFunction.class, "handleRequest"); | ||
|
||
FnResult result = testing.getOnlyResult(); | ||
assertEquals("Hello, world!", result.getBodyAsString()); | ||
} | ||
|
||
} |