Skip to content

Commit 1fa711c

Browse files
committed
Fix GradleTest
1 parent 086b014 commit 1fa711c

File tree

11 files changed

+80
-11
lines changed

11 files changed

+80
-11
lines changed

pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
<groupId>tools.jackson.dataformat</groupId>
108108
<artifactId>jackson-dataformat-smile</artifactId>
109109
</dependency>
110+
<dependency>
111+
<groupId>tools.jackson.dataformat</groupId>
112+
<artifactId>jackson-dataformat-toml</artifactId>
113+
</dependency>
110114
<dependency>
111115
<groupId>tools.jackson.dataformat</groupId>
112116
<artifactId>jackson-dataformat-xml</artifactId>
@@ -211,6 +215,11 @@
211215
<artifactId>junit-jupiter</artifactId>
212216
<scope>compile</scope>
213217
</dependency>
218+
<dependency>
219+
<groupId>org.junit.jupiter</groupId>
220+
<artifactId>junit-jupiter-params</artifactId>
221+
<scope>compile</scope>
222+
</dependency>
214223
<dependency>
215224
<groupId>org.assertj</groupId>
216225
<artifactId>assertj-core</artifactId>

src/main/java/module-info.java

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
requires transitive tools.jackson.dataformat.smile;
2020
requires transitive tools.jackson.dataformat.xml;
2121
requires transitive tools.jackson.dataformat.yaml;
22+
requires transitive tools.jackson.dataformat.toml;
2223

2324
// Base modules
2425

src/test/java/tools/jackson/integtest/BaseTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import tools.jackson.dataformat.protobuf.ProtobufMapper;
2323
import tools.jackson.dataformat.smile.SmileFactory;
2424
import tools.jackson.dataformat.smile.SmileMapper;
25+
import tools.jackson.dataformat.toml.TomlFactory;
26+
import tools.jackson.dataformat.toml.TomlMapper;
2527
import tools.jackson.dataformat.xml.XmlFactory;
2628
import tools.jackson.dataformat.xml.XmlMapper;
2729
import tools.jackson.dataformat.yaml.YAMLFactory;
@@ -266,6 +268,18 @@ protected static JavaPropsMapper propsMapper() {
266268
return propsMapperBuilder().build();
267269
}
268270

271+
protected static TomlMapper.Builder tomlMapperBuilder() {
272+
return TomlMapper.builder();
273+
}
274+
275+
protected static TomlMapper.Builder tomlMapperBuilder(TomlFactory f) {
276+
return TomlMapper.builder(f);
277+
}
278+
279+
protected static TomlMapper tomlMapper() {
280+
return tomlMapperBuilder().build();
281+
}
282+
269283
protected static XmlMapper.Builder xmlMapperBuilder() {
270284
return XmlMapper.builder();
271285
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package tools.jackson.integtest.df.basic;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import tools.jackson.databind.ObjectMapper;
6+
7+
import tools.jackson.integtest.BaseTest;
8+
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
11+
public class BasicReadWriteIonTest extends BaseTest
12+
{
13+
@Test
14+
public void testSimple() throws Exception
15+
{
16+
ObjectMapper mapper = ionMapper();
17+
18+
// !!! 23-Feb-2016, tatu: Trivial to avoid using any Schema
19+
assertNotNull(mapper);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package tools.jackson.integtest.df.basic;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import tools.jackson.databind.ObjectMapper;
6+
7+
import tools.jackson.integtest.BaseTest;
8+
9+
import static org.junit.jupiter.api.Assertions.assertNotNull;
10+
11+
public class BasicReadWriteTomlTest extends BaseTest
12+
{
13+
@Test
14+
public void testSimple() throws Exception
15+
{
16+
ObjectMapper mapper = tomlMapper();
17+
18+
// !!! 23-Feb-2016, tatu: Trivial to avoid using any Schema
19+
assertNotNull(mapper);
20+
}
21+
}

src/test/java/tools/jackson/integtest/gradle/GradleTest.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tools.jackson.integtest.gradle;
22

33
import java.io.*;
4+
import java.net.URL;
45
import java.nio.file.Files;
56

67
import org.junit.jupiter.api.Test;
@@ -12,9 +13,6 @@
1213

1314
public class GradleTest
1415
{
15-
@TempDir
16-
public File testFolder;
17-
1816
/**
1917
* This test calls the Gradle build in 'src/test/resources/com/fasterxml/jackson/integtest/gradle' which:
2018
* - Collects all entries from the latest Jackson BOM
@@ -27,19 +25,24 @@ public class GradleTest
2725
* <a href="https://blog.gradle.org/alignment-with-gradle-module-metadata">blog.gradle.org/alignment-with-gradle-module-metadata</a>
2826
*/
2927
@Test
30-
public void testJacksonBomDependency() throws Exception {
31-
copyToTestFolder("settings.gradle.kts");
32-
copyToTestFolder("build.gradle.kts");
33-
build(":checkMetadata");
28+
public void testJacksonBomDependency(@TempDir File tempDir) throws Exception {
29+
copyToTestFolder(tempDir, "settings.gradle.kts");
30+
copyToTestFolder(tempDir, "build.gradle.kts");
31+
build(tempDir, ":checkMetadata");
3432
}
3533

36-
private void copyToTestFolder(String fileName) throws IOException {
37-
Files.copy(new File(requireNonNull(getClass().getResource(fileName)).getFile()).toPath(),
34+
private void copyToTestFolder(File testFolder, String fileName) throws IOException {
35+
URL resource = getClass().getResource(fileName);
36+
assertNotNull(resource, "Null resource '"+fileName+"', from `"+getClass()+"`");
37+
Files.copy(new File(resource.getFile()).toPath(),
3838
new File(testFolder, fileName).toPath());
3939
}
4040

41-
private void build(String task) throws Exception {
42-
String gradlew = requireNonNull(getClass().getResource("gradlew")).getFile();
41+
private void build(File testFolder, String task) throws Exception {
42+
String fileName = "gradlew";
43+
URL resource = getClass().getResource(fileName);
44+
assertNotNull(resource, "Null resource '"+fileName+"', from `"+getClass()+"`");
45+
String gradlew = resource.getFile();
4346
Runtime.getRuntime().exec("chmod a+x " + gradlew).waitFor();
4447
ProcessBuilder bp = new ProcessBuilder(gradlew, task, "-q",
4548
"--project-dir", testFolder.getAbsolutePath());

0 commit comments

Comments
 (0)