Skip to content

Commit 0099c22

Browse files
committed
upgrade and cleanup
1 parent 55c2b3a commit 0099c22

4 files changed

Lines changed: 51 additions & 45 deletions

File tree

‎spring-mvc-java/pom.xml‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
<dependency>
4848
<groupId>javax.servlet</groupId>
4949
<artifactId>javax.servlet-api</artifactId>
50-
<version>3.0.1</version>
50+
<version>${javax.servlet-api.version}</version>
5151
<scope>provided</scope>
5252
</dependency>
5353
<dependency>
5454
<groupId>javax.servlet</groupId>
5555
<artifactId>jstl</artifactId>
56-
<version>1.2</version>
56+
<version>${jstl.version}</version>
5757
<scope>runtime</scope>
5858
</dependency>
5959

@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>commons-fileupload</groupId>
8080
<artifactId>commons-fileupload</artifactId>
81-
<version>1.3.1</version>
81+
<version>${commons-fileupload.version}</version>
8282
</dependency>
8383
<dependency>
8484
<groupId>net.sourceforge.htmlunit</groupId>
@@ -150,7 +150,7 @@
150150
<dependency>
151151
<groupId>com.jayway.jsonpath</groupId>
152152
<artifactId>json-path</artifactId>
153-
<version>2.2.0</version>
153+
<version>${jsonpath.version}</version>
154154
<scope>test</scope>
155155
</dependency>
156156
<dependency>
@@ -184,7 +184,7 @@
184184

185185
<plugin>
186186
<artifactId>maven-resources-plugin</artifactId>
187-
<version>2.7</version>
187+
<version>${maven-resources-plugin.version}</version>
188188
</plugin>
189189

190190
<plugin>
@@ -250,42 +250,46 @@
250250
<!-- Spring -->
251251
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
252252
<org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version>
253-
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
254-
<jackson.version>2.7.8</jackson.version>
253+
<thymeleaf.version>2.1.5.RELEASE</thymeleaf.version>
254+
<jackson.version>2.8.5</jackson.version>
255255

256256
<!-- persistence -->
257-
<hibernate.version>4.3.11.Final</hibernate.version>
258-
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
257+
<hibernate.version>5.2.5.Final</hibernate.version>
258+
<mysql-connector-java.version>5.1.40</mysql-connector-java.version>
259259

260260
<!-- logging -->
261261
<org.slf4j.version>1.7.21</org.slf4j.version>
262-
<logback.version>1.1.5</logback.version>
262+
<logback.version>1.1.7</logback.version>
263263

264264
<!-- various -->
265-
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
265+
<hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
266+
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
267+
<jstl.version>1.2</jstl.version>
266268

267269
<!-- util -->
268270
<guava.version>19.0</guava.version>
269-
<commons-lang3.version>3.4</commons-lang3.version>
271+
<commons-lang3.version>3.5</commons-lang3.version>
272+
<commons-fileupload.version>1.3.2</commons-fileupload.version>
273+
<jsonpath.version>2.2.0</jsonpath.version>
270274

271275
<!-- testing -->
272276
<org.hamcrest.version>1.3</org.hamcrest.version>
273277
<junit.version>4.12</junit.version>
274278
<mockito.version>1.10.19</mockito.version>
275-
<httpcore.version>4.4.1</httpcore.version>
276-
<httpclient.version>4.5</httpclient.version>
279+
<httpcore.version>4.4.5</httpcore.version>
280+
<httpclient.version>4.5.2</httpclient.version>
277281
<rest-assured.version>2.9.0</rest-assured.version>
278282
<net.sourceforge.htmlunit>2.23</net.sourceforge.htmlunit>
279283

280284
<!-- maven plugins -->
281-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
285+
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
282286
<maven-war-plugin.version>2.6</maven-war-plugin.version>
283287
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
284288
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
285-
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
289+
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
286290

287291
<!-- AspectJ -->
288-
<aspectj.version>1.8.7</aspectj.version>
292+
<aspectj.version>1.8.9</aspectj.version>
289293
</properties>
290294

291295
</project>

