Skip to content

Commit

Permalink
Merge pull request #85 from DerMistkaefer/feature/run-tests
Browse files Browse the repository at this point in the history
Enabling Automated Tests in Maven Build & Repairing Failed Tests
  • Loading branch information
KotlinFactory authored Dec 18, 2023
2 parents 551df8a + 82872c4 commit cf76828
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>

<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>

<plugin>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.leonhard.storage.util.FastStringWriter;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.Map;
Expand Down Expand Up @@ -159,7 +160,7 @@ public Map<String, Object> read(final File file) throws IOException, TomlExcepti
*/
public Map<String, Object> read(final File file, final boolean strictAsciiBareKeys)
throws IOException, TomlException {
return read(new FileInputStream(file), strictAsciiBareKeys);
return read(Files.newInputStream(file.toPath()), strictAsciiBareKeys);
}

/**
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/de/leonhard/storage/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.leonhard.storage.annotation.ConfigPath;
import de.leonhard.storage.internal.exceptions.SimplixValidationException;
import de.leonhard.storage.internal.settings.DataType;
import lombok.Getter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -89,25 +90,18 @@ void testAnnotations() {
}

@AfterAll
@Test
static void tearDown() {
config.clear();
Assertions.assertTrue(config.getFile().delete());
}

@Getter
static class AnnotationTests {

@ConfigPath("annotation-test")
public String annotationTest;

@ConfigPath("section.annotations")
public Integer annotationTest2;

public String getAnnotationTest() {
return annotationTest;
}

public int getAnnotationTest2() {
return annotationTest2;
}
}
}
7 changes: 3 additions & 4 deletions src/test/java/de/leonhard/storage/JsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class JsonTest {
@Test
void setUp() {
json = new Json("Example", "");
Assertions.assertEquals("Example.yml", json.getName());
Assertions.assertEquals("Example.json", json.getName());
}

@Test
void testGetDataType() {
Assertions.assertEquals(json.getDataType(), DataType.SORTED);
Assertions.assertEquals(json.getDataType(), DataType.UNSORTED);
}

@Test
Expand Down Expand Up @@ -68,8 +68,7 @@ void testSet() {
}

@AfterAll
@Test
void tearDown() {
static void tearDown() {
json.clear();
Assertions.assertTrue(json.getFile().delete());
}
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/de/leonhard/storage/TomlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public class TomlTest {
@Test
void setUp() {
toml = new Toml("Example", "");
Assertions.assertEquals("Example.yml", toml.getName());
Assertions.assertEquals("Example.toml", toml.getName());
}

@Test
void testGetDataType() {
Assertions.assertEquals(DataType.SORTED, toml.getDataType());
Assertions.assertEquals(DataType.UNSORTED, toml.getDataType());
}

@Test
Expand Down Expand Up @@ -68,8 +68,7 @@ void testSet() {
}

@AfterAll
@Test
void tearDown() {
static void tearDown() {
toml.clear();
Assertions.assertTrue(toml.getFile().delete());
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/de/leonhard/storage/YamlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void setUp() {

@Test
void testGetDataType() {
Assertions.assertEquals(DataType.SORTED, yaml.getDataType());
Assertions.assertEquals(DataType.UNSORTED, yaml.getDataType());
}

@Test
Expand Down Expand Up @@ -78,8 +78,7 @@ void testSet() {
}

@AfterAll
@Test
void tearDown() {
static void tearDown() {
yaml.clear();
Assertions.assertTrue(yaml.getFile().delete());
}
Expand Down

0 comments on commit cf76828

Please sign in to comment.