Skip to content

Commit dc86766

Browse files
committed
Merge branch 'master' of https://github.com/eugenp/tutorials
2 parents 1d0581c + 1635858 commit dc86766

File tree

30 files changed

+1269
-124
lines changed

30 files changed

+1269
-124
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
The "REST with Spring" Classes
33
==============================
44

5-
After 5 months of work, here's the Master Class of REST With Spring: <br/>
5+
Here's the Master Class of REST With Spring (price changes permanently next Friday): <br/>
66
**[>> THE REST WITH SPRING MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
77

88
And here's the Master Class of Learn Spring Security: <br/>

testing-modules/streams-ordering/src/test/java/benchmarking/TestBenchmark.java renamed to core-java-8/src/test/java/com/baeldung/streamordering/BenchmarkUnitTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package benchmarking;
1+
package com.baeldung.streamordering;
22

33
import org.junit.Test;
44
import org.openjdk.jmh.annotations.*;
@@ -15,7 +15,7 @@
1515
import java.util.stream.IntStream;
1616

1717

18-
public class TestBenchmark
18+
public class BenchmarkUnitTest
1919
{
2020

2121
@Test
@@ -94,4 +94,4 @@ public static class BenchmarkState
9494
for (int i = 0; i < 1000; i++)
9595
bh.consume (list.get (i));
9696
}
97-
}
97+
}

testing-modules/streams-ordering/src/test/java/StreamsOrderingTest.java renamed to core-java-8/src/test/java/com/baeldung/streamordering/StreamsOrderingUnitTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.baeldung.streamordering;
2+
13
import org.junit.Before;
24
import org.junit.Test;
35

@@ -10,10 +12,9 @@
1012

1113
import static org.junit.Assert.assertEquals;
1214

