diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 8e2db044a6..3c1e44d13a 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -47,13 +47,13 @@ javax.servlet javax.servlet-api - 3.0.1 + ${javax.servlet-api.version} provided javax.servlet jstl - 1.2 + ${jstl.version} runtime @@ -78,7 +78,7 @@ commons-fileupload commons-fileupload - 1.3.1 + ${commons-fileupload.version} net.sourceforge.htmlunit @@ -150,7 +150,7 @@ com.jayway.jsonpath json-path - 2.2.0 + ${jsonpath.version} test @@ -184,7 +184,7 @@ maven-resources-plugin - 2.7 + ${maven-resources-plugin.version} @@ -250,42 +250,46 @@ 4.3.4.RELEASE 4.2.0.RELEASE - 2.1.4.RELEASE - 2.7.8 + 2.1.5.RELEASE + 2.8.5 - 4.3.11.Final - 5.1.38 + 5.2.5.Final + 5.1.40 1.7.21 - 1.1.5 + 1.1.7 - 5.2.2.Final + 5.3.3.Final + 3.1.0 + 1.2 19.0 - 3.4 + 3.5 + 1.3.2 + 2.2.0 1.3 4.12 1.10.19 - 4.4.1 - 4.5 + 4.4.5 + 4.5.2 2.9.0 2.23 - 3.5.1 + 3.6.0 2.6 2.19.1 2.7 - 1.4.18 + 1.6.1 - 1.8.7 + 1.8.9 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 f97bedddef..327bfc4596 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 @@ -2,6 +2,11 @@ package com.baeldung.htmlunit; import java.util.List; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlHeading1; @@ -9,34 +14,31 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; public class HtmlUnitWebScraping { - private WebClient webClient; + private WebClient webClient; - @Before - public void init() throws Exception { - webClient = new WebClient(); - } + @Before + public void init() throws Exception { + webClient = new WebClient(); + } - @After - public void close() throws Exception { - webClient.close(); - } + @After + public void close() throws Exception { + webClient.close(); + } - @Test - public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1() - throws Exception { - webClient.getOptions().setCssEnabled(false); - webClient.getOptions().setJavaScriptEnabled(false); + @Test + public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1() throws Exception { + webClient.getOptions().setCssEnabled(false); + webClient.getOptions().setJavaScriptEnabled(false); - 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 String url = "http://www.baeldung.com/full_archive"; + final HtmlPage page = webClient.getPage(url); + final String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a"; + final HtmlAnchor latestPostLink = (HtmlAnchor) page.getByXPath(xpath).get(0); + final HtmlPage postPage = latestPostLink.click(); - List h1 - = (List) postPage.getByXPath("//h1"); + final List h1 = (List) postPage.getByXPath("//h1"); - Assert.assertTrue(h1.size() > 0); - } + Assert.assertTrue(h1.size() > 0); + } } diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java index db984eadfb..ca8c37175e 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java @@ -32,7 +32,7 @@ public class GreetControllerIntegrationTest { private MockMvc mockMvc; - private static final String CONTENT_TYPE = "application/json"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; @Before public void setup() throws Exception { @@ -41,7 +41,7 @@ public class GreetControllerIntegrationTest { @Test public void givenWAC_whenServletContext_thenItProvidesGreetController() { - ServletContext servletContext = wac.getServletContext(); + final ServletContext servletContext = wac.getServletContext(); Assert.assertNotNull(servletContext); Assert.assertTrue(servletContext instanceof MockServletContext); Assert.assertNotNull(wac.getBean("greetController")); @@ -54,7 +54,7 @@ public class GreetControllerIntegrationTest { @Test public void givenGreetURI_whenMockMVC_thenVerifyResponse() throws Exception { - MvcResult mvcResult = this.mockMvc.perform(MockMvcRequestBuilders.get("/greet")).andDo(print()).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Hello World!!!")).andReturn(); + final MvcResult mvcResult = this.mockMvc.perform(MockMvcRequestBuilders.get("/greet")).andDo(print()).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Hello World!!!")).andReturn(); Assert.assertEquals(CONTENT_TYPE, mvcResult.getResponse().getContentType()); } diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java index eacd256438..0475bd933d 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java @@ -16,7 +16,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; public class GreetControllerUnitTest { private MockMvc mockMvc; - private static final String CONTENT_TYPE = "application/json"; + private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; @Before public void setup() {