diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html b/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html
new file mode 100644
index 0000000000..291e8312ae
--- /dev/null
+++ b/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitTest.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitTest.java
new file mode 100644
index 0000000000..8395a49581
--- /dev/null
+++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitTest.java
@@ -0,0 +1,31 @@
+package com.baeldung.htmlunit;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class HtmlUnitAndJUnitTest {
+
+ @Before
+ public void init() throws Exception {
+ webClient = new WebClient();
+ }
+
+ @After
+ public void close() throws Exception {
+ webClient.close();
+ }
+
+ @Test
+ public void givenAClient_whenEnteringBaeldung_thenPageTitleIsOk()
+ throws Exception {
+ webClient.getOptions().setThrowExceptionOnScriptError(false);
+ HtmlPage page = webClient.getPage("http://www.baeldung.com/");
+ Assert.assertEquals(
+ "Baeldung | Java, Spring and Web Development tutorials",
+ page.getTitleText());
+ }
+
+}
diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java
deleted file mode 100644
index 406975b6cc..0000000000
--- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.baeldung.htmlunit;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
-import org.springframework.web.context.WebApplicationContext;
-
-import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
-import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration(classes = { TestConfig.class })
-public class HtmlUnitAndSpringIntegrationTest {
-
- @Autowired
- private WebApplicationContext wac;
-
- private WebClient webClient;
-
- @Before
- public void setup() {
- webClient = MockMvcWebClientBuilder.webAppContextSetup(wac).build();
- }
-
- //
-
- @Test
- @Ignore("Related view message.html does not exist check MessageController")
- public void givenAMessage_whenSent_thenItShows() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
- final String text = "Hello world!";
- final HtmlPage page = webClient.getPage("http://localhost/message/showForm");
- System.out.println(page.asXml());
-
- final HtmlTextInput messageText = page.getHtmlElementById("message");
- messageText.setValueAttribute(text);
-
- final HtmlForm form = page.getForms().get(0);
- final HtmlSubmitInput submit = form.getOneHtmlElementByAttribute("input", "type", "submit");
- final HtmlPage newPage = submit.click();
-
- final String receivedText = newPage.getHtmlElementById("received").getTextContent();
-
- Assert.assertEquals(receivedText, text);
- System.out.println(newPage.asXml());
- }
-
- @Test
- public void givenAClient_whenEnteringBaeldung_thenPageTitleIsCorrect() throws Exception {
- try (final WebClient client = new WebClient()) {
- webClient.getOptions().setThrowExceptionOnScriptError(false);
-
- final HtmlPage page = webClient.getPage("http://www.baeldung.com/");
- Assert.assertEquals("Baeldung | Java, Spring and Web Development tutorials", page.getTitleText());
- }
- }
-
-}
diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringTest.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringTest.java
new file mode 100644
index 0000000000..45e441f47f
--- /dev/null
+++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringTest.java
@@ -0,0 +1,61 @@
+package com.baeldung.htmlunit;
+
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
+import org.springframework.web.context.WebApplicationContext;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(classes = { TestConfig.class })
+public class HtmlUnitAndSpringTest {
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ private WebClient webClient;
+
+ @Before
+ public void setup() {
+ webClient = MockMvcWebClientBuilder
+ .webAppContextSetup(wac).build();
+ }
+
+ @Test
+ public void givenAMessage_whenSent_thenItShows() throws Exception {
+ String text = "Hello world!";
+ HtmlPage page;
+
+ String url = "http://localhost/message/showForm";
+ page = webClient.getPage(url);
+
+ HtmlTextInput messageText = page.getHtmlElementById("message");
+ messageText.setValueAttribute(text);
+
+ HtmlForm form = page.getForms().get(0);
+ HtmlSubmitInput submit = form.getOneHtmlElementByAttribute(
+ "input", "type", "submit");
+ HtmlPage newPage = submit.click();
+
+ String receivedText = newPage.getHtmlElementById("received")
+ .getTextContent();
+
+ Assert.assertEquals(receivedText, text);
+ }
+}
diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitTest.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitTest.java
deleted file mode 100644
index 6a7e961eb1..0000000000
--- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.htmlunit;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.gargoylesoftware.htmlunit.WebClient;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class HtmlUnitTest {
-
- @Test
- public void givenAClient_whenEnteringBaeldung_thenPageTitleIsCorrect() throws Exception {
- try (final WebClient webClient = new WebClient()) {
- webClient.getOptions().setThrowExceptionOnScriptError(false);
-
- final HtmlPage page = webClient.getPage("http://www.baeldung.com/");
- Assert.assertEquals("Baeldung | Java, Spring and Web Development tutorials", page.getTitleText());
- }
- }
-
-}
diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScraping.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScraping.java
index 9919d7571d..f97bedddef 100644
--- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScraping.java
+++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScraping.java
@@ -5,36 +5,38 @@ import java.util.List;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
-import com.gargoylesoftware.htmlunit.html.HtmlHeading2;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class HtmlUnitWebScraping {
- public static void main(final String[] args) throws Exception {
- try (final WebClient webClient = new WebClient()) {
+ private WebClient webClient;
- webClient.getOptions().setCssEnabled(false);
- webClient.getOptions().setJavaScriptEnabled(false);
+ @Before
+ public void init() throws Exception {
+ webClient = new WebClient();
+ }
- final HtmlPage page = webClient.getPage("http://www.baeldung.com/full_archive");
- final HtmlAnchor latestPostLink = (HtmlAnchor) page.getByXPath("(//ul[@class='car-monthlisting']/li)[1]/a").get(0);
+ @After
+ public void close() throws Exception {
+ webClient.close();
+ }
- System.out.println("Entering: " + latestPostLink.getHrefAttribute());
+ @Test
+ public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1()
+ throws Exception {
+ webClient.getOptions().setCssEnabled(false);
+ webClient.getOptions().setJavaScriptEnabled(false);
- final HtmlPage postPage = latestPostLink.click();
+ String url = "http://www.baeldung.com/full_archive";
+ HtmlPage page = webClient.getPage(url);
+ String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a";
+ HtmlAnchor latestPostLink
+ = (HtmlAnchor) page.getByXPath(xpath).get(0);
+ HtmlPage postPage = latestPostLink.click();
- final HtmlHeading1 heading1 = (HtmlHeading1) postPage.getByXPath("//h1").get(0);
- System.out.println("Title: " + heading1.getTextContent());
-
- final List headings2 = (List) postPage.getByXPath("//h2");
-
- final StringBuilder sb = new StringBuilder(heading1.getTextContent());
- for (final HtmlHeading2 h2 : headings2) {
- sb.append("\n").append(h2.getTextContent());
- }
-
- System.out.println(sb.toString());
- }
- }
+ List h1
+ = (List) postPage.getByXPath("//h1");
+ Assert.assertTrue(h1.size() > 0);
+ }
}
diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml
index 60f3ed41d1..df000d0df5 100644
--- a/spring-security-rest/pom.xml
+++ b/spring-security-rest/pom.xml
@@ -1,393 +1,400 @@
- 4.0.0
- com.baeldung
- spring-security-rest
- 0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.baeldung
+ spring-security-rest
+ 0.1-SNAPSHOT
- spring-security-rest
- war
+ spring-security-rest
+ war
-
+
-
+
-
- org.springframework.security
- spring-security-web
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-config
- ${org.springframework.security.version}
-
+
+ org.springframework.security
+ spring-security-web
+ ${org.springframework.security.version}
+
+
+ org.springframework.security
+ spring-security-config
+ ${org.springframework.security.version}
+
-
+
-
- org.springframework
- spring-core
- ${org.springframework.version}
-
-
- commons-logging
- commons-logging
-
-
-
-
- org.springframework
- spring-context
- ${org.springframework.version}
-
-
- org.springframework
- spring-jdbc
- ${org.springframework.version}
-
-
- org.springframework
- spring-beans
- ${org.springframework.version}
-
-
- org.springframework
- spring-aop
- ${org.springframework.version}
-
-
- org.springframework
- spring-tx
- ${org.springframework.version}
-
-
- org.springframework
- spring-expression
- ${org.springframework.version}
-
+
+ org.springframework
+ spring-core
+ ${org.springframework.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ org.springframework
+ spring-context
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-jdbc
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-beans
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-aop
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-tx
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-expression
+ ${org.springframework.version}
+
-
- org.springframework
- spring-web
- ${org.springframework.version}
-
-
- org.springframework
- spring-webmvc
- ${org.springframework.version}
-
+
+ org.springframework
+ spring-web
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-webmvc
+ ${org.springframework.version}
+
-
-
- org.springframework.hateoas
- spring-hateoas
- ${org.springframework.hateoas.version}
-
+
+
+ org.springframework.hateoas
+ spring-hateoas
+ ${org.springframework.hateoas.version}
+
-
+
-
- javax.servlet
- javax.servlet-api
- ${javax.servlet-api.version}
- provided
-
+
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet-api.version}
+ provided
+
-
- javax.servlet
- jstl
- ${jstl.version}
- runtime
-
+
+ javax.servlet
+ jstl
+ ${jstl.version}
+ runtime
+
-
- javax.validation
- validation-api
- ${javax.validation.version}
-
+
+ javax.validation
+ validation-api
+ ${javax.validation.version}
+
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
-
-
- com.google.guava
- guava
- ${guava.version}
-
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
-
-
- org.slf4j
- slf4j-api
- ${org.slf4j.version}
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
-
-
- org.slf4j
- jcl-over-slf4j
- ${org.slf4j.version}
-
-
-
- org.slf4j
- log4j-over-slf4j
- ${org.slf4j.version}
-
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
-
-
- org.springframework
- spring-test
- ${org.springframework.version}
- test
-
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${org.slf4j.version}
+
+
+
+ org.slf4j
+ log4j-over-slf4j
+ ${org.slf4j.version}
+
-
- org.springframework.security
- spring-security-test
- ${org.springframework.security.version}
- test
-
+
+
+ org.springframework
+ spring-test
+ ${org.springframework.version}
+ test
+
+
+
+ org.springframework.security
+ spring-security-test
+ ${org.springframework.security.version}
+ test
+
-
- com.jayway.restassured
- rest-assured
- ${rest-assured.version}
- test
-
-
- commons-logging
- commons-logging
-
-
-
+
+ com.jayway.restassured
+ rest-assured
+ ${rest-assured.version}
+ test
+
+
+ commons-logging
+ commons-logging
+
+
+
-
- junit
- junit
- ${junit.version}
- test
-
+
+ junit
+ junit
+ ${junit.version}
+ test
+
-
- org.hamcrest
- hamcrest-core
- ${org.hamcrest.version}
- test
-
-
- org.hamcrest
- hamcrest-library
- ${org.hamcrest.version}
- test
-
+
+ org.hamcrest
+ hamcrest-core
+ ${org.hamcrest.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
-
-
- io.springfox
- springfox-swagger2
- ${springfox-swagger.version}
-
+
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-swagger.version}
+
-
- io.springfox
- springfox-swagger-ui
- ${springfox-swagger.version}
-
+
+ io.springfox
+ springfox-swagger-ui
+ ${springfox-swagger.version}
+
-
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.2
+
-
- spring-security-rest
-
-
- src/main/resources
- true
-
-
+
-
+
+ spring-security-rest
+
+
+ src/main/resources
+ true
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- 1.8
-
-
+
-
- org.apache.maven.plugins
- maven-war-plugin
- ${maven-war-plugin.version}
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ 1.8
+
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
- **/*LiveTest.java
-
-
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
-
- org.codehaus.cargo
- cargo-maven2-plugin
- ${cargo-maven2-plugin.version}
-
-
- jetty8x
- embedded
-
-
-
-
-
-
- 8082
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ **/*LiveTest.java
+
+
+
+
+
+
-
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+
+ jetty8x
+ embedded
+
+
+
+
+
+
+ 8082
+
+
+
+
-
+
-
-
- live
-
-
-
- org.codehaus.cargo
- cargo-maven2-plugin
-
-
- start-server
- pre-integration-test
-
- start
-
-
-
- stop-server
- post-integration-test
-
- stop
-
-
-
-
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- none
-
-
- **/*LiveTest.java
-
-
- cargo
-
-
-
-
-
+
+
+ live
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+
+
+ start-server
+ pre-integration-test
+
+ start
+
+
+
+ stop-server
+ post-integration-test
+
+ stop
+
+
+
+
-
-
-
-
-
-
-
-
- 4.2.5.RELEASE
- 4.0.4.RELEASE
- 0.19.0.RELEASE
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ none
+
+
+ **/*LiveTest.java
+
+
+ cargo
+
+
+
+
+
-
- 4.3.11.Final
- 5.1.38
+
+
+
+
-
- 1.7.13
- 1.1.3
-
- 5.2.2.Final
- 3.0.1
- 1.1.0.Final
- 1.2
- 2.7.8
+
+
+ 4.2.5.RELEASE
+ 4.0.4.RELEASE
+ 0.19.0.RELEASE
-
- 19.0
- 3.4
+
+ 4.3.11.Final
+ 5.1.38
-
- 1.3
- 4.12
- 1.10.19
- 2.9.0
+
+ 1.7.13
+ 1.1.3
-
- 2.4.0
+
+ 5.2.2.Final
+ 3.0.1
+ 1.1.0.Final
+ 1.2
+ 2.7.8
- 4.4.1
- 4.5
+
+ 19.0
+ 3.4
- 2.9.0
+
+ 1.3
+ 4.12
+ 1.10.19
+ 2.9.0
-
- 3.5.1
- 2.6
- 2.19.1
- 1.4.18
+
+ 2.4.0
-
+ 4.4.1
+ 4.5
+
+ 2.9.0
+
+
+ 3.5.1
+ 2.6
+ 2.19.1
+ 1.4.18
+
+
diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/AsyncController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/AsyncController.java
new file mode 100644
index 0000000000..bc59b4226a
--- /dev/null
+++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/AsyncController.java
@@ -0,0 +1,24 @@
+package org.baeldung.web.controller;
+
+import java.util.concurrent.Callable;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.multipart.MultipartFile;
+
+@Controller
+public class AsyncController {
+
+ @RequestMapping(method = RequestMethod.POST, value = "/upload")
+ public Callable processUpload(final MultipartFile file) {
+
+ return new Callable() {
+ public Boolean call() throws Exception {
+ // ...
+ return true;
+ }
+ };
+ }
+
+}
diff --git a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml
index 4ba9642448..5a68371f6c 100644
--- a/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml
+++ b/spring-security-rest/src/main/webapp/WEB-INF/api-servlet.xml
@@ -1,6 +1,10 @@
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
+
+
+
\ No newline at end of file
diff --git a/spring-security-rest/src/main/webapp/WEB-INF/web.xml b/spring-security-rest/src/main/webapp/WEB-INF/web.xml
index 3af8709dab..c030a9dd63 100644
--- a/spring-security-rest/src/main/webapp/WEB-INF/web.xml
+++ b/spring-security-rest/src/main/webapp/WEB-INF/web.xml
@@ -1,54 +1,57 @@
-
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
- Spring MVC Application
+ Spring MVC Application
-
-
- contextClass
-
+
+
+ contextClass
+
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
-
-
- contextConfigLocation
- org.baeldung.spring
-
+
+
+ contextConfigLocation
+ org.baeldung.spring
+
-
- org.springframework.web.context.ContextLoaderListener
-
+
+ org.springframework.web.context.ContextLoaderListener
+
-
-
- api
- org.springframework.web.servlet.DispatcherServlet
-
- throwExceptionIfNoHandlerFound
- true
-
-
-
- api
- /api/*
-
+
+
+ api
+ org.springframework.web.servlet.DispatcherServlet
+
+ throwExceptionIfNoHandlerFound
+ true
+
+
+
+ api
+ /api/*
+
-
-
- springSecurityFilterChain
- org.springframework.web.filter.DelegatingFilterProxy
-
-
- springSecurityFilterChain
- /*
-
+
+
+ springSecurityFilterChain
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+ springSecurityFilterChain
+ /*
+ REQUEST
+ ASYNC
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/spring-security-rest/src/test/java/org/baeldung/web/AsyncControllerTest.java b/spring-security-rest/src/test/java/org/baeldung/web/AsyncControllerTest.java
new file mode 100644
index 0000000000..37122ed836
--- /dev/null
+++ b/spring-security-rest/src/test/java/org/baeldung/web/AsyncControllerTest.java
@@ -0,0 +1,51 @@
+package org.baeldung.web;
+
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.baeldung.spring.ClientWebConfig;
+import org.baeldung.spring.SecurityJavaConfig;
+import org.baeldung.spring.WebConfig;
+import org.baeldung.web.controller.AsyncController;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpSession;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration(classes = { ClientWebConfig.class, SecurityJavaConfig.class, WebConfig.class})
+public class AsyncControllerTest {
+
+ @Autowired
+ WebApplicationContext wac;
+ @Autowired
+ MockHttpSession session;
+
+ @Mock
+ AsyncController controller;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
+ }
+
+ @Test
+ public void testProcessUpload() throws Exception {
+ MockMultipartFile jsonFile = new MockMultipartFile("json", "", "application/json",
+ "{\"json\": \"someValue\"}".getBytes());
+ mockMvc.perform(MockMvcRequestBuilders.fileUpload("/upload").file(jsonFile)).andExpect(status().isOk());
+ }
+
+}
diff --git a/spring-security-rest/src/test/java/org/baeldung/web/TestConfig.java b/spring-security-rest/src/test/java/org/baeldung/web/TestConfig.java
index 8b55841508..bdce37dd10 100644
--- a/spring-security-rest/src/test/java/org/baeldung/web/TestConfig.java
+++ b/spring-security-rest/src/test/java/org/baeldung/web/TestConfig.java
@@ -1,10 +1,19 @@
package org.baeldung.web;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.web.multipart.MultipartResolver;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
@Configuration
@ComponentScan({ "org.baeldung.web" })
public class TestConfig {
+ @Bean
+ public MultipartResolver multipartResolver() {
+ CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
+ return multipartResolver;
+ }
+
}
\ No newline at end of file