diff --git a/spring-cloud-function-samples/function-sample/pom.xml b/spring-cloud-function-samples/function-sample/pom.xml index 5458c4193..280ec7572 100644 --- a/spring-cloud-function-samples/function-sample/pom.xml +++ b/spring-cloud-function-samples/function-sample/pom.xml @@ -29,11 +29,6 @@ org.springframework.cloud spring-cloud-starter-function-webflux - - org.springframework.cloud - spring-cloud-function-compiler - ${spring-cloud-function.version} - org.springframework.boot spring-boot-configuration-processor diff --git a/spring-cloud-function-samples/function-sample/src/main/java/com/example/SampleApplication.java b/spring-cloud-function-samples/function-sample/src/main/java/com/example/SampleApplication.java index 8f3097b0f..0274d8c08 100644 --- a/spring-cloud-function-samples/function-sample/src/main/java/com/example/SampleApplication.java +++ b/spring-cloud-function-samples/function-sample/src/main/java/com/example/SampleApplication.java @@ -23,10 +23,7 @@ import reactor.core.publisher.Flux; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.function.compiler.FunctionCompiler; -import org.springframework.cloud.function.compiler.proxy.LambdaCompilingFunction; import org.springframework.context.annotation.Bean; -import org.springframework.core.io.ByteArrayResource; // @checkstyle:off @SpringBootApplication @@ -56,28 +53,5 @@ public class SampleApplication { return () -> Flux.fromArray(new String[] {"foo", "bar"}); } - @Bean - public Function compiledUppercase( - FunctionCompiler compiler) { - String lambda = "s -> s.toUpperCase()"; - LambdaCompilingFunction function = new LambdaCompilingFunction<>( - new ByteArrayResource(lambda.getBytes()), compiler); - function.setTypeParameterizations("String", "String"); - return function; - } - - @Bean - public Function, Flux> compiledLowercase( - FunctionCompiler, Flux> compiler) { - String lambda = "f->f.map(o->o.toString().toLowerCase())"; - return new LambdaCompilingFunction<>(new ByteArrayResource(lambda.getBytes()), - compiler); - } - - @Bean - public FunctionCompiler compiler() { - return new FunctionCompiler<>(); - } - } // @checkstyle:on diff --git a/spring-cloud-function-samples/function-sample/src/test/java/com/example/SampleApplicationTests.java b/spring-cloud-function-samples/function-sample/src/test/java/com/example/SampleApplicationTests.java deleted file mode 100644 index 2e55283aa..000000000 --- a/spring-cloud-function-samples/function-sample/src/test/java/com/example/SampleApplicationTests.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; - -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import reactor.core.publisher.Flux; - -@SpringBootTest -public class SampleApplicationTests { - - @Autowired - private Function uppercase; - @Autowired - private Function, Flux> lowercase; - @Autowired - private Supplier hello; - @Autowired - private Supplier> words; - @Autowired - private Function compiledUppercase; - @Autowired - private Function, Flux> compiledLowercase; - @Autowired - private Function greeter; - @Autowired - private Function, Flux> exclaimer; - @Autowired - private Function charCounter; - - @Test - public void contextLoads() { - } - - @Test - public void testUppercase() { - String output = this.uppercase.apply("foobar"); - assertThat(output).isEqualTo("FOOBAR"); - } - - @Test - public void testLowercase() { - Flux output = this.lowercase.apply(Flux.just("FOO", "BAR")); - List results = output.collectList().block(); - assertThat(results.size()).isEqualTo(2); - assertThat(results.get(0)).isEqualTo("foo"); - assertThat(results.get(1)).isEqualTo("bar"); - } - - @Test - public void testHello() { - String output = this.hello.get(); - assertThat(output).isEqualTo("hello"); - } - - // the following are contributed via @FunctionScan: - - @Test - public void testWords() { - Flux output = this.words.get(); - List results = output.collectList().block(); - assertThat(results.size()).isEqualTo(2); - assertThat(results.get(0)).isEqualTo("foo"); - assertThat(results.get(1)).isEqualTo("bar"); - } - - @Test - public void testCompiledUppercase() { - String output = this.compiledUppercase.apply("foobar"); - assertThat(output).isEqualTo("FOOBAR"); - } - - @Test - public void testCompiledLowercase() { - Flux input = Flux.just("FOO", "BAR"); - Flux output = this.compiledLowercase.apply(input); - List results = output.collectList().block(); - assertThat(results.size()).isEqualTo(2); - assertThat(results.get(0)).isEqualTo("foo"); - assertThat(results.get(1)).isEqualTo("bar"); - } - - @Test - public void testGreeter() { - String greeting = this.greeter.apply("World"); - assertThat(greeting).isEqualTo("Hello World"); - } - - @Test - public void testExclaimer() { - Flux input = Flux.just("foo", "bar"); - Flux output = this.exclaimer.apply(input); - List results = output.collectList().block(); - assertThat(results.size()).isEqualTo(2); - assertThat(results.get(0)).isEqualTo("foo!!!"); - assertThat(results.get(1)).isEqualTo("bar!!!"); - } - - @Test - public void testCharCounter() { - Integer length = this.charCounter.apply("the quick brown fox"); - assertThat(length).isEqualTo(19); - } - -} diff --git a/spring-cloud-function-samples/function-sample/src/test/java/com/example/WebTestClientTests.java b/spring-cloud-function-samples/function-sample/src/test/java/com/example/WebTestClientTests.java index e0f7e6664..c74216e7b 100644 --- a/spring-cloud-function-samples/function-sample/src/test/java/com/example/WebTestClientTests.java +++ b/spring-cloud-function-samples/function-sample/src/test/java/com/example/WebTestClientTests.java @@ -43,25 +43,6 @@ public class WebTestClientTests { .expectStatus().isOk().expectBody(String.class).isEqualTo("[\"foo\"]"); } - @Test - public void testStream() { - - List asObjectExpect = new ArrayList<>(); - asObjectExpect.add("foobar"); - - //as object - client.post().uri("/lowercase").accept(MediaType.TEXT_EVENT_STREAM).body(Flux.just("FOO", "BAR"), String.class) - .exchange().expectBodyList(String.class).isEqualTo(asObjectExpect); - - List asFluxExpect = new ArrayList<>(); - asFluxExpect.add("foo"); - asFluxExpect.add("bar"); - - //as flux - client.post().uri("/lowercase").accept(MediaType.TEXT_EVENT_STREAM).body(Flux.just("FOO\n", "BAR\n"), String.class) - .exchange().expectBodyList(String.class).isEqualTo(asFluxExpect); - } - @Test public void testCollection() { client.post().uri("/lowercase").contentType(MediaType.APPLICATION_JSON).body(Mono.just("[\"FOO\", \"BAR\"]"), String.class)