Explorar o código

Update WebFlux samples to use Spring Boot

Fixes: gh-5411
Rob Winch %!s(int64=7) %!d(string=hai) anos
pai
achega
a9e6d7606e
Modificáronse 39 ficheiros con 286 adicións e 536 borrados
  1. 12 0
      samples/boot/hellowebflux-method/spring-security-samples-boot-hellowebflux-method.gradle
  2. 30 43
      samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java
  3. 32 0
      samples/boot/hellowebflux-method/src/main/java/sample/HelloWebfluxMethodApplication.java
  4. 0 0
      samples/boot/hellowebflux-method/src/main/java/sample/HelloWorldMessageService.java
  5. 0 0
      samples/boot/hellowebflux-method/src/main/java/sample/MessageController.java
  6. 0 0
      samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java
  7. 14 21
      samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java
  8. 2 4
      samples/boot/hellowebflux-method/src/test/java/sample/HelloWorldMessageServiceTests.java
  9. 11 0
      samples/boot/hellowebflux/spring-security-samples-boot-hellowebflux.gradle
  10. 10 21
      samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java
  11. 0 0
      samples/boot/hellowebflux/src/main/java/sample/HelloUserController.java
  12. 33 0
      samples/boot/hellowebflux/src/main/java/sample/HelloWebfluxApplication.java
  13. 0 0
      samples/boot/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java
  14. 16 21
      samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java
  15. 11 0
      samples/boot/hellowebfluxfn/spring-security-samples-boot-hellowebfluxfn.gradle
  16. 10 20
      samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java
  17. 0 0
      samples/boot/hellowebfluxfn/src/main/java/sample/HelloUserController.java
  18. 44 0
      samples/boot/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnApplication.java
  19. 0 0
      samples/boot/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java
  20. 17 24
      samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java
  21. 5 8
      samples/boot/webflux-form/spring-security-samples-boot-webflux-form.gradle
  22. 7 7
      samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java
  23. 0 0
      samples/boot/webflux-form/src/integration-test/java/sample/webdriver/IndexPage.java
  24. 0 0
      samples/boot/webflux-form/src/integration-test/java/sample/webdriver/LoginPage.java
  25. 0 0
      samples/boot/webflux-form/src/main/java/sample/CsrfControllerAdvice.java
  26. 0 0
      samples/boot/webflux-form/src/main/java/sample/IndexController.java
  27. 32 0
      samples/boot/webflux-form/src/main/java/sample/WebfluxFormApplication.java
  28. 0 0
      samples/boot/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java
  29. 0 0
      samples/boot/webflux-form/src/main/resources/logback.xml
  30. 0 0
      samples/boot/webflux-form/src/main/resources/templates/index.html
  31. 0 0
      samples/boot/webflux-form/src/main/resources/templates/login.html
  32. 0 16
      samples/javaconfig/hellowebflux-method/spring-security-samples-javaconfig-hellowebflux-method.gradle
  33. 0 56
      samples/javaconfig/hellowebflux-method/src/main/java/sample/HelloWebfluxMethodApplication.java
  34. 0 17
      samples/javaconfig/hellowebflux/spring-security-samples-javaconfig-hellowebflux.gradle
  35. 0 55
      samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxApplication.java
  36. 0 16
      samples/javaconfig/hellowebfluxfn/spring-security-samples-javaconfig-hellowebfluxfn.gradle
  37. 0 75
      samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnApplication.java
  38. 0 76
      samples/javaconfig/webflux-form/src/main/java/sample/ThymeleafConfig.java
  39. 0 56
      samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormApplication.java

+ 12 - 0
samples/boot/hellowebflux-method/spring-security-samples-boot-hellowebflux-method.gradle

@@ -0,0 +1,12 @@
+apply plugin: 'io.spring.convention.spring-sample-boot'
+
+dependencies {
+	compile project(':spring-security-core')
+	compile project(':spring-security-config')
+	compile project(':spring-security-web')
+	compile 'org.springframework.boot:spring-boot-starter-webflux'
+
+	testCompile project(':spring-security-test')
+	testCompile 'io.projectreactor:reactor-test'
+	testCompile 'org.springframework.boot:spring-boot-starter-test'
+}

