Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Dec 23, 2023
1 parent 6f04b25 commit 183f27f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/test/java/mpo/dayon/common/RunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ void shouldExtractProgramArgs() {
Map<String, String> programArgs = extractProgramArgs(args);
// then
assertEquals(2, programArgs.size(), "Unexpected number of extracted ProgramArgs");
assertEquals("en", programArgs.get("lang"), "Key 'lang' shold have value 'en'");
assertEquals("BAR", programArgs.get("foo"), "Key 'foo' shold have value 'BAR'");
assertEquals("en", programArgs.get("lang"), "Key 'lang' should have value 'en'");
assertEquals("BAR", programArgs.get("foo"), "Key 'foo' should have value 'BAR'");
}

@Test
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/mpo/dayon/common/buffer/MemByteBufferTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ void tearDown() throws IOException {
buffer.close();
}

@Test
void write() {
final int val = 234;
buffer.write(val);
assertEquals(1, buffer.size());
assertEquals((byte) val, buffer.getInternal()[0]);
}

@Test
void writeInt() {
buffer.writeInt(BEAST);
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/mpo/dayon/common/utils/SystemUtilitiesTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package mpo.dayon.common.utils;

import static java.lang.String.format;
import static mpo.dayon.common.utils.SystemUtilities.*;
import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;

class SystemUtilitiesTest {
Expand Down Expand Up @@ -105,4 +110,17 @@ void isValidPortNumberShouldReturnTrueForValidPorts(String port) {
// when, then
assertTrue(isValidPortNumber(port));
}

@Test
void shouldObtainWritableTempDir() throws IOException {
// when, then
assertTrue(Files.isWritable(new File(getTempDir()).toPath()), "TempDir should be writable");
}

@Test
void shouldObtainJarDir() throws IOException {
// when, then
assertTrue(new File(format("%s%sdayon.jar", getJarDir(), File.separator)).exists(), "JarDir should contain dayon.jar");
}

}

0 comments on commit 183f27f

Please sign in to comment.