diff options
author | Clyhtsuriva <61652557+clyhtsuriva@users.noreply.github.com> | 2021-06-26 22:24:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-26 22:24:05 +0000 |
commit | 18359e9e2892a332f283476bc3ae887308f51cec (patch) | |
tree | 79de50772e18722f57813b234dd541b1c701aa01 /src/test/java/musichub/util | |
parent | 5dc7dea3ef53a385442c6bfd59054faa4b1d73d9 (diff) | |
parent | 67ed18fe86ddfabe5f6c6c270273597799722a72 (diff) |
Merge pull request #8 from Said-Belhadj/feature/STZ-0009
Feature/stz 0009
Diffstat (limited to 'src/test/java/musichub/util')
-rw-r--r-- | src/test/java/musichub/util/LogHandlerTest.java | 41 | ||||
-rw-r--r-- | src/test/java/musichub/util/PathValidationTest.java | 26 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/test/java/musichub/util/LogHandlerTest.java b/src/test/java/musichub/util/LogHandlerTest.java new file mode 100644 index 0000000..17b47f6 --- /dev/null +++ b/src/test/java/musichub/util/LogHandlerTest.java @@ -0,0 +1,41 @@ +package musichub.util; + + +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static musichub.util.LogHandler.read; +import static musichub.util.LogHandler.write; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class LogHandlerTest { + @Test + void testWrite() { + try { + write("JUnit test", "INFO"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + void testRead() { + try { + read(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Test + void testLogHandlerClass() { + try { + LogHandler logHandlerClass = new LogHandler(); + } catch (Error ex) { + assertTrue(ex instanceof AssertionError); + assertEquals("You just can't instantiate this class.", ex.getMessage()); + } + } +} diff --git a/src/test/java/musichub/util/PathValidationTest.java b/src/test/java/musichub/util/PathValidationTest.java new file mode 100644 index 0000000..4c7a3d6 --- /dev/null +++ b/src/test/java/musichub/util/PathValidationTest.java @@ -0,0 +1,26 @@ +package musichub.util; + + +import org.junit.jupiter.api.Test; + +import static musichub.util.PathValidation.isPathValid; +import static org.junit.jupiter.api.Assertions.*; + +public class PathValidationTest { + @Test + void testIsPathValid() { + assertTrue(isPathValid("Song/Side_To_Side.wav")); //the right path + assertFalse(isPathValid("wrong_path/Side_To_Side.wav")); //wrong path + assertFalse(isPathValid("Song/Side_To_Side.mp3")); //wrong extension + } + + @Test + void testPathValidationClass() { + try { + PathValidation pathValidationClass = new PathValidation(); + } catch (Error ex) { + assertTrue(ex instanceof AssertionError); + assertEquals("You just can't instantiate this class.", ex.getMessage()); + } + } +} |