Skip to content

Commit 96f517c

Browse files
chore: Simplify reflect-config.json and add a large spring native XML test
1 parent ef9edfd commit 96f517c

File tree

5 files changed

+1207
-2
lines changed

5 files changed

+1207
-2
lines changed

spring-integration/spring-boot-autoconfigure/src/main/resources/META-INF/native-image/ai.timefold.solver/timefold-solver-spring-boot-autoconfigure/reflect-config.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,24 @@
633633
{
634634
"name": "ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter$JaxbAdaptedMap",
635635
"allDeclaredFields": true,
636-
"queryAllDeclaredMethods": true
636+
"queryAllDeclaredMethods": true,
637+
"methods": [
638+
{
639+
"name": "<init>",
640+
"parameterTypes": []
641+
}
642+
]
637643
},
638644
{
639645
"name": "ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter$JaxbAdaptedMapEntry",
640646
"allDeclaredFields": true,
641-
"queryAllDeclaredMethods": true
647+
"queryAllDeclaredMethods": true,
648+
"methods": [
649+
{
650+
"name": "<init>",
651+
"parameterTypes": []
652+
}
653+
]
642654
},
643655
{
644656
"name": "jakarta.xml.bind.Binder"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"resources": {
3+
"includes": [
4+
{
5+
"pattern": "solver.xsd"
6+
}
7+
]
8+
}
9+
}

spring-integration/spring-boot-integration-test/src/test/java/ai/timefold/solver/spring/boot/it/TimefoldSolverTestResourceIntegrationTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package ai.timefold.solver.spring.boot.it;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.io.IOException;
6+
import java.io.InputStreamReader;
37
import java.util.List;
48

9+
import ai.timefold.solver.core.config.solver.SolverConfig;
10+
import ai.timefold.solver.core.impl.io.jaxb.SolverConfigIO;
511
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestEntity;
612
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestSolution;
713
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestValue;
814

915
import org.junit.jupiter.api.Test;
16+
import org.springframework.beans.factory.annotation.Value;
1017
import org.springframework.boot.test.context.SpringBootTest;
1118
import org.springframework.boot.test.web.server.LocalServerPort;
19+
import org.springframework.core.io.Resource;
1220
import org.springframework.test.web.reactive.server.WebTestClient;
1321

1422
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@@ -17,6 +25,9 @@ public class TimefoldSolverTestResourceIntegrationTest {
1725
@LocalServerPort
1826
String port;
1927

28+
@Value("classpath:solver-full.xml")
29+
Resource exampleSolverConfigXml;
30+
2031
@Test
2132
void testSolve() {
2233
WebTestClient client = WebTestClient.bindToServer()
@@ -45,4 +56,17 @@ void testSolve() {
4556
.jsonPath("entityList[2].value.id").isEqualTo("2");
4657

4758
}
59+
60+
@Test
61+
void testSolverXmlParsing() throws IOException {
62+
// Test to verify parsing a complex SolverConfig will work in native image.
63+
// XML file was generated by taking the XSD file available at
64+
// https://timefold.ai/xsd/solver and generating an XML file from it using
65+
// the "Tools > XML Actions > Generate XML Document from XML Schema..." action in IDEA
66+
SolverConfigIO solverConfigIO = new SolverConfigIO();
67+
SolverConfig solverConfig = solverConfigIO.read(new InputStreamReader(exampleSolverConfigXml.getInputStream()));
68+
assertThat(solverConfig).isNotNull();
69+
assertThat(solverConfig.getSolutionClass()).isEqualTo(Object.class);
70+
assertThat(solverConfig.getPhaseConfigList()).isNotEmpty();
71+
}
4872
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"resources": {
3+
"includes": [
4+
{
5+
"pattern": "solver-full.xml"
6+
}
7+
]
8+
}
9+
}

0 commit comments

Comments
 (0)