+ 30 - 43
samples/javaconfig/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java → samples/boot/hellowebflux-method/src/integration-test/java/sample/HelloWebfluxMethodApplicationITests.java

@@ -15,75 +15,65 @@
  */
 package sample;
 
-import org.junit.Before;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
+import java.util.Map;
+import java.util.function.Consumer;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.http.HttpStatus;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
-
-import java.nio.charset.Charset;
-import java.time.Duration;
-import java.util.Base64;
-import java.util.Map;
-import java.util.function.Consumer;
-
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
+import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
 
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
-@TestPropertySource(properties = "server.port=0")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 public class HelloWebfluxMethodApplicationITests {
-	@Value("#{@nettyContext.address().getPort()}")
-	int port;
 
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
-		this.rest = WebTestClient.bindToServer()
-				.filter(basicAuthentication())
-				.responseTimeout(Duration.ofDays(1))
-				.baseUrl("http://localhost:" + this.port)
-				.build();
+	@Autowired
+	public void setRest(WebTestClient rest) {
+		this.rest = rest
+				.mutateWith((b, h, c) -> b.filter(ExchangeFilterFunctions.basicAuthentication()));
 	}
 
+
 	@Test
 	public void messageWhenNotAuthenticated() throws Exception {
 		this.rest
-			.get()
-			.uri("/message")
-			.exchange()
-			.expectStatus().isUnauthorized();
+				.get()
+				.uri("/message")
+				.exchange()
+				.expectStatus().isUnauthorized();
 	}
 
 	@Test
 	public void messageWhenUserThenForbidden() throws Exception {
 		this.rest
-			.get()
-			.uri("/message")
-			.attributes(robsCredentials())
-			.exchange()
-			.expectStatus().isEqualTo(HttpStatus.FORBIDDEN);
+				.get()
+				.uri("/message")
+				.attributes(robsCredentials())
+				.exchange()
+				.expectStatus().isEqualTo(HttpStatus.FORBIDDEN);
 	}
 
 	@Test
 	public void messageWhenAdminThenOk() throws Exception {
 		this.rest
-			.get()
-			.uri("/message")
-			.attributes(adminCredentials())
-			.exchange()
-			.expectStatus().isOk()
-			.expectBody(String.class).isEqualTo("Hello World!");
+				.get()
+				.uri("/message")
+				.attributes(adminCredentials())
+				.exchange()
+				.expectStatus().isOk()
+				.expectBody(String.class).isEqualTo("Hello World!");
 	}
 
 	private Consumer<Map<String, Object>> robsCredentials() {
@@ -93,8 +83,5 @@ public class HelloWebfluxMethodApplicationITests {
 	private Consumer<Map<String, Object>> adminCredentials() {
 		return basicAuthenticationCredentials("admin", "admin");
 	}
-
-	private String base64Encode(String value) {
-		return Base64.getEncoder().encodeToString(value.getBytes(Charset.defaultCharset()));
-	}
 }
+

+ 32 - 0
samples/boot/hellowebflux-method/src/main/java/sample/HelloWebfluxMethodApplication.java

@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-2017 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
+ *
+ *      http://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 sample;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author Rob Winch
+ * @since 5.0
+ */
+@SpringBootApplication
+public class HelloWebfluxMethodApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(HelloWebfluxMethodApplication.class, args);
+	}
+}

+ 0 - 0
samples/javaconfig/hellowebflux-method/src/main/java/sample/HelloWorldMessageService.java → samples/boot/hellowebflux-method/src/main/java/sample/HelloWorldMessageService.java


+ 0 - 0
samples/javaconfig/hellowebflux-method/src/main/java/sample/MessageController.java → samples/boot/hellowebflux-method/src/main/java/sample/MessageController.java


