Skip to content

Commit 5679aa4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents c75a986 + 74da012 commit 5679aa4

12 files changed

Lines changed: 98 additions & 94 deletions

File tree

‎core-java/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838
- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
3939
- [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java)
4040
- [How to Convert String to different data types in Java](http://www.baeldung.com/java-string-conversions)
41+
- [Introduction to Java Generics](http://www.baeldung.com/java-generics)

‎core-java/src/test/java/com/baeldung/encoderdecoder/EncoderDecoderUnitTest.java‎

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
import java.util.Map;
1515

1616
import static java.util.stream.Collectors.joining;
17+
import static org.hamcrest.CoreMatchers.*;
1718

1819
public class EncoderDecoderUnitTest {
1920

2021
private static final Logger LOGGER = LoggerFactory.getLogger(EncoderDecoderUnitTest.class);
21-
private static final String testUrl = "http://www.baeldung.com/path+1?key1=value+1&key2=value%40%21%242&key3=value%253#dummy+Fragment";
22+
private static final String testUrl = "http://www.baeldung.com?key1=value+1&key2=value%40%21%242&key3=value%253";
23+
private static final String testUrlWithPath = "http://www.baeldung.com/path+1?key1=value+1&key2=value%40%21%242&key3=value%253";
24+
2225

2326
private String encodeValue(String value) {
2427
String encoded = null;
@@ -42,13 +45,11 @@ private String decode(String value) {
4245

4346
@Test
4447
public void givenURL_whenAnalyze_thenCorrect() throws Exception {
45-
URI uri = new URI(testUrl);
48+
URL url = new URL(testUrl);
4649

47-
Assert.assertThat(uri.getScheme(), CoreMatchers.is("http"));
48-
Assert.assertThat(uri.getHost(), CoreMatchers.is("www.baeldung.com"));
49-
Assert.assertThat(uri.getRawPath(), CoreMatchers.is("/path+1"));
50-
Assert.assertThat(uri.getRawQuery(), CoreMatchers.is("key1=value+1&key2=value%40%21%242&key3=value%253"));
51-
Assert.assertThat(uri.getRawFragment(), CoreMatchers.is("dummy+Fragment"));
50+
Assert.assertThat(url.getProtocol(), is("http"));
51+
Assert.assertThat(url.getHost(), is("www.baeldung.com"));
52+
Assert.assertThat(url.getQuery(), is("key1=value+1&key2=value%40%21%242&key3=value%253"));
5253
}
5354

5455
@Test
@@ -58,35 +59,29 @@ public void givenRequestParam_whenUTF8Scheme_thenEncode() throws Exception {
5859
requestParams.put("key2", "value@!$2");
5960
requestParams.put("key3", "value%3");
6061

61-
String path = "path+1";
62-
String fragment = "dummy Fragment";
63-
64-
String encodedURL = requestParams.keySet().stream().map(key -> key + "=" + encodeValue(requestParams.get(key))).collect(joining("&", "http://www.baeldung.com/" + getPath(path) + "?", "#" + encodeValue(fragment)));
62+
String encodedURL = requestParams.keySet().stream()
63+
.map(key -> key + "=" + encodeValue(requestParams.get(key)))
64+
.collect(joining("&", "http://www.baeldung.com?", ""));
6565

66-
Assert.assertThat(testUrl, CoreMatchers.is(encodedURL));
66+
Assert.assertThat(testUrl, is(encodedURL));
6767
}
6868

6969
@Test
7070
public void givenRequestParam_whenUTF8Scheme_thenDecodeRequestParams() throws Exception {
71-
URI uri = new URI(testUrl);
71+
URL url = new URL(testUrl);
7272

73-
String scheme = uri.getScheme();
74-
String host = uri.getHost();
75-
String query = uri.getRawQuery();
76-
String path = uri.getRawPath();
77-
String fragment = uri.getRawFragment();
73+
String query = url.getQuery();
7874

7975
String decodedQuery = Arrays.stream(query.split("&")).map(param -> param.split("=")[0] + "=" + decode(param.split("=")[1])).collect(joining("&"));
80-
String decodedPath = Arrays.stream(path.split("/")).map(param -> getPath(param)).collect(joining("/"));
8176

82-
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));
77+
Assert.assertEquals("http://www.baeldung.com?key1=value 1&key2=value@!$2&key3=value%3", url.getProtocol() + "://" + url.getHost() + "?" + decodedQuery);
8378
}
8479

85-
private String getPath(String path) {
80+
private String encodePath(String path) {
8681
try {
8782
path = new URI(null, null, path, null).getPath();
8883
} catch (URISyntaxException e) {
89-
e.printStackTrace();
84+
LOGGER.error("Error encoding parameter {}", e.getMessage(), e);
9085
}
9186
return path;
9287
}
@@ -98,4 +93,22 @@ public void givenPath_thenEncodeDecodePath() throws URISyntaxException {
9893
Assert.assertEquals("/Path 1/Path+2", uri.getPath());
9994
Assert.assertEquals("/Path%201/Path+2", uri.getRawPath());
10095
}
96+
97+
@Test
98+
public void givenPathAndRequestParam_whenUTF8Scheme_thenEncode() throws Exception {
99+
Map<String, String> requestParams = new HashMap<>();
100+
requestParams.put("key1", "value 1");
101+
requestParams.put("key2", "value@!$2");
102+
requestParams.put("key3", "value%3");
103+
104+
String path = "path+1";
105+
106+
String encodedURL = requestParams.keySet().stream()
107+
.map(key -> key + "=" + encodeValue(requestParams.get(key)))
108+
.collect(joining("&", "http://www.baeldung.com/" + encodePath(path) + "?", ""));
109+
110+
Assert.assertThat(testUrlWithPath, is(encodedURL));
111+
}
112+
113+
101114
}

‎resteasy/pom.xml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
<packaging>war</packaging>
1010

1111
<properties>
12-
<resteasy.version>3.0.14.Final</resteasy.version>
12+
<resteasy.version>3.0.19.Final</resteasy.version>
13+
<junit.version>4.12</junit.version>
14+
<commons-io.version>2.5</commons-io.version>
1315
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
14-
<cargo-maven2-plugin.version>1.6.0</cargo-maven2-plugin.version>
16+
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
1517
</properties>
1618

1719
<build>
@@ -93,13 +95,13 @@
9395
<dependency>
9496
<groupId>junit</groupId>
9597
<artifactId>junit</artifactId>
96-
<version>4.4</version>
98+
<version>${junit.version}</version>
9799
</dependency>
98100

99101
<dependency>
100102
<groupId>commons-io</groupId>
101103
<artifactId>commons-io</artifactId>
102-
<version>2.4</version>
104+
<version>${commons-io.version}</version>
103105
</dependency>
104106

105107
</dependencies>

‎selenium-junit-testng/pom.xml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<plugins>
1010
<plugin>
1111
<artifactId>maven-compiler-plugin</artifactId>
12-
<version>3.1</version>
12+
<version>${maven-compiler-plugin.version}</version>
1313
<configuration>
1414
<source>1.8</source>
1515
<target>1.8</target>
@@ -18,7 +18,7 @@
1818
<plugin>
1919
<groupId>org.apache.maven.plugins</groupId>
2020
<artifactId>maven-surefire-plugin</artifactId>
21-
<version>2.19.1</version>
21+
<version>${maven-surefire-plugin.version}</version>
2222
<configuration>
2323
<testFailureIgnore>true</testFailureIgnore>
2424
<includes>
@@ -38,7 +38,7 @@
3838
<plugin>
3939
<groupId>org.apache.maven.plugins</groupId>
4040
<artifactId>maven-surefire-plugin</artifactId>
41-
<version>2.19.1</version>
41+
<version>${maven-surefire-plugin.version}</version>
4242
<configuration>
4343
<includes>
4444
<include>**/*LiveTest.java</include>
@@ -55,17 +55,26 @@
5555
<dependency>
5656
<groupId>org.seleniumhq.selenium</groupId>
5757
<artifactId>selenium-java</artifactId>
58-
<version>3.0.1</version>
58+
<version>${selenium-java.version}</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>junit</groupId>
6262
<artifactId>junit</artifactId>
63-
<version>4.12</version>
63+
<version>${junit.version}</version>
6464
</dependency>
6565
<dependency>
6666
<groupId>org.testng</groupId>
6767
<artifactId>testng</artifactId>
68-
<version>6.9.13.6</version>
68+
<version>${testng.version}</version>
6969
</dependency>
7070
</dependencies>
71+
72+
<properties>
73+
<junit.version>4.12</junit.version>
74+
<testng.version>6.10</testng.version>
75+
<selenium-java.version>3.0.1</selenium-java.version>
76+
77+
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
78+
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
79+
</properties>
7180
</project>

‎spring-akka/pom.xml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@
115115
</profiles>
116116

117117
<properties>
118-
<spring.version>4.3.2.RELEASE</spring.version>
119-
<akka.version>2.4.8</akka.version>
118+
<spring.version>4.3.4.RELEASE</spring.version>
119+
<akka.version>2.4.14</akka.version>
120120
<junit.version>4.12</junit.version>
121121

122-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
122+
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
123123
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
124124

125125
</properties>

‎spring-all/pom.xml‎

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>1.3.6.RELEASE</version>
14+
<version>1.4.2.RELEASE</version>
1515
</parent>
1616

1717
<dependencies>
@@ -134,7 +134,7 @@
134134
<dependency>
135135
<groupId>org.assertj</groupId>
136136
<artifactId>assertj-core</artifactId>
137-
<version>3.5.1</version>
137+
<version>${assertj.version}</version>
138138
<scope>test</scope>
139139
</dependency>
140140

@@ -158,13 +158,13 @@
158158
<dependency>
159159
<groupId>org.easymock</groupId>
160160
<artifactId>easymock</artifactId>
161-
<version>3.4</version>
161+
<version>${easymock.version}</version>
162162
<scope>test</scope>
163163
</dependency>
164164
<dependency>
165165
<groupId>org.ehcache</groupId>
166166
<artifactId>ehcache</artifactId>
167-
<version>3.1.3</version>
167+
<version>${ehcache.version}</version>
168168
</dependency>
169169

170170
</dependencies>
@@ -273,42 +273,17 @@
273273

274274
<properties>
275275
<!-- Spring -->
276-
<org.springframework.version>4.3.1.RELEASE</org.springframework.version>
277-
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
278-
<javassist.version>3.20.0-GA</javassist.version>
279-
<jstl.version>1.2</jstl.version>
276+
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
277+
<org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version>
280278

281279
<!-- persistence -->
282-
<hibernate.version>4.3.11.Final</hibernate.version>
283-
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
284-
285-
<!-- logging -->
286-
<org.slf4j.version>1.7.13</org.slf4j.version>
287-
<logback.version>1.1.3</logback.version>
288-
289-
<!-- various -->
290-
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
280+
<hibernate.version>5.2.5.Final</hibernate.version>
291281

292282
<!-- util -->
293283
<guava.version>19.0</guava.version>
294-
<commons-lang3.version>3.4</commons-lang3.version>
295-
296-
<!-- testing -->
297-
<org.hamcrest.version>1.3</org.hamcrest.version>
298-
<junit.version>4.12</junit.version>
299-
<mockito.version>1.10.19</mockito.version>
300-
301-
<httpcore.version>4.4.1</httpcore.version>
302-
<httpclient.version>4.5</httpclient.version>
303-
304-
<rest-assured.version>2.9.0</rest-assured.version>
305-
306-
<!-- maven plugins -->
307-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
308-
<maven-war-plugin.version>2.6</maven-war-plugin.version>
309-
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
310-
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
311-
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
284+
<ehcache.version>3.1.3</ehcache.version>
285+
<easymock.version>3.4</easymock.version>
286+
<assertj.version>3.6.1</assertj.version>
312287

313288
</properties>
314289

‎spring-apache-camel/pom.xml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
<properties>
1212
<env.camel.version>2.16.1</env.camel.version>
13-
<env.spring.version>4.2.4.RELEASE</env.spring.version>
13+
<env.spring.version>4.3.4.RELEASE</env.spring.version>
1414
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
15-
<java.version>1.7</java.version>
15+
<java.version>1.8</java.version>
1616
<junit.version>4.12</junit.version>
1717
</properties>
1818

‎spring-autowire/pom.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<org.springframework.version>4.2.5.RELEASE</org.springframework.version>
16-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
15+
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
16+
<junit.version>4.12</junit.version>
17+
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
1718
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
1819
</properties>
1920

2021
<dependencies>
2122
<dependency>
2223
<groupId>junit</groupId>
2324
<artifactId>junit</artifactId>
24-
<version>4.11</version>
25+
<version>${junit.version}</version>
2526
</dependency>
2627
<dependency>
2728
<groupId>org.springframework</groupId>

‎spring-batch/pom.xml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<spring.version>4.2.0.RELEASE</spring.version>
15-
<spring.batch.version>3.0.5.RELEASE</spring.batch.version>
16-
<sqlite.version>3.8.11.2</sqlite.version>
14+
<spring.version>4.3.4.RELEASE</spring.version>
15+
<spring.batch.version>3.0.7.RELEASE</spring.batch.version>
16+
<sqlite.version>3.15.1</sqlite.version>
1717
</properties>
1818

1919
<dependencies>

‎spring-boot/pom.xml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@
7373
<dependency>
7474
<groupId>org.subethamail</groupId>
7575
<artifactId>subethasmtp</artifactId>
76-
<version>3.1.7</version>
76+
<version>${subethasmtp.version}</version>
7777
<scope>test</scope>
7878
</dependency>
7979

8080
<dependency>
8181
<groupId>org.webjars</groupId>
8282
<artifactId>bootstrap</artifactId>
83-
<version>3.3.7-1</version>
83+
<version>${bootstrap.version}</version>
8484
</dependency>
8585
<dependency>
8686
<groupId>org.webjars</groupId>
8787
<artifactId>jquery</artifactId>
88-
<version>3.1.1</version>
88+
<version>${jquery.version}</version>
8989
</dependency>
9090
</dependencies>
9191

@@ -122,7 +122,7 @@
122122
<plugin>
123123
<groupId>pl.project13.maven</groupId>
124124
<artifactId>git-commit-id-plugin</artifactId>
125-
<version>2.2.1</version>
125+
<version>${git-commit-id-plugin.version}</version>
126126
</plugin>
127127

128128
<plugin>
@@ -182,6 +182,10 @@
182182
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
183183
<java.version>1.8</java.version>
184184
<spring.version>4.3.4.RELEASE</spring.version>
185+
<git-commit-id-plugin.version>2.2.1</git-commit-id-plugin.version>
186+
<jquery.version>3.1.1</jquery.version>
187+
<bootstrap.version>3.3.7-1</bootstrap.version>
188+
<subethasmtp.version>3.1.7</subethasmtp.version>
185189
</properties>
186190

187191
</project>

0 commit comments

Comments
 (0)