upgrade and cleanup

This commit is contained in:
DOHA 2016-12-06 23:52:34 +02:00
parent 55c2b3a338
commit 0099c22654
4 changed files with 51 additions and 45 deletions

View File

@ -47,13 +47,13 @@
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version> <version>${javax.servlet-api.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId> <artifactId>jstl</artifactId>
<version>1.2</version> <version>${jstl.version}</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@ -78,7 +78,7 @@
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
<version>1.3.1</version> <version>${commons-fileupload.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sourceforge.htmlunit</groupId> <groupId>net.sourceforge.htmlunit</groupId>
@ -150,7 +150,7 @@
<dependency> <dependency>
<groupId>com.jayway.jsonpath</groupId> <groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId> <artifactId>json-path</artifactId>
<version>2.2.0</version> <version>${jsonpath.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -184,7 +184,7 @@
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>2.7</version> <version>${maven-resources-plugin.version}</version>
</plugin> </plugin>
<plugin> <plugin>
@ -250,42 +250,46 @@
<!-- Spring --> <!-- Spring -->
<org.springframework.version>4.3.4.RELEASE</org.springframework.version> <org.springframework.version>4.3.4.RELEASE</org.springframework.version>
<org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version> <org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version> <thymeleaf.version>2.1.5.RELEASE</thymeleaf.version>
<jackson.version>2.7.8</jackson.version> <jackson.version>2.8.5</jackson.version>
<!-- persistence --> <!-- persistence -->
<hibernate.version>4.3.11.Final</hibernate.version> <hibernate.version>5.2.5.Final</hibernate.version>
<mysql-connector-java.version>5.1.38</mysql-connector-java.version> <mysql-connector-java.version>5.1.40</mysql-connector-java.version>
<!-- logging --> <!-- logging -->
<org.slf4j.version>1.7.21</org.slf4j.version> <org.slf4j.version>1.7.21</org.slf4j.version>
<logback.version>1.1.5</logback.version> <logback.version>1.1.7</logback.version>
<!-- various --> <!-- various -->
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version> <hibernate-validator.version>5.3.3.Final</hibernate-validator.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<jstl.version>1.2</jstl.version>
<!-- util --> <!-- util -->
<guava.version>19.0</guava.version> <guava.version>19.0</guava.version>
<commons-lang3.version>3.4</commons-lang3.version> <commons-lang3.version>3.5</commons-lang3.version>
<commons-fileupload.version>1.3.2</commons-fileupload.version>
<jsonpath.version>2.2.0</jsonpath.version>
<!-- testing --> <!-- testing -->
<org.hamcrest.version>1.3</org.hamcrest.version> <org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version> <mockito.version>1.10.19</mockito.version>
<httpcore.version>4.4.1</httpcore.version> <httpcore.version>4.4.5</httpcore.version>
<httpclient.version>4.5</httpclient.version> <httpclient.version>4.5.2</httpclient.version>
<rest-assured.version>2.9.0</rest-assured.version> <rest-assured.version>2.9.0</rest-assured.version>
<net.sourceforge.htmlunit>2.23</net.sourceforge.htmlunit> <net.sourceforge.htmlunit>2.23</net.sourceforge.htmlunit>
<!-- maven plugins --> <!-- maven plugins -->
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<maven-resources-plugin.version>2.7</maven-resources-plugin.version> <maven-resources-plugin.version>2.7</maven-resources-plugin.version>
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version> <cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
<!-- AspectJ --> <!-- AspectJ -->
<aspectj.version>1.8.7</aspectj.version> <aspectj.version>1.8.9</aspectj.version>
</properties> </properties>
</project> </project>

View File

@ -2,6 +2,11 @@ package com.baeldung.htmlunit;
import java.util.List; 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.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlHeading1; import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
@ -22,20 +27,17 @@ public class HtmlUnitWebScraping {
} }
@Test @Test
public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1() public void givenBaeldungArchive_whenRetrievingArticle_thenHasH1() throws Exception {
throws Exception {
webClient.getOptions().setCssEnabled(false); webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(false); webClient.getOptions().setJavaScriptEnabled(false);
String url = "http://www.baeldung.com/full_archive"; final String url = "http://www.baeldung.com/full_archive";
HtmlPage page = webClient.getPage(url); final HtmlPage page = webClient.getPage(url);
String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a"; final String xpath = "(//ul[@class='car-monthlisting']/li)[1]/a";
HtmlAnchor latestPostLink final HtmlAnchor latestPostLink = (HtmlAnchor) page.getByXPath(xpath).get(0);
= (HtmlAnchor) page.getByXPath(xpath).get(0); final HtmlPage postPage = latestPostLink.click();
HtmlPage postPage = latestPostLink.click();
List<HtmlHeading1> h1 final List<HtmlHeading1> h1 = (List<HtmlHeading1>) postPage.getByXPath("//h1");
= (List<HtmlHeading1>) postPage.getByXPath("//h1");
Assert.assertTrue(h1.size() > 0); Assert.assertTrue(h1.size() > 0);
} }

View File

@ -32,7 +32,7 @@ public class GreetControllerIntegrationTest {
private MockMvc mockMvc; private MockMvc mockMvc;
private static final String CONTENT_TYPE = "application/json"; private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
@ -41,7 +41,7 @@ public class GreetControllerIntegrationTest {
@Test @Test
public void givenWAC_whenServletContext_thenItProvidesGreetController() { public void givenWAC_whenServletContext_thenItProvidesGreetController() {
ServletContext servletContext = wac.getServletContext(); final ServletContext servletContext = wac.getServletContext();
Assert.assertNotNull(servletContext); Assert.assertNotNull(servletContext);
Assert.assertTrue(servletContext instanceof MockServletContext); Assert.assertTrue(servletContext instanceof MockServletContext);
Assert.assertNotNull(wac.getBean("greetController")); Assert.assertNotNull(wac.getBean("greetController"));
@ -54,7 +54,7 @@ public class GreetControllerIntegrationTest {
@Test @Test
public void givenGreetURI_whenMockMVC_thenVerifyResponse() throws Exception { 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()); Assert.assertEquals(CONTENT_TYPE, mvcResult.getResponse().getContentType());
} }

View File

@ -16,7 +16,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
public class GreetControllerUnitTest { public class GreetControllerUnitTest {
private MockMvc mockMvc; private MockMvc mockMvc;
private static final String CONTENT_TYPE = "application/json"; private static final String CONTENT_TYPE = "application/json;charset=UTF-8";
@Before @Before
public void setup() { public void setup() {