Java env alpha (#656)
This change adds support for JVM based environment for running Java functions. This is alpha release of JVM environment and might undergo changes.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package io.fission;
|
||||
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import io.fission.Function;
|
||||
import io.fission.Context;
|
||||
|
||||
public class HelloWorld implements Function {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<?> call(RequestEntity req, Context context) {
|
||||
return ResponseEntity.ok("Hello World!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.fission;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class HelloWorldTest {
|
||||
|
||||
public void testResponse() {
|
||||
HelloWorld hw = new HelloWorld();
|
||||
RequestEntity request = null;
|
||||
try {
|
||||
request = RequestEntity.get(new URI("http://example.com/bar")).build();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ResponseEntity resp = hw.call(request, null);
|
||||
Assert.hasText(resp.getBody().toString(), "Hello World!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user