diff --git a/core-kotlin-2/build.gradle b/core-kotlin-2/build.gradle
index b058e0ecad..1c52172404 100644
--- a/core-kotlin-2/build.gradle
+++ b/core-kotlin-2/build.gradle
@@ -5,7 +5,7 @@ version '1.0-SNAPSHOT'
buildscript {
- ext.kotlin_version = '1.2.41'
+ ext.kotlin_version = '1.3.30'
repositories {
mavenCentral()
@@ -26,8 +26,6 @@ sourceCompatibility = 1.8
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }
-kotlin { experimental { coroutines "enable" } }
-
repositories {
mavenCentral()
jcenter()
@@ -39,10 +37,22 @@ sourceSets {
srcDirs 'com/baeldung/ktor'
}
}
+}
+test {
+ useJUnitPlatform()
+ testLogging {
+ events "passed", "skipped", "failed"
+ }
}
dependencies {
- compile "ch.qos.logback:logback-classic:1.2.1"
- testCompile group: 'junit', name: 'junit', version: '4.12'
-}
\ No newline at end of file
+ implementation "ch.qos.logback:logback-classic:1.2.1"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
+ testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2'
+ testImplementation 'junit:junit:4.12'
+ testImplementation 'org.assertj:assertj-core:3.12.2'
+ testImplementation 'org.mockito:mockito-core:2.27.0'
+ testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
+ testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:${kotlin_version}"
+}
diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar b/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar
index 01b8bf6b1f..5c2d1cf016 100644
Binary files a/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar and b/core-kotlin-2/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties b/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties
index 933b6473ce..5f1b1201a7 100644
--- a/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties
+++ b/core-kotlin-2/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
diff --git a/core-kotlin-2/gradlew b/core-kotlin-2/gradlew
index cccdd3d517..b0d6d0ab5d 100644
--- a/core-kotlin-2/gradlew
+++ b/core-kotlin-2/gradlew
@@ -1,5 +1,21 @@
#!/usr/bin/env sh
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
diff --git a/core-kotlin-2/gradlew.bat b/core-kotlin-2/gradlew.bat
index f9553162f1..9991c50326 100644
--- a/core-kotlin-2/gradlew.bat
+++ b/core-kotlin-2/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
diff --git a/core-kotlin-2/pom.xml b/core-kotlin-2/pom.xml
index e329611593..be2f5fa68f 100644
--- a/core-kotlin-2/pom.xml
+++ b/core-kotlin-2/pom.xml
@@ -20,9 +20,21 @@
${kotlin.version}
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.jupiter.version}
+ test
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+ net.bytebuddy
+ byte-buddy
+ ${byte-buddy.version}
test
@@ -37,6 +49,12 @@
${kotlin.version}
test
+
+ org.jetbrains.kotlin
+ kotlin-test-junit5
+ ${kotlin.version}
+ test
+
@@ -69,10 +87,11 @@
- 1.2.71
- 1.1.1
- 5.2.0
+ 1.3.30
+ 5.4.2
+ 2.27.0
+ 1.9.12
3.10.0
-
\ No newline at end of file
+
diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt b/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt
new file mode 100644
index 0000000000..c73096fce6
--- /dev/null
+++ b/core-kotlin-2/src/test/kotlin/com/baeldung/console/ConsoleIOUnitTest.kt
@@ -0,0 +1,79 @@
+package com.baeldung.console
+
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.Test
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.mock
+import java.io.BufferedReader
+import java.io.ByteArrayInputStream
+import java.io.ByteArrayOutputStream
+import java.io.Console
+import java.io.InputStreamReader
+import java.io.PrintStream
+import java.util.*
+
+
+class ConsoleIOUnitTest {
+
+ @Test
+ fun givenText_whenPrint_thenPrintText() {
+ val expectedTest = "Hello from Kotlin"
+ val out = ByteArrayOutputStream()
+ System.setOut(PrintStream(out))
+
+ print(expectedTest)
+ out.flush()
+ val printedText = String(out.toByteArray())
+
+ assertThat(printedText).isEqualTo(expectedTest)
+ }
+
+ @Test
+ fun givenInput_whenRead_thenReadText() {
+ val expectedTest = "Hello from Kotlin"
+ val input = ByteArrayInputStream(expectedTest.toByteArray())
+ System.setIn(input)
+
+ val readText = readLine()
+
+ assertThat(readText).isEqualTo(expectedTest)
+ }
+
+ @Test
+ fun givenInput_whenReadWithScanner_thenReadText() {
+ val expectedTest = "Hello from Kotlin"
+ val scanner = Scanner(ByteArrayInputStream(expectedTest.toByteArray()))
+
+ val readText = scanner.nextLine()
+
+ assertThat(readText).isEqualTo(expectedTest)
+ }
+
+ @Test
+ fun givenInput_whenReadWithBufferedReader_thenReadText() {
+ val expectedTest = "Hello from Kotlin"
+ val reader = BufferedReader(InputStreamReader(ByteArrayInputStream(expectedTest.toByteArray())))
+
+ val readText = reader.readLine()
+
+ assertThat(readText).isEqualTo(expectedTest)
+ }
+
+ @Test
+ fun givenInput_whenReadWithConsole_thenReadText() {
+ val expectedTest = "Hello from Kotlin"
+ val console = mock(Console::class.java)
+ `when`(console.readLine()).thenReturn(expectedTest)
+
+ val readText = console.readLine()
+
+ assertThat(readText).isEqualTo(expectedTest)
+ }
+
+ @AfterEach
+ fun resetIO() {
+ System.setOut(System.out)
+ System.setIn(System.`in`)
+ }
+}
\ No newline at end of file
diff --git a/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
new file mode 100644
index 0000000000..ca6ee9cea8
--- /dev/null
+++ b/core-kotlin-2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
@@ -0,0 +1 @@
+mock-maker-inline
\ No newline at end of file
diff --git a/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt
index 3437ddb68a..d10d23bef0 100644
--- a/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt
+++ b/core-kotlin-io/src/test/kotlin/com/baeldung/inputstream/InputStreamToStringTest.kt
@@ -8,7 +8,8 @@ import kotlin.test.assertEquals
class InputStreamToStringTest {
private val fileName = "src/test/resources/inputstream2string.txt"
- private val fileFullContent = "Computer programming can be a hassle\r\n" +
+ private val endOfLine = System.lineSeparator()
+ private val fileFullContent = "Computer programming can be a hassle$endOfLine" +
"It's like trying to take a defended castle"
@Test
@@ -46,7 +47,7 @@ class InputStreamToStringTest {
} finally {
reader.close()
}
- assertEquals(fileFullContent.replace("\r\n", ""), content.toString())
+ assertEquals(fileFullContent.replace(endOfLine, ""), content.toString())
}
diff --git a/parent-kotlin/pom.xml b/parent-kotlin/pom.xml
index 7a3a8b10ca..86ab45ecb1 100644
--- a/parent-kotlin/pom.xml
+++ b/parent-kotlin/pom.xml
@@ -202,10 +202,10 @@
- 1.3.10
+ 1.3.30
1.0.0
0.9.5
- 3.11.0
- 1.2.0
+ 3.12.0
+ 1.3.2