Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 1483420

Browse files
authored
Merge pull request #164 from marklogic-community/feature/java17-testing
Added JAXB test for Java 11 and 17
2 parents 90297f4 + b75732a commit 1483420

File tree

3 files changed

+81
-7
lines changed

3 files changed

+81
-7
lines changed

build.gradle

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ plugins {
22
id "java-library"
33
id "maven-publish"
44
id "signing"
5-
id "com.github.jk1.dependency-license-report" version "2.1"
65
id "io.snyk.gradle.plugin.snykplugin" version "0.4"
6+
7+
// This plugin requires Java 11; keeping it commented out so that this project can be built and tested via
8+
// Java 8, 11 or 17; to use this plugin, uncomment this line and use java 11 or higher
9+
// id "com.github.jk1.dependency-license-report" version "2.1"
710
}
811

912
group = "com.marklogic"
1013
version = "4.3.7"
1114

12-
sourceCompatibility = "8"
13-
targetCompatibility = "8"
15+
java {
16+
sourceCompatibility = 1.8
17+
targetCompatibility = 1.8
18+
}
1419

1520
repositories {
1621
mavenCentral()
@@ -37,9 +42,18 @@ dependencies {
3742
testImplementation files("lib/modules.jar")
3843

3944
// Forcing Spring to use logback instead of commons-logging
40-
testImplementation "ch.qos.logback:logback-classic:1.4.5"
45+
testImplementation "ch.qos.logback:logback-classic:1.3.5" // Not using 1.4.x yet as it requires Java 11
4146
testImplementation "org.slf4j:jcl-over-slf4j:1.7.36"
4247
testImplementation "org.slf4j:slf4j-api:1.7.36"
48+
49+
// For verifying that JAXB can be used in a test on Java 11 or higher
50+
testImplementation "javax.xml.bind:jaxb-api:2.3.1"
51+
testImplementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
52+
testImplementation "org.glassfish.jaxb:jaxb-core:2.3.0.1"
53+
54+
// Including the "new" JAXB libraries to verify that their presence doesn't cause the "old" JAXB libraries to fail
55+
testImplementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0"
56+
testImplementation "com.sun.xml.bind:jaxb-impl:4.0.1"
4357
}
4458

4559
test {

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ It is not intended to be used to build this project.
4040
<dependency>
4141
<groupId>com.marklogic</groupId>
4242
<artifactId>marklogic-client-api</artifactId>
43-
<version>5.5.3</version>
43+
<version>5.5.4</version>
4444
<scope>compile</scope>
4545
</dependency>
4646
<dependency>
4747
<groupId>com.marklogic</groupId>
4848
<artifactId>marklogic-xcc</artifactId>
49-
<version>10.0.9</version>
49+
<version>10.0.9.5</version>
5050
<scope>compile</scope>
5151
</dependency>
5252
<dependency>
5353
<groupId>org.springframework</groupId>
5454
<artifactId>spring-context</artifactId>
55-
<version>5.3.22</version>
55+
<version>5.3.24</version>
5656
<scope>compile</scope>
5757
</dependency>
5858
<dependency>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.marklogic.client.ext.jaxb;
2+
3+
import com.marklogic.client.io.JAXBHandle;
4+
import org.junit.jupiter.api.Test;
5+
6+
import javax.xml.bind.JAXBContext;
7+
import javax.xml.bind.JAXBException;
8+
import javax.xml.bind.annotation.XmlRootElement;
9+
10+
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
12+
public class JAXBHandleTest {
13+
14+
/**
15+
* Included solely to verify that when the test is run using Java 11 or Java 17, it will succeed given that the
16+
* testImplementation configuration in Gradle imports the necessary "old" JAXB libraries.
17+
*
18+
* @throws JAXBException
19+
*/
20+
@Test
21+
void simpleTest() throws JAXBException {
22+
JAXBHandle handle = new JAXBHandle(JAXBContext.newInstance(Product.class));
23+
Product p = new Product();
24+
p.setName("My name");
25+
p.setIndustry("My industry");
26+
handle.set(p);
27+
String xml = handle.toString();
28+
29+
Product p2 = (Product) handle.bytesToContent(xml.getBytes());
30+
assertEquals("My name", p2.getName());
31+
assertEquals("My industry", p2.getIndustry());
32+
}
33+
34+
@XmlRootElement
35+
static public class Product {
36+
private String name;
37+
private String industry;
38+
39+
public Product() {
40+
super();
41+
}
42+
43+
public String getName() {
44+
return name;
45+
}
46+
47+
public void setName(String name) {
48+
this.name = name;
49+
}
50+
51+
public String getIndustry() {
52+
return industry;
53+
}
54+
55+
public void setIndustry(String industry) {
56+
this.industry = industry;
57+
}
58+
}
59+
60+
}

0 commit comments

Comments
 (0)