+ 0 - 0
samples/javaconfig/hellowebflux-method/src/main/java/sample/SecurityConfig.java → samples/boot/hellowebflux-method/src/main/java/sample/SecurityConfig.java


+ 14 - 21
samples/javaconfig/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java → samples/boot/hellowebflux-method/src/test/java/sample/HelloWebfluxMethodApplicationTests.java

@@ -15,48 +15,41 @@
  */
 package sample;
 
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
 import java.util.Map;
 import java.util.function.Consumer;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.ApplicationContext;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
 
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
-
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
-@ActiveProfiles("test")
+@SpringBootTest
 public class HelloWebfluxMethodApplicationTests {
-	@Autowired
-	ApplicationContext context;
-
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
+	@Autowired
+	public void setup(ApplicationContext context) {
 		this.rest = WebTestClient
-			.bindToApplicationContext(this.context)
-			.apply(springSecurity())
-			.configureClient()
-			.filter(basicAuthentication())
-			.build();
+				.bindToApplicationContext(context)
+				.apply(springSecurity())
+				.configureClient()
+				.filter(basicAuthentication())
+				.build();
 	}
 
 	@Test

+ 2 - 4
samples/javaconfig/hellowebflux-method/src/test/java/sample/HelloWorldMessageServiceTests.java → samples/boot/hellowebflux-method/src/test/java/sample/HelloWorldMessageServiceTests.java

@@ -19,10 +19,9 @@ package sample;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.security.access.AccessDeniedException;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import reactor.test.StepVerifier;
 
@@ -31,8 +30,7 @@ import reactor.test.StepVerifier;
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
-@ActiveProfiles("test")
+@SpringBootTest
 public class HelloWorldMessageServiceTests {
 	@Autowired
 	HelloWorldMessageService messages;

+ 11 - 0
samples/boot/hellowebflux/spring-security-samples-boot-hellowebflux.gradle

@@ -0,0 +1,11 @@
+apply plugin: 'io.spring.convention.spring-sample-boot'
+
+dependencies {
+	compile project(':spring-security-core')
+	compile project(':spring-security-config')
+	compile project(':spring-security-web')
+	compile 'org.springframework.boot:spring-boot-starter-webflux'
+
+	testCompile project(':spring-security-test')
+	testCompile 'org.springframework.boot:spring-boot-starter-test'
+}

+ 10 - 21
samples/javaconfig/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java → samples/boot/hellowebflux/src/integration-test/java/sample/HelloWebfluxApplicationITests.java

@@ -15,46 +15,35 @@
  */
 package sample;
 
-import java.time.Duration;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
 import java.util.Map;
 import java.util.function.Consumer;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
-
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
 
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxApplication.class)
-@TestPropertySource(properties = "server.port=0")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 public class HelloWebfluxApplicationITests {
-	@Value("#{@nettyContext.address().getPort()}")
-	int port;
 
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
-		this.rest = WebTestClient.bindToServer()
-				.responseTimeout(Duration.ofDays(1))
-				.baseUrl("http://localhost:" + this.port)
-				.filter(basicAuthentication())
-				.build();
+	@Autowired
+	public void setRest(WebTestClient rest) {
+		this.rest = rest
+				.mutateWith((b, h, c) -> b.filter(ExchangeFilterFunctions.basicAuthentication()));
 	}
 
-
 	@Test
 	public void basicWhenNoCredentialsThenUnauthorized() throws Exception {
 		this.rest

+ 0 - 0
samples/javaconfig/hellowebflux/src/main/java/sample/HelloUserController.java → samples/boot/hellowebflux/src/main/java/sample/HelloUserController.java


+ 33 - 0
samples/boot/hellowebflux/src/main/java/sample/HelloWebfluxApplication.java

@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-2017 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
+ *
+ *      http://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 sample;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author Rob Winch
+ * @since 5.0
+ */
+@SpringBootApplication
+public class HelloWebfluxApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(HelloWebfluxApplication.class, args);
+	}
+
+}

+ 0 - 0
samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java → samples/boot/hellowebflux/src/main/java/sample/HelloWebfluxSecurityConfig.java


+ 16 - 21
samples/javaconfig/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java → samples/boot/hellowebflux/src/test/java/sample/HelloWebfluxApplicationTests.java

@@ -15,47 +15,42 @@
  */
 package sample;
 
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
 import java.util.Map;
 import java.util.function.Consumer;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.ApplicationContext;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
 
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
-
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxApplication.class)
-@ActiveProfiles("test")
+@SpringBootTest
+@AutoConfigureWebTestClient
 public class HelloWebfluxApplicationTests {
-	@Autowired
-	ApplicationContext context;
-
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
+	@Autowired
+	public void setup(ApplicationContext context) {
 		this.rest = WebTestClient
-			.bindToApplicationContext(this.context)
-			.apply(springSecurity())
-			.configureClient()
-			.filter(basicAuthentication())
-			.build();
+				.bindToApplicationContext(context)
+				.apply(springSecurity())
+				.configureClient()
+				.filter(basicAuthentication())
+				.build();
 	}
 
 	@Test

+ 11 - 0
samples/boot/hellowebfluxfn/spring-security-samples-boot-hellowebfluxfn.gradle

@@ -0,0 +1,11 @@
+apply plugin: 'io.spring.convention.spring-sample-boot'
+
+dependencies {
+	compile project(':spring-security-core')
+	compile project(':spring-security-config')
+	compile project(':spring-security-web')
+	compile 'org.springframework.boot:spring-boot-starter-webflux'
+
+	testCompile project(':spring-security-test')
+	testCompile 'org.springframework.boot:spring-boot-starter-test'
+}

+ 10 - 20
samples/javaconfig/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java → samples/boot/hellowebfluxfn/src/integration-test/java/sample/HelloWebfluxFnApplicationITests.java

@@ -15,43 +15,33 @@
  */
 package sample;
 
-import java.time.Duration;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
 import java.util.Map;
 import java.util.function.Consumer;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
-
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+import org.springframework.web.reactive.function.client.ExchangeFilterFunctions;
 
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxFnApplication.class)
-@TestPropertySource(properties = "server.port=0")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 public class HelloWebfluxFnApplicationITests {
-	@Value("#{@nettyContext.address().getPort()}")
-	int port;
 
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
-		this.rest = WebTestClient.bindToServer()
-				.responseTimeout(Duration.ofDays(1))
-				.baseUrl("http://localhost:" + this.port)
-				.filter(basicAuthentication())
-				.build();
+	@Autowired
+	public void setRest(WebTestClient rest) {
+		this.rest = rest
+				.mutateWith((b, h, c) -> b.filter(ExchangeFilterFunctions.basicAuthentication()));
 	}
 
 	@Test

+ 0 - 0
samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloUserController.java → samples/boot/hellowebfluxfn/src/main/java/sample/HelloUserController.java


+ 44 - 0
samples/boot/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnApplication.java

@@ -0,0 +1,44 @@
+/*
+ * Copyright 2002-2017 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
+ *
+ *      http://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 sample;
+
+import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
+import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.reactive.function.server.RouterFunction;
+import org.springframework.web.reactive.function.server.ServerResponse;
+
+/**
+ * @author Rob Winch
+ * @since 5.0
+ */
+@SpringBootApplication
+public class HelloWebfluxFnApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(HelloWebfluxFnApplication.class, args);
+	}
+
+	@Bean
+	public RouterFunction<ServerResponse> routes(HelloUserController userController) {
+		return route(
+			GET("/"), userController::hello);
+	}
+}

