Add tests to illustrate the bug
This commit is contained in:
committed by
Oleg Zhurakousky
parent
f3b9896010
commit
c97c0b2a96
@@ -41,6 +41,8 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -79,6 +81,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Soby Chacko
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class SimpleFunctionRegistryTests {
|
||||
|
||||
@@ -190,6 +193,20 @@ public class SimpleFunctionRegistryTests {
|
||||
assertThat(result).isEqualTo("{\"HELLO\":\"WORLD\"}");
|
||||
}
|
||||
|
||||
// TODO: Once bug is fixed this test (last entry) will fully pass and this COMMENT should be removed
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"[hello", "hello]", "[hello]"})
|
||||
void textContentTypeWithValueWrappedBracketsIsOk(String inputMessagePayloadValue) {
|
||||
var catalog = new SimpleFunctionRegistry(this.conversionService, this.messageConverter, new JacksonMapper(new ObjectMapper()));
|
||||
catalog.register(new FunctionRegistration<>(new Echo(), "echo").type(Echo.class));
|
||||
FunctionInvocationWrapper lookedUpFunction = catalog.lookup("echo");
|
||||
var inputMessage = MessageBuilder.withPayload(inputMessagePayloadValue)
|
||||
.setHeader("contentType", "text/plain")
|
||||
.build();
|
||||
var functionResult = lookedUpFunction.apply(inputMessage);
|
||||
assertThat(functionResult).isEqualTo(inputMessagePayloadValue);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSCF762() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.function.web.mvc;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -30,6 +31,8 @@ import java.util.stream.Collectors;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -56,6 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Chris Bono
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.main.web-application-type=servlet")
|
||||
@ContextConfiguration(classes = { RestApplication.class, ApplicationConfiguration.class })
|
||||
@@ -124,6 +128,18 @@ public class HttpGetIntegrationTests {
|
||||
assertThat(result.getBody()).isEqualTo("foo");
|
||||
}
|
||||
|
||||
// TODO: Once bug is fixed this test (last entry) will fully pass and this COMMENT should be removed
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"[hello", "hello]", "[hello]"})
|
||||
void textContentTypeWithValueWrappedBracketsIsOk(String inputMessagePayloadValue) throws URISyntaxException {
|
||||
ResponseEntity<String> postForEntity = this.rest
|
||||
.exchange(RequestEntity.post(new URI("/echo"))
|
||||
.contentType(MediaType.TEXT_PLAIN)
|
||||
.body(inputMessagePayloadValue), String.class);
|
||||
assertThat(postForEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(postForEntity.getBody()).isEqualTo(inputMessagePayloadValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foos() throws Exception {
|
||||
ResponseEntity<String> result = this.rest
|
||||
@@ -301,6 +317,11 @@ public class HttpGetIntegrationTests {
|
||||
return () -> "foo";
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> echo() {
|
||||
return (input) -> input;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Supplier<Flux<Foo>> foos() {
|
||||
return () -> Flux.just(new Foo("foo"), new Foo("bar"));
|
||||
|
||||
Reference in New Issue
Block a user