‎spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScraping.java‎

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,43 @@
22

33
import java.util.List;
44

5+
import org.junit.After;
6+
import org.junit.Assert;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
510
import com.gargoylesoftware.htmlunit.WebClient;
611
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
712
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
813
import com.gargoylesoftware.htmlunit.html.HtmlPage;
914

1015
public class HtmlUnitWebScraping {
1116

12-
private WebClient webClient;
17+
private WebClient webClient;
1318

14-
@Before
15-
public void init() throws Exception {
16-
webClient = new WebClient();
17-
}
19+
@Before
20+
public void init() throws Exception {
21+
webClient = new WebClient();
22+
}
1823

19-
@After
20-
public void close() throws Exception {
21-
webClient.close();
22-
}
24+
@After
25+
public void close() throws Exception {
26+
webClient.close();
27+
}
2328

24-
@Test
25-
public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1()
26-
throws Exception {
27-
webClient.getOptions().setCssEnabled(false);
28-
webClient.getOptions().setJavaScriptEnabled(false);
29+
@Test
30+
public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1() throws Exception {
31+
webClient.getOptions().setCssEnabled(false);
32+
webClient.getOptions().setJavaScriptEnabled(false);
2933

30-
String url = "http://www.baeldung.com/full_archive";
31-
HtmlPage page = webClient.getPage(url);
32-
String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a";
33-
HtmlAnchor latestPostLink
34-
= (HtmlAnchor) page.getByXPath(xpath).get(0);
35-
HtmlPage postPage = latestPostLink.click();
34+
final String url = "http://www.baeldung.com/full_archive";
35+
final HtmlPage page = webClient.getPage(url);
36+
final String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a";
37+
final HtmlAnchor latestPostLink = (HtmlAnchor) page.getByXPath(xpath).get(0);
38+
final HtmlPage postPage = latestPostLink.click();
3639

37-
List<HtmlHeading1> h1
38-
= (List<HtmlHeading1>) postPage.getByXPath("//h1");
40+
final List<HtmlHeading1> h1 = (List<HtmlHeading1>) postPage.getByXPath("//h1");
3941

40-
Assert.assertTrue(h1.size() > 0);
41-
}
42+
Assert.assertTrue(h1.size() > 0);
43+
}
4244
}

‎spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class GreetControllerIntegrationTest {
3232

3333
private MockMvc mockMvc;
3434

35-
private static final String CONTENT_TYPE = "application/json";
35+
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
3636

3737
@Before
3838
public void setup() throws Exception {
@@ -41,7 +41,7 @@ public void setup() throws Exception {
4141

4242
@Test
4343
public void givenWAC_whenServletContext_thenItProvidesGreetController() {
44-
ServletContext servletContext = wac.getServletContext();
44+
final ServletContext servletContext = wac.getServletContext();
4545
Assert.assertNotNull(servletContext);
4646
Assert.assertTrue(servletContext instanceof MockServletContext);
4747
Assert.assertNotNull(wac.getBean("greetController"));
@@ -54,7 +54,7 @@ public void givenHomePageURI_whenMockMVC_thenReturnsIndexJSPViewName() throws Ex
5454

5555
@Test
5656
public void givenGreetURI_whenMockMVC_thenVerifyResponse() throws Exception {
57-
MvcResult mvcResult = this.mockMvc.perform(MockMvcRequestBuilders.get("/greet")).andDo(print()).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Hello World!!!")).andReturn();
57+
final MvcResult mvcResult = this.mockMvc.perform(MockMvcRequestBuilders.get("/greet")).andDo(print()).andExpect(MockMvcResultMatchers.status().isOk()).andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Hello World!!!")).andReturn();
5858
Assert.assertEquals(CONTENT_TYPE, mvcResult.getResponse().getContentType());
5959
}
6060

‎spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class GreetControllerUnitTest {
1717

1818
private MockMvc mockMvc;
19-
private static final String CONTENT_TYPE = "application/json";
19+
private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
2020

2121
@Before
2222
public void setup() {

0 commit comments

Comments
 (0)