Skip to content

Commit ca01d23

Browse files
committed
Merge remote-tracking branch 'upstream/master'
# Conflicts: # spring-session/jetty-session-demo/src/main/java/com/baeldung/spring/session/tomcatex/JettyWebApplication.java # spring-session/jetty-session-demo/src/main/java/com/baeldung/spring/session/tomcatex/SecurityConfig.java # spring-session/jetty-session-demo/src/main/java/com/baeldung/spring/session/tomcatex/SessionConfig.java # spring-session/jetty-session-demo/src/main/resources/application.properties # spring-session/pom.xml # spring-session/tomcat-session-demo/src/main/java/com/baeldung/spring/session/tomcatex/SecurityConfig.java # spring-session/tomcat-session-demo/src/main/java/com/baeldung/spring/session/tomcatex/TomcatWebApplication.java
2 parents 9689d46 + 584ae41 commit ca01d23

70 files changed

Lines changed: 2485 additions & 212 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎core-java-9/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Core Java 9 Examples
44

5-
http://inprogress.baeldung.com/java-9-new-features/
5+
[Java 9 New Features](http://www.baeldung.com/new-java-9)
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package com.baeldung.java9.language.stream;
2+
3+
import org.junit.Test;
4+
5+
import java.util.Arrays;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
import java.util.stream.Collectors;
10+
import java.util.stream.Stream;
11+
12+
import static java.lang.Integer.*;
13+
import static org.junit.Assert.assertEquals;
14+
15+
public class StreamFeaturesTest {
16+
17+
public static class TakeAndDropWhileTest {
18+
19+
public Stream<String> getStreamAfterTakeWhileOperation() {
20+
return Stream
21+
.iterate("", s -> s + "s")
22+
.takeWhile(s -> s.length() < 10);
23+
}
24+
25+
public Stream<String> getStreamAfterDropWhileOperation() {
26+
return Stream
27+
.iterate("", s -> s + "s")
28+
.takeWhile(s -> s.length() < 10)
29+
.dropWhile(s -> !s.contains("sssss"));
30+
}
31+
32+
@Test
33+
public void testTakeWhileOperation() {
34+
List<String> list = getStreamAfterTakeWhileOperation().collect(Collectors.toList());
35+
36+
assertEquals(10, list.size());
37+
38+
assertEquals("", list.get(0));
39+
assertEquals("ss", list.get(2));
40+
assertEquals("sssssssss", list.get(list.size() - 1));
41+
}
42+
43+
@Test
44+
public void testDropWhileOperation() {
45+
List<String> list = getStreamAfterDropWhileOperation().collect(Collectors.toList());
46+
47+
assertEquals(5, list.size());
48+
49+
assertEquals("sssss", list.get(0));
50+
assertEquals("sssssss", list.get(2));
51+
assertEquals("sssssssss", list.get(list.size() - 1));
52+
}
53+
54+
}
55+
56+
public static class IterateTest {
57+
58+
private Stream<Integer> getStream() {
59+
return Stream.iterate(0, i -> i < 10, i -> i + 1);
60+
}
61+
62+
@Test
63+
public void testIterateOperation() {
64+
List<Integer> list = getStream().collect(Collectors.toList());
65+
66+
assertEquals(10, list.size());
67+
68+
assertEquals(valueOf(0), list.get(0));
69+
assertEquals(valueOf(5), list.get(5));
70+
assertEquals(valueOf(9), list.get(list.size() - 1));
71+
}
72+
73+
}
74+
75+
public static class OfNullableTest {
76+
77+
private List<String> collection = Arrays.asList("A", "B", "C");
78+
private Map<String, Integer> map = new HashMap<>() {{
79+
put("A", 10);
80+
put("C", 30);
81+
}};
82+
83+
private Stream<Integer> getStreamWithOfNullable() {
84+
return collection.stream()
85+
.flatMap(s -> Stream.ofNullable(map.get(s)));
86+
}
87+
88+
private Stream<Integer> getStream() {
89+
return collection.stream()
90+
.flatMap(s -> {
91+
Integer temp = map.get(s);
92+
return temp != null ? Stream.of(temp) : Stream.empty();
93+
});
94+
}
95+
96+
private List<Integer> testOfNullableFrom(Stream<Integer> stream) {
97+
List<Integer> list = stream.collect(Collectors.toList());
98+
99+
assertEquals(2, list.size());
100+
101+
assertEquals(valueOf(10), list.get(0));
102+
assertEquals(valueOf(30), list.get(list.size() - 1));
103+
104+
return list;
105+
}
106+
107+
@Test
108+
public void testOfNullable() {
109+
110+
assertEquals(
111+
testOfNullableFrom(getStream()),
112+
testOfNullableFrom(getStreamWithOfNullable())
113+
);
114+
115+
}
116+
117+
}
118+
119+
}

‎core-java/0.12457740242410742‎

Whitespace-only changes.

‎core-java/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535
- [Java 8 Streams Advanced](http://www.baeldung.com/java-8-streams)
3636
- [Introduction to Thread Pools in Java](http://www.baeldung.com/thread-pool-java-and-guava)
3737
- [Introduction to Java 8 Streams](http://www.baeldung.com/java-8-streams-introduction)
38-
- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
38+
- [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join)
39+
- [How to Print Screen in Java](http://www.baeldung.com/print-screen-in-java)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.baeldung.java.conversion;
2+
3+
import java.text.ParseException;
4+
import java.text.SimpleDateFormat;
5+
import java.time.LocalDateTime;
6+
import java.util.Date;
7+
8+
import com.baeldung.datetime.UseLocalDateTime;
9+
10+
public class StringConversion {
11+
12+
public static int getInt(String str) {
13+
return Integer.parseInt(str);
14+
}
15+
16+
public static int getInteger(String str) {
17+
return Integer.valueOf(str);
18+
}
19+
20+
public static long getLongPrimitive(String str) {
21+
return Long.parseLong(str);
22+
}
23+
24+
public static Long getLong(String str) {
25+
return Long.valueOf(str);
26+
}
27+
28+
public static double getDouble(String str) {
29+
return Double.parseDouble(str);
30+
}
31+
32+
public static double getDoublePrimitive(String str) {
33+
return Double.valueOf(str);
34+
}
35+
36+
public static byte[] getByteArray(String str) {
37+
return str.getBytes();
38+
}
39+
40+
public static char[] getCharArray(String str) {
41+
return str.toCharArray();
42+
}
43+
44+
public static boolean getBooleanPrimitive(String str) {
45+
return Boolean.parseBoolean(str);
46+
}
47+
48+
public static boolean getBoolean(String str) {
49+
return Boolean.valueOf(str);
50+
}
51+
52+
public static Date getJava6Date(String str, String format) throws ParseException {
53+
SimpleDateFormat formatter = new SimpleDateFormat(format);
54+
return formatter.parse(str);
55+
}
56+
57+
public static LocalDateTime getJava8Date(String str) throws ParseException {
58+
return new UseLocalDateTime().getLocalDateTimeUsingParseMethod(str);
59+
}
60+
}

‎httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java‎

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
package org.baeldung.httpclient;
22

3-
import static org.hamcrest.CoreMatchers.equalTo;
4-
import static org.junit.Assert.assertThat;
5-
6-
import java.io.IOException;
7-
import java.security.GeneralSecurityException;
8-
import java.security.KeyManagementException;
9-
import java.security.KeyStoreException;
10-
import java.security.NoSuchAlgorithmException;
11-
12-
import javax.net.ssl.SSLContext;
13-
import javax.net.ssl.SSLException;
14-
153
import org.apache.http.HttpResponse;
164
import org.apache.http.client.methods.HttpGet;
175
import org.apache.http.conn.ClientConnectionManager;
186
import org.apache.http.conn.scheme.Scheme;
197
import org.apache.http.conn.scheme.SchemeRegistry;
20-
import org.apache.http.conn.ssl.NoopHostnameVerifier;
21-
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
22-
import org.apache.http.conn.ssl.SSLContextBuilder;
23-
import org.apache.http.conn.ssl.SSLContexts;
24-
import org.apache.http.conn.ssl.SSLSocketFactory;
25-
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
26-
import org.apache.http.conn.ssl.TrustStrategy;
8+
import org.apache.http.conn.ssl.*;
279
import org.apache.http.impl.client.CloseableHttpClient;
2810
import org.apache.http.impl.client.DefaultHttpClient;
2911
import org.apache.http.impl.client.HttpClientBuilder;
3012
import org.apache.http.impl.client.HttpClients;
3113
import org.apache.http.impl.conn.PoolingClientConnectionManager;
14+
import org.apache.http.ssl.SSLContextBuilder;
15+
import org.apache.http.ssl.SSLContexts;
3216
import org.junit.Test;
3317

18+
import javax.net.ssl.SSLContext;
19+
import javax.net.ssl.SSLException;
20+
import java.io.IOException;
21+
import java.security.GeneralSecurityException;
22+
23+
import static org.hamcrest.CoreMatchers.equalTo;
24+
import static org.junit.Assert.assertThat;
25+
3426
/**
3527
* This test requires a localhost server over HTTPS <br>
3628
* It should only be manually run, not part of the automated build
@@ -101,17 +93,9 @@ public final void givenHttpClientPost4_3_whenAcceptingAllCertificates_thenCanCon
10193
}
10294

10395
@Test
104-
public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws IOException {
105-
106-
final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true;
107-
108-
SSLContext sslContext = null;
109-
try {
110-
sslContext = new SSLContextBuilder().loadTrustMaterial(null, acceptingTrustStrategy).build();
111-
112-
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
113-
e.printStackTrace();
114-
}
96+
public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws Exception {
97+
SSLContext sslContext = new SSLContextBuilder()
98+
.loadTrustMaterial(null, (certificate, authType) -> true).build();
11599

116100
final CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
117101
final HttpGet httpGet = new HttpGet(HOST_WITH_SSL);

‎pdf/pom.xml‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,41 @@
2424
<version>3.8.1</version>
2525
<scope>test</scope>
2626
</dependency>
27-
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
28-
<dependency>
29-
<groupId>org.apache.pdfbox</groupId>
30-
<artifactId>pdfbox</artifactId>
31-
<version>2.0.3</version>
32-
</dependency>
33-
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox-tools -->
3427
<dependency>
3528
<groupId>org.apache.pdfbox</groupId>
3629
<artifactId>pdfbox-tools</artifactId>
3730
<version>2.0.3</version>
3831
</dependency>
39-
<!-- https://mvnrepository.com/artifact/net.sf.cssbox/pdf2dom -->
4032
<dependency>
4133
<groupId>net.sf.cssbox</groupId>
4234
<artifactId>pdf2dom</artifactId>
4335
<version>1.6</version>
4436
</dependency>
45-
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
4637
<dependency>
4738
<groupId>com.itextpdf</groupId>
4839
<artifactId>itextpdf</artifactId>
4940
<version>5.5.10</version>
5041
</dependency>
51-
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
5242
<dependency>
5343
<groupId>org.apache.poi</groupId>
5444
<artifactId>poi</artifactId>
5545
<version>3.15</version>
5646
</dependency>
57-
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
58-
<dependency>
59-
<groupId>org.apache.poi</groupId>
60-
<artifactId>poi-ooxml</artifactId>
61-
<version>3.15</version>
62-
</dependency>
63-
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
6447
<dependency>
6548
<groupId>org.apache.poi</groupId>
6649
<artifactId>poi-scratchpad</artifactId>
6750
<version>3.15</version>
6851
</dependency>
69-
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-transcoder -->
7052
<dependency>
7153
<groupId>org.apache.xmlgraphics</groupId>
7254
<artifactId>batik-transcoder</artifactId>
7355
<version>1.8</version>
7456
</dependency>
57+
<dependency>
58+
<groupId>org.apache.poi</groupId>
59+
<artifactId>poi-ooxml</artifactId>
60+
<version>3.15</version>
61+
</dependency>
7562
</dependencies>
7663

7764
<build>

‎pdf/src/main/java/com/baeldung/pdf/PDF2HTMLExample.java‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ public static void main(String[] args) {
2323
}
2424

2525
private static void generateHTMLFromPDF(String filename) throws ParserConfigurationException, IOException {
26-
try {
27-
PDDocument pdf = PDDocument.load(new File(filename));
28-
PDFDomTree parser = new PDFDomTree();
29-
Writer output = new PrintWriter("src/output/pdf.html", "utf-8");
30-
parser.writeText(pdf, output);
31-
output.close();
32-
if (pdf != null) {
33-
pdf.close();
34-
}
35-
} catch (IOException e) {
36-
e.printStackTrace();
26+
PDDocument pdf = PDDocument.load(new File(filename));
27+
PDFDomTree parser = new PDFDomTree();
28+
Writer output = new PrintWriter("src/output/pdf.html", "utf-8");
29+
parser.writeText(pdf, output);
30+
output.close();
31+
if (pdf != null) {
32+
pdf.close();
3733
}
3834
}
3935
}

0 commit comments

Comments
 (0)