Skip to content

Commit 5c5cb24

Browse files
committed
fixing tests
1 parent 7451ec9 commit 5c5cb24

File tree

4 files changed

+46
-36
lines changed

4 files changed

+46
-36
lines changed

reflection-config-generator/acceptance-tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies {
22

3-
compileOnly(project(":reflection-config-generator"))
3+
compile(project(":reflection-config-generator")) // compile for third party generation
44
annotationProcessor(project(":reflection-config-generator"))
55

66
compile ("com.fasterxml.jackson.core:jackson-databind:2.10.1")

reflection-config-generator/acceptance-tests/src/main/java/com/acme/TestUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.acme;
22

3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
36
import com.fasterxml.jackson.databind.MapperFeature;
47
import com.fasterxml.jackson.databind.ObjectMapper;
58
import com.fasterxml.jackson.databind.SerializationFeature;
6-
import org.apache.commons.io.IOUtils;
79

8-
import java.io.IOException;
10+
import org.apache.commons.io.IOUtils;
911

1012
public class TestUtils {
1113

@@ -14,12 +16,16 @@ private TestUtils() {
1416

1517
public static String getResourceAsString(String path) {
1618
try {
17-
return IOUtils.toString(TestUtils.class.getResourceAsStream(path), "UTF-8");
19+
return IOUtils.toString(getResourceAsStream(path), "UTF-8");
1820
} catch (IOException e) {
1921
throw new RuntimeException(e);
2022
}
2123
}
2224

25+
public static InputStream getResourceAsStream(String path) {
26+
return TestUtils.class.getResourceAsStream(path);
27+
}
28+
2329
public static String sortJson(String json){
2430
try {
2531
final ObjectMapper om = new ObjectMapper()
Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
package com.acme;
22

3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.nio.file.Files;
6+
import java.nio.file.Path;
37
import java.util.ArrayList;
48
import java.util.Collections;
59
import java.util.Comparator;
610
import java.util.List;
711

8-
import com.fasterxml.jackson.core.JsonProcessingException;
912
import com.fasterxml.jackson.databind.JsonNode;
1013
import com.fasterxml.jackson.databind.ObjectMapper;
1114
import com.fasterxml.jackson.databind.SerializationFeature;
1215

13-
import org.junit.jupiter.api.Disabled;
1416
import org.junit.jupiter.api.Test;
17+
import org.junit.jupiter.api.io.TempDir;
1518

19+
import static com.acme.TestUtils.getResourceAsStream;
1620
import static com.acme.TestUtils.getResourceAsString;
21+
import nativeimage.core.thirdparty.Main;
1722
import static org.junit.jupiter.api.Assertions.assertEquals;
1823

1924
class ReflectionConfigGenerationTest {
@@ -23,33 +28,30 @@ class ReflectionConfigGenerationTest {
2328
;
2429

2530
@Test
26-
void mustConfigureReflectJson() throws JsonProcessingException {
31+
void mustConfigureReflectJson() throws IOException {
2732
// arrange
28-
2933
// act
30-
final List<JsonNode> items = readReflectConfig("reflect.json");
31-
3234
// assert
33-
assertEquals(13, items.size());
3435
assertEquals(
3536
getResourceAsString("/reflection-config-generation-test/001.json"),
36-
objectMapper.writeValueAsString(items)
37+
readReflectConfig("reflect.json")
3738
);
3839
}
3940

4041
@Test
41-
@Disabled
42-
void mustConfigureThirdPartyReflectJson() throws JsonProcessingException {
42+
void mustConfigureThirdPartyReflectJson(@TempDir Path tmpDir) throws Exception {
4343
// arrange
44+
final Path reflectFile = Files.createTempFile(tmpDir, "reflect", ".json");
4445

4546
// act
46-
final List<JsonNode> items = readReflectConfig("reflect-third-party.json");
47+
Main.main(new String[]{
48+
"com.fasterxml.jackson.core.util", reflectFile.toString()
49+
});
4750

4851
// assert
49-
assertEquals(14, items.size());
5052
assertEquals(
51-
getResourceAsString("/reflection-config-generation-test/002.json"),
52-
objectMapper.writeValueAsString(items)
53+
readReflectConfig(getResourceAsStream("/reflection-config-generation-test/002.json")),
54+
readReflectConfig(Files.newInputStream(reflectFile))
5355
);
5456
}
5557

@@ -66,11 +68,13 @@ void mustConfigureNativeImagePropertiesFile(){
6668
}
6769

6870

69-
private List<JsonNode> readReflectConfig(final String fileName) throws JsonProcessingException {
71+
private String readReflectConfig(final String fileName) throws IOException {
72+
return readReflectConfig(getResourceAsStream("/META-INF/native-image/com.acme/" + fileName));
73+
}
74+
75+
private String readReflectConfig(final InputStream in) throws IOException {
7076
final List<JsonNode> items = new ArrayList<>();
71-
final JsonNode reflectItems = this.objectMapper.readTree(
72-
getResourceAsString("/META-INF/native-image/com.acme/" + fileName)
73-
);
77+
final JsonNode reflectItems = this.objectMapper.readTree(in);
7478
for (JsonNode jsonNode : reflectItems) {
7579
items.add(jsonNode);
7680
}
@@ -80,7 +84,7 @@ public int compare(JsonNode a, JsonNode b) {
8084
return a.at("/name").asText().compareTo(b.at("/name").asText());
8185
}
8286
});
83-
return items;
87+
return objectMapper.writeValueAsString(items);
8488
}
8589

8690
}

reflection-config-generator/acceptance-tests/src/test/resources/reflection-config-generation-test/002.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
[ {
2-
"name" : "com.fasterxml.jackson.core.util.ByteArrayBuilder",
2+
"name" : "com.fasterxml.jackson.core.util.BufferRecycler",
33
"allDeclaredConstructors" : false,
44
"allPublicConstructors" : false,
55
"allDeclaredMethods" : false,
66
"allPublicMethods" : false,
77
"allPublicFields" : false,
88
"allDeclaredFields" : false
99
}, {
10-
"name" : "com.fasterxml.jackson.core.util.DefaultIndenter",
10+
"name" : "com.fasterxml.jackson.core.util.BufferRecyclers",
1111
"allDeclaredConstructors" : false,
1212
"allPublicConstructors" : false,
1313
"allDeclaredMethods" : false,
1414
"allPublicMethods" : false,
1515
"allPublicFields" : false,
1616
"allDeclaredFields" : false
1717
}, {
18-
"name" : "com.fasterxml.jackson.core.util.DefaultPrettyPrinter",
18+
"name" : "com.fasterxml.jackson.core.util.DefaultIndenter",
1919
"allDeclaredConstructors" : false,
2020
"allPublicConstructors" : false,
2121
"allDeclaredMethods" : false,
2222
"allPublicMethods" : false,
2323
"allPublicFields" : false,
2424
"allDeclaredFields" : false
2525
}, {
26-
"name" : "com.fasterxml.jackson.core.util.DefaultPrettyPrinter$FixedSpaceIndenter",
26+
"name" : "com.fasterxml.jackson.core.util.DefaultPrettyPrinter",
2727
"allDeclaredConstructors" : false,
2828
"allPublicConstructors" : false,
2929
"allDeclaredMethods" : false,
3030
"allPublicMethods" : false,
3131
"allPublicFields" : false,
3232
"allDeclaredFields" : false
3333
}, {
34-
"name" : "com.fasterxml.jackson.core.util.DefaultPrettyPrinter$Indenter",
34+
"name" : "com.fasterxml.jackson.core.util.DefaultPrettyPrinter$FixedSpaceIndenter",
3535
"allDeclaredConstructors" : false,
3636
"allPublicConstructors" : false,
3737
"allDeclaredMethods" : false,
@@ -47,63 +47,63 @@
4747
"allPublicFields" : false,
4848
"allDeclaredFields" : false
4949
}, {
50-
"name" : "com.fasterxml.jackson.core.util.Instantiatable",
50+
"name" : "com.fasterxml.jackson.core.util.JacksonFeatureSet",
5151
"allDeclaredConstructors" : false,
5252
"allPublicConstructors" : false,
5353
"allDeclaredMethods" : false,
5454
"allPublicMethods" : false,
5555
"allPublicFields" : false,
5656
"allDeclaredFields" : false
5757
}, {
58-
"name" : "com.fasterxml.jackson.core.util.InternCache",
58+
"name" : "com.fasterxml.jackson.core.util.MinimalPrettyPrinter",
5959
"allDeclaredConstructors" : false,
6060
"allPublicConstructors" : false,
6161
"allDeclaredMethods" : false,
6262
"allPublicMethods" : false,
6363
"allPublicFields" : false,
6464
"allDeclaredFields" : false
6565
}, {
66-
"name" : "com.fasterxml.jackson.core.util.JsonGeneratorDelegate",
66+
"name" : "com.fasterxml.jackson.core.util.RequestPayload",
6767
"allDeclaredConstructors" : false,
6868
"allPublicConstructors" : false,
6969
"allDeclaredMethods" : false,
7070
"allPublicMethods" : false,
7171
"allPublicFields" : false,
7272
"allDeclaredFields" : false
7373
}, {
74-
"name" : "com.fasterxml.jackson.core.util.JsonParserDelegate",
74+
"name" : "com.fasterxml.jackson.core.util.Separators",
7575
"allDeclaredConstructors" : false,
7676
"allPublicConstructors" : false,
7777
"allDeclaredMethods" : false,
7878
"allPublicMethods" : false,
7979
"allPublicFields" : false,
8080
"allDeclaredFields" : false
8181
}, {
82-
"name" : "com.fasterxml.jackson.core.util.JsonParserSequence",
82+
"name" : "com.fasterxml.jackson.core.util.TextBuffer",
8383
"allDeclaredConstructors" : false,
8484
"allPublicConstructors" : false,
8585
"allDeclaredMethods" : false,
8686
"allPublicMethods" : false,
8787
"allPublicFields" : false,
8888
"allDeclaredFields" : false
8989
}, {
90-
"name" : "com.fasterxml.jackson.core.util.MinimalPrettyPrinter",
90+
"name" : "com.fasterxml.jackson.core.util.ThreadLocalBufferManager",
9191
"allDeclaredConstructors" : false,
9292
"allPublicConstructors" : false,
9393
"allDeclaredMethods" : false,
9494
"allPublicMethods" : false,
9595
"allPublicFields" : false,
9696
"allDeclaredFields" : false
9797
}, {
98-
"name" : "com.fasterxml.jackson.core.util.RequestPayload",
98+
"name" : "com.fasterxml.jackson.core.util.ThreadLocalBufferManager$ThreadLocalBufferManagerHolder",
9999
"allDeclaredConstructors" : false,
100100
"allPublicConstructors" : false,
101101
"allDeclaredMethods" : false,
102102
"allPublicMethods" : false,
103103
"allPublicFields" : false,
104104
"allDeclaredFields" : false
105105
}, {
106-
"name" : "com.fasterxml.jackson.core.util.Separators",
106+
"name" : "com.fasterxml.jackson.core.util.VersionUtil",
107107
"allDeclaredConstructors" : false,
108108
"allPublicConstructors" : false,
109109
"allDeclaredMethods" : false,

0 commit comments

Comments
 (0)