Skip to content

Commit 6f5493c

Browse files
committed
Add specific 8-friendly test and pom for boilerplate test.
1 parent e2e131c commit 6f5493c

5 files changed

Lines changed: 87 additions & 3 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
schema_version: 20180708
2+
name: hellofunc
3+
version: 0.0.1
4+
runtime: java8
5+
cmd: com.fnproject.fn.integration.hello.HelloFunction::handleRequest
6+
format: http-stream
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<properties>
7+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
8+
<fdk.version>1.0.0-SNAPSHOT</fdk.version>
9+
</properties>
10+
<groupId>com.example.fn</groupId>
11+
<artifactId>hello-func</artifactId>
12+
<version>1.0.0</version>
13+
14+
<repositories>
15+
<repository>
16+
<id>fn-release-repo</id>
17+
<url>https://dl.bintray.com/fnproject/fnproject</url>
18+
</repository>
19+
</repositories>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.fnproject.fn</groupId>
24+
<artifactId>api</artifactId>
25+
<version>${fdk.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.fnproject.fn</groupId>
29+
<artifactId>testing-core</artifactId>
30+
<version>${fdk.version}</version>
31+
<scope>test</scope>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.fnproject.fn</groupId>
35+
<artifactId>testing-junit4</artifactId>
36+
<version>${fdk.version}</version>
37+
<scope>test</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>junit</groupId>
41+
<artifactId>junit</artifactId>
42+
<version>4.12</version>
43+
<scope>test</scope>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-compiler-plugin</artifactId>
52+
<version>3.3</version>
53+
<configuration>
54+
<source>8</source>
55+
<target>8</target>
56+
</configuration>
57+
</plugin>
58+
<plugin>
59+
<groupId>org.apache.maven.plugins</groupId>
60+
<artifactId>maven-surefire-plugin</artifactId>
61+
<version>2.22.1</version>
62+
<configuration>
63+
<useSystemClassLoader>false</useSystemClassLoader>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.fnproject.fn.integration.hello;
2+
3+
public class HelloFunction {
4+
public String handleRequest(String input) {
5+
String name = (input == null || input.isEmpty()) ? "world" : input;
6+
return "Hello, " + name + "!";
7+
}
8+
}

integration-tests/src/main/java/com/fnproject/fn/integrationtest/IntegrationTestRule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ public CmdResult runFnWithInput(String input, String... args) throws Exception {
153153
CmdResult res = runFnWithInputAllowError(input, args);
154154

155155
if (res.isSuccess() == false) {
156-
System.out.println(res.toString());
156+
System.err.println(res.toString());
157157
}
158-
Assertions.assertThat(res.isSuccess()).withFailMessage("Expected command '" + res.cmd + "' to return 0. " + res).isTrue();
158+
159+
Assertions.assertThat(res.isSuccess()).withFailMessage("Expected command '" + res.cmd + "' to return 0.").isTrue();
159160
return res;
160161
}
161162

integration-tests/src/test/java/com/fnproject/fn/integrationtest/FunctionsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ public void checkBoilerPlate() throws Exception {
4848
for (String format : new String[]{"http-stream"}) {
4949
for (String runtime : new String[]{"java9", "java8"}) {
5050
IntegrationTestRule.TestContext tc = testRule.newTest();
51-
String fnName = "bp" + format + runtime;
51+
tc.withDirFrom("funcs/hellofunc");
5252

53+
String fnName = "bp" + format + runtime;
5354
tc.runFn("init", "--runtime", runtime, "--name", fnName, "--format", format);
5455
tc.rewritePOM();
5556
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");

0 commit comments

Comments
 (0)