+ 0 - 0
samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java → samples/boot/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnSecurityConfig.java


+ 17 - 24
samples/javaconfig/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java → samples/boot/hellowebfluxfn/src/test/java/sample/HelloWebfluxFnApplicationTests.java

@@ -15,50 +15,43 @@
  */
 package sample;
 
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
+import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
+import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
+
 import java.util.Map;
 import java.util.function.Consumer;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.security.web.server.WebFilterChainProxy;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
-import org.springframework.web.reactive.function.server.RouterFunction;
-
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.mockUser;
-import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
 
 /**
  * @author Rob Winch
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = HelloWebfluxFnApplication.class)
-@ActiveProfiles("test")
+@SpringBootTest
+@AutoConfigureWebTestClient
 public class HelloWebfluxFnApplicationTests {
-	@Autowired
-	RouterFunction<?> routerFunction;
-	@Autowired WebFilterChainProxy springSecurityFilterChain;
 
 	WebTestClient rest;
 
-	@Before
-	public void setup() {
+	@Autowired
+	public void setup(ApplicationContext context) {
 		this.rest = WebTestClient
-			.bindToRouterFunction(this.routerFunction)
-			.webFilter(this.springSecurityFilterChain)
-			.apply(springSecurity())
-			.configureClient()
-			.filter(basicAuthentication())
-			.build();
+				.bindToApplicationContext(context)
+				.apply(springSecurity())
+				.configureClient()
+				.filter(basicAuthentication())
+				.build();
 	}
 
 	@Test

+ 5 - 8
samples/javaconfig/webflux-form/spring-security-samples-javaconfig-webflux-form.gradle → samples/boot/webflux-form/spring-security-samples-boot-webflux-form.gradle

@@ -14,24 +14,21 @@
  * limitations under the License.
  */
 
