Migrate to servlet binder for web features

This commit is contained in:
Dave Syer
2017-08-08 08:27:04 +01:00
parent 540b4d378e
commit 1af0d451cf
107 changed files with 4055 additions and 2010 deletions

View File

@@ -26,6 +26,7 @@
<aws-lambda-events.version>1.2.1</aws-lambda-events.version>
<reactor.version>3.0.7.RELEASE</reactor.version>
<spring-cloud-function.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
<spring-cloud-stream-servlet.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-stream-servlet.version>
<start-class>example.Config</start-class>
</properties>
@@ -36,7 +37,12 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-function-stream</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
@@ -72,6 +78,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
<version>${spring-cloud-stream-servlet.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -1 +1,2 @@
dependencies.spring-cloud-function-web: org.springframework.cloud:spring-cloud-function-web
dependencies.spring-cloud-function-stream: org.springframework.cloud:spring-cloud-function-stream
dependencies.spring-cloud-stream-binder-servlet: org.springframework.cloud:spring-cloud-stream-binder-servlet

View File

@@ -26,17 +26,13 @@
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
@@ -65,6 +61,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
<version>${spring-cloud-stream-servlet.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -16,8 +16,6 @@
package com.example;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,17 +26,16 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
/**
* @author Mark Fisher
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {
"spring.cloud.function.compile.test.lambda=com.example.SampleCompiledConsumerTests.Reference::set",
"spring.cloud.function.compile.test.inputType=String",
"spring.cloud.function.compile.test.type=consumer"
})
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"spring.cloud.function.compile.test.lambda=com.example.SampleCompiledConsumerTests.Reference::set",
"spring.cloud.function.compile.test.inputType=String",
"spring.cloud.function.compile.test.type=consumer" })
public class SampleCompiledConsumerTests {
@LocalServerPort
@@ -47,8 +44,8 @@ public class SampleCompiledConsumerTests {
@Test
public void print() {
assertThat(new TestRestTemplate().postForObject(
"http://localhost:" + port + "/test", "it works",
String.class)).isEqualTo("it works");
"http://localhost:" + port + "/stream/test", "it works", String.class))
.isEqualTo("it works");
assertEquals("it works", Reference.instance);
}

View File

@@ -43,7 +43,7 @@ public class SampleCompiledFunctionTests {
@Test
public void lowercase() {
assertThat(new TestRestTemplate().postForObject(
"http://localhost:" + port + "/test", "it works", String.class))
"http://localhost:" + port + "/stream/test", "it works", String.class))
.isEqualTo("it works!!!");
}

View File

@@ -22,16 +22,18 @@
<java.version>1.8</java.version>
<reactor.version>3.1.1.RELEASE</reactor.version>
<spring-cloud-function.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
<spring-cloud-stream-servlet.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-stream-servlet.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-function-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
<version>${spring-cloud-stream-servlet.version}</version>
</dependency>
</dependencies>

View File

@@ -27,7 +27,11 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-function-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -40,7 +40,7 @@ public class SampleApplicationTests {
@Test
public void words() {
assertThat(new TestRestTemplate()
.getForObject("http://localhost:" + port + "/words", String.class))
.getForObject("http://localhost:" + port + "/stream/words", String.class))
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
}
@@ -48,14 +48,14 @@ public class SampleApplicationTests {
public void uppercase() {
// TODO: make this work with a JSON stream as well (like in WebFlux)
assertThat(new TestRestTemplate().postForObject(
"http://localhost:" + port + "/uppercase", "[{\"value\":\"foo\"}]",
"http://localhost:" + port + "/stream/uppercase", "[{\"value\":\"foo\"}]",
String.class)).isEqualTo("[{\"value\":\"FOO\"}]");
}
@Test
public void lowercase() {
assertThat(new TestRestTemplate().postForObject(
"http://localhost:" + port + "/lowercase", "[{\"value\":\"Foo\"}]",
"http://localhost:" + port + "/stream/lowercase", "[{\"value\":\"Foo\"}]",
String.class)).isEqualTo("[{\"value\":\"foo\"}]");
}

View File

@@ -31,7 +31,11 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -27,11 +27,11 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-web</artifactId>
<artifactId>spring-cloud-function-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -0,0 +1,9 @@
<<<<<<< HEAD:spring-cloud-function-samples/function-sample/src/main/resources/META-INF/thin-stream.properties
boms.spring-cloud-dependencies: org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE
dependencies.spring-cloud-function-stream: org.springframework.cloud:spring-cloud-function-stream:1.0.0.BUILD-SNAPSHOT
dependencies.spring-cloud-stream-rabbit: org.springframework.cloud:spring-cloud-starter-stream-rabbit
=======
boms.spring-cloud-dependencies: org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE
exclusions.spring-cloud-function-stream-binder-servlet: org.springframework.cloud:spring-cloud-stream-binder-servlet
dependencies.spring-cloud-stream-rabbit: org.springframework.cloud:spring-cloud-stream-binder-rabbit
>>>>>>> Migrate to servlet binder for web features:spring-cloud-function-samples/function-sample/src/main/resources/META-INF/thin-rabbit.properties

View File

@@ -1,3 +0,0 @@
boms.spring-cloud-dependencies: org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE
dependencies.spring-cloud-function-stream: org.springframework.cloud:spring-cloud-function-stream:1.0.0.BUILD-SNAPSHOT
dependencies.spring-cloud-stream-rabbit: org.springframework.cloud:spring-cloud-starter-stream-rabbit