Merge pull request #4833 from amit2103/BAEL-7608-1
[BAEL-7608] - Fixed spring-5-reactive integration tests
This commit is contained in:
commit
e6cea7449a
|
@ -34,8 +34,7 @@ public class FormHandler {
|
|||
|
||||
private AtomicLong extractData(List<DataBuffer> dataBuffers) {
|
||||
AtomicLong atomicLong = new AtomicLong(0);
|
||||
dataBuffers.forEach(d -> atomicLong.addAndGet(d.asByteBuffer()
|
||||
.array().length));
|
||||
dataBuffers.forEach(d -> atomicLong.addAndGet(d.readableByteCount()));
|
||||
return atomicLong;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.List;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Wrapper;
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
|
@ -61,7 +62,8 @@ public class FunctionalWebApplication {
|
|||
tomcat.setPort(9090);
|
||||
Context rootContext = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
|
||||
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
|
||||
Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
|
||||
Wrapper servletWrapper = Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
|
||||
servletWrapper.setAsyncSupported(true);
|
||||
rootContext.addServletMappingDecoded("/", "httpHandlerServlet");
|
||||
|
||||
TomcatWebServer server = new TomcatWebServer(tomcat);
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@RestController
|
||||
@RestController("FurtherCorsConfigsController-cors-on-global-config-and-more")
|
||||
@RequestMapping("/cors-on-global-config-and-more")
|
||||
public class FurtherCorsConfigsController {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@RestController
|
||||
@RestController("RegularRestController-cors-on-global-config")
|
||||
@RequestMapping("/cors-on-global-config")
|
||||
public class RegularRestController {
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.t
|
|||
import static org.springframework.web.reactive.function.server.ServerResponse.ok;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Wrapper;
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
|
@ -41,7 +42,8 @@ public class ExploreSpring5URLPatternUsingRouterFunctions {
|
|||
tomcat.setPort(9090);
|
||||
Context rootContext = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
|
||||
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
|
||||
Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
|
||||
Wrapper servletWrapper = Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
|
||||
servletWrapper.setAsyncSupported(true);
|
||||
rootContext.addServletMappingDecoded("/", "httpHandlerServlet");
|
||||
|
||||
TomcatWebServer server = new TomcatWebServer(tomcat);
|
||||
|
|
|
@ -4,8 +4,12 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class EmployeeCreationEvent {
|
||||
private String employeeId;
|
||||
private String creationTime;
|
||||
public EmployeeCreationEvent(String employeeId, String creationTime) {
|
||||
super();
|
||||
this.employeeId = employeeId;
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Component
|
||||
@Component("EmployeeWebSocketHandler")
|
||||
public class EmployeeWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
package com.baeldung.websocket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.reactive.socket.WebSocketHandler;
|
||||
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class ReactiveWebSocketConfiguration {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("ReactiveWebSocketHandler")
|
||||
private WebSocketHandler webSocketHandler;
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.time.Duration;
|
|||
import static java.time.LocalDateTime.now;
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
@Component
|
||||
@Component("ReactiveWebSocketHandler")
|
||||
public class ReactiveWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
private static final ObjectMapper json = new ObjectMapper();
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.baeldung.functional;
|
||||
|
||||
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
|
||||
import static org.springframework.web.reactive.function.BodyInserters.fromResource;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -12,9 +15,6 @@ import org.springframework.util.LinkedMultiValueMap;
|
|||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
|
||||
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
|
||||
import static org.springframework.web.reactive.function.BodyInserters.fromResource;
|
||||
|
||||
public class FunctionalWebApplicationIntegrationTest {
|
||||
|
||||
private static WebTestClient client;
|
||||
|
|
|
@ -6,8 +6,6 @@ import org.junit.Test;
|
|||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import com.baeldung.reactive.urlmatch.ExploreSpring5URLPatternUsingRouterFunctions;
|
||||
|
||||
public class ExploreSpring5URLPatternUsingRouterFunctionsIntegrationTest {
|
||||
|
||||
private static WebTestClient client;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class SecurityIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void whenNoCredentials_thenRedirectToLogin() {
|
||||
this.rest.get().uri("/").exchange().expectStatus().is3xxRedirection();
|
||||
this.rest.get().uri("/").exchange().expectStatus().is4xxClientError();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -53,7 +53,7 @@ public class WebTestClientIntegrationTest {
|
|||
.uri("/resource")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is3xxRedirection()
|
||||
.isOk()
|
||||
.expectBody();
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Loading…
Reference in New Issue