CAMEL-16950: camel-servlet-starter doesn't support multipart requests (#367)

diff --git a/components-starter/camel-servlet-starter/src/main/docs/servlet-starter.adoc b/components-starter/camel-servlet-starter/src/main/docs/servlet-starter.adoc
index 869e4dd..2af428e 100644
--- a/components-starter/camel-servlet-starter/src/main/docs/servlet-starter.adoc
+++ b/components-starter/camel-servlet-starter/src/main/docs/servlet-starter.adoc
@@ -40,3 +40,6 @@
 | *camel.servlet.mapping.servlet-name* | The name of the Camel servlet. | CamelServlet | String
 |===
 // spring-boot-auto-configure options: END
+
+==== Advance Multipart configuration
+The multipart configuration is enabled by default. It is inherited from spring servlet's https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/web/servlet/MultipartProperties.html[multipart properties] which can be used for further customization.
diff --git a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
index dce472c..08b1d78 100644
--- a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
+++ b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.java
@@ -24,6 +24,7 @@
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
+import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.web.servlet.ServletRegistrationBean;
 import org.springframework.context.annotation.Bean;
@@ -38,17 +39,19 @@
 @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
 @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
 @ConditionalOnWebApplication
-@EnableConfigurationProperties(ServletMappingConfiguration.class)
+@EnableConfigurationProperties({ServletMappingConfiguration.class, MultipartProperties.class})
 public class ServletMappingAutoConfiguration {
 
     @Bean
-    ServletRegistrationBean camelServletRegistrationBean(ServletMappingConfiguration config) {
+    ServletRegistrationBean camelServletRegistrationBean(ServletMappingConfiguration config, MultipartProperties multipartProperties) {
         ServletRegistrationBean mapping = new ServletRegistrationBean();
         mapping.setServlet(new CamelHttpTransportServlet());
         mapping.addUrlMappings(config.getContextPath());
         mapping.setName(config.getServletName());
         mapping.setLoadOnStartup(1);
-
+        if (multipartProperties != null && multipartProperties.getEnabled()){
+            mapping.setMultipartConfig(multipartProperties.createMultipartConfig());
+        }
         return mapping;
     }
 
diff --git a/components-starter/camel-servlet-starter/src/test/java/org/apache/camel/component/servlet/springboot/test/ServletMultiPartTest.java b/components-starter/camel-servlet-starter/src/test/java/org/apache/camel/component/servlet/springboot/test/ServletMultiPartTest.java
new file mode 100644
index 0000000..1f92c73
--- /dev/null
+++ b/components-starter/camel-servlet-starter/src/test/java/org/apache/camel/component/servlet/springboot/test/ServletMultiPartTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.camel.component.servlet.springboot.test;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.LinkedMultiValueMap;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Testing multipart processing with camel servlet
+ */
+@RunWith(SpringRunner.class)
+@SpringBootApplication
+@DirtiesContext
+@ContextConfiguration(classes = ServletMultiPartTest.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+public class ServletMultiPartTest {
+
+    @Autowired
+    private TestRestTemplate restTemplate;
+
+    @Autowired
+    private CamelContext context;
+
+    @Before
+    public void setup() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("servlet:/test?disableStreamCache=true")
+                        .process(exchange -> {
+                            HttpServletRequest httpServletRequest = exchange.getIn().getBody(HttpServletRequest.class);
+                            exchange.getIn().setBody(httpServletRequest.getPart("file").getName());
+                        });
+                    }
+                 });
+              }
+    @Test
+    public void testMultipartRequest() throws Exception {
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
+        LinkedMultiValueMap<String, Object> message = new LinkedMultiValueMap<>();
+        message.add("file","Multipart Test");
+        HttpEntity<LinkedMultiValueMap<String, Object>> httpEntity = new HttpEntity<>(message,httpHeaders);
+        Assert.assertEquals("file", restTemplate.postForEntity("/camel/test",httpEntity,String.class).getBody());
+    }
+
+}
+