From 8c27b3240dcbaed7be1e2a157092466aedfbf4ce Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 9 Dec 2016 23:14:10 +0200 Subject: [PATCH 1/5] upgrade dependencies --- spring-akka/pom.xml | 6 +++--- spring-all/pom.xml | 45 +++++++++-------------------------------- spring-autowire/pom.xml | 7 ++++--- spring-batch/pom.xml | 6 +++--- spring-boot/pom.xml | 12 +++++++---- 5 files changed, 28 insertions(+), 48 deletions(-) diff --git a/spring-akka/pom.xml b/spring-akka/pom.xml index eb33ca4848..1a273b0fed 100644 --- a/spring-akka/pom.xml +++ b/spring-akka/pom.xml @@ -115,11 +115,11 @@ - 4.3.2.RELEASE - 2.4.8 + 4.3.4.RELEASE + 2.4.14 4.12 - 3.5.1 + 3.6.0 2.19.1 diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 23f2531b51..e77bf0b284 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.6.RELEASE + 1.4.2.RELEASE @@ -134,7 +134,7 @@ org.assertj assertj-core - 3.5.1 + ${assertj.version} test @@ -158,13 +158,13 @@ org.easymock easymock - 3.4 + ${easymock.version} test org.ehcache ehcache - 3.1.3 + ${ehcache.version} @@ -273,42 +273,17 @@ - 4.3.1.RELEASE - 4.0.4.RELEASE - 3.20.0-GA - 1.2 + 4.3.4.RELEASE + 4.2.0.RELEASE - 4.3.11.Final - 5.1.38 - - - 1.7.13 - 1.1.3 - - - 5.2.2.Final + 5.2.5.Final 19.0 - 3.4 - - - 1.3 - 4.12 - 1.10.19 - - 4.4.1 - 4.5 - - 2.9.0 - - - 3.5.1 - 2.6 - 2.19.1 - 2.7 - 1.4.18 + 3.1.3 + 3.4 + 3.6.1 diff --git a/spring-autowire/pom.xml b/spring-autowire/pom.xml index fd03c77605..391cfc018e 100644 --- a/spring-autowire/pom.xml +++ b/spring-autowire/pom.xml @@ -12,8 +12,9 @@ UTF-8 - 4.2.5.RELEASE - 3.5.1 + 4.3.4.RELEASE + 4.12 + 3.6.0 2.19.1 @@ -21,7 +22,7 @@ junit junit - 4.11 + ${junit.version} org.springframework diff --git a/spring-batch/pom.xml b/spring-batch/pom.xml index 5538dd912f..a92a0e8323 100644 --- a/spring-batch/pom.xml +++ b/spring-batch/pom.xml @@ -11,9 +11,9 @@ UTF-8 - 4.2.0.RELEASE - 3.0.5.RELEASE - 3.8.11.2 + 4.3.4.RELEASE + 3.0.7.RELEASE + 3.15.1 diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 5d29b55a19..cd2beb4201 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -73,19 +73,19 @@ org.subethamail subethasmtp - 3.1.7 + ${subethasmtp.version} test org.webjars bootstrap - 3.3.7-1 + ${bootstrap.version} org.webjars jquery - 3.1.1 + ${jquery.version} @@ -122,7 +122,7 @@ pl.project13.maven git-commit-id-plugin - 2.2.1 + ${git-commit-id-plugin.version} @@ -182,6 +182,10 @@ UTF-8 1.8 4.3.4.RELEASE + 2.2.1 + 3.1.1 + 3.3.7-1 + 3.1.7 From da045d1d6f25e61605e464e1458000f81ff000ae Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 9 Dec 2016 23:38:16 +0200 Subject: [PATCH 2/5] upgrade dependencies --- resteasy/pom.xml | 10 ++++++---- selenium-junit-testng/pom.xml | 21 +++++++++++++++------ spring-apache-camel/pom.xml | 4 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/resteasy/pom.xml b/resteasy/pom.xml index 04e8576e1f..f0bd8298f5 100644 --- a/resteasy/pom.xml +++ b/resteasy/pom.xml @@ -9,9 +9,11 @@ war - 3.0.14.Final + 3.0.19.Final + 4.12 + 2.5 2.19.1 - 1.6.0 + 1.6.1 @@ -93,13 +95,13 @@ junit junit - 4.4 + ${junit.version} commons-io commons-io - 2.4 + ${commons-io.version} diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml index 754bf679b5..b4490f779b 100644 --- a/selenium-junit-testng/pom.xml +++ b/selenium-junit-testng/pom.xml @@ -9,7 +9,7 @@ maven-compiler-plugin - 3.1 + ${maven-compiler-plugin.version} 1.8 1.8 @@ -18,7 +18,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + ${maven-surefire-plugin.version} true @@ -38,7 +38,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + ${maven-surefire-plugin.version} **/*LiveTest.java @@ -55,17 +55,26 @@ org.seleniumhq.selenium selenium-java - 3.0.1 + ${selenium-java.version} junit junit - 4.12 + ${junit.version} org.testng testng - 6.9.13.6 + ${testng.version} + + + 4.12 + 6.10 + 3.0.1 + + 2.19.1 + 3.6.0 + \ No newline at end of file diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml index 6cd4f136e0..e68768a624 100644 --- a/spring-apache-camel/pom.xml +++ b/spring-apache-camel/pom.xml @@ -10,9 +10,9 @@ 2.16.1 - 4.2.4.RELEASE + 4.3.4.RELEASE 2.19.1 - 1.7 + 1.8 4.12 From 6882b767ce5a6ea5a0a6998952adcb4f53398730 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Fri, 9 Dec 2016 22:40:29 +0100 Subject: [PATCH 3/5] NOJIRA - updating README files --- core-java/README.md | 1 + spring-session/README.md | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 spring-session/README.md diff --git a/core-java/README.md b/core-java/README.md index 92f124d14b..aca8deb9c9 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -38,3 +38,4 @@ - [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join) - [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java) - [How to Convert String to different data types in Java](http://www.baeldung.com/java-string-conversions) +- [Introduction to Java Generics](http://www.baeldung.com/java-generics) diff --git a/spring-session/README.md b/spring-session/README.md new file mode 100644 index 0000000000..0d802a4715 --- /dev/null +++ b/spring-session/README.md @@ -0,0 +1,6 @@ +========= + +## Spring Session Examples + +### Relevant Articles: +- [Introduction to Spring Session](http://www.baeldung.com/spring-session) From b7db6cef7f2837562f2255019f158e149f8f65ac Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Fri, 9 Dec 2016 23:51:00 +0100 Subject: [PATCH 4/5] BAEL-276 - Refactoring encoding test --- .../EncoderDecoderUnitTest.java | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java b/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java index 0b63d2b51a..08f4e0b4bd 100644 --- a/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java +++ b/core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java @@ -14,11 +14,14 @@ import java.util.HashMap; import java.util.Map; import static java.util.stream.Collectors.joining; +import static org.hamcrest.CoreMatchers.*; public class EncoderDecoderUnitTest { private static final Logger LOGGER = LoggerFactory.getLogger(EncoderDecoderUnitTest.class); - private static final String testUrl = "http://www.baeldung.com/path+1?key1=value+1&key2=value%40%21%242&key3=value%253#dummy+Fragment"; + private static final String testUrl = "http://www.baeldung.com?key1=value+1&key2=value%40%21%242&key3=value%253"; + private static final String testUrlWithPath = "http://www.baeldung.com/path+1?key1=value+1&key2=value%40%21%242&key3=value%253"; + private String encodeValue(String value) { String encoded = null; @@ -42,13 +45,11 @@ public class EncoderDecoderUnitTest { @Test public void givenURL_whenAnalyze_thenCorrect() throws Exception { - URI uri = new URI(testUrl); + URL url = new URL(testUrl); - Assert.assertThat(uri.getScheme(), CoreMatchers.is("http")); - Assert.assertThat(uri.getHost(), CoreMatchers.is("www.baeldung.com")); - Assert.assertThat(uri.getRawPath(), CoreMatchers.is("/path+1")); - Assert.assertThat(uri.getRawQuery(), CoreMatchers.is("key1=value+1&key2=value%40%21%242&key3=value%253")); - Assert.assertThat(uri.getRawFragment(), CoreMatchers.is("dummy+Fragment")); + Assert.assertThat(url.getProtocol(), is("http")); + Assert.assertThat(url.getHost(), is("www.baeldung.com")); + Assert.assertThat(url.getQuery(), is("key1=value+1&key2=value%40%21%242&key3=value%253")); } @Test @@ -58,35 +59,29 @@ public class EncoderDecoderUnitTest { requestParams.put("key2", "value@!$2"); requestParams.put("key3", "value%3"); - String path = "path+1"; - String fragment = "dummy Fragment"; + String encodedURL = requestParams.keySet().stream() + .map(key -> key + "=" + encodeValue(requestParams.get(key))) + .collect(joining("&", "http://www.baeldung.com?", "")); - String encodedURL = requestParams.keySet().stream().map(key -> key + "=" + encodeValue(requestParams.get(key))).collect(joining("&", "http://www.baeldung.com/" + getPath(path) + "?", "#" + encodeValue(fragment))); - - Assert.assertThat(testUrl, CoreMatchers.is(encodedURL)); + Assert.assertThat(testUrl, is(encodedURL)); } @Test public void givenRequestParam_whenUTF8Scheme_thenDecodeRequestParams() throws Exception { - URI uri = new URI(testUrl); + URL url = new URL(testUrl); - String scheme = uri.getScheme(); - String host = uri.getHost(); - String query = uri.getRawQuery(); - String path = uri.getRawPath(); - String fragment = uri.getRawFragment(); + String query = url.getQuery(); String decodedQuery = Arrays.stream(query.split("&")).map(param -> param.split("=")[0] + "=" + decode(param.split("=")[1])).collect(joining("&")); - String decodedPath = Arrays.stream(path.split("/")).map(param -> getPath(param)).collect(joining("/")); - Assert.assertEquals("http://www.baeldung.com/path+1?key1=value 1&key2=value@!$2&key3=value%3#dummy Fragment", scheme + "://" + host + decodedPath + "?" + decodedQuery + "#" + decode(fragment)); + Assert.assertEquals("http://www.baeldung.com?key1=value 1&key2=value@!$2&key3=value%3", url.getProtocol() + "://" + url.getHost() + "?" + decodedQuery); } - private String getPath(String path) { + private String encodePath(String path) { try { path = new URI(null, null, path, null).getPath(); } catch (URISyntaxException e) { - e.printStackTrace(); + LOGGER.error("Error encoding parameter {}", e.getMessage(), e); } return path; } @@ -98,4 +93,22 @@ public class EncoderDecoderUnitTest { Assert.assertEquals("/Path 1/Path+2", uri.getPath()); Assert.assertEquals("/Path%201/Path+2", uri.getRawPath()); } + + @Test + public void givenPathAndRequestParam_whenUTF8Scheme_thenEncode() throws Exception { + Map requestParams = new HashMap<>(); + requestParams.put("key1", "value 1"); + requestParams.put("key2", "value@!$2"); + requestParams.put("key3", "value%3"); + + String path = "path+1"; + + String encodedURL = requestParams.keySet().stream() + .map(key -> key + "=" + encodeValue(requestParams.get(key))) + .collect(joining("&", "http://www.baeldung.com/" + encodePath(path) + "?", "")); + + Assert.assertThat(testUrlWithPath, is(encodedURL)); + } + + } From 74da012f6f3393328a142026174c6efe96360f31 Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 10 Dec 2016 10:14:29 +0200 Subject: [PATCH 5/5] minor formatting work --- .../htmlunit/HtmlUnitAndSpringTest.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) 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 index 45e441f47f..da1b0e484a 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringTest.java @@ -1,10 +1,7 @@ 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; @@ -14,7 +11,6 @@ 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; @@ -33,8 +29,7 @@ public class HtmlUnitAndSpringTest { @Before public void setup() { - webClient = MockMvcWebClientBuilder - .webAppContextSetup(wac).build(); + webClient = MockMvcWebClientBuilder.webAppContextSetup(wac).build(); } @Test @@ -44,18 +39,16 @@ public class HtmlUnitAndSpringTest { 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"); + HtmlSubmitInput submit = form.getOneHtmlElementByAttribute("input", "type", "submit"); HtmlPage newPage = submit.click(); - String receivedText = newPage.getHtmlElementById("received") - .getTextContent(); + String receivedText = newPage.getHtmlElementById("received").getTextContent(); - Assert.assertEquals(receivedText, text); + Assert.assertEquals(receivedText, text); } }