15+
public class StreamsOrderingUnitTest {
1316

14-
public class StreamsOrderingTest {
15-
16-
Logger logger = Logger.getLogger( StreamsOrderingTest.class.getName());
17+
Logger logger = Logger.getLogger( StreamsOrderingUnitTest.class.getName());
1718

1819
@Before
1920
public void setUp() throws Exception {

core-java-io/src/test/java/org/baeldung/java/io/JavaXToInputStreamUnitTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.baeldung.java.io;
22

33
import java.io.ByteArrayInputStream;
4+
import java.io.DataInputStream;
45
import java.io.File;
56
import java.io.FileInputStream;
67
import java.io.IOException;
78
import java.io.InputStream;
9+
import java.io.SequenceInputStream;
810

911
import org.apache.commons.io.FileUtils;
1012
import org.apache.commons.io.IOUtils;
@@ -74,6 +76,28 @@ public final void givenUsingPlainJava_whenConvertingFileToInputStream_thenCorrec
7476
IOUtils.closeQuietly(targetStream);
7577
}
7678

79+
@Test
80+
public final void givenUsingPlainJava_whenConvertingFileToDataInputStream_thenCorrect() throws IOException {
81+
final File initialFile = new File("src/test/resources/sample.txt");
82+
final InputStream targetStream = new DataInputStream(new FileInputStream(initialFile));
83+
84+
IOUtils.closeQuietly(targetStream);
85+
}
86+
87+
@Test
88+
public final void givenUsingPlainJava_whenConvertingFileToSequenceInputStream_thenCorrect() throws IOException {
89+
final File initialFile = new File("src/test/resources/sample.txt");
90+
final File anotherFile = new File("src/test/resources/anothersample.txt");
91+
final InputStream targetStream = new FileInputStream(initialFile);
92+
final InputStream anotherTargetStream = new FileInputStream(anotherFile);
93+
94+
InputStream sequenceTargetStream = new SequenceInputStream(targetStream, anotherTargetStream);
95+
96+
IOUtils.closeQuietly(targetStream);
97+
IOUtils.closeQuietly(anotherTargetStream);
98+
IOUtils.closeQuietly(sequenceTargetStream);
99+
}
100+
77101
@Test
78102
public final void givenUsingGuava_whenConvertingFileToInputStream_thenCorrect() throws IOException {
79103
final File initialFile = new File("src/test/resources/sample.txt");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
...Continues

core-java/src/test/java/com/baeldung/throwsexception/PersonRepositoryUnitTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,31 @@ public class PersonRepositoryUnitTest {
1313
PersonRepository personRepository = new PersonRepository();
1414

1515
@Test
16-
public void whenIdIsNull_thenExceptionIsThrown() throws Exception {
17-
assertThrows(Exception.class,
16+
public void whenIdIsNull_thenExceptionIsThrown() {
17+
assertThrows(IllegalArgumentException.class,
1818
() ->
1919
Optional
2020
.ofNullable(personRepository.findNameById(null))
21-
.orElseThrow(Exception::new));
21+
.orElseThrow(IllegalArgumentException::new));
2222
}
2323

2424
@Test
25-
public void whenIdIsNonNull_thenNoExceptionIsThrown() throws Exception {
25+
public void whenIdIsNonNull_thenNoExceptionIsThrown() {
2626
assertAll(
2727
() ->
2828
Optional
2929
.ofNullable(personRepository.findNameById("id"))
30-
.orElseThrow(Exception::new));
30+
.orElseThrow(RuntimeException::new));
31+
}
32+
33+
@Test
34+
public void whenIdNonNull_thenReturnsNameUpperCase() {
35+
String name = Optional
36+
.ofNullable(personRepository.findNameById("id"))
37+
.map(String::toUpperCase)
38+
.orElseThrow(RuntimeException::new);
39+
40+
assertEquals("NAME", name);
3141
}
3242

3343
@Test

core-kotlin/pom.xml

Lines changed: 98 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,105 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<artifactId>core-kotlin</artifactId>
6-
<packaging>jar</packaging>
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<artifactId>core-kotlin</artifactId>
6+
<packaging>jar</packaging>
77

8-
<parent>
9-
<groupId>com.baeldung</groupId>
10-
<artifactId>parent-kotlin</artifactId>
11-
<version>1.0.0-SNAPSHOT</version>
12-
<relativePath>../parent-kotlin</relativePath>
13-
</parent>
8+
<parent>
9+
<groupId>com.baeldung</groupId>
10+
<artifactId>parent-kotlin</artifactId>
11+
<version>1.0.0-SNAPSHOT</version>
12+
<relativePath>../parent-kotlin</relativePath>
13+
</parent>
1414

15-
<dependencies>
16-
<dependency>
17-
<groupId>org.jetbrains.spek</groupId>
18-
<artifactId>spek-api</artifactId>
19-
<version>1.1.5</version>
20-
<scope>test</scope>
21-
</dependency>
22-
<dependency>
23-
<groupId>org.jetbrains.spek</groupId>
24-
<artifactId>spek-subject-extension</artifactId>
25-
<version>1.1.5</version>
26-
<scope>test</scope>
27-
</dependency>
28-
<dependency>
29-
<groupId>org.jetbrains.spek</groupId>
30-
<artifactId>spek-junit-platform-engine</artifactId>
31-
<version>1.1.5</version>
32-
<scope>test</scope>
33-
</dependency>
34-
<dependency>
35-
<groupId>org.apache.commons</groupId>
36-
<artifactId>commons-math3</artifactId>
37-
<version>${commons-math3.version}</version>
38-
</dependency>
39-
<dependency>
40-
<groupId>org.junit.platform</groupId>
41-
<artifactId>junit-platform-runner</artifactId>
42-
<version>${junit.platform.version}</version>
43-
<scope>test</scope>
44-
</dependency>
45-
<dependency>
46-
<groupId>khttp</groupId>
47-
<artifactId>khttp</artifactId>
48-
<version>${khttp.version}</version>
49-
</dependency>
50-
<dependency>
51-
<groupId>com.nhaarman</groupId>
52-
<artifactId>mockito-kotlin</artifactId>
53-
<version>${mockito-kotlin.version}</version>
54-
<scope>test</scope>
55-
</dependency>
56-
<dependency>
57-
<groupId>com.github.salomonbrys.kodein</groupId>
58-
<artifactId>kodein</artifactId>
59-
<version>${kodein.version}</version>
60-
</dependency>
61-
<dependency>
62-
<groupId>org.assertj</groupId>
63-
<artifactId>assertj-core</artifactId>
64-
<version>${assertj.version}</version>
65-
<scope>test</scope>
66-
</dependency>
67-
<dependency>
68-
<groupId>com.beust</groupId>
69-
<artifactId>klaxon</artifactId>
70-
<version>${klaxon.version}</version>
71-
</dependency>
72-
</dependencies>
15+
<repositories>
16+
<repository>
17+
<id>exposed</id>
18+
<name>exposed</name>
19+
<url>https://dl.bintray.com/kotlin/exposed</url>
20+
</repository>
21+
</repositories>
7322

74-
<properties>
75-
<mockito-kotlin.version>1.5.0</mockito-kotlin.version>
76-
<kodein.version>4.1.0</kodein.version>
77-
<klaxon.version>3.0.4</klaxon.version>
78-
<khttp.version>0.1.0</khttp.version>
79-
<commons-math3.version>3.6.1</commons-math3.version>
80-
<junit.platform.version>1.1.1</junit.platform.version>
81-
<junit.vintage.version>5.2.0</junit.vintage.version>
82-
<assertj.version>3.10.0</assertj.version>
83-
</properties>
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.jetbrains.spek</groupId>
26+
<artifactId>spek-api</artifactId>
27+
<version>1.1.5</version>
28+
<scope>test</scope>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.jetbrains.spek</groupId>
32+
<artifactId>spek-subject-extension</artifactId>
33+
<version>1.1.5</version>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.jetbrains.spek</groupId>
38+
<artifactId>spek-junit-platform-engine</artifactId>
39+
<version>1.1.5</version>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.apache.commons</groupId>
44+
<artifactId>commons-math3</artifactId>
45+
<version>${commons-math3.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.junit.platform</groupId>
49+
<artifactId>junit-platform-runner</artifactId>
50+
<version>${junit.platform.version}</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>khttp</groupId>
55+
<artifactId>khttp</artifactId>
56+
<version>${khttp.version}</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.nhaarman</groupId>
60+
<artifactId>mockito-kotlin</artifactId>
61+
<version>${mockito-kotlin.version}</version>
62+
<scope>test</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>com.github.salomonbrys.kodein</groupId>
66+
<artifactId>kodein</artifactId>
67+
<version>${kodein.version}</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.assertj</groupId>
71+
<artifactId>assertj-core</artifactId>
72+
<version>${assertj.version}</version>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>com.beust</groupId>
77+
<artifactId>klaxon</artifactId>
78+
<version>${klaxon.version}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.jetbrains.exposed</groupId>
82+
<artifactId>exposed</artifactId>
83+
<version>${exposed.version}</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>com.h2database</groupId>
87+
<artifactId>h2</artifactId>
88+
<version>${h2database.version}</version>
89+
</dependency>
90+
</dependencies>
91+
92+
<properties>
93+
<mockito-kotlin.version>1.5.0</mockito-kotlin.version>
94+
<kodein.version>4.1.0</kodein.version>
95+
<klaxon.version>3.0.4</klaxon.version>
96+
<khttp.version>0.1.0</khttp.version>
97+
<commons-math3.version>3.6.1</commons-math3.version>
98+
<junit.platform.version>1.1.1</junit.platform.version>
99+
<junit.vintage.version>5.2.0</junit.vintage.version>
100+
<assertj.version>3.10.0</assertj.version>
101+
<h2database.version>1.4.197</h2database.version>
102+
<exposed.version>0.10.4</exposed.version>
103+
</properties>
84104

85105
</project>

0 commit comments

Comments
 (0)