Merge branch 'master' into master

This commit is contained in:
dev-chirag
2019-05-02 22:24:56 +05:30
committed by GitHub
180 changed files with 2102 additions and 483 deletions
@@ -0,0 +1,2 @@
### Relevant Articles:
-
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>junit-5-configuration</artifactId>
<version>1.0-SNAPSHOT</version>
<name>junit-5-configuration</name>
<description>Intro to JUnit 5 configuration</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<junit.jupiter.version>5.3.1</junit.jupiter.version>
<junit.platform.version>1.2.0</junit.platform.version>
<junit.vintage.version>5.2.0</junit.vintage.version>
</properties>
</project>
@@ -0,0 +1,45 @@
package com.baeldung.resourcedirectory;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ReadResourceDirectoryUnitTest {
@Test
public void givenResourcePath_whenReadAbsolutePathWithFile_thenAbsolutePathEndsWithDirectory() {
String path = "src/test/resources";
File file = new File(path);
String absolutePath = file.getAbsolutePath();
System.out.println(absolutePath);
Assert.assertTrue(absolutePath.endsWith("src/test/resources"));
}
@Test
public void givenResourcePath_whenReadAbsolutePathWithPaths_thenAbsolutePathEndsWithDirectory() {
Path resourceDirectory = Paths.get("src", "test", "resources");
String absolutePath = resourceDirectory.toFile().getAbsolutePath();
System.out.println(absolutePath);
Assert.assertTrue(absolutePath.endsWith("src/test/resources"));
}
@Test
public void givenResourceFile_whenReadResourceWithClassLoader_thenPathEndWithFilename() {
String resourceName = "example_resource.txt";
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(resourceName).getFile());
String absolutePath = file.getAbsolutePath();
System.out.println(absolutePath);
Assert.assertTrue(absolutePath.endsWith("/example_resource.txt"));
}
}
+3 -10
View File
@@ -103,13 +103,6 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -130,10 +123,10 @@
</build>
<properties>
<junit.jupiter.version>5.3.1</junit.jupiter.version>
<junit.jupiter.version>5.4.2</junit.jupiter.version>
<mockito.junit.jupiter.version>2.23.0</mockito.junit.jupiter.version>
<junit.platform.version>1.2.0</junit.platform.version>
<junit.vintage.version>5.2.0</junit.vintage.version>
<junit.platform.version>1.4.2</junit.platform.version>
<junit.vintage.version>5.4.2</junit.vintage.version>
<log4j2.version>2.8.2</log4j2.version>
<h2.version>1.4.196</h2.version>
<powermock.version>2.0.0-RC.1</powermock.version>
@@ -86,7 +86,30 @@ class StringsUnitTest {
assertEquals(expected, actualValue);
}
@ParameterizedTest
@NullSource
void isBlank_ShouldReturnTrueForNullInputs(String input) {
assertTrue(Strings.isBlank(input));
}
@ParameterizedTest
@EmptySource
void isBlank_ShouldReturnTrueForEmptyStrings(String input) {
assertTrue(Strings.isBlank(input));
}
@ParameterizedTest
@NullAndEmptySource
void isBlank_ShouldReturnTrueForNullAndEmptyStrings(String input) {
assertTrue(Strings.isBlank(input));
}
@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = {" ", "\t", "\n"})
void isBlank_ShouldReturnTrueForAllTypesOfBlankStrings(String input) {
assertTrue(Strings.isBlank(input));
}
private static Stream<Arguments> provideStringsForIsBlank() {
return Stream.of(
+1
View File
@@ -33,5 +33,6 @@
<module>testing</module>
<module>testng</module>
<module>junit-5-2</module>
<module>junit-5-configuration</module>
</modules>
</project>