-apply plugin: 'io.spring.convention.spring-sample'
+apply plugin: 'io.spring.convention.spring-sample-boot'
 
 dependencies {
 	compile project(':spring-security-core')
 	compile project(':spring-security-config')
 	compile project(':spring-security-web')
-	compile 'com.fasterxml.jackson.core:jackson-databind'
-	compile 'io.netty:netty-buffer'
-	compile 'io.projectreactor.ipc:reactor-netty'
-	compile 'org.springframework:spring-context'
-	compile 'org.springframework:spring-webflux'
-	compile 'org.thymeleaf:thymeleaf-spring5'
-	compile slf4jDependencies
+	compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
+	compile 'org.springframework.boot:spring-boot-starter-webflux'
 
 	testCompile project(':spring-security-test')
+	testCompile 'org.springframework.boot:spring-boot-starter-test'
 	testCompile 'io.projectreactor:reactor-test'
 	testCompile 'org.skyscreamer:jsonassert'
 	testCompile 'org.springframework:spring-test'
 
 	integrationTestCompile seleniumDependencies
 }
+

+ 7 - 7
samples/javaconfig/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java → samples/boot/webflux-form/src/integration-test/java/sample/WebfluxFormApplicationTests.java

@@ -15,16 +15,17 @@
  */
 package sample;
 
-import com.gargoylesoftware.htmlunit.BrowserVersion;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.server.LocalServerPort;
 import org.springframework.test.context.junit4.SpringRunner;
+
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+
 import sample.webdriver.IndexPage;
 import sample.webdriver.LoginPage;
 
@@ -33,12 +34,11 @@ import sample.webdriver.LoginPage;
  * @since 5.0
  */
 @RunWith(SpringRunner.class)
-@ContextConfiguration(classes = WebfluxFormApplication.class)
-@TestPropertySource(properties = "server.port=0")
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 public class WebfluxFormApplicationTests {
 	WebDriver driver;
 
-	@Value("#{@nettyContext.address().getPort()}")
+	@LocalServerPort
 	int port;
 
 	@Before

+ 0 - 0
samples/javaconfig/webflux-form/src/integration-test/java/sample/webdriver/IndexPage.java → samples/boot/webflux-form/src/integration-test/java/sample/webdriver/IndexPage.java


+ 0 - 0
samples/javaconfig/webflux-form/src/integration-test/java/sample/webdriver/LoginPage.java → samples/boot/webflux-form/src/integration-test/java/sample/webdriver/LoginPage.java


+ 0 - 0
samples/javaconfig/webflux-form/src/main/java/sample/CsrfControllerAdvice.java → samples/boot/webflux-form/src/main/java/sample/CsrfControllerAdvice.java


+ 0 - 0
samples/javaconfig/webflux-form/src/main/java/sample/IndexController.java → samples/boot/webflux-form/src/main/java/sample/IndexController.java


+ 32 - 0
samples/boot/webflux-form/src/main/java/sample/WebfluxFormApplication.java

@@ -0,0 +1,32 @@
+/*
+ * Copyright 2002-2017 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
+ *
+ *      http://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 sample;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author Rob Winch
+ * @since 5.0
+ */
+@SpringBootApplication
+public class WebfluxFormApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(WebfluxFormApplication.class, args);
+	}
+}

