Skip to content

Commit

Permalink
Add JDK 17 test functionality (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim authored Oct 10, 2024
1 parent 400de82 commit 57974d2
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,58 @@ alternative support for serializing POJOs as XML and deserializing XML as pojos.
</repository>
</repositories>

<profiles>
<profile>
<!-- And different set up for JDK 17 -->
<id>java17</id>
<activation>
<jdk>17</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test-jdk17/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<!-- Enable Java 17 for all sources so that Intellij picks the right language level -->
<source>17</source>
<release>17</release>
<compilerArgs>
<arg>-parameters</arg>
<arg>--add-opens=java.base/java.lang=ALL-UNNAMED</arg>
<arg>--add-opens=java.base/java.util=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.fasterxml.jackson.dataformat.xml.jdk17;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;

public class Java17CollectionsTest extends XmlTestBase
{

private final XmlMapper _xmlMapper = new XmlMapper();

public void testStreamOf()
throws Exception
{
List<String> input = Stream.of("a", "b", "c").collect(Collectors.toList());

String ser = _xmlMapper.writeValueAsString(input);
assertEquals("<ArrayList><item>a</item><item>b</item><item>c</item></ArrayList>", ser);

List<?> deser = _xmlMapper.readValue(ser, List.class);
assertEquals(input, deser);

input = Stream.of("a", "b", "c").toList();
ser = _xmlMapper.writeValueAsString(input);
deser = _xmlMapper.readValue(ser, List.class);
assertEquals(input, deser);
}

}

0 comments on commit 57974d2

Please sign in to comment.