From 2d34971fcc35dbad2bdbe2bdda586c709a19fa81 Mon Sep 17 00:00:00 2001
From: maibin <michal.aibin@gmail.com>
Date: Mon, 14 Nov 2016 09:45:01 +0100
Subject: [PATCH] Junit5 (latest two commits) (#825)

* PDF to X

* PDF to X

* Remove created doc

* Code fixes and cleanup for PDF module

* Fix web.xml in spring-mvc-web-vs-initializer project

* Rollback web.xml

* Fixes to PDF article

* Merge with main eugen branch

* Junit 5

* Fix name of test and modifier
---
 .../com/baeldung/hexToAscii/HexToAscii.java   |  46 +++++
 .../equalshashcode/entities/ComplexClass.java |  63 ++++++
 .../entities/PrimitiveClass.java              |  54 +++++
 .../equalshashcode/entities/Rectangle.java    |  58 ++++++
 .../equalshashcode/entities/Shape.java        |   7 +
 .../equalshashcode/entities/Square.java       |  58 ++++++
 .../executable/ExecutableMavenJar.java        |  11 +
 .../interfaces/NetworkInterfaceTest.java      | 122 +++++++++++
 .../java/com/baeldung/java/nio2/PathTest.java | 195 ++++++++++++++++++
 .../front/controller/filters/AuditFilter.java |  25 +++
 .../filters/VisitorCounterFilter.java         |  23 +++
 enterprise-patterns/pom.xml                   |  35 ++++
 junit5/{REDAME.md => README.md}               |   0
 junit5/pom.xml                                | 120 ++++-------
 .../test/java/com/baeldung/AssertionTest.java |  29 +++
 .../java/com/baeldung/AssumptionTest.java     |   8 +-
 .../test/java/com/baeldung/ExceptionTest.java |  30 ++-
 .../src/test/java/com/baeldung/FirstTest.java |   6 +-
 .../com/baeldung/JUnit5NewFeaturesTest.java   |  50 +++++
 .../src/test/java/com/baeldung/LiveTest.java  |  38 ++++
 .../test/java/com/baeldung/NestedTest.java    |   8 +-
 .../test/java/com/baeldung/StringUtils.java   |  11 +
 .../test/java/com/baeldung/TaggedTest.java    |   6 +-
 .../java/com/baeldung/suites/AllTests.java    |   8 +
 24 files changed, 914 insertions(+), 97 deletions(-)
 create mode 100644 core-java/src/main/java/com/baeldung/hexToAscii/HexToAscii.java
 create mode 100644 core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
 create mode 100644 core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
 create mode 100644 core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
 create mode 100644 core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
 create mode 100644 core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java
 create mode 100644 core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java
 create mode 100644 core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java
 create mode 100644 core-java/src/test/java/com/baeldung/java/nio2/PathTest.java
 create mode 100644 enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java
 create mode 100644 enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java
 create mode 100644 enterprise-patterns/pom.xml
 rename junit5/{REDAME.md => README.md} (100%)
 create mode 100644 junit5/src/test/java/com/baeldung/AssertionTest.java
 create mode 100644 junit5/src/test/java/com/baeldung/JUnit5NewFeaturesTest.java
 create mode 100644 junit5/src/test/java/com/baeldung/LiveTest.java
 create mode 100644 junit5/src/test/java/com/baeldung/StringUtils.java
 create mode 100644 junit5/src/test/java/com/baeldung/suites/AllTests.java

diff --git a/core-java/src/main/java/com/baeldung/hexToAscii/HexToAscii.java b/core-java/src/main/java/com/baeldung/hexToAscii/HexToAscii.java
new file mode 100644
index 0000000000..2a3c4b109e
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/hexToAscii/HexToAscii.java
@@ -0,0 +1,46 @@
+package com.baeldung.hexToAscii;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class HexToAscii {
+
+    @Test
+    public static void whenHexToAscii() {
+        String asciiString = "http://www.baeldung.com/jackson-serialize-dates";
+        String hexEquivalent = "687474703a2f2f7777772e6261656c64756e672e636f6d2f6a61636b736f6e2d73657269616c697a652d6461746573";
+
+        assertEquals(asciiString, hexToAscii(hexEquivalent));
+    }
+
+    @Test
+    public static void whenAsciiToHex() {
+        String asciiString = "http://www.baeldung.com/jackson-serialize-dates";
+        String hexEquivalent = "687474703a2f2f7777772e6261656c64756e672e636f6d2f6a61636b736f6e2d73657269616c697a652d6461746573";
+
+        assertEquals(hexEquivalent, asciiToHex(asciiString));
+    }
+
+    //
+
+    private static String asciiToHex(String asciiStr) {
+        char[] chars = asciiStr.toCharArray();
+        StringBuilder hex = new StringBuilder();
+        for (char ch : chars) {
+            hex.append(Integer.toHexString((int) ch));
+        }
+
+        return hex.toString();
+    }
+
+    private static String hexToAscii(String hexStr) {
+        StringBuilder output = new StringBuilder("");
+        for (int i = 0; i < hexStr.length(); i += 2) {
+            String str = hexStr.substring(i, i + 2);
+            output.append((char) Integer.parseInt(str, 16));
+        }
+        return output.toString();
+    }
+
+}
diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
new file mode 100644
index 0000000000..6329f41252
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/ComplexClass.java
@@ -0,0 +1,63 @@
+package org.baeldung.equalshashcode.entities;
+
+import java.util.List;
+import java.util.Set;
+
+public class ComplexClass {
+
+    private List<?> genericList;
+    private Set<Integer> integerSet;
+
+    public ComplexClass(List<?> genericArrayList, Set<Integer> integerHashSet) {
+        super();
+        this.genericList = genericArrayList;
+        this.integerSet = integerHashSet;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((genericList == null) ? 0 : genericList.hashCode());
+        result = prime * result + ((integerSet == null) ? 0 : integerSet.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (!(obj instanceof ComplexClass))
+            return false;
+        ComplexClass other = (ComplexClass) obj;
+        if (genericList == null) {
+            if (other.genericList != null)
+                return false;
+        } else if (!genericList.equals(other.genericList))
+            return false;
+        if (integerSet == null) {
+            if (other.integerSet != null)
+                return false;
+        } else if (!integerSet.equals(other.integerSet))
+            return false;
+        return true;
+    }
+
+    protected List<?> getGenericList() {
+        return genericList;
+    }
+
+    protected void setGenericArrayList(List<?> genericList) {
+        this.genericList = genericList;
+    }
+
+    protected Set<Integer> getIntegerSet() {
+        return integerSet;
+    }
+
+    protected void setIntegerSet(Set<Integer> integerSet) {
+        this.integerSet = integerSet;
+    }
+}
diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
new file mode 100644
index 0000000000..ebe005688c
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/PrimitiveClass.java
@@ -0,0 +1,54 @@
+package org.baeldung.equalshashcode.entities;
+
+public class PrimitiveClass {
+
+    private boolean primitiveBoolean;
+    private int primitiveInt;
+
+    public PrimitiveClass(boolean primitiveBoolean, int primitiveInt) {
+        super();
+        this.primitiveBoolean = primitiveBoolean;
+        this.primitiveInt = primitiveInt;
+    }
+
+    protected boolean isPrimitiveBoolean() {
+        return primitiveBoolean;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (primitiveBoolean ? 1231 : 1237);
+        result = prime * result + primitiveInt;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        PrimitiveClass other = (PrimitiveClass) obj;
+        if (primitiveBoolean != other.primitiveBoolean)
+            return false;
+        if (primitiveInt != other.primitiveInt)
+            return false;
+        return true;
+    }
+
+    protected void setPrimitiveBoolean(boolean primitiveBoolean) {
+        this.primitiveBoolean = primitiveBoolean;
+    }
+
+    protected int getPrimitiveInt() {
+        return primitiveInt;
+    }
+
+    protected void setPrimitiveInt(int primitiveInt) {
+        this.primitiveInt = primitiveInt;
+    }
+}
diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
new file mode 100644
index 0000000000..1e1423f0b3
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Rectangle.java
@@ -0,0 +1,58 @@
+package org.baeldung.equalshashcode.entities;
+
+public class Rectangle extends Shape {
+    private double width;
+    private double length;
+
+    public Rectangle(double width, double length) {
+        this.width = width;
+        this.length = length;
+    }
+
+    @Override
+    public double area() {
+        return width * length;
+    }
+
+    @Override
+    public double perimeter() {
+        return 2 * (width + length);
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        long temp;
+        temp = Double.doubleToLongBits(length);
+        result = prime * result + (int) (temp ^ (temp >>> 32));
+        temp = Double.doubleToLongBits(width);
+        result = prime * result + (int) (temp ^ (temp >>> 32));
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Rectangle other = (Rectangle) obj;
+        if (Double.doubleToLongBits(length) != Double.doubleToLongBits(other.length))
+            return false;
+        if (Double.doubleToLongBits(width) != Double.doubleToLongBits(other.width))
+            return false;
+        return true;
+    }
+
+    protected double getWidth() {
+        return width;
+    }
+
+    protected double getLength() {
+        return length;
+    }
+
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
new file mode 100644
index 0000000000..3bfc81da8f
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Shape.java
@@ -0,0 +1,7 @@
+package org.baeldung.equalshashcode.entities;
+
+public abstract class Shape {
+    public abstract double area();
+
+    public abstract double perimeter();
+}
diff --git a/core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java
new file mode 100644
index 0000000000..f11e34f0ba
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/equalshashcode/entities/Square.java
@@ -0,0 +1,58 @@
+package org.baeldung.equalshashcode.entities;
+
+import java.awt.Color;
+
+public class Square extends Rectangle {
+
+    Color color;
+
+    public Square(double width, Color color) {
+        super(width, width);
+        this.color = color;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((color == null) ? 0 : color.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof Square)) {
+            return false;
+        }
+        Square other = (Square) obj;
+        if (color == null) {
+            if (other.color != null) {
+                return false;
+            }
+        } else if (!color.equals(other.color)) {
+            return false;
+        }
+        return true;
+    }
+
+    protected Color getColor() {
+        return color;
+    }
+
+    protected void setColor(Color color) {
+        this.color = color;
+    }
+
+}
diff --git a/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java b/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java
new file mode 100644
index 0000000000..09344902b7
--- /dev/null
+++ b/core-java/src/main/java/org/baeldung/executable/ExecutableMavenJar.java
@@ -0,0 +1,11 @@
+package org.baeldung.executable;
+
+import javax.swing.JOptionPane;
+
+public class ExecutableMavenJar {
+
+    public static void main(String[] args) {
+        JOptionPane.showMessageDialog(null, "It worked!", "Executable Jar with Maven", 1);
+    }
+
+}
diff --git a/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java b/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java
new file mode 100644
index 0000000000..4a8ef57b8f
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java
@@ -0,0 +1,122 @@
+package com.baeldung.java.networking.interfaces;
+
+import static org.junit.Assert.*;
+
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.junit.Test;
+
+public class NetworkInterfaceTest {
+    @Test
+    public void givenName_whenReturnsNetworkInterface_thenCorrect() throws SocketException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenInExistentName_whenReturnsNull_thenCorrect() throws SocketException {
+        NetworkInterface nif = NetworkInterface.getByName("inexistent_name");
+        assertNull(nif);
+    }
+
+    @Test
+    public void givenIP_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException {
+        byte[] ip = new byte[] { 127, 0, 0, 1 };
+        NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getByAddress(ip));
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenHostName_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getByName("localhost"));
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenLocalHost_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getLocalHost());
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenLoopBack_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getLoopbackAddress());
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenIndex_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByIndex(0);
+        assertNotNull(nif);
+    }
+
+    @Test
+    public void givenInterface_whenReturnsInetAddresses_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        Enumeration<InetAddress> addressEnum = nif.getInetAddresses();
+        InetAddress address = addressEnum.nextElement();
+        assertEquals("127.0.0.1", address.getHostAddress());
+    }
+
+    @Test
+    public void givenInterface_whenReturnsInterfaceAddresses_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+
+        List<InterfaceAddress> addressEnum = nif.getInterfaceAddresses();
+        InterfaceAddress address = addressEnum.get(0);
+        InetAddress localAddress = address.getAddress();
+        InetAddress broadCastAddress = address.getBroadcast();
+        assertEquals("127.0.0.1", localAddress.getHostAddress());
+        assertEquals("127.255.255.255", broadCastAddress.getHostAddress());
+    }
+
+    @Test
+    public void givenInterface_whenChecksIfLoopback_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertTrue(nif.isLoopback());
+    }
+
+    @Test
+    public void givenInterface_whenChecksIfUp_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertTrue(nif.isUp());
+    }
+
+    @Test
+    public void givenInterface_whenChecksIfPointToPoint_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertFalse(nif.isPointToPoint());
+    }
+
+    @Test
+    public void givenInterface_whenChecksIfVirtual_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertFalse(nif.isVirtual());
+    }
+
+    @Test
+    public void givenInterface_whenChecksMulticastSupport_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        assertTrue(nif.supportsMulticast());
+    }
+
+    @Test
+    public void givenInterface_whenGetsMacAddress_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("lo");
+        byte[] bytes = nif.getHardwareAddress();
+        assertNotNull(bytes);
+    }
+
+    @Test
+    public void givenInterface_whenGetsMTU_thenCorrect() throws SocketException, UnknownHostException {
+        NetworkInterface nif = NetworkInterface.getByName("net0");
+        int mtu = nif.getMTU();
+        assertEquals(1500, mtu);
+    }
+}
diff --git a/core-java/src/test/java/com/baeldung/java/nio2/PathTest.java b/core-java/src/test/java/com/baeldung/java/nio2/PathTest.java
new file mode 100644
index 0000000000..004aeb3deb
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/java/nio2/PathTest.java
@@ -0,0 +1,195 @@
+package com.baeldung.java.nio2;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Date;
+
+import org.junit.Test;
+
+public class PathTest {
+
+    private static final String HOME = System.getProperty("user.home");
+
+    // creating a path
+    @Test
+    public void givenPathString_whenCreatesPathObject_thenCorrect() {
+        Path p = Paths.get("/articles/baeldung");
+        assertEquals("\\articles\\baeldung", p.toString());
+
+    }
+
+    @Test
+    public void givenPathParts_whenCreatesPathObject_thenCorrect() {
+        Path p = Paths.get("/articles", "baeldung");
+        assertEquals("\\articles\\baeldung", p.toString());
+
+    }
+
+    // retrieving path info
+    @Test
+    public void givenPath_whenRetrievesFileName_thenCorrect() {
+        Path p = Paths.get("/articles/baeldung/logs");
+        assertEquals("logs", p.getFileName().toString());
+    }
+
+    @Test
+    public void givenPath_whenRetrievesNameByIndex_thenCorrect() {
+        Path p = Paths.get("/articles/baeldung/logs");
+        assertEquals("articles", p.getName(0).toString());
+        assertEquals("baeldung", p.getName(1).toString());
+        assertEquals("logs", p.getName(2).toString());
+    }
+
+    @Test
+    public void givenPath_whenCountsParts_thenCorrect() {
+        Path p = Paths.get("/articles/baeldung/logs");
+        assertEquals(3, p.getNameCount());
+    }
+
+    @Test
+    public void givenPath_whenCanRetrieveSubsequenceByIndex_thenCorrect() {
+        Path p = Paths.get("/articles/baeldung/logs");
+        assertEquals("articles", p.subpath(0, 1).toString());
+        assertEquals("articles\\baeldung", p.subpath(0, 2).toString());
+        assertEquals("articles\\baeldung\\logs", p.subpath(0, 3).toString());
+        assertEquals("baeldung", p.subpath(1, 2).toString());
+        assertEquals("baeldung\\logs", p.subpath(1, 3).toString());
+        assertEquals("logs", p.subpath(2, 3).toString());
+    }
+
+    @Test
+    public void givenPath_whenRetrievesParent_thenCorrect() {
+        Path p1 = Paths.get("/articles/baeldung/logs");
+        Path p2 = Paths.get("/articles/baeldung");
+        Path p3 = Paths.get("/articles");
+        Path p4 = Paths.get("/");
+
+        assertEquals("\\articles\\baeldung", p1.getParent().toString());
+        assertEquals("\\articles", p2.getParent().toString());
+        assertEquals("\\", p3.getParent().toString());
+        assertEquals(null, p4.getParent());
+    }
+
+    @Test
+    public void givenPath_whenRetrievesRoot_thenCorrect() {
+        Path p1 = Paths.get("/articles/baeldung/logs");
+        Path p2 = Paths.get("c:/articles/baeldung/logs");
+
+        assertEquals("\\", p1.getRoot().toString());
+        assertEquals("c:\\", p2.getRoot().toString());
+    }
+
+    // removing redundancies from path
+    @Test
+    public void givenPath_whenRemovesRedundancies_thenCorrect1() {
+        Path p = Paths.get("/home/./baeldung/articles");
+        p = p.normalize();
+        assertEquals("\\home\\baeldung\\articles", p.toString());
+    }
+
+    @Test
+    public void givenPath_whenRemovesRedundancies_thenCorrect2() {
+        Path p = Paths.get("/home/baeldung/../articles");
+        p = p.normalize();
+        assertEquals("\\home\\articles", p.toString());
+    }
+
+    // converting a path
+    @Test
+    public void givenPath_whenConvertsToBrowseablePath_thenCorrect() {
+        Path p = Paths.get("/home/baeldung/articles.html");
+        URI uri = p.toUri();
+        assertEquals("file:///E:/home/baeldung/articles.html", uri.toString());
+    }
+
+    @Test
+    public void givenPath_whenConvertsToAbsolutePath_thenCorrect() {
+        Path p = Paths.get("/home/baeldung/articles.html");
+        assertEquals("E:\\home\\baeldung\\articles.html", p.toAbsolutePath().toString());
+    }
+
+    @Test
+    public void givenAbsolutePath_whenRetainsAsAbsolute_thenCorrect() {
+        Path p = Paths.get("E:\\home\\baeldung\\articles.html");
+        assertEquals("E:\\home\\baeldung\\articles.html", p.toAbsolutePath().toString());
+    }
+
+    @Test
+    public void givenExistingPath_whenGetsRealPathToFile_thenCorrect() throws IOException {
+        Path p = Paths.get(HOME);
+        assertEquals(HOME, p.toRealPath().toString());
+    }
+
+    @Test(expected = NoSuchFileException.class)
+    public void givenInExistentPath_whenFailsToConvert_thenCorrect() throws IOException {
+        Path p = Paths.get("E:\\home\\baeldung\\articles.html");
+
+        p.toRealPath();
+    }
+
+    // joining paths
+    @Test
+    public void givenTwoPaths_whenJoinsAndResolves_thenCorrect() throws IOException {
+        Path p = Paths.get("/baeldung/articles");
+        assertEquals("\\baeldung\\articles\\java", p.resolve("java").toString());
+    }
+
+    @Test
+    public void givenAbsolutePath_whenResolutionRetainsIt_thenCorrect() throws IOException {
+        Path p = Paths.get("/baeldung/articles");
+        assertEquals("C:\\baeldung\\articles\\java", p.resolve("C:\\baeldung\\articles\\java").toString());
+    }
+
+    @Test
+    public void givenPathWithRoot_whenResolutionRetainsIt_thenCorrect2() throws IOException {
+        Path p = Paths.get("/baeldung/articles");
+        assertEquals("\\java", p.resolve("/java").toString());
+    }
+
+    // creating a path between 2 paths
+    @Test
+    public void givenSiblingPaths_whenCreatesPathToOther_thenCorrect() throws IOException {
+        Path p1 = Paths.get("articles");
+        Path p2 = Paths.get("authors");
+        assertEquals("..\\authors", p1.relativize(p2).toString());
+        assertEquals("..\\articles", p2.relativize(p1).toString());
+    }
+
+    @Test
+    public void givenNonSiblingPaths_whenCreatesPathToOther_thenCorrect() throws IOException {
+        Path p1 = Paths.get("/baeldung");
+        Path p2 = Paths.get("/baeldung/authors/articles");
+        assertEquals("authors\\articles", p1.relativize(p2).toString());
+        assertEquals("..\\..", p2.relativize(p1).toString());
+    }
+
+    // comparing 2 paths
+    @Test
+    public void givenTwoPaths_whenTestsEquality_thenCorrect() throws IOException {
+        Path p1 = Paths.get("/baeldung/articles");
+        Path p2 = Paths.get("/baeldung/articles");
+        Path p3 = Paths.get("/baeldung/authors");
+
+        assertTrue(p1.equals(p2));
+        assertFalse(p1.equals(p3));
+    }
+
+    @Test
+    public void givenPath_whenInspectsStart_thenCorrect() {
+        Path p1 = Paths.get("/baeldung/articles");
+        assertTrue(p1.startsWith("/baeldung"));
+    }
+
+    @Test
+    public void givenPath_whenInspectsEnd_thenCorrect() {
+        Path p1 = Paths.get("/baeldung/articles");
+        assertTrue(p1.endsWith("articles"));
+    }
+}
diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java
new file mode 100644
index 0000000000..d24c0a94b3
--- /dev/null
+++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java
@@ -0,0 +1,25 @@
+package com.baeldung.enterprise.patterns.front.controller.filters;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+public class AuditFilter extends BaseFilter {
+    @Override
+    public void doFilter(
+      ServletRequest request,
+      ServletResponse response,
+      FilterChain chain
+    ) throws IOException, ServletException {
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        HttpSession session = httpServletRequest.getSession(false);
+        if (session != null && session.getAttribute("username") != null) {
+            request.setAttribute("username", session.getAttribute("username"));
+        }
+        chain.doFilter(request, response);
+    }
+}
diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java
new file mode 100644
index 0000000000..0ae7cd73fd
--- /dev/null
+++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java
@@ -0,0 +1,23 @@
+package com.baeldung.enterprise.patterns.front.controller.filters;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import java.io.IOException;
+
+@WebFilter(servletNames = "front-controller")
+public class VisitorCounterFilter extends BaseFilter {
+    private int counter;
+
+    @Override
+    public void doFilter(
+      ServletRequest request,
+      ServletResponse response,
+      FilterChain chain
+    ) throws IOException, ServletException {
+        request.setAttribute("counter", ++counter);
+        chain.doFilter(request, response);
+    }
+}
diff --git a/enterprise-patterns/pom.xml b/enterprise-patterns/pom.xml
new file mode 100644
index 0000000000..036a61c44a
--- /dev/null
+++ b/enterprise-patterns/pom.xml
@@ -0,0 +1,35 @@
+<?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>
+
+    <groupId>com.baeldung.enterprise.patterns</groupId>
+    <artifactId>enterprise-patterns-parent</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>spring-dispatcher-servlet</module>
+    </modules>
+
+    <parent>
+        <groupId>com.baeldung</groupId>
+        <artifactId>parent-modules</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.5.1</version>
+                    <configuration>
+                        <source>1.8</source>
+                        <target>1.8</target>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>
diff --git a/junit5/REDAME.md b/junit5/README.md
similarity index 100%
rename from junit5/REDAME.md
rename to junit5/README.md
diff --git a/junit5/pom.xml b/junit5/pom.xml
index 5a2ea61668..84d64e7b42 100644
--- a/junit5/pom.xml
+++ b/junit5/pom.xml
@@ -1,83 +1,53 @@
 <?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>