+ 0 - 0
samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java → samples/boot/webflux-form/src/main/java/sample/WebfluxFormSecurityConfig.java


+ 0 - 0
samples/javaconfig/webflux-form/src/main/resources/logback.xml → samples/boot/webflux-form/src/main/resources/logback.xml


+ 0 - 0
samples/javaconfig/webflux-form/src/main/resources/templates/index.html → samples/boot/webflux-form/src/main/resources/templates/index.html


+ 0 - 0
samples/javaconfig/webflux-form/src/main/resources/templates/login.html → samples/boot/webflux-form/src/main/resources/templates/login.html


+ 0 - 16
samples/javaconfig/hellowebflux-method/spring-security-samples-javaconfig-hellowebflux-method.gradle

@@ -1,16 +0,0 @@
-apply plugin: 'io.spring.convention.spring-sample'
-
-dependencies {
-	compile project(':spring-security-core')
-	compile project(':spring-security-config')
-	compile project(':spring-security-web')
-	compile 'com.fasterxml.jackson.core:jackson-databind'
-	compile 'io.projectreactor.ipc:reactor-netty'
-	compile 'org.springframework:spring-context'
-	compile 'org.springframework:spring-webflux'
-
-	testCompile project(':spring-security-test')
-	testCompile 'io.projectreactor:reactor-test'
-	testCompile 'org.skyscreamer:jsonassert'
-	testCompile 'org.springframework:spring-test'
-}

+ 0 - 56
samples/javaconfig/hellowebflux-method/src/main/java/sample/HelloWebfluxMethodApplication.java

@@ -1,56 +0,0 @@
-/*
- * Copyright 2002-2017 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
- *
- *      http://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 sample;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.*;
-import org.springframework.http.server.reactive.HttpHandler;
-import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.config.EnableWebFlux;
-import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
-import reactor.ipc.netty.NettyContext;
-import reactor.ipc.netty.http.server.HttpServer;
-
-/**
- * @author Rob Winch
- * @since 5.0
- */
-@Configuration
-@EnableWebFlux
-@ComponentScan
-public class HelloWebfluxMethodApplication {
-	@Value("${server.port:8080}")
-	private int port = 8080;
-
-	public static void main(String[] args) throws Exception {
-		try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
-			HelloWebfluxMethodApplication.class)) {
-			context.getBean(NettyContext.class).onClose().block();
-		}
-	}
-
-	@Profile("default")
-	@Bean
-	public NettyContext nettyContext(ApplicationContext context) {
-		HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
-			.build();
-		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
-		HttpServer httpServer = HttpServer.create("localhost", port);
-		return httpServer.newHandler(adapter).block();
-	}
-}

+ 0 - 17
samples/javaconfig/hellowebflux/spring-security-samples-javaconfig-hellowebflux.gradle

@@ -1,17 +0,0 @@
-apply plugin: 'io.spring.convention.spring-sample'
-
-dependencies {
-	compile project(':spring-security-core')
-	compile project(':spring-security-config')
-	compile project(':spring-security-web')
-	compile 'com.fasterxml.jackson.core:jackson-databind'
-	compile 'io.projectreactor.ipc:reactor-netty'
-	compile 'org.springframework:spring-context'
-	compile 'org.springframework:spring-webflux'
-	compile slf4jDependencies
-
-	testCompile project(':spring-security-test')
-	testCompile 'io.projectreactor:reactor-test'
-	testCompile 'org.skyscreamer:jsonassert'
-	testCompile 'org.springframework:spring-test'
-}

