GH-386 Fixed NPE for non-existing functions invoked as REST endpoints

Resolves #386
This commit is contained in:
Oleg Zhurakousky
2019-07-09 16:35:06 +02:00
parent 3ae9d0523d
commit 70d46f8b9f
2 changed files with 17 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.cloud.function.context.FunctionType;
import org.springframework.cloud.function.context.FunctionalSpringApplication;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.SocketUtils;
@@ -54,6 +55,17 @@ public class FunctionEndpointInitializerTests {
System.clearProperty("server.port");
}
@Test
public void testNonExistingFunction() throws Exception {
FunctionalSpringApplication.run(ApplicationConfiguration.class);
TestRestTemplate testRestTemplate = new TestRestTemplate();
String port = System.getProperty("server.port");
Thread.sleep(200);
ResponseEntity<String> response = testRestTemplate
.postForEntity(new URI("http://localhost:" + port + "/foo"), "stressed", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
@Test
public void testSingleFunctionMapping() throws Exception {
FunctionalSpringApplication.run(ApplicationConfiguration.class);