+<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>
 
-    <groupId>com.baeldung</groupId>
-    <artifactId>junit5</artifactId>
-    <version>1.0-SNAPSHOT</version>
+	<groupId>com.baeldung</groupId>
+	<artifactId>junit5</artifactId>
+	<version>1.0-SNAPSHOT</version>
 
-    <name>junit5</name>
-    <description>Intro to JUnit 5</description>
+	<name>junit5</name>
+	<description>Intro to JUnit 5</description>
 
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <java.version>1.8</java.version>
-        <!-- Due to a bug in surefire-junit5-5.0.0-ALPHA we use the latest snapshot instead -->
-        <junit.gen5.version>5.0.0-SNAPSHOT</junit.gen5.version>
-    </properties>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<java.version>1.8</java.version>
+		<junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
+		<junit.platform.version>1.0.0-M2</junit.platform.version>
+	</properties>
 
-    <repositories>
-        <repository>
-            <id>snapshots-repo</id>
-            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-            <snapshots>
-                <!-- Do NOT cache JUnit 5 snapshot JARs. -->
-                <updatePolicy>always</updatePolicy>
-                <enabled>true</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.1</version>
+				<configuration>
+					<source>${java.version}</source>
+					<target>${java.version}</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.19</version>
+				<dependencies>
+					<dependency>
+						<groupId>org.junit.platform</groupId>
+						<artifactId>junit-platform-surefire-provider</artifactId>
+						<version>${junit.platform.version}</version>
+					</dependency>
+				</dependencies>
+			</plugin>
+		</plugins>
+	</build>
 