+ 0 - 55
samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxApplication.java

@@ -1,55 +0,0 @@
-/*
- * Copyright 2002-2017 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
- *
- *      http://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 sample;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.*;
-import org.springframework.http.server.reactive.HttpHandler;
-import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.config.EnableWebFlux;
-import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
-import reactor.ipc.netty.NettyContext;
-import reactor.ipc.netty.http.server.HttpServer;
-
-/**
- * @author Rob Winch
- * @since 5.0
- */
-@Configuration
-@EnableWebFlux
-@ComponentScan
-public class HelloWebfluxApplication {
-	@Value("${server.port:8080}")
-	private int port = 8080;
-
-	public static void main(String[] args) throws Exception {
-		try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(HelloWebfluxApplication.class)) {
-			context.getBean(NettyContext.class).onClose().block();
-		}
-	}
-
-	@Profile("default")
-	@Bean
-	public NettyContext nettyContext(ApplicationContext context) {
-		HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
-			.build();
-		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
-		HttpServer httpServer = HttpServer.create("localhost", port);
-		return httpServer.newHandler(adapter).block();
-	}
-}

+ 0 - 16
samples/javaconfig/hellowebfluxfn/spring-security-samples-javaconfig-hellowebfluxfn.gradle

@@ -1,16 +0,0 @@
-apply plugin: 'io.spring.convention.spring-sample'
-
-dependencies {
-	compile project(':spring-security-core')
-	compile project(':spring-security-config')
-	compile project(':spring-security-web')
-	compile 'com.fasterxml.jackson.core:jackson-databind'
-	compile 'io.projectreactor.ipc:reactor-netty'
-	compile 'org.springframework:spring-context'
-	compile 'org.springframework:spring-webflux'
-
-	testCompile project(':spring-security-test')
-	testCompile 'io.projectreactor:reactor-test'
-	testCompile 'org.skyscreamer:jsonassert'
-	testCompile 'org.springframework:spring-test'
-}

+ 0 - 75
samples/javaconfig/hellowebfluxfn/src/main/java/sample/HelloWebfluxFnApplication.java

@@ -1,75 +0,0 @@
-/*
- * Copyright 2002-2017 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
- *
- *      http://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 sample;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.*;
-import org.springframework.http.server.reactive.HttpHandler;
-import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.config.EnableWebFlux;
-import org.springframework.web.reactive.function.server.HandlerStrategies;
-import org.springframework.web.reactive.function.server.RouterFunction;
-import org.springframework.web.reactive.function.server.RouterFunctions;
-import org.springframework.web.reactive.function.server.ServerResponse;
-import org.springframework.web.server.WebFilter;
-import reactor.ipc.netty.NettyContext;
-import reactor.ipc.netty.http.server.HttpServer;
-
-import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
-import static org.springframework.web.reactive.function.server.RouterFunctions.route;
-
-/**
- * @author Rob Winch
- * @since 5.0
- */
-@Configuration
-@EnableWebFlux
-@ComponentScan
-public class HelloWebfluxFnApplication {
-	@Value("${server.port:8080}")
-	private int port = 8080;
-
-	public static void main(String[] args) throws Exception {
-		try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(HelloWebfluxFnApplication.class)) {
-			context.getBean(NettyContext.class).onClose().block();
-		}
-	}
-
-	@Profile("default")
-	@Bean
-	public NettyContext nettyContext(HttpHandler handler) {
-		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
-		HttpServer httpServer = HttpServer.create("localhost", this.port);
-		return httpServer.newHandler(adapter).block();
-	}
-
-	@Bean
-	public RouterFunction<ServerResponse> routes(HelloUserController userController) {
-		return route(
-			GET("/"), userController::hello);
-	}
-
-	@Bean
-	public HttpHandler httpHandler(RouterFunction<ServerResponse> routes, WebFilter springSecurityFilterChain) {
-		HandlerStrategies handlerStrategies = HandlerStrategies.builder()
-			.webFilter(springSecurityFilterChain)
-			.build();
-
-		return RouterFunctions.toHttpHandler(routes, handlerStrategies);
-	}
-
-}

