Move CLI samples to sample repo
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package oz.spring.aws;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FunctionAwsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FunctionAwsApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package oz.spring.aws.functions;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class FunctionConfiguration {
|
||||
|
||||
@Bean
|
||||
public Function<String, String> uppercase() {
|
||||
return value -> value.toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package oz.spring.aws;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.cloud.function.adapter.aws.FunctionInvoker;
|
||||
|
||||
class FunctionAwsApplicationTests {
|
||||
|
||||
@Test
|
||||
void validateFunctionInvocation() throws Exception {
|
||||
System.setProperty("MAIN_CLASS", FunctionAwsApplication.class.getName());
|
||||
FunctionInvoker invoker = new FunctionInvoker("uppercase");
|
||||
|
||||
InputStream targetStream = new ByteArrayInputStream("\"hello aws\"".getBytes());
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
invoker.handleRequest(targetStream, output, null);
|
||||
String result = new String(output.toByteArray(), StandardCharsets.UTF_8);
|
||||
assertThat(result).isEqualTo("\"HELLO AWS\"");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user