-    <pluginRepositories>
-        <pluginRepository>
-            <id>snapshots-repo</id>
-            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-            <snapshots>
-                <!-- Do NOT cache JUnit 5 snapshot JARs. -->
-                <updatePolicy>always</updatePolicy>
-                <enabled>true</enabled>
-            </snapshots>
-        </pluginRepository>
-    </pluginRepositories>
+	<dependencies>
+		<dependency>
+			<groupId>org.junit.jupiter</groupId>
+			<artifactId>junit-jupiter-engine</artifactId>
+			<version>${junit.jupiter.version}</version>
+			<scope>test</scope>
+		</dependency>
 
-    <build>
-        <plugins>
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
-                <configuration>
-                    <source>${java.version}</source>
-                    <target>${java.version}</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.19</version>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.junit</groupId>
-                        <artifactId>surefire-junit5</artifactId>
-                        <version>${junit.gen5.version}</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.junit</groupId>
-            <artifactId>junit5-api</artifactId>
-            <version>${junit.gen5.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+	</dependencies>
 </project>
\ No newline at end of file
diff --git a/junit5/src/test/java/com/baeldung/AssertionTest.java b/junit5/src/test/java/com/baeldung/AssertionTest.java
new file mode 100644
index 0000000000..70297b9073
--- /dev/null
+++ b/junit5/src/test/java/com/baeldung/AssertionTest.java
@@ -0,0 +1,29 @@
+package com.baeldung;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.expectThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class AssertionTest {
+
+	@Test
+	public void testConvertToDoubleThrowException() {
+		String age = "eighteen";
+		expectThrows(NumberFormatException.class, () -> {
+			convertToInt(age);
+		});
+
+		assertThrows(NumberFormatException.class, () -> {
+			convertToInt(age);
+		});
+	}
+	
+	private static Integer convertToInt(String str) {
+		if (str == null) {
+			return null;
+		}
+		return Integer.valueOf(str);
+	}
+
+}
diff --git a/junit5/src/test/java/com/baeldung/AssumptionTest.java b/junit5/src/test/java/com/baeldung/AssumptionTest.java
index e4c2b56124..f6f288e8a7 100644
--- a/junit5/src/test/java/com/baeldung/AssumptionTest.java
+++ b/junit5/src/test/java/com/baeldung/AssumptionTest.java
@@ -1,9 +1,11 @@
 package com.baeldung;
 
-import org.junit.gen5.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.junit.jupiter.api.Assumptions.assumingThat;
 
-import static org.junit.gen5.api.Assertions.assertEquals;
-import static org.junit.gen5.api.Assumptions.*;
+import org.junit.jupiter.api.Test;
 
 public class AssumptionTest {
 
diff --git a/junit5/src/test/java/com/baeldung/ExceptionTest.java b/junit5/src/test/java/com/baeldung/ExceptionTest.java
index 5c30ad5b44..31a6dff657 100644
--- a/junit5/src/test/java/com/baeldung/ExceptionTest.java
+++ b/junit5/src/test/java/com/baeldung/ExceptionTest.java
@@ -1,18 +1,26 @@
 package com.baeldung;
 
-import org.junit.gen5.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.expectThrows;
 
-import static org.junit.gen5.api.Assertions.assertEquals;
-import static org.junit.gen5.api.Assertions.expectThrows;
+import org.junit.jupiter.api.Test;
 
 public class ExceptionTest {
 
-    @Test
-    void shouldThrowException() {
-        Throwable exception = expectThrows(UnsupportedOperationException.class,
-                () -> {
-                    throw new UnsupportedOperationException("Not supported");
-                });
-        assertEquals(exception.getMessage(), "Not supported");
-    }
+	@Test
+	void shouldThrowException() {
+		Throwable exception = expectThrows(UnsupportedOperationException.class, () -> {
+			throw new UnsupportedOperationException("Not supported");
+		});
+		assertEquals(exception.getMessage(), "Not supported");
+	}
+
+	@Test
+	void assertThrowsException() {
+		String str = null;
+		assertThrows(IllegalArgumentException.class, () -> {
+			Integer.valueOf(str);
+		});
+	}
 }
diff --git a/junit5/src/test/java/com/baeldung/FirstTest.java b/junit5/src/test/java/com/baeldung/FirstTest.java
index 3306dc01f9..817d8b36de 100644
--- a/junit5/src/test/java/com/baeldung/FirstTest.java
+++ b/junit5/src/test/java/com/baeldung/FirstTest.java
@@ -1,12 +1,12 @@
 package com.baeldung;
 
-import org.junit.gen5.api.Disabled;
-import org.junit.gen5.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Arrays;
 import java.util.List;
 
-import static org.junit.gen5.api.Assertions.*;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 class FirstTest {
 
diff --git a/junit5/src/test/java/com/baeldung/JUnit5NewFeaturesTest.java b/junit5/src/test/java/com/baeldung/JUnit5NewFeaturesTest.java
new file mode 100644
index 0000000000..6c790a7c8e
--- /dev/null
+++ b/junit5/src/test/java/com/baeldung/JUnit5NewFeaturesTest.java
@@ -0,0 +1,50 @@
+package com.baeldung;
+
+import java.util.logging.Logger;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+//@RunWith(JUnitPlatform.class)
+public class JUnit5NewFeaturesTest {
+
+	private static final Logger log = Logger.getLogger(JUnit5NewFeaturesTest.class.getName());
+
+	@BeforeAll
+	static void setup() {
+		log.info("@BeforeAll - executes once before all test methods in this class");
+	}
+
+	@BeforeEach
+	void init() {
+		log.info("@BeforeEach - executes before each test method in this class");
+	}
+
+	@DisplayName("Single test successful")
+	@Test
+	void testSingleSuccessTest() {
+		log.info("Success");
+
+	}
+
+	@Test
+	@Disabled("Not implemented yet.")
+	void testShowSomething() {
+	}
+
+	@AfterEach
+	void tearDown() {
+		log.info("@AfterEach - executed after each test method.");
+	}
+
+	@AfterAll
+	static void done() {
+		log.info("@AfterAll - executed after all test methods.");
+	}
+
+}
diff --git a/junit5/src/test/java/com/baeldung/LiveTest.java b/junit5/src/test/java/com/baeldung/LiveTest.java
new file mode 100644
index 0000000000..e0e267da0b
--- /dev/null
+++ b/junit5/src/test/java/com/baeldung/LiveTest.java
@@ -0,0 +1,38 @@
+package com.baeldung;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.DynamicTest;
+import org.junit.jupiter.api.TestFactory;
+
+public class LiveTest {
+
+	private List<String> in = new ArrayList<>(Arrays.asList("Hello", "Yes", "No"));
+	private List<String> out = new ArrayList<>(Arrays.asList("Cześć", "Tak", "Nie"));
+
+	@TestFactory
+	public Stream<DynamicTest> translateDynamicTestsFromStream() {
+
+		return in.stream().map(word -> DynamicTest.dynamicTest("Test translate " + word, () -> {
+			int id = in.indexOf(word);
+			assertEquals(out.get(id), translate(word));
+		}));
+	}
+
+	private String translate(String word) {
+		if ("Hello".equalsIgnoreCase(word)) {
+			return "Cześć";
+		} else if ("Yes".equalsIgnoreCase(word)) {
+			return "Tak";
+		} else if ("No".equalsIgnoreCase(word)) {
+			return "Nie";
+		}
+		return "Error";
+	}
+
+}
diff --git a/junit5/src/test/java/com/baeldung/NestedTest.java b/junit5/src/test/java/com/baeldung/NestedTest.java
index 3fbe4f8644..b1c873e258 100644
--- a/junit5/src/test/java/com/baeldung/NestedTest.java
+++ b/junit5/src/test/java/com/baeldung/NestedTest.java
@@ -1,10 +1,14 @@
 package com.baeldung;
 
-import org.junit.gen5.api.*;
-
 import java.util.EmptyStackException;
 import java.util.Stack;
 
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+
 public class NestedTest {
     Stack<Object> stack;
     boolean isRun = false;
diff --git a/junit5/src/test/java/com/baeldung/StringUtils.java b/junit5/src/test/java/com/baeldung/StringUtils.java
new file mode 100644
index 0000000000..c1852113bc
--- /dev/null
+++ b/junit5/src/test/java/com/baeldung/StringUtils.java
@@ -0,0 +1,11 @@
+package com.baeldung;
+
+public final class StringUtils {
+
+	public static Double convertToDouble(String str) {
+		if (str == null) {
+			return null;
+		}
+		return Double.valueOf(str);
+	}
+}
diff --git a/junit5/src/test/java/com/baeldung/TaggedTest.java b/junit5/src/test/java/com/baeldung/TaggedTest.java
index dbc82f4022..fa3a500240 100644
--- a/junit5/src/test/java/com/baeldung/TaggedTest.java
+++ b/junit5/src/test/java/com/baeldung/TaggedTest.java
@@ -1,9 +1,9 @@
 package com.baeldung;
 
-import org.junit.gen5.api.Tag;
-import org.junit.gen5.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import static org.junit.gen5.api.Assertions.assertEquals;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
 
 @Tag("Test case")
 public class TaggedTest {
diff --git a/junit5/src/test/java/com/baeldung/suites/AllTests.java b/junit5/src/test/java/com/baeldung/suites/AllTests.java
new file mode 100644
index 0000000000..24af1e733b
--- /dev/null
+++ b/junit5/src/test/java/com/baeldung/suites/AllTests.java
@@ -0,0 +1,8 @@
+package com.baeldung.suites;
+
+//@RunWith(JUnitPlatform.class)
+//@SelectPackages("com.baeldung")
+//@SelectClasses({AssertionTest.class, AssumptionTest.class, ExceptionTest.class})
+public class AllTests {
+
+}