+ 0 - 76
samples/javaconfig/webflux-form/src/main/java/sample/ThymeleafConfig.java

@@ -1,76 +0,0 @@
-/*
- * Copyright 2002-2017 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
- *
- *      http://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 sample;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.config.ViewResolverRegistry;
-import org.springframework.web.reactive.config.WebFluxConfigurer;
-import org.thymeleaf.spring5.ISpringWebFluxTemplateEngine;
-import org.thymeleaf.spring5.SpringWebFluxTemplateEngine;
-import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
-import org.thymeleaf.spring5.view.reactive.ThymeleafReactiveViewResolver;
-import org.thymeleaf.templatemode.TemplateMode;
-
-/**
- * @author Rob Winch
- * @since 5.0
- */
-@Configuration
-public class ThymeleafConfig implements WebFluxConfigurer {
-	private ApplicationContext applicationContext;
-
-	public ThymeleafConfig(final ApplicationContext applicationContext) {
-		this.applicationContext = applicationContext;
-	}
-
-	@Bean
-	public SpringResourceTemplateResolver thymeleafTemplateResolver() {
-
-		SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
-		resolver.setApplicationContext(this.applicationContext);
-		resolver.setPrefix("classpath:/templates/");
-		resolver.setSuffix(".html");
-		resolver.setTemplateMode(TemplateMode.HTML);
-		resolver.setCacheable(false);
-		resolver.setCheckExistence(true);
-		return resolver;
-
-	}
-
-	@Bean
-	public ISpringWebFluxTemplateEngine thymeleafTemplateEngine() {
-		SpringWebFluxTemplateEngine templateEngine = new SpringWebFluxTemplateEngine();
-		templateEngine.setTemplateResolver(thymeleafTemplateResolver());
-		return templateEngine;
-	}
-
-	@Bean
-	public ThymeleafReactiveViewResolver thymeleafChunkedAndDataDrivenViewResolver() {
-		ThymeleafReactiveViewResolver viewResolver = new ThymeleafReactiveViewResolver();
-		viewResolver.setTemplateEngine(thymeleafTemplateEngine());
-		viewResolver.setOrder(1);
-		viewResolver.setResponseMaxChunkSizeBytes(8192); // OUTPUT BUFFER size limit
-		return viewResolver;
-	}
-
-	@Override
-	public void configureViewResolvers(ViewResolverRegistry registry) {
-		registry.viewResolver(thymeleafChunkedAndDataDrivenViewResolver());
-	}
-}

+ 0 - 56
samples/javaconfig/webflux-form/src/main/java/sample/WebfluxFormApplication.java

@@ -1,56 +0,0 @@
-/*
- * Copyright 2002-2017 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
- *
- *      http://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 sample;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.*;
-import org.springframework.http.server.reactive.HttpHandler;
-import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.config.EnableWebFlux;
-import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
-import reactor.ipc.netty.NettyContext;
-import reactor.ipc.netty.http.server.HttpServer;
-
-/**
- * @author Rob Winch
- * @since 5.0
- */
-@Configuration
-@EnableWebFlux
-@ComponentScan
-public class WebfluxFormApplication {
-	@Value("${server.port:8080}")
-	private int port = 8080;
-
-	public static void main(String[] args) throws Exception {
-		try(AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
-			WebfluxFormApplication.class)) {
-			context.getBean(NettyContext.class).onClose().block();
-		}
-	}
-
-	@Profile("default")
-	@Bean
-	public NettyContext nettyContext(ApplicationContext context) {
-		HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
-			.build();
-		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
-		HttpServer httpServer = HttpServer.create("localhost", port);
-		return httpServer.newHandler(adapter).block();
-	}
-}